From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 A276D1991D2 for ; Thu, 20 Nov 2025 09:38:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763631481; cv=none; b=JeUv/uDh21N4JPUxhGfAt/zjdVJlBhI+FFZWbi2qlPGnXztzpSMLavNcZN2MWIFJgxgFc3goF91IsHogCGb8FSMHd5Xs3QR5G99R+enuTO1RV2Vy5VpUTRs0q9Fd0rQuJdlvV5Jq0lkRoXWmbtJV3RcnRVN8T+DMUzXX+r8vzNs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763631481; c=relaxed/simple; bh=zKiYw+XBXS9PtcgHarEfgMCTcUZOHXMGkouq0MOYdT4=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=FVouswR/1bAzSBMxaIorfugIuERyGJ6f5on3lyjcrpGsD5R5sdchiR7RhjEmpT+uLQ0eDE5lXekqE8YwWzMh6NILVdtVZdl12WNaMcBRC91Sgn4Yf822CDhcHXz0XZpqKb8DqEt6LFaNF3cO7Q30vfBKUfIOmY4e3OEfLyWsjTg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SMjkakUH; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="SMjkakUH" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D5960C116D0; Thu, 20 Nov 2025 09:37:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1763631481; bh=zKiYw+XBXS9PtcgHarEfgMCTcUZOHXMGkouq0MOYdT4=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=SMjkakUH+b8+6PMAYnTLY8lDCmLp50jbcE4zGqHhjRrkZ6WfZjsq5LNxpMqRK2/gO YySAauK12v8bJa7pmoqDi8SBx4VeAVRQGatfGKK/j3FrWiLAyrUwi1X93y4dQGfPxL q1RCYxGAFCuvCT3vvW26wzP8pRwlu+uB3sbeab3hNHiuSCg3REQPBoh7TRDln4Qr4P OXb/XbQXk+ZLgENPcT4MDZRBzBgUhnAJNqP7JUxRqLMh6/WL+fDObvyLAFEup9ynBy +wCe+thwRScKMlc852OJIbp74rkF3hWNdHhNqBHUEnhqEBDy0tvotYUhwHGrYb1RLj 08n0OqKtn2cDA== Message-ID: Date: Thu, 20 Nov 2025 10:37:55 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH 3/3] mm/memory-failure: handle min_order_for_split() error code properly To: Zi Yan , Lorenzo Stoakes Cc: Andrew Morton , Baolin Wang , "Liam R. Howlett" , Nico Pache , Ryan Roberts , Dev Jain , Barry Song , Lance Yang , Miaohe Lin , Naoya Horiguchi , linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20251120035953.1115736-1-ziy@nvidia.com> <20251120035953.1115736-4-ziy@nvidia.com> From: "David Hildenbrand (Red Hat)" Content-Language: en-US In-Reply-To: <20251120035953.1115736-4-ziy@nvidia.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 11/20/25 04:59, Zi Yan wrote: > min_order_for_split() returns -EBUSY when the folio is truncated and cannot > be split. In commit 77008e1b2ef7 ("mm/huge_memory: do not change > split_huge_page*() target order silently"), memory_failure() does not > handle it and pass -EBUSY to try_to_split_thp_page() directly. > try_to_split_thp_page() returns -EINVAL since -EBUSY becomes 0xfffffff0 as I'm wondering whether we should change min_order_for_split() to something like: diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 7c69572b6c3f5..34eb6fec9a059 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -4210,16 +4210,19 @@ int folio_split(struct folio *folio, unsigned int new_order, SPLIT_TYPE_NON_UNIFORM); } -int min_order_for_split(struct folio *folio) +unsigned int min_order_for_split(struct folio *folio) { if (folio_test_anon(folio)) return 0; + /* + * If the folio got truncated, we don't know the previous mapping and + * consequently the old min order. But it doesn't matter, as any split + * attempt will immediately fail with -EBUSY as the folio cannot get + * split until freed. + */ if (!folio->mapping) { - if (folio_test_pmd_mappable(folio)) - count_vm_event(THP_SPLIT_PAGE_FAILED); - return -EBUSY; - } + return 0; return mapping_min_folio_order(folio->mapping); } -- Cheers David