PDA

View Full Version : Kernel mode cpu usage is high in opengl rendering.



GL Starter
11-30-2010, 01:30 AM
Experts,

Sometimes CPU usage of my application( uses opengl and CG shader for display) is very high( 50%).


This issue appears in rare scenarios, when starting my application.
I cant say any scenario which will cause the issue.
Once the issue appeared at startup, the cpu usage remainsas high.

When I checked cpu usage of individual threads, I found the thread responsible for
opengl display cause high cpu usage. all other threads working with normal cpu usage.


After anlaysing cpu usage, I found kernel mode cpu time higher than user mode cpu time.
In normal case( when cpu is below 10%) the kernel mode is less than user mode.

There is no never ending loop, or dead locks.
Normal call sequence but the Kernel mode cpu usage is very high.

In normal case cpu usage of application is below 10%.
kernel time: 0:00:16:640
User time: 0:02:33:421


In Error case, cpu usage is 50%.
kernel time: 0:11:56:437
User time: 0:04:26:359


Any possibility for high Kernel mode cpu usage ?
or what may the possible reason ?


I suspect the data transfer between gpu and cpu is high.


But the following calls also take CPU.
In my understanding, all below functions changes opengl state,
glMatrixMode();
glLoadIdentity();
gluPerspective( );
gluLookAt( );
glViewport( );


What are the possible reasons for high cpu time in kernel mode ?
How can find which call is blocking in Kernel mode ?

mfort
11-30-2010, 02:57 PM
Some drivers are using busy waiting in functions like SwapBuffers or glFinish.

GL Starter
12-19-2010, 05:20 PM
But when I checked calstack, I found like this
ntkrnlpa.exe!KiUnexpectedInterrupt+0x121
ntkrnlpa.exe!ZwYieldExecution+0x1c8e
ntkrnlpa.exe!ZwYieldExecution+0x2570
ntkrnlpa.exe!ProbeForRead+0x605
ntkrnlpa.exe!KeReleaseInStackQueuedSpinLockFromDpc Level+0xb74
ntdll.dll!KiFastSystemCallRet
kernel32.dll!Sleep+0xf
nvoglnt.dll!DrvCopyContext+0x5b97
cgGL.dll!cgGLBindProgram+0x2a

It shows cgGLBindProgram cause the Sleep. When I checked similiar scenarios, almost every cg calls I got this sleep.