Subject: Re: [PATCH resend v6 02/30] mm: mempolicy: fix interleave index for unaligned VMA start

From: "Michael S. Tsirkin" <[email-masked]>
Date: Mon, 11 May 2026 11:26:36 -0400

On Mon, May 11, 2026 at 10:59:46AM -0400, Gregory Price wrote:
> > ---
> >  mm/mempolicy.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/mm/mempolicy.c b/mm/mempolicy.c
> > index 6832cc68120f..39e556e3d263 100644
> > --- a/mm/mempolicy.c
> > +++ b/mm/mempolicy.c
> > @@ -2049,7 +2049,8 @@ struct mempolicy *get_vma_policy(struct vm_area_struct *vma,
> >  	if (pol->mode == MPOL_INTERLEAVE ||
> >  	    pol->mode == MPOL_WEIGHTED_INTERLEAVE) {
> >  		*ilx += vma->vm_pgoff >> order;
> > -		*ilx += (addr - vma->vm_start) >> (PAGE_SHIFT + order);
> > +		*ilx += (addr >> (PAGE_SHIFT + order)) -
> > +			(vma->vm_start >> (PAGE_SHIFT + order));
> 
> There's enough (PAGE_SHIFT + ...) spread around the kernel, i wonder if
> it's worth a define or a function (not in scope, just pondering).
> 
> ~Gregory

66 of these. many are not about order. Popular ones:
PAGE_SHIFT + 3 is bits per page (for bitmaps)
PAGE_SHIFT + 1  is thread stack

definitely not in scope