lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20120326155027.GF16573@suse.de>
Date:	Mon, 26 Mar 2012 16:50:27 +0100
From:	Mel Gorman <mgorman@...e.de>
To:	Peter Zijlstra <a.p.zijlstra@...llo.nl>
Cc:	Andrew Morton <akpm@...ux-foundation.org>,
	Miao Xie <miaox@...fujitsu.com>,
	David Rientjes <rientjes@...gle.com>,
	Christoph Lameter <cl@...ux.com>, linux-mm@...ck.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] cpuset: mm: Reduce large amounts of memory barrier
 related damage v3

On Mon, Mar 26, 2012 at 12:56:24PM +0200, Peter Zijlstra wrote:
> On Wed, 2012-03-07 at 18:08 +0000, Mel Gorman wrote:
> > +               } while (!put_mems_allowed(cpuset_mems_cookie) && !page);
> 
> Sorry for only noticing this now, but wouldn't it be better to first
> check page and only then bother with the put_mems_allowed() thing? That
> avoids the smp_rmb() and seqcount conditional all together in the likely
> case the allocation actually succeeded.
> 
> <SNIP>
>
> diff --git a/mm/filemap.c b/mm/filemap.c
> index c3811bc..3b41553 100644
> --- a/mm/filemap.c
> +++ b/mm/filemap.c
> @@ -504,7 +504,7 @@ struct page *__page_cache_alloc(gfp_t gfp)
>  			cpuset_mems_cookie = get_mems_allowed();
>  			n = cpuset_mem_spread_node();
>  			page = alloc_pages_exact_node(n, gfp, 0);
> -		} while (!put_mems_allowed(cpuset_mems_cookie) && !page);
> +		} while (!page && !put_mems_allowed(cpuset_mems_cookie));
>  
>  		return page;
>  	}

I think such a change would be better but should also rename the API.
If developers see a get_foo type call, they will expect to see a put_foo
call or assume it's a bug even though the implementation happens to be ok
with that. Any suggestion on what a good new name would be?

How about read_mems_allowed_begin() and read_mems_allowed_retry()?

read_mems_allowed_begin would be a rename of get_mems_allowed().  In an
error path, read_mems_allowed_retry() would documented to be *optionally*
called when deciding whether to retry the operation or not. In this scheme,
!put_mems_allowed would become read_mems_allowed_retry() which might be
a bit easier to read overall.

-- 
Mel Gorman
SUSE Labs
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ