Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752167AbbG2JTA (ORCPT ); Wed, 29 Jul 2015 05:19:00 -0400 Received: from TYO201.gate.nec.co.jp ([210.143.35.51]:63775 "EHLO tyo201.gate.nec.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751309AbbG2JS6 convert rfc822-to-8bit (ORCPT ); Wed, 29 Jul 2015 05:18:58 -0400 From: Naoya Horiguchi To: Wang Xiaoqiang CC: "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" Subject: Re: [PATCH] memory_failure: remove redundant check for the PG_HWPoison flag of 'hpage' Thread-Topic: [PATCH] memory_failure: remove redundant check for the PG_HWPoison flag of 'hpage' Thread-Index: AQHQydOI/d8Vnbby60+maleIYYAvm53xlDyA Date: Wed, 29 Jul 2015 09:17:32 +0000 Message-ID: <20150729091725.GA1256@hori1.linux.bs1.fc.nec.co.jp> References: <20150729155246.2fed1b96@hp> In-Reply-To: <20150729155246.2fed1b96@hp> Accept-Language: ja-JP, en-US Content-Language: ja-JP X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.128.101.3] Content-Type: text/plain; charset="iso-2022-jp" Content-ID: <2EFB11D90BBD494EB805C635DBD1F4A8@gisp.nec.co.jp> Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2085 Lines: 62 # CC:ed linux-mm Hi Xiaoqiang, On Wed, Jul 29, 2015 at 03:52:46PM +0800, Wang Xiaoqiang wrote: > Hi, > > I find a little problem in the memory_failure function in > mm/memory-failure.c . Please check it. > > memory_failure: remove redundant check for the PG_HWPoison flag of > `hpage'. > > Since we have check the PG_HWPoison flag by `PageHWPoison' before, > so the later check by `TestSetPageHWPoison' must return true, there > is no need to check again! I'm afraid that this TestSetPageHWPoison is not redundant, because this code serializes the concurrent memory error events over the same hugetlb page (, where 'p' indicates the 4kB error page and 'hpage' indicates the head page.) When an error hits a hugetlb page, set_page_hwpoison_huge_page() sets PageHWPoison flags over all subpages of the hugetlb page in the ascending order of pfn. So if we don't have this TestSet, memory error handler can run more than once on concurrent errors when the 1st memory error hits (for example) the 100th subpage and the 2nd memory error hits (for example) the 50th subpage. Thanks, Naoya Horiguchi > Signed-off-by: Wang Xiaoqiang > --- > mm/memory-failure.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/mm/memory-failure.c b/mm/memory-failure.c > index 1cf7f29..7794fd8 100644 > --- a/mm/memory-failure.c > +++ b/mm/memory-failure.c > @@ -1115,7 +1115,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags) > lock_page(hpage); > if (PageHWPoison(hpage)) { > if ((hwpoison_filter(p) && TestClearPageHWPoison(p)) > - || (p != hpage && TestSetPageHWPoison(hpage))) { > + || p != hpage) { > atomic_long_sub(nr_pages, &num_poisoned_pages); > unlock_page(hpage); > return 0; > -- > 1.7.10.4 > > > > -- > thx! > Wang Xiaoqiang > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/