From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from canpmsgout05.his.huawei.com (canpmsgout05.his.huawei.com [113.46.200.220]) (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 3A96334BA49; Sat, 11 Oct 2025 04:12:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.220 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760155947; cv=none; b=iL/lNxMN+AbX7CV+Vp7AQZQYpq++1LpX9OKJ0GHAMLpxkv3JxtS02iSvai7A3uOjIyF7raOdAU03n3FaYsIVr632HXn3VyWHEqzj1FZ73tNb05rS1G+wFMrLz0B5UTRyzsJZJjY678PPDlw9lM1n00cnH+Dzh/0C30p9lL9fhE4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760155947; c=relaxed/simple; bh=ulYOqSKIubs9K2wu/jlWOyDKb/l4q1WVrGP0tS/yfWI=; h=Subject:To:CC:References:From:Message-ID:Date:MIME-Version: In-Reply-To:Content-Type; b=dEeOJaMoc56ergm87cF2Ppamkff85eRminWqaJmSrdkEhazDVjcWjp0FkQ3U0MdOK4Wd+BnLl4DwTxVdY4soo4QSuwqo+3PtIYi+/DlKx+yc5OW1SFSB5LYWMdNLlbRc2Wn/649govIVPLdZvPaalrYVJAFreCm7rnJMPebwMFM= 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; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=KW5EKoBu; arc=none smtp.client-ip=113.46.200.220 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="KW5EKoBu" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=ygFS1bldtMkr5dFGTAJA64zNslwuK13Ve5ak8PbmFps=; b=KW5EKoBu0ELPnLe7ewEVMD/Rw+7ZwHyBBfHXllC7O9UycE3vBbIFbbHCOSHRKJMKoYpk2vnAw 9owfJMl95t95dJi44FzsWsNTrTwPS7dhFFXUYYhW/npBheqwJmbFqhINODkboOWabiuK+7oWuLv v8V7af/tBTSbFiTlSppR7CE= Received: from mail.maildlp.com (unknown [172.19.88.105]) by canpmsgout05.his.huawei.com (SkyGuard) with ESMTPS id 4ck9Cf4d1gz12LDR; Sat, 11 Oct 2025 12:11:26 +0800 (CST) Received: from dggemv705-chm.china.huawei.com (unknown [10.3.19.32]) by mail.maildlp.com (Postfix) with ESMTPS id 26A4A1402CA; Sat, 11 Oct 2025 12:12:14 +0800 (CST) Received: from kwepemq500010.china.huawei.com (7.202.194.235) by dggemv705-chm.china.huawei.com (10.3.19.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Sat, 11 Oct 2025 12:12:13 +0800 Received: from [10.173.125.37] (10.173.125.37) by kwepemq500010.china.huawei.com (7.202.194.235) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Sat, 11 Oct 2025 12:12:12 +0800 Subject: Re: [PATCH 2/2] mm/memory-failure: improve large block size folio handling. To: Zi Yan CC: , , , Lorenzo Stoakes , Baolin Wang , "Liam R. Howlett" , Nico Pache , Ryan Roberts , Dev Jain , Barry Song , Lance Yang , "Matthew Wilcox (Oracle)" , , , , , , , , References: <20251010173906.3128789-1-ziy@nvidia.com> <20251010173906.3128789-3-ziy@nvidia.com> From: Miaohe Lin Message-ID: <934db898-5244-50b9-7ef7-b42f1e40ddca@huawei.com> Date: Sat, 11 Oct 2025 12:12:12 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: <20251010173906.3128789-3-ziy@nvidia.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-ClientProxiedBy: kwepems200002.china.huawei.com (7.221.188.68) To kwepemq500010.china.huawei.com (7.202.194.235) On 2025/10/11 1:39, Zi Yan wrote: > Large block size (LBS) folios cannot be split to order-0 folios but > min_order_for_folio(). Current split fails directly, but that is not > optimal. Split the folio to min_order_for_folio(), so that, after split, > only the folio containing the poisoned page becomes unusable instead. > > For soft offline, do not split the large folio if it cannot be split to > order-0. Since the folio is still accessible from userspace and premature > split might lead to potential performance loss. Thanks for your patch. > > Suggested-by: Jane Chu > Signed-off-by: Zi Yan > --- > mm/memory-failure.c | 25 +++++++++++++++++++++---- > 1 file changed, 21 insertions(+), 4 deletions(-) > > diff --git a/mm/memory-failure.c b/mm/memory-failure.c > index f698df156bf8..443df9581c24 100644 > --- a/mm/memory-failure.c > +++ b/mm/memory-failure.c > @@ -1656,12 +1656,13 @@ static int identify_page_state(unsigned long pfn, struct page *p, > * there is still more to do, hence the page refcount we took earlier > * is still needed. > */ > -static int try_to_split_thp_page(struct page *page, bool release) > +static int try_to_split_thp_page(struct page *page, unsigned int new_order, > + bool release) > { > int ret; > > lock_page(page); > - ret = split_huge_page(page); > + ret = split_huge_page_to_list_to_order(page, NULL, new_order); > unlock_page(page); > > if (ret && release) > @@ -2280,6 +2281,7 @@ int memory_failure(unsigned long pfn, int flags) > folio_unlock(folio); > > if (folio_test_large(folio)) { > + int new_order = min_order_for_split(folio); > /* > * The flag must be set after the refcount is bumped > * otherwise it may race with THP split. > @@ -2294,7 +2296,14 @@ int memory_failure(unsigned long pfn, int flags) > * page is a valid handlable page. > */ > folio_set_has_hwpoisoned(folio); > - if (try_to_split_thp_page(p, false) < 0) { > + /* > + * If the folio cannot be split to order-0, kill the process, > + * but split the folio anyway to minimize the amount of unusable > + * pages. > + */ > + if (try_to_split_thp_page(p, new_order, false) || new_order) { > + /* get folio again in case the original one is split */ > + folio = page_folio(p); If original folio A is split and the after-split new folio is B (A != B), will the refcnt of folio A held above be missing? I.e. get_hwpoison_page() held the extra refcnt of folio A, but we put the refcnt of folio B below. Is this a problem or am I miss something? Thanks. .