From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out30-111.freemail.mail.aliyun.com (out30-111.freemail.mail.aliyun.com [115.124.30.111]) (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 948A3282F03 for ; Tue, 3 Mar 2026 02:16:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.111 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772504166; cv=none; b=vBLkw0tPbum6/Drjqj2qh5SMxelcnzk3EueKohRvd0ewWxDuX606qgepT99BuRoCvjah2vA4PzIK0AuAzaLGHMu7iKnIx6JKsAoYP53OV5/0m8h86KMR0kb4pHUIWQ63FbsZgMowVWGHrpJCUKOo5kUOkJ8WjdwBxFGfbOY0veU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772504166; c=relaxed/simple; bh=Tcky8kxlxxVf7/PXi9Tli1BPp/Lew5iyol6sP9Kcw8M=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Ct8CtLMXYGTjhQN1s4o0txzvKhHaj+blqDsPHeMZ8qP0ZLHpRjVIC+hhxQy1U+dLekISw4pl19JKKXRUclcRLzhShilQWbHTr2dQykLm4eWZXIg+MJi22FOHXUeSG4u8hc8ZOMEp5XYlUidel65VpVelnIgwqhlI1vVkEYqg6B0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=LY1UZt+l; arc=none smtp.client-ip=115.124.30.111 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="LY1UZt+l" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1772504162; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=yV4vZDGDVVlhjOAdU9w5q9Pwayzq2sJKIaf2Eslzy9E=; b=LY1UZt+llyc55502iarm1ioW+05mku0F8Rf2pKh8rLe3An9F3go2hrkFyDugaWMea29T0CEBAocw+zpZyjc15zsT5tWoSVf4hjvlvXjXfoZTwWg+RRLToxO6kaaWrMOYwWGIfnyIHjL1YF1GsZq9CdF8bLTY/iOKobhmGapjmZw= Received: from 30.74.144.119(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0X-80hnW_1772504161 cluster:ay36) by smtp.aliyun-inc.com; Tue, 03 Mar 2026 10:16:01 +0800 Message-ID: <0c742d98-82ee-4085-bf3b-26fac5897bde@linux.alibaba.com> Date: Tue, 3 Mar 2026 10:16:00 +0800 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] khugepaged: remove redundant index check for pmd-folios To: Dev Jain , akpm@linux-foundation.org, david@kernel.org, lorenzo.stoakes@oracle.com Cc: ziy@nvidia.com, Liam.Howlett@oracle.com, npache@redhat.com, ryan.roberts@arm.com, baohua@kernel.org, lance.yang@linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20260227143501.1488110-1-dev.jain@arm.com> From: Baolin Wang In-Reply-To: <20260227143501.1488110-1-dev.jain@arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2/27/26 10:35 PM, Dev Jain wrote: > Claim: folio_order(folio) == HPAGE_PMD_ORDER => folio->index == start. > > Proof: Both loops in hpage_collapse_scan_file and collapse_file, which > iterate on the xarray, have the invariant that > start <= folio->index < start + HPAGE_PMD_NR ... (i) > > A folio is always naturally aligned in the pagecache, therefore > folio_order == HPAGE_PMD_ORDER => IS_ALIGNED(folio->index, HPAGE_PMD_NR) == true ... (ii) > > thp_vma_allowable_order -> thp_vma_suitable_order requires that the virtual > offsets in the VMA are aligned to the order, > => IS_ALIGNED(start, HPAGE_PMD_NR) == true ... (iii) > > Combining (i), (ii) and (iii), the claim is proven. > > Therefore, remove this check. > While at it, simplify the comments. > > Signed-off-by: Dev Jain > --- Reviewed-by: Baolin Wang