From patchwork Tue Jul 12 03:28:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 12914504 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 2E060C433EF for ; Tue, 12 Jul 2022 03:29:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C5B18940040; Mon, 11 Jul 2022 23:29:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BEFF4940033; Mon, 11 Jul 2022 23:29:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AD577940040; Mon, 11 Jul 2022 23:29:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 9C81B940033 for ; Mon, 11 Jul 2022 23:29:36 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 756DD80CCF for ; Tue, 12 Jul 2022 03:29:36 +0000 (UTC) X-FDA: 79677017952.12.F0E374D Received: from out1.migadu.com (out1.migadu.com [91.121.223.63]) by imf01.hostedemail.com (Postfix) with ESMTP id F3B9C40030 for ; Tue, 12 Jul 2022 03:29:35 +0000 (UTC) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1657596574; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JJR7dULwsOIjRg//T0qlgKrx4YFTh/hs84EjZZCEhdE=; b=vRXFw5cmieXxyqaeMPEA8Zvk2csvZYgjvfGPd4EdqNrkZKBZOZ4WVxVO0DfEd4GJnBreJ6 ijWzaeE9mtO4XbTu1cadYLWZEkZdcsQyOkQmvZpL+LU5U0CIo0Cm7isW4aXWbyIlVrp7tZ hlIQPAfSEW3ZdPe2Mi6o4Wd14bPmaR0= 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: [mm-unstable PATCH v6 6/8] mm, hwpoison: make __page_handle_poison returns int Date: Tue, 12 Jul 2022 12:28:56 +0900 Message-Id: <20220712032858.170414-7-naoya.horiguchi@linux.dev> In-Reply-To: <20220712032858.170414-1-naoya.horiguchi@linux.dev> References: <20220712032858.170414-1-naoya.horiguchi@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1657596576; a=rsa-sha256; cv=none; b=OXwmXBjG1qIPHBC6ARnY89XFNI9cJdYCeIsUQZFqj7rEArqOCjKf2aiVXKoisVxoOkiDoF rEdtEUc5rPHtaCaLXurAo1+o3tWZNzqwVa5Walg2UrSOvWLlRc6pfVw0aPvNQYHNiHth+e AvB4vqFQorVsNzuAp+Ojkrn90ziE+z4= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=vRXFw5cm; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf01.hostedemail.com: domain of naoya.horiguchi@linux.dev designates 91.121.223.63 as permitted sender) smtp.mailfrom=naoya.horiguchi@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1657596576; 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=JJR7dULwsOIjRg//T0qlgKrx4YFTh/hs84EjZZCEhdE=; b=HE9G3z3Tx/c9EZYN2lQQ/FXrKgJ1X+th/D/nF+zkpWHeYqPHbNfe3Oacm56bHzrmJsY/0G 4Hr53FoA2POmQGE8AVxyHZ0XlRJQBWM7m5k7K1xxRmnnsQDZFAc8zxIW3OY4tUkW2HRZdo s4VgYelfV9sixfrdk3OcYNp1VfcIPrY= Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=vRXFw5cm; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf01.hostedemail.com: domain of naoya.horiguchi@linux.dev designates 91.121.223.63 as permitted sender) smtp.mailfrom=naoya.horiguchi@linux.dev X-Stat-Signature: ekk1a5uascgb7huq38dcfx8smrid8kut X-Rspamd-Queue-Id: F3B9C40030 X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1657596575-419824 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 --- v2 -> v3: - move deleting "res = MF_FAILED" to the later patch. (by Miaohe) --- mm/memory-failure.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index e90a685e326b..390cb7df2f4a 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 @@ -1086,7 +1092,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; } @@ -1852,7 +1858,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; }