[linux-mm-cc] Re: CCache problem

Rik van Riel riel at redhat.com
Tue Jun 27 23:42:03 EDT 2006


On Tue, 27 Jun 2006, Nitin Gupta wrote:

> Problem 1: Can we busy wait here (spinlock vs semaphore)? : 
> Decompression is a quick operation but I doubt if its quick 'enough' to 
> be spinlock'ed (esp. LZO)

I suspect it is fast enough, especially with Wnk4x4...

The overhead of yielding the CPU and maybe being
rescheduled to another CPU, getting cache misses,
and all the other disadvantages of semaphores do
not seem warranted here.

> Also, I have doubt if find_get_page() can sleep. If it can, should I use a
> semaphore there?

It does not look like find_get_page() can sleep.

> Problem 2: These allocation can sleep (esp. under mem pressure).
> If find_get_page() cannot sleep then how can we do decompression?

After you allocate a fresh page, re-take the lock.

It is possible somebody else also allocated a page simultaneously,
and hooked that page into the the page cache before you.  In that
case, free your page and use the other guy's page :)

> Do you think there are problems in above code?

You do not check *slot after you re-take the lock.

Remember that you dropped the lock, so anything could have
happened.  Better start from the beginning, maybe using a
goto?

The function do_generic_mapping_read() in mm/filemap.c
is a nice example of all the things that could go wrong,
and how easy it is to deal with those by simply starting
your lookup from the beginning again :)

-- 
All Rights Reversed


More information about the linux-mm-cc mailing list