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 2E9E913D503 for ; Thu, 20 Nov 2025 09:27:25 +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=1763630846; cv=none; b=eBMtbdjWxtt+H1LEDo8uellqn1HCz9hs6+9Am1yJTuf3w/6v3X0PqpEWTcnwtMrcPKqtiIqogsw0WPgDAC7z2e7xab5QQmfgnWAQHbYPhsiHONiQFk+Bf7OFeH32eUigIkV2NO29ARz64FiHxGCGSZviYLfxB4iCCgBLSpWe/lE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763630846; c=relaxed/simple; bh=QdloOt8cu34ANIA6zb8ozqP/R30pLrtG2CYpcwlNMT8=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=UsGDPfGUrgZwIDcfw7MFHAZ7bFkZ2pfPqOV3r278cbKub5dq4QGKUsPOVnXjkGr8cxql7e3tiVJXA/w7f4wiSxcGyyQIrkXDPOI7oA+kceYvz601H8Zh8RBNWTF3qKAYl0rVNU7U/NgKvEiEi2T8nQER9C1QQv/1M3pPQcITzSg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fHEGkPPQ; 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="fHEGkPPQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5BACBC116C6; Thu, 20 Nov 2025 09:27:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1763630845; bh=QdloOt8cu34ANIA6zb8ozqP/R30pLrtG2CYpcwlNMT8=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=fHEGkPPQu0ebI3D6LHZEQujaFH8VCYB4yPZR+rA+Drp09TVIcgDPn9DcClu9Igd/c EgOEwWGTFPNyGKr397R19g+6P84WxXoFpGoWANv5nbwOvzbkMaMvOO7h2+XFaYZvDz C0sRlfhWPBcE87N5zw4gM5jBePSf2I+h0M+KCYJ0QXJ7RP3Cgp6KuEK5NrnV+8a2GK sAlJHIPMt3GGo6uBJrgRRwybVOPFhH/b2vhX7o9aPSgcwrHZf/srs/1k784BPw0NUc oi02jujRz/qMBL8TWq6LPmJWJgwDxi+R4RmOTPI6eJ/K662GbCtsFuTdK14X4iOiqJ GUZtCkKz0QaEQ== Message-ID: Date: Thu, 20 Nov 2025 10:27:20 +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 2/3] mm/huge_memory: add kernel-doc for folio_split_supported() 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-3-ziy@nvidia.com> From: "David Hildenbrand (Red Hat)" Content-Language: en-US In-Reply-To: <20251120035953.1115736-3-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: > It clarifies that folio_split_supported() does not check folio->mapping and > can dereference it. > > Signed-off-by: Zi Yan > --- > mm/huge_memory.c | 17 +++++++++++++++++ > 1 file changed, 17 insertions(+) > > diff --git a/mm/huge_memory.c b/mm/huge_memory.c > index efea42d68157..15e555f1b85d 100644 > --- a/mm/huge_memory.c > +++ b/mm/huge_memory.c > @@ -3688,6 +3688,23 @@ static int __split_unmapped_folio(struct folio *folio, int new_order, > return 0; > } > > +/** > + * folio_split_supported() - check if a folio can be split to a given order > + * @folio: folio to be split > + * @new_order: the smallest order of the after split folios (since buddy > + * allocator like split generates folios with orders from @folio's > + * order - 1 to new_order). > + * @split_type: uniform or non-uniform split > + * @warns: whether gives warnings or not for the checks in the function > + * > + * folio_split_supported() checks if @folio can be split to @new_order using > + * @split_type method. > + * > + * Context: Caller must make sure folio->mapping is not NULL, since the > + * function does not check it and can dereference folio->mapping Only for anon folios. Also, I would drop the detail about dereference. I guess we really need the folio lock to prevent concurrent truncation. Maybe something like: "The folio must be locked. For non-anon folios, the caller must make sure that folio->mapping is not NULL (e.g., not truncated)." -- Cheers David