From patchwork Tue Jun 27 11:28:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 13294368 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 F3467EB64D9 for ; Tue, 27 Jun 2023 11:29:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 55A998D0002; Tue, 27 Jun 2023 07:29:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 50A988D0001; Tue, 27 Jun 2023 07:29:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3F94A8D0002; Tue, 27 Jun 2023 07:29:04 -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 308A18D0001 for ; Tue, 27 Jun 2023 07:29:04 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id EB6881A0925 for ; Tue, 27 Jun 2023 11:29:03 +0000 (UTC) X-FDA: 80948306166.19.5AE0E0F Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf11.hostedemail.com (Postfix) with ESMTP id 0E88640014 for ; Tue, 27 Jun 2023 11:29:00 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=none; spf=pass (imf11.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 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=1687865342; 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: references; bh=nJkRWWjjcmNGWnGXLBNt6LMqyAe6b+JC/x/Tv1oyfXA=; b=6L2Rld9QRuG8F4c3bP69rmR6iOj5Ib3G6uAeSH+Ctgqfm1sPyej4xaiTDb/SUfzCUH5XYO 6+wXLc2Cep9S49Y9y1MCH0GflvnhzRFtZvUYUC2bpqLvpU0eVzYyrInbXKCS9KHBAarMKU wmHdehrKKResKEbukYWy+8EMIMfv0sE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687865342; a=rsa-sha256; cv=none; b=7/HeeBEBhaH0hkZ4wobIA4tk13p2BFx1Uer0hRJq78m8yQ08Zr0SsJuYLe6VYwniB2W2it ReeI6d5QxqhIaqRw1UNbsbpj/wpKSFCx/aIHOcswsnNN1OKVaM2UUTIbZ8S+e1nCxHAyMP 236xVnFiptZzSYCS6eu6N1ZtTTtqexc= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=none; spf=pass (imf11.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from canpemm500002.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Qr2T42PkBzMpbK; Tue, 27 Jun 2023 19:25:44 +0800 (CST) Received: from huawei.com (10.175.104.170) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Tue, 27 Jun 2023 19:28:54 +0800 From: Miaohe Lin To: , CC: , , Subject: [PATCH] mm: memory-failure: fix unexpected return value in soft_offline_page() Date: Tue, 27 Jun 2023 19:28:08 +0800 Message-ID: <20230627112808.1275241-1-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 X-Originating-IP: [10.175.104.170] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 0E88640014 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 7n95rmdxpysumfzp99z76y8hu5hux5wt X-HE-Tag: 1687865340-763697 X-HE-Meta: U2FsdGVkX18wVdWr2JEC+RcdAZLhOmMfTv2bisWzF3xtQxgXPWXx08eMgSxA5Prnow2VnJ91IdGmlpDvkFsOXRdmkQmprLc18c5iYT26q7LNQKr4Tmf61k7YzLPMmGkYM7bUaaRUyQLNWa/zbb5GeLLzoKKTj+XRyEhCuGVQLsG1ZjJBsp6K4tT16yZUqQdKo+iwCBJvCo64NLAg+1dVS3kuyHYzEFIQLXoGFol8wK6Lti70vgfiTRLA8euoJfOe6pfxnC+cMj4bhYFZvziqYQ1D7WGWRGLr4rq5EzTks7G2i7uX/qdH4TUb2yH6+sVLQ8N/Uft+SWu8i9+LY7namxem5hyA6erv5Uo2hrTIIsQvMosUP4uiaEljQ+tmo5pVFQL9AWfE+wIqQy/GrbQELTRToH4VLHrutFUdL8URekIMx8am7wXpDGQ3awe8da0sK1LIH9cc+KsSEQGkK0/5GpRsqCl/qynpGhAgWOvs5S3b4qcMXWZ550EiPA6SZguQAlL6dAub+y/9P5pDmUKQ6hsqBRj8J1vRYReSaGUptvrzIqwAEUlk9TgpZp18l3O5z44nsliNt95WeQhBu/KdhGFwHXyb6fsX/Yln6AMZaAWYPIalGq9aQcMSB+gaGfOzXBKeItUCA1ok62DFnh9/Wukdp+4JZpG8POWEOZwviNFjstKG4BC+SrUJRaWUntNLVeyQipWM6RilHvtmBR9MtZ5CPo9+QqwQFnqNR9aCf+4qmaryyhBlfKtgpL5t9mDxFQNZu2wJMeAfMg6qNOVje4HPuhGESiawbZhTGOpPhlejBk2avsRSQSpiA3byH/d410ifmc+IvXEd+6dIFFeMSxSAUemlqsHXa0jbyGbHA56ip0l8ad1RRmb3qkPpmi/RO6tc82dL6uNK9wtLUh160iizUMJ2mTkyZzhFCUmEwL1haua4gqNjd7+MELoKQhEns0cFtkTBGGN4hLHA2VA HmcGxrGY ICpq0dI/kvEZWU5XgFSsW4jt+KgpUmwLPLtUX1MjNcYvGEott2QPGpjj8ByFU4aZao0nqbWbjZt5giPshucJBrvH3/LR9bZkvQ2SGoSKPF4NYPwCXSdGrubZlBBsMGbexQrAm/HtpF1I3XG4tsQFncV63JkHs5u8axIoE45vi1wRAYIlzBswag0UArJICZI2f2eiV 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: When page_handle_poison() fails to handle the hugepage or free page in retry path, soft_offline_page() will return 0 while -EBUSY is expected in this case. Fixes: b94e02822deb ("mm,hwpoison: try to narrow window race for free pages") Signed-off-by: Miaohe Lin Acked-by: Naoya Horiguchi --- mm/memory-failure.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index aada6ac72fe5..dc1572818b7d 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -2737,10 +2737,13 @@ int soft_offline_page(unsigned long pfn, int flags) if (ret > 0) { ret = soft_offline_in_use_page(page); } else if (ret == 0) { - if (!page_handle_poison(page, true, false) && try_again) { - try_again = false; - flags &= ~MF_COUNT_INCREASED; - goto retry; + if (!page_handle_poison(page, true, false)) { + if (try_again) { + try_again = false; + flags &= ~MF_COUNT_INCREASED; + goto retry; + } + ret = -EBUSY; } }