Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2043362pxk; Mon, 14 Sep 2020 03:19:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwcD0PC/uaFqzHKRgEu8IuJt16ib3J/WW1gIbqjE6aEur9GIpkt75rvksBHKoI/Gc831KkU X-Received: by 2002:a05:6402:1544:: with SMTP id p4mr16137117edx.346.1600078747247; Mon, 14 Sep 2020 03:19:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600078747; cv=none; d=google.com; s=arc-20160816; b=LA1R1Myg1xYY+QAgebrnNA94U5mE7cvWG+kQBirJAOuk/6XPJpnuq2+xGUJ7bO8Evp OvWigc6gkT39DZ/Z5AS8o5hI70x62g189kdGvg3P82Su3aCumZAO1p9Yh5HghXzhr6q+ weZrWSNA9q8fGDE+28i7YpN2iXpwcYVBTA9iIjHpUpquR+hzYbSFeVNNrvkoX68L/TvM XJJdcafvcebUG1kQC0KF9+3yMCNZSLSF8ME0HuyWl4bP2twbwzBP1FzUlM4x7/8bJt9p rtoF9/ogaKF/hj0e3gPgWz0l7y0a7Jc/IZtkbYPD9n99nG2jDaKZ97gQ6jlGfpsGCgjq Fc/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=BmkBfsT8TZSn2Hd5fN62FvFwEP0LYv6F6M6RsJsKR4U=; b=VPRFeg3CYzaS5vXryLAmD28mDfuH3Bp0RSxGfa7+OJ37zzoHMbXiORv8QCUbILF2Nr rktrlosSEYZIi5YrFgNZPYZMS9I7CBXitANaLbef113bRyQnkgX5fqUKjAjZj+JwQvDo obbbw8uuZX+95LK1VKspIqgZpsozCDybFpC74aOhsll6iKyAgq5vhfZNI+b+N4yEtoYz KrH6pa4wpiwr9mZiuKIm2DDumPyNaMwaeXMXxA5twyHJdbGtyqRdcCUDCsG7jh+aG4vr xgY4EKqClmc3D3L9gfYONFpbvXfoguGwMuR/bSxY4fXizLwCIUKvoGj5rFbFe+f8sP0l UegA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q24si6358241eja.493.2020.09.14.03.18.44; Mon, 14 Sep 2020 03:19:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726450AbgINKQo (ORCPT + 99 others); Mon, 14 Sep 2020 06:16:44 -0400 Received: from mx2.suse.de ([195.135.220.15]:44774 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726398AbgINKQG (ORCPT ); Mon, 14 Sep 2020 06:16:06 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 73BECAD21; Mon, 14 Sep 2020 10:16:20 +0000 (UTC) From: Oscar Salvador To: akpm@linux-foundation.org Cc: naoya.horiguchi@nec.com, mhocko@kernel.org, tony.luck@intel.com, cai@lca.pw, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Oscar Salvador , Oscar Salvador , Stephen Rothwell Subject: [PATCH v3 3/5] mm,hwpoison: drain pcplists before bailing out for non-buddy zero-refcount page Date: Mon, 14 Sep 2020 12:15:57 +0200 Message-Id: <20200914101559.17103-4-osalvador@suse.de> X-Mailer: git-send-email 2.13.7 In-Reply-To: <20200914101559.17103-1-osalvador@suse.de> References: <20200914101559.17103-1-osalvador@suse.de> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org A page with 0-refcount and !PageBuddy could perfectly be a pcppage. Currently, we bail out with an error if we encounter such a page, meaning that we do not handle pcppages neither from hard-offline nor from soft-offline path. Fix this by draining pcplists whenever we find this kind of page and retry the check again. It might be that pcplists have been spilled into the buddy allocator and so we can handle it. Link: https://lkml.kernel.org/r/20200908075626.11976-4-osalvador@suse.de Signed-off-by: Oscar Salvador Cc: Michal Hocko Cc: Naoya Horiguchi Cc: Oscar Salvador Cc: Qian Cai Cc: Tony Luck Signed-off-by: Andrew Morton Signed-off-by: Stephen Rothwell --- mm/memory-failure.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 989fb3efdca6..4468c1eb5027 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -948,13 +948,13 @@ static int page_action(struct page_state *ps, struct page *p, } /** - * get_hwpoison_page() - Get refcount for memory error handling: + * __get_hwpoison_page() - Get refcount for memory error handling: * @page: raw error page (hit by memory error) * * Return: return 0 if failed to grab the refcount, otherwise true (some * non-zero value.) */ -static int get_hwpoison_page(struct page *page) +static int __get_hwpoison_page(struct page *page) { struct page *head = compound_head(page); @@ -984,6 +984,26 @@ static int get_hwpoison_page(struct page *page) return 0; } +static int get_hwpoison_page(struct page *p) +{ + int ret; + bool drained = false; + +retry: + ret = __get_hwpoison_page(p); + if (!ret && !is_free_buddy_page(p) && !page_count(p) && !drained) { + /* + * The page might be in a pcplist, so try to drain those + * and see if we are lucky. + */ + drain_all_pages(page_zone(p)); + drained = true; + goto retry; + } + + return ret; +} + /* * Do all that is necessary to remove user space mappings. Unmap * the pages and send SIGBUS to the processes if the data was dirty. -- 2.26.2