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 5FC2C312832 for ; Thu, 9 Apr 2026 07:36: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=1775720169; cv=none; b=jXwli3WSyAzYZhSSMma6cdROsF2WEfhkQeuXv0ZGwwsUoe1hzI9eKUNQ2lfGoPERnrK/qgzpqawnbUMc4AbPQaL3nzotNVFx+qY+zCxK/GTkz7nrOU22sFbbbTJMHdChctenZ5xD94l46KrTz9OB6ITVSDV7A2CQjN7n4zh3l1I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775720169; c=relaxed/simple; bh=briQCaY9uH7vIRYVKSDxcvroZBPJ2CIodNJu6UDH5EU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=MmtGMGMabRVIyMENx+J3sWB3UqzfJS6i2c5MgIuzdvxRuKzudzMz55sSg2I8/wVHCg8fHj7G2yyXipID4Y6/uyzvZqeaVFwZzuIAXDAjsHbF+pzGTQKun/nuT//ZGm1QTvnCHnAmb312MZLyeStxMxRTqiOu/aD23jSjFUgi/NE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=D4jIiKbb; 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="D4jIiKbb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B990DC19424; Thu, 9 Apr 2026 07:36:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1775720168; bh=briQCaY9uH7vIRYVKSDxcvroZBPJ2CIodNJu6UDH5EU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=D4jIiKbbdSXPmsGikexUvR5ryZm6GS5ahpuWztmVW2V+zsifytIQVFK5eQHYpNd1r Pg9U4tCS2RKGTkeLCrzDDs2x0plWBjGn3a/3iM4FaYw2D3hFrnDwwjNiRqTudf2OFB JllnHJ1LFHd+w/k9NMqXF4sgtndM4Vd5SUkhtRoS42cb96PIx8yQ1RduZ1zhBo8qTu sE2Aak3AaKGmalo5Saj9tYZ0tndaYtQxvgAfSom0yI9uGjKLBRywNbfiL2p4kToPcn w/z3X6iR8SRlDrwPap0IiuY4/fcXcJm1laxpLdSDbswKlxA82LVW/16l2yvRoGHi6o c6BMzkwr9VgOQ== Date: Thu, 9 Apr 2026 08:36:03 +0100 From: Lorenzo Stoakes To: Lance Yang Cc: ye.liu@linux.dev, akpm@linux-foundation.org, david@kernel.org, liuye@kylinos.cn, ziy@nvidia.com, baolin.wang@linux.alibaba.com, Liam.Howlett@oracle.com, npache@redhat.com, ryan.roberts@arm.com, dev.jain@arm.com, baohua@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] mm/khugepaged: use ALIGN helpers for PMD alignment Message-ID: References: <20260409014323.2385982-1-ye.liu@linux.dev> <20260409031242.91778-1-lance.yang@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260409031242.91778-1-lance.yang@linux.dev> On Thu, Apr 09, 2026 at 11:12:42AM +0800, Lance Yang wrote: > > On Thu, Apr 09, 2026 at 09:43:22AM +0800, Ye Liu wrote: > >From: Ye Liu > > > >PMD alignment in khugepaged is currently implemented using a mix of > >rounding helpers and open-coded bitmask operations. > > > >Use ALIGN() and ALIGN_DOWN() consistently for PMD-sized address range > >alignment, matching the preferred style for address and size handling. > > One more spot in madvise_collapse(): > > hend = min(hend, vma->vm_end & HPAGE_PMD_MASK); > > Maybe switch that one to ALIGN_DOWN() as well. Sorry to bikeshed but I'm not sure if: hend = min(hend, ALIGN_DOWN(vma->vm_end, HPAGE_PMD_SIZE)); Really adds any clarity there, possibly better to just leave that one as-is. > > And there is also in try_collapse_pte_mapped_thp(): > > unsigned long haddr = addr & HPAGE_PMD_MASK; This one's fine though, be good to also const-ify haddr and end there. > > Just a thought :) > Lance Cheers, Lorenzo