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 D47EBC43334 for ; Thu, 30 Jun 2022 02:28:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6F3C78E0003; Wed, 29 Jun 2022 22:28:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6A2238E0001; Wed, 29 Jun 2022 22:28:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 591488E0003; Wed, 29 Jun 2022 22:28:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 4A4198E0001 for ; Wed, 29 Jun 2022 22:28:38 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id 246B760388 for ; Thu, 30 Jun 2022 02:28:38 +0000 (UTC) X-FDA: 79633318716.17.80F5B9F Received: from out2.migadu.com (out2.migadu.com [188.165.223.204]) by imf22.hostedemail.com (Postfix) with ESMTP id 9FC28C0031 for ; Thu, 30 Jun 2022 02:28:37 +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=1656556116; 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=F1HjpbdSg3INkY0e3nuMILPlQpmtYTlbMJAcRh/swko=; b=TXlbsl+jLSMbzIlvE6VKU8WOFAO2e2aBhqXGEKD5kEcPLHiYms/CrrRiHMSAYCjDMBvNJ9 fxD63qOHRTm8VvAIoskAbJ5oxA2hLWzGGuVasdhTBrfzJQxja3e6/29L5MbxK1sYkL4pYu tsZ2cT1bPVOgDXSDTKr8LCzdf7SflHg= 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 v3 7/9] mm, hwpoison: make __page_handle_poison returns int Date: Thu, 30 Jun 2022 11:27:53 +0900 Message-Id: <20220630022755.3362349-8-naoya.horiguchi@linux.dev> In-Reply-To: <20220630022755.3362349-1-naoya.horiguchi@linux.dev> References: <20220630022755.3362349-1-naoya.horiguchi@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656556117; 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=F1HjpbdSg3INkY0e3nuMILPlQpmtYTlbMJAcRh/swko=; b=UVMR05OKHfYJU6WpItVU2ul0tJjTp2CY/fSSTQzb02ofUUxB1g9eH4Uw4g+MMNAbzY7Rh7 SAsgyfIYUQ63M+fDRhZr9fQXvVeQXON5NP1sLcSDBZScvUfqD0C0NxRpo8vhdgwsCCnm/n Z0jftWXHAcQIZcRtcc9elCmQVolWx9c= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656556117; a=rsa-sha256; cv=none; b=xe3zSwnFcBo6/7QsNHVgE4hvCxZGepppQt/twzlZTlUFya2hc6lE6slcEr9fLx8kkRO31T OmBZ+zXkQD26GOETTBeR31h1jWHvzro4arjHCA/PI/GafM4314fhvh9JgdCjE6iqN8j8GB UUOR3a3TDok0KQQnoyZtm3aKPxdDm/w= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=TXlbsl+j; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf22.hostedemail.com: domain of naoya.horiguchi@linux.dev designates 188.165.223.204 as permitted sender) smtp.mailfrom=naoya.horiguchi@linux.dev Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=TXlbsl+j; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf22.hostedemail.com: domain of naoya.horiguchi@linux.dev designates 188.165.223.204 as permitted sender) smtp.mailfrom=naoya.horiguchi@linux.dev X-Rspamd-Server: rspam03 X-Rspam-User: X-Stat-Signature: ptp7w9r7wg3q6umyui89xhz4ofmc768p X-Rspamd-Queue-Id: 9FC28C0031 X-HE-Tag: 1656556117-807008 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 81e591cf8b4a..6c7b9129eade 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; } @@ -1684,7 +1690,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; } -- 2.25.1