Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp2610002ybg; Fri, 31 Jul 2020 05:26:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwhrL9nfaXRPTJPHKNIaEkWIYy+rMihGDeP2IfQ9uMhwNQgfZ7l7TDvaxU9NY0a1zdQdonp X-Received: by 2002:a17:906:7e0a:: with SMTP id e10mr3758925ejr.312.1596198364956; Fri, 31 Jul 2020 05:26:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596198364; cv=none; d=google.com; s=arc-20160816; b=SpBLjEAjMI55BytLrDT58oOYVNDcaxC+fchMOrsMq7sQaLSTbl39s/Xh+LX/728EDS YdT4A+616iMKRqKabpXx2CXpTWK9z7+8A1jTeIt0+FC4146ywryoZMnfIz1Ik7w6oniu HTENGTq8SfzHVH/GIZIAB0ysHvmDaXjAU7xLPG5xO33hCD+5KlElZfOUdSK+/RSg/HNF TXdb/KQMsjHyImScDTEEXF/PApfOfXBhbeP7G6+Gq2VraAhyH+S8kZE7EX5XNbLlTPKl nvx4xsZ/f6vCYL6Tr4vhsW0XgpUJZ/uTt2karC6XDPJByWVdd21eOWue2/8m8xNNu9cC zV3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=FxsDgzNEqcc+GXlTBcfp5pXxxLZ1MIauOw9FRAHNDPk=; b=hqxqNcvTt5kyQpn/XeMj4WtXHGIknFSLNKMaFNaABmWTaucr0114/3SppS3yoS0OWV BPXdmmEebhBOp7GYYoiboOcl5PwCaJNc8AtYKutQuefSdL9PahB9TJ6jkjIRVOO1Uyk0 Babi8mDlCZuw5thqV6SElLtTYNB69W4Kfa3hqpXEF41VfJOImqyi36o0NFJCusdg9eOC yffl9E8AD3Sc1Bt0uzp+m8ZmA1MYWOa9DwvIkoK4x2bdKt+QYc+2MfYT7KlpiCnRc/ZQ ha4uHeM5HF2AwE9xdpaU9A2JNvAZ71QLfrgU7Q7rRSsX3t6OVjWGZ4Ab7UyqGtbrg7UB T9LA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=j+cx1OBS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s16si4958038ejm.36.2020.07.31.05.25.42; Fri, 31 Jul 2020 05:26:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=j+cx1OBS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733288AbgGaMWO (ORCPT + 99 others); Fri, 31 Jul 2020 08:22:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733266AbgGaMWH (ORCPT ); Fri, 31 Jul 2020 08:22:07 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0906C061574 for ; Fri, 31 Jul 2020 05:22:07 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id lx9so7654524pjb.2 for ; Fri, 31 Jul 2020 05:22:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=FxsDgzNEqcc+GXlTBcfp5pXxxLZ1MIauOw9FRAHNDPk=; b=j+cx1OBS8E2bvt6ejm6GtzbVnuEmdrBXlXUDGDyHS3BN14d+J8qglCNA8P5dyscdbE rhejc2/0Tv6FSxi3a/KiNIknFxgHibNSBa7BstR1B4aTgDmtMwDvpFjTrHrgQiV2Io4n 87litnwpe3vNHIVjCOHjje2lKf9c1C5TVWEFzHZZ9m9xj9jIAqOfWvVQ8RhPS30KKPdC hu/De093jGTRJlfZ33ye+FvGa9Y8IsXm7OSUv9jTYCPqIp7RPzo1LVbYwK9SBIMZhC4X ZV/NQmbTRf7uXrYGvEK81AEqwsVkAFqUfj8WjxMGmm/Jb998vCq0Exbcfie0jdmxPt4x k01w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=FxsDgzNEqcc+GXlTBcfp5pXxxLZ1MIauOw9FRAHNDPk=; b=OZdRiijunaI7qomH9klwewMPmBgllvCKVT3AF0lbix5Njuxnw4UWcyfIHks7X4zhMC qE3vm1gWGNrxpfXDk5xB3mt2upvL0dX1OhDv8Box0ArxBqtUlAurmRM69ZkIBT3NvKeH 4g3He7+PD4V0iM1gJzs1kubEa1TX+s7bD9HtqNupnqRUqh7HcCKEiDbZOZTVQO6owclz ZR7xPZDN47DFndOO5BMv52FXvtE/N+Tc8M7MxaPZY20Tf1BQ7pI9vuOTN8HdoKwoFBpG zbIFcHwwv6Vnsd+um0dAEY7qomNuBfVdkwgZCsPXvyj5L0L0f4BPA11FD0Q3z+7dhhy9 FTbQ== X-Gm-Message-State: AOAM530eCqrEQOiWkxm6Lfddmw/+xv2jA5/fz6M67ew4fMiMugI0i2Zb lEX8Shw4YB9JzR1Mb57zDw== X-Received: by 2002:a17:90a:ef17:: with SMTP id k23mr3484135pjz.45.1596198127344; Fri, 31 Jul 2020 05:22:07 -0700 (PDT) Received: from ip-172-31-41-194.ap-northeast-1.compute.internal (ec2-52-199-21-241.ap-northeast-1.compute.amazonaws.com. [52.199.21.241]) by smtp.gmail.com with ESMTPSA id m19sm3675692pjv.34.2020.07.31.05.22.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 05:22:06 -0700 (PDT) From: nao.horiguchi@gmail.com To: linux-mm@kvack.org Cc: mhocko@kernel.org, akpm@linux-foundation.org, mike.kravetz@oracle.com, osalvador@suse.de, tony.luck@intel.com, david@redhat.com, aneesh.kumar@linux.vnet.ibm.com, zeil@yandex-team.ru, cai@lca.pw, naoya.horiguchi@nec.com, linux-kernel@vger.kernel.org Subject: [PATCH v5 16/16] mm,hwpoison: double-check page count in __get_any_page() Date: Fri, 31 Jul 2020 12:21:12 +0000 Message-Id: <20200731122112.11263-17-nao.horiguchi@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200731122112.11263-1-nao.horiguchi@gmail.com> References: <20200731122112.11263-1-nao.horiguchi@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Naoya Horiguchi Soft offlining could fail with EIO due to the race condition with hugepage migration. This issuse became visible due to the change by previous patch that makes soft offline handler take page refcount by its own. We have no way to directly pin zero refcount page, and the page considered as a zero refcount page could be allocated just after the first check. This patch adds the second check to find the race and gives us chance to handle it more reliably. Reported-by: Qian Cai Signed-off-by: Naoya Horiguchi --- mm/memory-failure.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git v5.8-rc7-mmotm-2020-07-27-18-18/mm/memory-failure.c v5.8-rc7-mmotm-2020-07-27-18-18_patched/mm/memory-failure.c index 6f242a194c64..b2753ce2b85b 100644 --- v5.8-rc7-mmotm-2020-07-27-18-18/mm/memory-failure.c +++ v5.8-rc7-mmotm-2020-07-27-18-18_patched/mm/memory-failure.c @@ -1694,6 +1694,9 @@ static int __get_any_page(struct page *p, unsigned long pfn) } else if (is_free_buddy_page(p)) { pr_info("%s: %#lx free buddy page\n", __func__, pfn); ret = 0; + } else if (page_count(p)) { + /* raced with allocation */ + ret = -EBUSY; } else { pr_info("%s: %#lx: unknown zero refcount page type %lx\n", __func__, pfn, p->flags); @@ -1710,6 +1713,9 @@ static int get_any_page(struct page *page, unsigned long pfn) { int ret = __get_any_page(page, pfn); + if (ret == -EBUSY) + ret = __get_any_page(page, pfn); + if (ret == 1 && !PageHuge(page) && !PageLRU(page) && !__PageMovable(page)) { /* -- 2.17.1