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: <4B595904.4000202@zytor.com>
Date:	Thu, 21 Jan 2010 23:51:32 -0800
From:	"H. Peter Anvin" <hpa@...or.com>
To:	Wu Fengguang <fengguang.wu@...el.com>
CC:	Thomas Gleixner <tglx@...utronix.de>,
	Ingo Molnar <mingo@...hat.com>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Chen Liqin <liqin.chen@...plusct.com>,
	Lennox Wu <lennox.wu@...il.com>,
	Ralf Baechle <ralf@...ux-mips.org>,
	Américo Wang <xiyou.wangcong@...il.com>,
	linux-mips@...ux-mips.org,
	KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>,
	Yinghai Lu <yinghai@...nel.org>, x86@...nel.org,
	LKML <linux-kernel@...r.kernel.org>,
	Andi Kleen <andi@...stfloor.org>, shaohui.zheng@...el.com
Subject: Re: [PATCH 1/3] resources: introduce generic page_is_ram()

On 01/21/2010 07:21 PM, Wu Fengguang wrote:
> --- linux-mm.orig/kernel/resource.c	2010-01-22 11:20:34.000000000 +0800
> +++ linux-mm/kernel/resource.c	2010-01-22 11:20:35.000000000 +0800
> @@ -327,6 +327,17 @@ int walk_system_ram_range(unsigned long 
>  
>  #endif
>  
> +#define PAGE_IS_RAM	24
> +static int __is_ram(unsigned long pfn, unsigned long nr_pages, void *arg)
> +{
> +	return PAGE_IS_RAM;
> +}
> +int __attribute__((weak)) page_is_ram(unsigned long pfn)
> +{
> +	return PAGE_IS_RAM == walk_system_ram_range(pfn, 1, NULL, __is_ram);
> +}
> +#undef PAGE_IS_RAM
> +

Stylistic nitpick:

The use of the magic number "24" here is pretty ugly; it seems to imply
that there is something peculiar with this number and that it is trying
to avoid an overlap, whereas in fact any number but 0 and -1 would do.

I would rather see just returning 1 and do:

	return walk_system_ram_range(pfn, 1, NULL, __is_ram) == 1;

(walk_system_ram_range() returning -1 on error, and 0 means continue.)

Note also that we don't write "constant == expression"; although some
schools teach it as a way to avoid the "=" versus "==" beginner C
mistake, it makes the code less intuitive to read.

Other than that, the patchset looks good; if Ingo doesn't beat me to it
I'll put it in tomorrow (need sleep right now.)

	-hpa

-- 
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.
--
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