From patchwork Fri Nov 9 06:47:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 10675381 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 41448109C for ; Fri, 9 Nov 2018 06:48:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2D73A2DD40 for ; Fri, 9 Nov 2018 06:48:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 204282DD76; Fri, 9 Nov 2018 06:48:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A5CE32DD40 for ; Fri, 9 Nov 2018 06:48:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AEBD16B06AA; Fri, 9 Nov 2018 01:47:55 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A4A216B06AC; Fri, 9 Nov 2018 01:47:55 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 878B76B06AD; Fri, 9 Nov 2018 01:47:55 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by kanga.kvack.org (Postfix) with ESMTP id 3769B6B06AA for ; Fri, 9 Nov 2018 01:47:55 -0500 (EST) Received: by mail-pf1-f198.google.com with SMTP id j9-v6so757557pfn.20 for ; Thu, 08 Nov 2018 22:47:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:sender:from:to:cc:subject:date :message-id:in-reply-to:references; bh=4TesSbGB62xA3TfNct4mvP8iyx81/GNoDwFhQH3EAIk=; b=c3qTwc/GyYSpIY7HrxIT3WjgSB9WdHeoQ35Xqp5JIJOcH2ly3XEIXTPCrkqXWscncq TD3FcY4/yyIR2cwTta99wck9ct8pubciHvsoWouFrcKRrXhwGogIbh6S2jKrUyN1D/Ll GDQQQfohKfKq59PP0Lm3e42RqV2ILQYATIWAAKNEb66eOR4SkCw2neltY1LnPHD3n8Db H6D4b9HD8UcQVtvN4u+YJHsPW9XsRHqhPN+3u01OYM9jcwJT2bpevWNBqOkKIjMdAiS0 GjWe2Mpk7apx/mLTVnah7kaeYjGPTmDEYU/ZFN5FGxJh0EtEOTDLwN0US2iVTqQRaoZQ L7Vw== X-Gm-Message-State: AGRZ1gK6QFti5TYNGiQh4OJAmf4mrhz2bJmfDdR5UlBrcP1Q1ohHl99f zoFvAWWdqVQy7se+wvxmLl6V4PQms2bCldsMrmjIiKLQzlH3Runq7fsicmyffYTwlF2ifJ2O6LK vZ7Ztpbl1hH61WZTY80vFIAJH+PI/C2TTulDQKqxNnkdOCsC/EJIQ9RYQHlTMuWjo2gG6ui1xca lQD1UClTKvoIJXSs0HhIN6UlfX5QHRhUm6rQoYU7sI2h+34o1WQLQbRtJfgiaIXLiItURZFliV6 yZWmlQnnqKXWhCgRH8QWMk/Tu3QNtt+EmhBd0mWLwE1Zzyp2/RDN2uaKWAzZzxrAo4BUFkVyu8i bgDGYmauGpPaGINbK0G+4xprh8/LJXFxSUkYsLJSpb7N/rcS/5pKqSzuBloASU74u9JKbr2BLw= = X-Received: by 2002:a63:e19:: with SMTP id d25mr6450985pgl.272.1541746074895; Thu, 08 Nov 2018 22:47:54 -0800 (PST) X-Received: by 2002:a63:e19:: with SMTP id d25mr6450956pgl.272.1541746074162; Thu, 08 Nov 2018 22:47:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541746074; cv=none; d=google.com; s=arc-20160816; b=mZJ1KIDhtfRFLWLwogyDxcswlcfvRBaVJK4cwLAFwXPbjcupxj6lnkE2buEegIblwQ g4bA/1W5kXKPlVP+w95/QgFQaZX0nWRsU12i8ZodvmB2GpJO87PRdzXbkAJ+425cVD5y rhKqT7DKXKZAJe96Je0r84yzJnbE4nmRQmCMXEhCwluUMnVDMGZ2YtHSkCTJOZUDKbhF saLqrzfIXKaX18+6Dppk1q7b1otGGHYL4d9rDanutAIfB0rhxwZ/zwHC1kG4lycxE3Yd qb6uTlYicSUKzNCsnjpwMRoY9Xl6xhGV04pDV0zeXkdHBxv8bArqo18oF0Tjry3fxuWf Tm+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=4TesSbGB62xA3TfNct4mvP8iyx81/GNoDwFhQH3EAIk=; b=Xyeln2W3lRNnwjDTOOr1LdXQnaGvvXfyhgRYOgYdzDarnQlRd/GjMQkzynH/H6Etir 7SbvGxwsZC9uLdtWZiKnDnYjVUTaeBxdVJIxkksGvpgUGCso1Id5pXkU7QLLtZ98NpwQ nIpInlR88fKrGAzhmbP/bRtZwC1pbkHNgtQFEIlJsyBpXrH5jbOspFgumMft6pBeRI0B N89Tf1IrUnqZ68ahPWXzz9L3ibJLiEwEgDXkMfx9HgnRKoUnBs/3wHjD46srmJ+BVjas Yh/2aQEfyxKQbqeKO9dz1Fy53NX1ngkw/+mlXzVRgz8tDAPNmRulR1456GSKvNBXhgc4 NeBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=EQCCDU5j; spf=pass (google.com: domain of nao.horiguchi@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=nao.horiguchi@gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id e2-v6sor7945475pfb.55.2018.11.08.22.47.54 for (Google Transport Security); Thu, 08 Nov 2018 22:47:54 -0800 (PST) Received-SPF: pass (google.com: domain of nao.horiguchi@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=EQCCDU5j; spf=pass (google.com: domain of nao.horiguchi@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=nao.horiguchi@gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=4TesSbGB62xA3TfNct4mvP8iyx81/GNoDwFhQH3EAIk=; b=EQCCDU5jq8dKBb9Bx2axPP3NPwImXWLIPPUpv6FEDxDH6cnYuYAEup/9e1nd1HT5N8 PrN6eCPerDhFcP0D3dfwCsuegvm/ltXibHwfpR33+gfOu09iv9sELlZWny6hu+Lh/Sr+ W9hCcUKUeeguNjMo0Rw68BNVGO+y1udwMd4/FgcMNnM8BAygV6TYK7tSZ93c5GaMXaPW nArAMbBHt61uPNwtg43oGpRHRI/cfPOZHANtnpon5Hbhhy8ejsy/UGu5F22z4rue0hAe 3qrpRMZ2WUJMmtsiuyVdGN6UD/PETdMFvaMhwgpg/AlwrYVL0KzJgjPa84BkSLYlzKGc 8O6g== X-Google-Smtp-Source: AJdET5e+UNfklH05dKVCHvqkkKfrITeoZS/A79nDLAMCoHowK8sSI9VuqNMTbZy8PQiybkjee+Akew== X-Received: by 2002:a62:2c16:: with SMTP id s22-v6mr7724641pfs.6.1541746073710; Thu, 08 Nov 2018 22:47:53 -0800 (PST) Received: from www9186uo.sakura.ne.jp (www9186uo.sakura.ne.jp. [153.121.56.200]) by smtp.gmail.com with ESMTPSA id c70-v6sm6808355pfg.97.2018.11.08.22.47.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Nov 2018 22:47:53 -0800 (PST) From: Naoya Horiguchi To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Michal Hocko , Andrew Morton , Mike Kravetz , xishi.qiuxishi@alibaba-inc.com, Laurent Dufour Subject: [RFC][PATCH v1 11/11] mm: hwpoison: introduce clear_hwpoison_free_buddy_page() Date: Fri, 9 Nov 2018 15:47:15 +0900 Message-Id: <1541746035-13408-12-git-send-email-n-horiguchi@ah.jp.nec.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1541746035-13408-1-git-send-email-n-horiguchi@ah.jp.nec.com> References: <1541746035-13408-1-git-send-email-n-horiguchi@ah.jp.nec.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP The new function is a reverse operation of set_hwpoison_free_buddy_page() to adjust unpoison_memory() to the new semantics. Signed-off-by: Naoya Horiguchi --- include/linux/page-flags.h | 8 +++++++- mm/memory-failure.c | 5 +++-- mm/page_alloc.c | 21 +++++++++++++++++++++ 3 files changed, 31 insertions(+), 3 deletions(-) diff --git v4.19-mmotm-2018-10-30-16-08/include/linux/page-flags.h v4.19-mmotm-2018-10-30-16-08_patched/include/linux/page-flags.h index 50ce1bd..ab0bde0 100644 --- v4.19-mmotm-2018-10-30-16-08/include/linux/page-flags.h +++ v4.19-mmotm-2018-10-30-16-08_patched/include/linux/page-flags.h @@ -382,11 +382,17 @@ PAGEFLAG(HWPoison, hwpoison, PF_ANY) TESTSCFLAG(HWPoison, hwpoison, PF_ANY) #define __PG_HWPOISON (1UL << PG_hwpoison) extern bool set_hwpoison_free_buddy_page(struct page *page); +extern bool clear_hwpoison_free_buddy_page(struct page *page); #else PAGEFLAG_FALSE(HWPoison) static inline bool set_hwpoison_free_buddy_page(struct page *page) { - return 0; + return false; +} + +static inline bool clear_hwpoison_free_buddy_page(struct page *page) +{ + return false; } #define __PG_HWPOISON 0 #endif diff --git v4.19-mmotm-2018-10-30-16-08/mm/memory-failure.c v4.19-mmotm-2018-10-30-16-08_patched/mm/memory-failure.c index af541141..a0e1cd4 100644 --- v4.19-mmotm-2018-10-30-16-08/mm/memory-failure.c +++ v4.19-mmotm-2018-10-30-16-08_patched/mm/memory-failure.c @@ -1590,8 +1590,9 @@ int unpoison_memory(unsigned long pfn) } if (!get_hwpoison_page(p)) { - if (TestClearPageHWPoison(p)) - num_poisoned_pages_dec(); + if (!clear_hwpoison_free_buddy_page(p)) + return 0; + num_poisoned_pages_dec(); unpoison_pr_info("Unpoison: Software-unpoisoned free page %#lx\n", pfn, &unpoison_rs); return 0; diff --git v4.19-mmotm-2018-10-30-16-08/mm/page_alloc.c v4.19-mmotm-2018-10-30-16-08_patched/mm/page_alloc.c index 27826b3..9a90f93 100644 --- v4.19-mmotm-2018-10-30-16-08/mm/page_alloc.c +++ v4.19-mmotm-2018-10-30-16-08_patched/mm/page_alloc.c @@ -8270,4 +8270,25 @@ bool set_hwpoison_free_buddy_page(struct page *page) return hwpoisoned; } + +/* + * Reverse operation of set_hwpoison_free_buddy_page(), which is expected + * to work only on error pages isolated from buddy allocator. + */ +bool clear_hwpoison_free_buddy_page(struct page *page) +{ + struct zone *zone = page_zone(page); + bool unpoisoned = false; + + spin_lock(&zone->lock); + if (TestClearPageHWPoison(page)) { + unsigned long pfn = page_to_pfn(page); + int migratetype = get_pfnblock_migratetype(page, pfn); + + __free_one_page(page, pfn, zone, 0, migratetype); + unpoisoned = true; + } + spin_unlock(&zone->lock); + return unpoisoned; +} #endif