Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752743AbbGaGt1 (ORCPT ); Fri, 31 Jul 2015 02:49:27 -0400 Received: from TYO201.gate.nec.co.jp ([210.143.35.51]:49343 "EHLO tyo201.gate.nec.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752668AbbGaGtX convert rfc822-to-8bit (ORCPT ); Fri, 31 Jul 2015 02:49:23 -0400 From: Naoya Horiguchi To: Andrew Morton CC: Andi Kleen , Dean Nelson , "Tony Luck" , "Kirill A. Shutemov" , "Hugh Dickins" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , "Naoya Horiguchi" , Naoya Horiguchi Subject: [PATCH v2 2/5] mm/memory-failure: fix race in counting num_poisoned_pages Thread-Topic: [PATCH v2 2/5] mm/memory-failure: fix race in counting num_poisoned_pages Thread-Index: AQHQy1yXAT8aZxPxtEiZKiA/uFaPUA== Date: Fri, 31 Jul 2015 06:46:13 +0000 Message-ID: <1438325105-10059-3-git-send-email-n-horiguchi@ah.jp.nec.com> References: <1438325105-10059-1-git-send-email-n-horiguchi@ah.jp.nec.com> In-Reply-To: <1438325105-10059-1-git-send-email-n-horiguchi@ah.jp.nec.com> Accept-Language: ja-JP, en-US Content-Language: ja-JP X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.128.101.6] Content-Type: text/plain; charset="iso-2022-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: 1160 Lines: 31 When memory_failure() is called on a page which are just freed after page migration from soft offlining, the counter num_poisoned_pages is raised twice. So let's fix it with using TestSetPageHWPoison. Signed-off-by: Naoya Horiguchi --- mm/memory-failure.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git v4.2-rc4.orig/mm/memory-failure.c v4.2-rc4/mm/memory-failure.c index 04d677048af7..f72d2fad0b90 100644 --- v4.2-rc4.orig/mm/memory-failure.c +++ v4.2-rc4/mm/memory-failure.c @@ -1671,8 +1671,8 @@ static int __soft_offline_page(struct page *page, int flags) if (ret > 0) ret = -EIO; } else { - SetPageHWPoison(page); - atomic_long_inc(&num_poisoned_pages); + if (!TestSetPageHWPoison(page)) + atomic_long_inc(&num_poisoned_pages); } } else { pr_info("soft offline: %#lx: isolation failed: %d, page count %d, type %lx\n", -- 2.4.3 -- 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/