From patchwork Wed Jun 12 07:18:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 13694532 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 D24E9C27C75 for ; Wed, 12 Jun 2024 07:22:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 887626B016D; Wed, 12 Jun 2024 03:22:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7A0156B016C; Wed, 12 Jun 2024 03:22:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 54EDA6B016A; Wed, 12 Jun 2024 03:22:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 317CA6B0169 for ; Wed, 12 Jun 2024 03:22:27 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id DCD5F140F76 for ; Wed, 12 Jun 2024 07:22:26 +0000 (UTC) X-FDA: 82221393492.24.FAC74BE Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf26.hostedemail.com (Postfix) with ESMTP id 7B3CA14000E for ; Wed, 12 Jun 2024 07:22:24 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=none; spf=pass (imf26.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718176944; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=X2T5SjfSLlo3Fw+620ziHItY48mlr8d/xzkyNpMM/iY=; b=ygTHlyoFQrMDSOybuWMd1OBJGpxQC3I46ThKB9Jf2qDRqjnDyhyROTx5oKeJebOxtKMHLk MdJkaEF+m+nGjqU0zo/fHHOlWk6o5iuG2b7YrvXwZVck6nOwosS9Z24CLs1ntcalPB64l/ 5yh6RDY16RgoC0Bcaw9LwXVFyaBqj0o= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718176944; a=rsa-sha256; cv=none; b=pVm0xHKJvk4FzomMf+FpPgrRNhBsj7vECwMkD/LrZS7/u10QlBIB4OGhpe5iqVa0wivhYB 8QFOM/e2YZ4k5utwX1IT1ZdnfE+85scmnmVJI9FFRdT8MyMRJft52RlG+hgbDcPy2ccakr cVekWjYeKz4L1r5l+y+OAasWEnikNew= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=none; spf=pass (imf26.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4VzcMW2kkSz1JCg2; Wed, 12 Jun 2024 15:18:15 +0800 (CST) Received: from canpemm500002.china.huawei.com (unknown [7.192.104.244]) by mail.maildlp.com (Postfix) with ESMTPS id D6827180AA6; Wed, 12 Jun 2024 15:22:20 +0800 (CST) Received: from huawei.com (10.173.127.72) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Wed, 12 Jun 2024 15:22:20 +0800 From: Miaohe Lin To: , , CC: , , , , Subject: [PATCH v3 03/13] mm/memory-failure: add macro GET_PAGE_MAX_RETRY_NUM Date: Wed, 12 Jun 2024 15:18:25 +0800 Message-ID: <20240612071835.157004-4-linmiaohe@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240612071835.157004-1-linmiaohe@huawei.com> References: <20240612071835.157004-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.173.127.72] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To canpemm500002.china.huawei.com (7.192.104.244) X-Rspamd-Server: rspam03 X-Stat-Signature: sp5a4nqhm3r4ehobhcqbyh4zx4r5fbjg X-Rspamd-Queue-Id: 7B3CA14000E X-Rspam-User: X-HE-Tag: 1718176944-954863 X-HE-Meta: U2FsdGVkX18sFnwU8v3LERt1dAJVTYBZqV9cNeYZ1LjbtWkrmawMGSpOoPizxOyKSR6uq9VGQVBLMeOhP/r8Nk9kYmHlM1d7LB6lKjvnua0WpRDKXTQbflVpLMlBmpfVkrQ1DMnsFzGIjeQS0+9P+oLNe4AmbyJSUQb5+iIhXQoApfK8tmpX3OLA6g25u1GFv0a8ZuhyT7ZNxHJOmb330rbYOjIwKzrya/CBxPt3mhzpuyuC35V+Y+BgcdnFHyYGP/SL3V7RmWDiX1YB/18aYcZmVnxCGl+OWIbc2FDPs5OZD0sTzLVoJnta8wTVV0aXP5biTQ4gotiwftJrhFlqJSOtzJ4Ae4jyeUvAeDhAn04DwmO+HQTGbBpzXJMjT3gC05NIf9LDXkKznueO0sJRTyZ5MQt9AfxmyaOapFUEyRI47iPVmlcY2g2HifFewEUqOWsEmr5Hl2BCFrqWyFuidjX2F9YMDc2gTHdTZ89KczJFf9yl0zUd9O8r0/u4+VVKaRtijxt0Nc/99BjDCzp8DcfeM9qblBBHzOyt6fLebiBEg+/0aLqIb/A91XX6TpD6IM9UQbw01AO7qjpufWYvkl9ogcYmYffm9x0fVzeMnD8gf3JkuBB6XVsBlFxcqueap6zcA/iTrdmh/EElZsyXOhM6PgBN03n5S26sCDDzsFNTYNCbRRFruhGU2DdPpxv4SQR11FLxuLDfgpslbPP8qa75bmDaxTxhjqCFqUsI4uX+0imqlTN+mrLnYbhdqnZ0hnN1RgM4iW76AjpFuTRntFrfUv4fue2xMgZeFVFWjP6lZi2Ls0B04pshuAqx3hhHaJvcyh/D6flIsrN6zig3y8lnsSkVylzyTNT8uIFKMGLm0lnm5c/lg2o+nC5PVoiDoUX0Vtgk+FxKYMebJq2bWQp8qMAqVSjsug/w2hlaGjn/cV09aj0gbYhlWcsKURO+c3JfwSloHzjDiP1iYg1 NMkkBFih //ECB06x69p3OCX9IdjcO7oXMwmDz34ADSiWB1Yrdhe45d7CnFSOsWFW3GAEXmCr53yMmvdS+fWTB0HkEd0NqJA8V4+r+tGAT8l2hPFRbjxJxloKEsga/jjRvC5ycqBm+SwIj5uTg3tvV2H/OZSGWuEsG3cWSrX4r80CMjdNJQGuy1s9KWH9jWyt1Kvta8eYwZtB0CCEZ0ugkdm1e+S2Oi5pBUbfWDLIklUJd551MiKSFEHlvvR/Ukoq5lSzXKTiqUTGauIOuQackQEs= 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: List-Subscribe: List-Unsubscribe: Add helper macro GET_PAGE_MAX_RETRY_NUM to replace magic number 3. No functional change intended. Signed-off-by: Miaohe Lin --- mm/memory-failure.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 4b9a9298d478..958b17a4b0f5 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1417,6 +1417,8 @@ static int __get_hwpoison_page(struct page *page, unsigned long flags) return 0; } +#define GET_PAGE_MAX_RETRY_NUM 3 + static int get_any_page(struct page *p, unsigned long flags) { int ret = 0, pass = 0; @@ -1431,12 +1433,12 @@ static int get_any_page(struct page *p, unsigned long flags) if (!ret) { if (page_count(p)) { /* We raced with an allocation, retry. */ - if (pass++ < 3) + if (pass++ < GET_PAGE_MAX_RETRY_NUM) goto try_again; ret = -EBUSY; } else if (!PageHuge(p) && !is_free_buddy_page(p)) { /* We raced with put_page, retry. */ - if (pass++ < 3) + if (pass++ < GET_PAGE_MAX_RETRY_NUM) goto try_again; ret = -EIO; } @@ -1462,7 +1464,7 @@ static int get_any_page(struct page *p, unsigned long flags) * A page we cannot handle. Check whether we can turn * it into something we can handle. */ - if (pass++ < 3) { + if (pass++ < GET_PAGE_MAX_RETRY_NUM) { put_page(p); shake_page(p); count_increased = false;