Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752010AbbG3Cwc (ORCPT ); Wed, 29 Jul 2015 22:52:32 -0400 Received: from mail.lzu.edu.cn ([202.201.0.205]:48848 "EHLO lzu.edu.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750866AbbG3Cwb (ORCPT ); Wed, 29 Jul 2015 22:52:31 -0400 Date: Thu, 30 Jul 2015 10:52:46 +0800 From: Wang Xiaoqiang To: Naoya Horiguchi 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' Message-ID: <20150730105246.6bcc0af5@hp> In-Reply-To: <20150729091725.GA1256@hori1.linux.bs1.fc.nec.co.jp> References: <20150729155246.2fed1b96@hp> <20150729091725.GA1256@hori1.linux.bs1.fc.nec.co.jp> X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.10; i486-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-CM-TRANSID: zQDJygBHTt5rkblVvD9WAA--.1355S2 X-Coremail-Antispam: 1UD129KBjvJXoWxGFWkCF4fXFy5GrWDWFyUWrg_yoW5Ww13pF Wrt3Wqy3Z3WasIywnFyrZavan7t345Kr42qrWDA345Gw13Xr1Ikr18Wa15urW5Ww1vkw4x AF4UGryq93s0gFJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUU9Kb7Iv0xC_Zr1lb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I2 0VC2zVCF04k26cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rw A2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xII jxv20xvEc7CjxVAFwI0_Cr0_Gr1UM28EF7xvwVC2z280aVAFwI0_Cr1j6rxdM28EF7xvwV C2z280aVCY1x0267AKxVW0oVCq3wAac4AC62xK8xCEY4vEwIxC4wAS0I0E0xvYzxvE52x0 82IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUJVWUGw Av7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48J M4x0Y48IcxkI7VAKI48G6xCjnVAKz4kxMxkIecxEwVAFwVW8JwCF04k20xvY0x0EwIxGrw CFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE 14v26r106r1rMI8E67AF67kF1VAFwI0_Jrv_JF1lIxkGc2Ij64vIr41lIxAIcVC0I7IYx2 IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Jr0_Gr1lIxAIcVCF04k26cxK x2IYs7xG6rW3Jr0E3s1lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267 AKxVWUJVW8JbIYCTnIWIevJa73UjIFyTuYvjxUIna9UUUUU X-CM-SenderInfo: pzdqw5btrqqzl2xovvfxof0/ Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3232 Lines: 102 On Wed, 29 Jul 2015 09:17:32 +0000 Naoya Horiguchi wrote: > # 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. In your example, the 100th subage enter the memory error handler firstly, and then it uses the set_page_hwpoison_huge_page to set all subpages with PG_HWPoison flag, the 50th page handler waits for grab the lock_page(hpage) now. When the 100th page handler unlock the 'hpage', the 50th grab it, and now the 'hapge' has been set with PG_HWPosison. So PageHWPoison micro will return true, and the following code will be executed: if (PageHWPoison(hpage)) { if ((hwpoison_filter(p) && TestClearPageHWPoison(p)) || (p != hpage && TestSetPageHWPoison(hpage))) { atomic_long_sub(nr_pages, &num_poisoned_pages); unlock_page(hpage); return 0; } } Now 'p' is 50th subpage, it doesn't equal the 'hpage' obviously, so if we don't have TestSetPageHWPoison here, it still will ignore the 50th error. Why the memory error handler can run more than once? Hope to receive from you! thx, Wang Xiaoqiang > > 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/