Re: [PATCH] kanoj-mm17-2.3.21 kswapd vma scanning protection

Manfred Spraul (manfreds@colorfullife.com)
Fri, 15 Oct 1999 20:26:25 +0200


Kanoj Sarcar wrote:
> If you wanted to be more careful, you
> could define the swapout prototype as swapout(start, end, flags, file).
> That *should* be enough for most future 2.3/2.4 driver.

"file" can go away if you do not call "get_file()" before releasing the
locking.

>
> > - swap_out() is called with the semaphore held,
>
> Look below for why this is not safe.
You are right, this can lock-up. Swapper is only protected from
reentrancy on it's own stack, not from reentrancy from another thread.

>
> > Or: ->swapout() releases the semaphore,
> >
>
> This works for filemap_swapout, but you can not expect every regular Joe
> driver writer to adhere to this rule.
The result is not a rare lock-up, but it will lock-up nearly
immediately. Even Joe would notice that.
[I know this is ugly]

> And here's one more. Before invoking swapout(), and before loosing the
> vmlist_lock in try_to_swap_out, the vma might be marked with a flag
> that indicates that swapout() is looking at the vma.
Or: use a multiple reader - single writer semaphore with "starve writer"
policy.
IMO that's cleaner than a semaphore with an attached waitqueue for
do_munmap().

> This swapout() cleanup is independent of the patch I have already posted,
> so the patch should be integrated into 2.3, while we debate how to tackle
> the cleanup.

Ok.

--
	Manfred

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/