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: <507ECA43.3070402@linux.vnet.ibm.com>
Date:	Wed, 17 Oct 2012 08:09:55 -0700
From:	Dave Hansen <dave@...ux.vnet.ibm.com>
To:	wency@...fujitsu.com
CC:	linux-mm@...ck.org, linux-kernel@...r.kernel.org,
	rientjes@...gle.com, liuj97@...il.com, len.brown@...el.com,
	benh@...nel.crashing.org, paulus@...ba.org, minchan.kim@...il.com,
	akpm@...ux-foundation.org, kosaki.motohiro@...fujitsu.com,
	isimatu.yasuaki@...fujitsu.com, Christoph Lameter <cl@...ux.com>
Subject: Re: [PATCH v2 2/5] memory-hotplug: update mce_bad_pages when removing
 the memory

Hi Wen,

> +#ifdef CONFIG_MEMORY_FAILURE
> +static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
> +{
> +	int i;
> +
> +	if (!memmap)
> +		return;

I guess free_section_usemap() does the same thing.

> +	for (i = 0; i < PAGES_PER_SECTION; i++) {
> +		if (PageHWPoison(&memmap[i])) {
> +			atomic_long_sub(1, &mce_bad_pages);
> +			ClearPageHWPoison(&memmap[i]);
> +		}
> +	}
> +}
> +#endif
> +
>  void sparse_remove_one_section(struct zone *zone, struct mem_section *ms)
>  {
>  	struct page *memmap = NULL;
> @@ -786,6 +803,10 @@ void sparse_remove_one_section(struct zone *zone, struct mem_section *ms)
>  		ms->pageblock_flags = NULL;
>  	}
> 
> +#ifdef CONFIG_MEMORY_FAILURE
> +	clear_hwpoisoned_pages(memmap, PAGES_PER_SECTION);
> +#endif
> +
>  	free_section_usemap(memmap, usemap);
>  }
>  #endif

But why put the call outside the  "if (ms->section_mem_map)" block?  If
you put it inside, then you don't have to check for !memmap in
clear_hwpoisoned_pages().

Also, we really frown on #ifdefs scattered throughout code.  I'd suggest
either:

+static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
+{
+#ifdef CONFIG_MEMORY_FAILURE
... existing code
+#endif /* CONFIG_MEMORY_FAILURE */
+}

or

+#ifdef CONFIG_MEMORY_FAILURE
+static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
+{
... existing code
+}
+#else
+static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
+{}
+#endif /* CONFIG_MEMORY_FAILURE */

and keep the #ifdef out of sparse_remove_one_section().

--
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