Subject: Re: [vserver] patch for conflict in mm/memory.c in 2.6.27.52
From: Herbert Poetzl <herbert@13thfloor.at>
Date: Sun, 22 Aug 2010 19:18:42 +0200

On Fri, Aug 20, 2010 at 08:01:23PM -0500, Corey Wright wrote:
> the recent 2.6.27.52 conflicts with patch-2.6.27.48-vs2.3.0.36.9.diff
> in mm/memory.c and attached is my attempt at resolving the conflict.

> 2.6.27.52 adds check_stack_guard_page() to do_anonymous_page() right
> before anon_vma_prepare(), which conflicts with linux-vserver's
> addition of vx_rss_avail() in the same location. which one should be
> first or does it matter at all)?

if both functions have no side-effects, the criterion would
be to put simple checks first, but it would not matter for
the end result ...

> my guess, as reflected in the attached patch, is
> check_stack_guard_page() then vx_rss_avail() (because
> check_stack_guard_page() is more important than vx_rss_avail(), so
> check it first). 

the Linux-VServer vx_rss_avail() has no side-effects but
might cause significant delays due to vxi dereferencing
so the check_stack_guard_page() might be faster ...

> if i'm wrong (or even right, but for the wrong reason), 
> then please let me know why, as i'm interested in learning.

however, in this case, the check_stack_guard_page() has,
under certain circumstances, side-effects which can not
easily be undone in case the vx_rss_avail() fails, so
you definitely want to put that check first, despite the
fact that it might be more resource intensive than the
other one

HTC,
Herbert

> corey
> -- 
> undefined@pobox.com

> --- linux-2.6.27.52/mm/memory.c	2010-08-20 17:59:24.000000000 -0500
> +++ linux-2.6.27.52-vs2.3.0.36.9/mm/memory.c	2010-08-20 19:56:34.000000000 -0500
> @@ -2434,6 +2442,9 @@ static int do_anonymous_page(struct mm_s
>  	if (check_stack_guard_page(vma, address) < 0)
>  		return VM_FAULT_SIGBUS;
>  
> +	if (!vx_rss_avail(mm, 1))
> +		goto oom;
> +
>  	/* Allocate our own private page. */
>  	if (unlikely(anon_vma_prepare(vma)))
>  		goto oom;