Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 4 Apr 2012 18:54:06 -0700 (PDT)
From:      Sushanth Rai <sushanth_rai@yahoo.com>
To:        freebsd-hackers@freebsd.org
Subject:   Startvation of realtime piority threads
Message-ID:  <1333590846.58474.YahooMailClassic@web180011.mail.gq1.yahoo.com>

next in thread | raw e-mail | index | archive | help
I have a multithreaded user space program that basically runs at realtime priority. Synchronization between threads are done using spinlock. When running this program on a SMP system under heavy memory pressure I see that thread holding the spinlock is starved out of cpu. The cpus are effectively consumed by other threads that are spinning for lock to become available. 

After instrumenting the kernel a little bit what I found was that under memory pressure, when the user thread holding the spinlock traps into the kernel due to page fault, that thread sleeps until the free pages are available. The thread sleeps PUSER priority (within vm_waitpfault()). When it is ready to run, it is queued at PUSER priority even thought it's base priority is realtime. The other siblings threads that are spinning at realtime priority to acquire the spinlock starves the owner of spinlock. 

I was wondering if the sleep in vm_waitpfault() should be a MAX(td_user_pri, PUSER) instead of just PUSER. I'm running on 7.2 and it looks like this logic is the same in the trunk.

Thanks,
Sushanth



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1333590846.58474.YahooMailClassic>