From patchwork Thu Jun 23 23:51:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 12893261 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 BB9A2C433EF for ; Thu, 23 Jun 2022 23:52:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 646FB8E01AC; Thu, 23 Jun 2022 19:52:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 61D378E01A1; Thu, 23 Jun 2022 19:52:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 50D228E01AC; Thu, 23 Jun 2022 19:52:51 -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 4208C8E01A1 for ; Thu, 23 Jun 2022 19:52:51 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id 22261604BB for ; Thu, 23 Jun 2022 23:52:51 +0000 (UTC) X-FDA: 79611153342.15.D8188DE Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) by imf23.hostedemail.com (Postfix) with ESMTP id AC1C614002E for ; Thu, 23 Jun 2022 23:52:50 +0000 (UTC) Received: by mail-pf1-f179.google.com with SMTP id bo5so1058017pfb.4 for ; Thu, 23 Jun 2022 16:52:50 -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=5pQfND038h5QWcn78qM/I1ai1qmbxoygS2JmZLRC1mQ=; b=iXRbqsMPfof+NUltQHH89pGwAzb42H/dstNMxQgGGt6Yt//W8LgTGOTG0OaoSTeNRz dZWUB59vT4SDDN3iALIsxg16784gK20+rZPhBd+mZNDSqMB9O7U2WxsqjohKmBB6pXUG nibweuhhc5VKaNupCNP0N0YPwZxrsIyX/Bb9vW1e68rAyv5FmPBsYHd9kQFfKyW1Ez5f w5un26afpOlcnOq5acBDDRhfwfXCkdcFPIehGQOKnQhnUuw02P3Yd7V2Oqo0X9yKyjgn RWPTgZnrtjJ7VlJaB/hzIuIdKb1hqY3+8AgAQyB9hZ3NMamUhCbmytLPWpfDRAdW+V2/ eftw== 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=5pQfND038h5QWcn78qM/I1ai1qmbxoygS2JmZLRC1mQ=; b=cMe8aKwM1X2+OQhlLXaeCM1A/snCiF4ukNHvbtPcIB7dpVvMESvt84Q/XblFVGaG7c 3oWZBFTWkFCOT6DJ+mwmkkjlEeuZlH4RIotDMW2FSWd4IwX+0oURbYlZOmfUb1mebJ6v GrtnrxvuBuzxOx84yiVk7oXU/QcvqbVFqtwYwV5UgXOocBGJkADECCeAMS3h2+CT7ntV DkuwveI424FtjDpsSzQUl/3rvQpYCtrxkkZvB6z3+tUUvmJgDt9azLIL1LHn/XZ3hmYg WpKq528OgU3BPF4FzOABzrnn2xbzx+cn7KinyBNK2egYYrQPj3KBJe8rPgdkNbQG1WL5 K+UQ== X-Gm-Message-State: AJIora/bj29MXYIyhahAvhYa4Qep6YCZ28RLBmhvc2lQ2MOXRKfJwEcE bkkCvRcHsbIuuGzW/lcpsepXCGYZ1w== X-Google-Smtp-Source: AGRyM1s96G2FFH66JXa8bc7eH4qd+fIDxeMhCkK8flgwP1JhK2XMzt6hxEJTmkotzQNPWlNmHQYnig== X-Received: by 2002:a63:7b5c:0:b0:40d:684:b760 with SMTP id k28-20020a637b5c000000b0040d0684b760mr9535270pgn.323.1656028369640; Thu, 23 Jun 2022 16:52:49 -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.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jun 2022 16:52:49 -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 7/9] mm, hwpoison: make __page_handle_poison returns int Date: Fri, 24 Jun 2022 08:51:51 +0900 Message-Id: <20220623235153.2623702-8-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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656028370; a=rsa-sha256; cv=none; b=DtnaTEtEmGcLADe4ayqMXNFWI9NsB660Ov1uB/3ZCoi7NbW3IvUFPb+uRS37JHabNuh7VP K0DJ2nWHSbdMjgRqKf+h9VUCBRJcJgmIUzoruRL9xxAEXqtkSxFjeYyP352+erZu60Zvhw PIvxoA0X/st5uB47lOtmkKFVLNb3ri4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656028370; 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=5pQfND038h5QWcn78qM/I1ai1qmbxoygS2JmZLRC1mQ=; b=Y5um0eEcIFkOVB57S5C6Pogj308h9FGOV04VABAIIAGDef9y4+CMg+gwJRt4YiHDEYJHD2 t5cx08G9chqozX3GOXt2JTm0YbuQRdxQB7WUinXqjsdfjhvyCSe+Uf/zvj23aej7pWHC6E cbVUJ/cj8G6TJ3F5+vW4ggPOZmiRz3o= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=iXRbqsMP; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf23.hostedemail.com: domain of nao.horiguchi@gmail.com designates 209.85.210.179 as permitted sender) smtp.mailfrom=nao.horiguchi@gmail.com X-Stat-Signature: 1di557orptjgjhnjjw5eort5c6ofkd5j X-Rspamd-Queue-Id: AC1C614002E Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=iXRbqsMP; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf23.hostedemail.com: domain of nao.horiguchi@gmail.com designates 209.85.210.179 as permitted sender) smtp.mailfrom=nao.horiguchi@gmail.com X-Rspam-User: X-Rspamd-Server: rspam04 X-HE-Tag: 1656028370-498680 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 __page_handle_poison() returns bool that shows whether take_page_off_buddy() has passed or not now. But we will want to distinguish another case of "dissolve has passed but taking off failed" by its return value. So change the type of the return value. No functional change. Signed-off-by: Naoya Horiguchi Reviewed-by: Miaohe Lin --- mm/memory-failure.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index ce045d0d6115..db85f644a1e3 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -71,7 +71,13 @@ atomic_long_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0); static bool hw_memory_failure __read_mostly = false; -static bool __page_handle_poison(struct page *page) +/* + * Return values: + * 1: the page is dissolved (if needed) and taken off from buddy, + * 0: the page is dissolved (if needed) and not taken off from buddy, + * < 0: failed to dissolve. + */ +static int __page_handle_poison(struct page *page) { int ret; @@ -81,7 +87,7 @@ static bool __page_handle_poison(struct page *page) ret = take_page_off_buddy(page); zone_pcp_enable(page_zone(page)); - return ret > 0; + return ret; } static bool page_handle_poison(struct page *page, bool hugepage_or_freepage, bool release) @@ -91,7 +97,7 @@ static bool page_handle_poison(struct page *page, bool hugepage_or_freepage, boo * Doing this check for free pages is also fine since dissolve_free_huge_page * returns 0 for non-hugetlb pages as well. */ - if (!__page_handle_poison(page)) + if (__page_handle_poison(page) <= 0) /* * We could fail to take off the target page from buddy * for example due to racy page allocation, but that's @@ -1048,7 +1054,7 @@ static int me_huge_page(struct page_state *ps, struct page *p) * subpages. */ put_page(hpage); - if (__page_handle_poison(p)) { + if (__page_handle_poison(p) > 0) { page_ref_inc(p); res = MF_RECOVERED; } @@ -1698,8 +1704,7 @@ static int try_memory_failure_hugetlb(unsigned long pfn, int flags, int *hugetlb */ if (res == 0) { unlock_page(head); - res = MF_FAILED; - if (__page_handle_poison(p)) { + if (__page_handle_poison(p) > 0) { page_ref_inc(p); res = MF_RECOVERED; }