From patchwork Thu Jun 6 06:32:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 13687871 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9055440BE5; Thu, 6 Jun 2024 06:36:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.189 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717655789; cv=none; b=agao5Xn0+PpDtYuJ0WCjqaBibyXA2Ioa4/6gIKs4YEWNOR1KtCJ7nbXwxz88gOe/nrePb7TrO+nOsxbmBeHWMLVosEMGGHcfQklhBy+Oq3WHNGRc2/Y9OPQ4e2dezhgFVZ7PGBz4UI/Fi/ZB4UStE0aLPAzSne0yH99i2oEw8YA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717655789; c=relaxed/simple; bh=LpCilvrxxf8tM9GGSPfQXv0XzkTIE5c7P5qRmJ7Ugoo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YqHmum8zH9cBn5yI4IRfLOGTUFCRixJhJ2nvhj/hu1DzdBpNY68OyoNkFz3w0QWCnDiYjkAZHHmjiePhTj7LG/UPgygnv5b5BIixp9sVr6WPH/JeHs9bCCHnfWJBpX5u59dhAr/d72h49RrzDUFPdgXB8GFLFICJOYA9tvRdhvA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.189 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.194]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4Vvvf95PB3zPpZH; Thu, 6 Jun 2024 14:33:05 +0800 (CST) Received: from canpemm500002.china.huawei.com (unknown [7.192.104.244]) by mail.maildlp.com (Postfix) with ESMTPS id 16305140133; Thu, 6 Jun 2024 14:36:24 +0800 (CST) Received: from huawei.com (10.173.135.154) 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; Thu, 6 Jun 2024 14:36:23 +0800 From: Miaohe Lin To: , , CC: , , , , Subject: [PATCH v2 03/13] mm/memory-failure: add macro GET_PAGE_MAX_RETRY_NUM Date: Thu, 6 Jun 2024 14:32:37 +0800 Message-ID: <20240606063247.712575-4-linmiaohe@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240606063247.712575-1-linmiaohe@huawei.com> References: <20240606063247.712575-1-linmiaohe@huawei.com> Precedence: bulk X-Mailing-List: linux-edac@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To canpemm500002.china.huawei.com (7.192.104.244) 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;