Re: [PATCH] mm: PageLRU can be non-atomic bit operation

Hugh Dickins
2007-04-23T13:42:47Z

On Mon, 23 Apr 2007, Hisashi Hifumi wrote:
> >No. The PG_lru flag bit is just one bit amongst many others:
> >what of concurrent operations changing other bits in that same
> >unsigned long e.g. trying to lock the page by setting PG_locked?
> >There are some places where such micro-optimizations can be made
> >(typically while first allocating the page); but in general, no.
>
> In i386 and x86_64, btsl is used to change page flag. In this case, if btsl
> without lock prefix
> set PG_locked and PG_lru flag concurrently, does only one operation
> succeed ?

That's right: on an SMP machine, without the lock prefix, the operation
is no longer atomic: what's stored back may be missing the result of
one or the other of the racing operations.

Hugh