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 CF3C721A449 for ; Mon, 24 Nov 2025 10:43:09 +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=1763980989; cv=none; b=mYFpRpOtXGefKKlUMSzBjwEffy8ret9Vlb1zcExI+gxFfjes1ZsL33BzEgjn6I0zvqH1nWMxarearfYLUXzuAhI6+4v4gSVnsXm4pCxwD8AftHCz4MYBfrMQGboDjmcqYb/20xmJJPOxjisJjjdj1ddpqbC6HsEbUzs+9YDK9HQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763980989; c=relaxed/simple; bh=8yb/Zh8IAsTuyjN2fF0L3+H/I8uGrHqhJzE3awGGxmo=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=rNgaIW4TBdG8yhb0Sw27n81wZ/jZJ/PScJvJBRaZM0zU/RoGojMHQa/8GQnwTOKRSofwc/rAQy3XY+qb8qEr/HMkmGWl761JGd+5EifeVyDLJ0VCD/bLK3Ww8LfWguFwNxWUDIWVWRx/kNDIWO6vF30KXBIQOsHJwDMqY1zCgk8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FhkI/+ir; 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="FhkI/+ir" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9F97CC4CEF1; Mon, 24 Nov 2025 10:43:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1763980989; bh=8yb/Zh8IAsTuyjN2fF0L3+H/I8uGrHqhJzE3awGGxmo=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=FhkI/+ir/Y5bu4smkD5Dwiy9+sPSNUS/9fjx2uGPQ6n0JvQh67miHY4FSU8MEIKgO amkv+wUp0mylorizSl0Pb4QmzLWVKpdEnBuKNfudku/Oez8D7WtlAEJ1eEUeIyFnhB CC77P1EYfJH8/puLaX1si83dJrEpDIH0i4Um/8KBXVx31RRjsfAc5V+rDskmrHiBl9 1UTFas2ELYz8hA/saYlmBaqTivJ2nP8Q4p5shN4T8htWyMeco1Ow2Yoj3uopulzicA 3UdW1zgTQMTIM9/m38MxRHcWJdMqunYrb5Ca5Rao2c/bxs+5W1msWTA4cMydYw9x9U JzlUeGdXQGVvQ== Message-ID: <257c778f-1997-4986-8a6b-ae42bffc46d6@kernel.org> Date: Mon, 24 Nov 2025 11:43:03 +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: [PATCH v2 3/4] mm/huge_memory: make min_order_for_split() always return an order 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 , Wei Yang , Balbir Singh , linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20251122025529.1562592-1-ziy@nvidia.com> <20251122025529.1562592-4-ziy@nvidia.com> From: "David Hildenbrand (Red Hat)" Content-Language: en-US In-Reply-To: <20251122025529.1562592-4-ziy@nvidia.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 11/22/25 03:55, 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 > new_order is unsigned int in __folio_split() and this large new_order is > rejected as an invalid input. The code does not cause a bug. > soft_offline_in_use_page() also uses min_order_for_split() but it always > passes 0 as new_order for split. > > Fix it by making min_order_for_split() always return an order. When the > given folio is truncated, namely folio->mapping == NULL, return 0 and let > a subsequent split function handle the situation and return -EBUSY. > > Add kernel-doc to min_order_for_split() to clarify its use. > > Signed-off-by: Zi Yan Acked-by: David Hildenbrand (Red Hat) -- Cheers David