From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1B7D3C433EF for ; Thu, 23 Jun 2022 23:52:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B4F9F8E01AB; Thu, 23 Jun 2022 19:52:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AFFD28E01A1; Thu, 23 Jun 2022 19:52:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9C7E88E01AB; Thu, 23 Jun 2022 19:52:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 8E8B98E01A1 for ; Thu, 23 Jun 2022 19:52:48 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 72D49607CE for ; Thu, 23 Jun 2022 23:52:48 +0000 (UTC) X-FDA: 79611153216.07.BA25061 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) by imf13.hostedemail.com (Postfix) with ESMTP id BCEA72001C for ; Thu, 23 Jun 2022 23:52:47 +0000 (UTC) Received: by mail-pl1-f171.google.com with SMTP id o18so634818plg.2 for ; Thu, 23 Jun 2022 16:52:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KvUi4xXUaw0Gsdez/sII2VYp9q4T8l1odrgep5/r9aE=; b=b71HZZHM2aY5ylc8U6Uu7sxHM5Q4Dz7cL/mOReiZJuAaeu2rHNu+hnQmQAv38dDmwP pOKIk5yY/X85zQfa1Ys2n7GhIPD0SVPxsFL/z9/OGvRegbXwb/U4EHvDpjg7cQ1S0pyP KWtLwypFgkCY/db06rZ/D2urozJab3xD2VJxRbQ0no53NC4CzSsNbu/G6NHqRh9A8X+F 8OTJbDheCebOpKua3A0uEj2qHKjRhFb2+wCy2g910KB5HQ2VrIMCFd/2r8H0V9axz7PU b2cZtNIaDaxWhsGU+tHFIrLWR/bKzQEwuNlwc7ldCcwha2zy4xep6e7bfU6vHKhpsNqV 7Cvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KvUi4xXUaw0Gsdez/sII2VYp9q4T8l1odrgep5/r9aE=; b=k7/h6bYnzuAGyY5jluzm+niCx1e8yaQ5BKryo2dVCAOGNzg9U40l3PnYpYIlXbrZsL K+CP6TMmIeg5uXS6Z2w3sHC3rbOjJxuOAF4DzfmGOyMY5pmE21yamm0y/Myc/mDndH2h rs1JLX+TBL2aqScb7fRupSsOYdtfT6lWhKbysqxH3N4Whz6Nhv1bydXyRyfFkCvlAleE D01Glz1XgiGM8Wxer+3NT0bfQXCSvE/GoAHpevbmaovcNGkxSiBNnScONt+llqaGwJDf N6aWgONQI3wH1qb/drzx0/P6nTSbA3+cJbklNsFRMzQAV0b0OFFgjt7cZArEx4CgC9xS SOhA== X-Gm-Message-State: AJIora+ngoVhUJlziYDiZdiIJmOJMpa4SieF4oYIM4SaPG+vxw5cMxnt XLon35VrXTj4rbkqhpSzi34L5b0qQg== X-Google-Smtp-Source: AGRyM1u3RWXKYbvMbZlXJV9HgWdbCWIpY9vHZiP0MBdnlmG8yhoNWv12HEJym6YydHWar1VwhEIpYw== X-Received: by 2002:a17:902:ebc1:b0:168:fd13:8adc with SMTP id p1-20020a170902ebc100b00168fd138adcmr41512651plg.161.1656028366487; Thu, 23 Jun 2022 16:52:46 -0700 (PDT) Received: from ik1-406-35019.vs.sakura.ne.jp (ik1-406-35019.vs.sakura.ne.jp. [153.127.16.23]) by smtp.gmail.com with ESMTPSA id r10-20020a170903020a00b00168eab11f67sm362571plh.94.2022.06.23.16.52.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jun 2022 16:52:46 -0700 (PDT) From: Naoya Horiguchi X-Google-Original-From: Naoya Horiguchi To: linux-mm@kvack.org Cc: Andrew Morton , David Hildenbrand , Mike Kravetz , Miaohe Lin , Liu Shixin , Yang Shi , Oscar Salvador , Muchun Song , Naoya Horiguchi , linux-kernel@vger.kernel.org Subject: [PATCH v2 6/9] mm, hwpoison: set PG_hwpoison for busy hugetlb pages Date: Fri, 24 Jun 2022 08:51:50 +0900 Message-Id: <20220623235153.2623702-7-naoya.horiguchi@linux.dev> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220623235153.2623702-1-naoya.horiguchi@linux.dev> References: <20220623235153.2623702-1-naoya.horiguchi@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=b71HZZHM; spf=pass (imf13.hostedemail.com: domain of nao.horiguchi@gmail.com designates 209.85.214.171 as permitted sender) smtp.mailfrom=nao.horiguchi@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656028367; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=KvUi4xXUaw0Gsdez/sII2VYp9q4T8l1odrgep5/r9aE=; b=Ncg+CeelNr5x4wiHgv3kWKyCq0zQ6LCxCJYhP8rC46cE02bk9op+VLYWhVAgLa+l/v8oyI Q8VNGO83pplAswINV4uFuhz/oTwQOuDbcTBPIywjSCP5FNqzWo34deJwp2IAVwdqKpKU65 wCdZc9WMFRtDJX+dwnRSb8a+QhUQYHY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656028367; a=rsa-sha256; cv=none; b=D7hNbmPeR4HFV0Mygu4CTe2j3++84MsjRHznc3qco/+Va/ElG7rAdIjO+eEco8HkaYWwKM Mx42A8QJraVjqysIh+MptU36Xj+e2N2Y/I3NMD8C3PLxMG52DHzYGW8B0VlsVevqh/q80q IOV2Q/GGl1AAG0m0uV0vi9HD8X2fMfQ= X-Stat-Signature: q73s4g7unr8iinr13kb1jdscpayxh8nq X-Rspamd-Queue-Id: BCEA72001C X-Rspam-User: Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=b71HZZHM; spf=pass (imf13.hostedemail.com: domain of nao.horiguchi@gmail.com designates 209.85.214.171 as permitted sender) smtp.mailfrom=nao.horiguchi@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam02 X-HE-Tag: 1656028367-677854 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: From: Naoya Horiguchi If memory_failure() fails to grab page refcount on a hugetlb page because it's busy, it returns without setting PG_hwpoison on it. This not only loses a chance of error containment, but breaks the rule that action_result() should be called only when memory_failure() do any of handling work (even if that's just setting PG_hwpoison). This inconsistency could harm code maintainability. So set PG_hwpoison and call hugetlb_set_page_hwpoison() for such a case. Fixes: 405ce051236c ("mm/hwpoison: fix race between hugetlb free/demotion and memory_failure_hugetlb()") Signed-off-by: Naoya Horiguchi --- include/linux/mm.h | 1 + mm/memory-failure.c | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 4346e51484ba..044dc5a2e361 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3233,6 +3233,7 @@ enum mf_flags { MF_SOFT_OFFLINE = 1 << 3, MF_UNPOISON = 1 << 4, MF_SW_SIMULATED = 1 << 5, + MF_NO_RETRY = 1 << 6, }; extern int memory_failure(unsigned long pfn, int flags); extern void memory_failure_queue(unsigned long pfn, int flags); diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 6005e953d011..ce045d0d6115 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1632,7 +1632,8 @@ int __get_huge_page_for_hwpoison(unsigned long pfn, int flags) count_increased = true; } else { ret = -EBUSY; - goto out; + if (!(flags & MF_NO_RETRY)) + goto out; } if (hugetlb_set_page_hwpoison(head, page)) { @@ -1659,7 +1660,6 @@ static int try_memory_failure_hugetlb(unsigned long pfn, int flags, int *hugetlb struct page *p = pfn_to_page(pfn); struct page *head; unsigned long page_flags; - bool retry = true; *hugetlb = 1; retry: @@ -1675,8 +1675,8 @@ static int try_memory_failure_hugetlb(unsigned long pfn, int flags, int *hugetlb } return res; } else if (res == -EBUSY) { - if (retry) { - retry = false; + if (!(flags & MF_NO_RETRY)) { + flags |= MF_NO_RETRY; goto retry; } action_result(pfn, MF_MSG_UNKNOWN, MF_IGNORED); -- 2.25.1