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: 113386 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp8145388vqr; Tue, 27 Jun 2023 05:11:14 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5zYlnV9VShm7bbuza+gxb2ihfsWWbZ2GaufUFpXQvkcEMC/DD7JKJNiyZ9Ss4VNEqzGYo2 X-Received: by 2002:a05:6a21:3292:b0:126:561c:9ebc with SMTP id yt18-20020a056a21329200b00126561c9ebcmr13050251pzb.31.1687867874022; Tue, 27 Jun 2023 05:11:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687867874; cv=none; d=google.com; s=arc-20160816; b=th0keM6BNgEpCLTb8N5SWmN8mNep/HHgnVg3yP1kftsARHFG9HLMxpJuqtwKkI1p2T xA8it6ejjFLeWZODLVzigb2p2Q7YaO9GAPJekqDhSTYR/6gnrlaujHQGhpF3mgODRlgE cU/5xnAtPmS0Lr+kes7lve4n3gywHvR/FEOYxEZPWTgD5IPg7G9a360H9kPmXN0uAfnh XA2VWmCA1FXCF0HsXCp5GkJ91xW1QRNykfc7EFUTTcWBIG5pNxNvbags2CEgE+oQ7DeS cJEjKUGgowujjI8nBlplRKSQg6jDVEYuDRXFSZhwEB3P67tvuPiIreuKMDPnbvrm1Odr 5S5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=nJkRWWjjcmNGWnGXLBNt6LMqyAe6b+JC/x/Tv1oyfXA=; fh=kP0L7jzW604qIlwIWwCV4xHGxfeYL9qfthvX96QEubA=; b=0PW20x7SZhFmtqKcmNB7WQpuJxeT1KE8DDX6v6OkIkYjnbcctjkJIleOZrwrD7CU+Z R6oIbxTXnqb24UH0mFrftjyVGV1oXAYwcea4gf+9RWGIEwS7IIRXxpJlw0o/pFkykStQ iMR9hq5/jL2zSB2ZY4N4KoILMPmBFdDTeWJcv2HOuCxPzCGcuiQoQpEXd24FDCQT0OAD TKSZt2jOr227uGCrnLnCnGs+ub9JU8HahM2t3rktWfghhmjpavjorra8Ge5toM1u97xy TzMROFMrKHN4LtR2GjdjAyWd2YrYos4tQO062HEZpNIjwPg8NHKfDQewQG1AJtjAtYCj g5lw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y191-20020a638ac8000000b005538cf8f180si7277221pgd.413.2023.06.27.05.11.01; Tue, 27 Jun 2023 05:11:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231167AbjF0L3E (ORCPT + 99 others); Tue, 27 Jun 2023 07:29:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229501AbjF0L26 (ORCPT ); Tue, 27 Jun 2023 07:28:58 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C75C26A9 for ; Tue, 27 Jun 2023 04:28:57 -0700 (PDT) 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-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769857743817399978?= X-GMAIL-MSGID: =?utf-8?q?1769857743817399978?= 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; } }