Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp240856pxk; Thu, 17 Sep 2020 01:31:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwOIOxrTjLfueUaQM7QPgd7v8c2dIQN0wsWcG5T45uIDetIyoJOUkotrphMoKobeVdEDxKv X-Received: by 2002:aa7:d7ca:: with SMTP id e10mr30815229eds.191.1600331506424; Thu, 17 Sep 2020 01:31:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600331506; cv=none; d=google.com; s=arc-20160816; b=uE6oVOXLM5M9kgLz5poHcIUyRsn0r0RuBsESyOXmKlDXXc/G+MET/PG4LRb8sOgjJs WhPN6MpjQghKTZ5iVx2CcStH4RHrJUxo3DQ6PyC885CHTdSqn5m2frAvbZ/Y2t3rlbsN NH897aBoiqRo5oEg3NujogeQK0gVnkK2nVwFlILnK84jbGhzO+gNpDCxn4P752drI+6X C953eHDgFdcX9NgjDTRVidtVeaOsEBmoPLRw01VA5TMkt5iknje+VEFu2vgEroatPhOb bQ9fFXEhKtHt5Fs0g+6Ax08h5bmkiFUpMheypCgazbwEeS+Ff9HvBShVfgT+Gmsd6idv +fZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=6EqYb/AmEgT2sEZElMzivh2pMn8Nf0qEkFy2xnieggo=; b=desXm6UH1p2PlGpYeLERurzrkPd1SUTwnmVHw7OUEodZj8lxRhkiAS688/I8e/VAtz +seNtgcqxNFBC/x7ljQxkJHb1s2SXcm8L94ZYdj2nQipApnOz1osFq2RujkhpvuH+7/W Fx2gAZIckcYYJUkieOEJxvLhn9fxeQ8kS1yO4Ie0fBnKaVqKi3d7kNf+rjzteLEJC3px QJfKBjoKHNm3Jns/f+4uZe/fGMjQrjaDrE5z9CAUD0q258PdGH1wtf45lEWBqd7BEyf8 DsPwySEZnUSAe4LzJLB/e10bx4kGbm7ExHHhfk71h+DDZV7/xQms0e8aptfY7pSqrWB/ 0kTA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h21si12793922edq.257.2020.09.17.01.31.23; Thu, 17 Sep 2020 01:31:46 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726355AbgIQI1t (ORCPT + 99 others); Thu, 17 Sep 2020 04:27:49 -0400 Received: from mx2.suse.de ([195.135.220.15]:47690 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726185AbgIQI1s (ORCPT ); Thu, 17 Sep 2020 04:27:48 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 2A772B134; Thu, 17 Sep 2020 08:28:18 +0000 (UTC) From: Oscar Salvador To: akpm@linux-foundation.org Cc: aris@ruivo.org, naoya.horiguchi@nec.com, mhocko@kernel.org, tony.luck@intel.com, cai@lca.pw, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Oscar Salvador Subject: [PATCH v4 3/7] mm,hwpoison: Try to narrow window race for free pages Date: Thu, 17 Sep 2020 10:10:45 +0200 Message-Id: <20200917081049.27428-4-osalvador@suse.de> X-Mailer: git-send-email 2.13.7 In-Reply-To: <20200917081049.27428-1-osalvador@suse.de> References: <20200917081049.27428-1-osalvador@suse.de> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Aristeu Rozanski reported that a customer test case started to report -EBUSY after the hwpoison report patchset. There is a race window between spotting a free page and taking it off its buddy freelist, so it might be that by the time we try to take it off, the page has been already allocated. This patch tries to handle such race window by trying to handle the new type of page again if the page was allocated under us. After this patch, Aristeu said the test cases work properly. Signed-off-by: Oscar Salvador Reported-by: Aristeu Rozanski --- mm/memory-failure.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index db61bdee9734..a2ccd3ba4015 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1917,6 +1917,7 @@ int soft_offline_page(unsigned long pfn, int flags) { int ret; struct page *page; + bool try_again = true; if (!pfn_valid(pfn)) return -ENXIO; @@ -1932,6 +1933,7 @@ int soft_offline_page(unsigned long pfn, int flags) return 0; } +retry: get_online_mems(); ret = get_any_page(page, pfn, flags); put_online_mems(); @@ -1939,7 +1941,10 @@ int soft_offline_page(unsigned long pfn, int flags) if (ret > 0) ret = soft_offline_in_use_page(page); else if (ret == 0) - ret = soft_offline_free_page(page); + if (soft_offline_free_page(page) && try_again) { + try_again = false; + goto retry; + } return ret; } -- 2.26.2