mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: dhowells@redhat.com, linux-afs@lists.infradead.org,
	kernel test robot <lkp@intel.com>,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 11/11] afs: Fix dirty-region encoding on ppc32 with 64K pages
Date: Wed, 28 Oct 2020 16:53:01 +0000	[thread overview]
Message-ID: <541369.1603903981@warthog.procyon.org.uk> (raw)
In-Reply-To: <20201028143442.GA20115@casper.infradead.org>

Matthew Wilcox <willy@infradead.org> wrote:

> > +static inline unsigned int afs_page_dirty_resolution(void)
> 
> I've been using size_t for offsets within a struct page.  I don't know
> that we'll ever support pages larger than 2GB (they're completely
> impractical with today's bus speeds), but I'd rather not be the one
> who has to track down all the uses of 'int' in the kernel in fifteen
> years time.

Going beyond 2G page size won't be fun and a lot of our APIs will break -
write_begin, write_end, invalidatepage to name a few.

It would probably require an analysis program to trace all the usages of such
information within the kernel.

> > +{
> > +	if (PAGE_SIZE - 1 <= __AFS_PAGE_PRIV_MASK)
> > +		return 1;
> > +	else
> > +		return PAGE_SIZE / (__AFS_PAGE_PRIV_MASK + 1);
> 
> Could this be DIV_ROUND_UP(PAGE_SIZE, __AFS_PAGE_PRIV_MASK + 1); avoiding
> a conditional?  I appreciate it's calculated at compile time today, but
> it'll be dynamic with THP.

That seems to work.

> >  static inline unsigned int afs_page_dirty_to(unsigned long priv)
> >  {
> > -	return ((priv >> __AFS_PAGE_PRIV_SHIFT) & __AFS_PAGE_PRIV_MASK) + 1;
> > +	unsigned int x = (priv >> __AFS_PAGE_PRIV_SHIFT) & __AFS_PAGE_PRIV_MASK;
> > +
> > +	/* The upper bound is exclusive */
> 
> I think you mean 'inclusive'.

The returned upper bound points immediately beyond the range.  E.g. 0-0 is an
empty range.  Changing that is way too big an overhaul outside the merge
window.

> > +	return (x + 1) * afs_page_dirty_resolution();
> >  }
> >  
> >  static inline unsigned long afs_page_dirty(unsigned int from, unsigned int to)
> >  {
> > +	unsigned int res = afs_page_dirty_resolution();
> > +	from /= res; /* Round down */
> > +	to = (to + res - 1) / res; /* Round up */
> >  	return ((unsigned long)(to - 1) << __AFS_PAGE_PRIV_SHIFT) | from;
> 
> Wouldn't it produce the same result to just round down?  ie:
> 
> 	to = (to - 1) / res;
> 	return ((unsigned long)to << __AFS_PAGE_PRIV_SHIFT) | from;

Actually, yes, because res/res==1, which I then subtract afterwards.

David


  parent reply	other threads:[~2020-10-28 21:54 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-28 14:09 [PATCH 00/11] AFS fixes [ver #2] David Howells
2020-10-28 14:09 ` [PATCH 01/11] afs: Fix copy_file_range() David Howells
2020-10-28 14:10 ` [PATCH 02/11] afs: Fix tracing deref-before-check David Howells
2020-10-28 14:10 ` [PATCH 03/11] afs: Fix a use after free in afs_xattr_get_acl() David Howells
2020-10-28 14:10 ` [PATCH 04/11] afs: Fix afs_launder_page to not clear PG_writeback David Howells
2020-10-28 14:10 ` [PATCH 05/11] afs: Fix to take ref on page when PG_private is set David Howells
2020-10-28 14:20   ` Matthew Wilcox
2020-10-28 15:24   ` David Howells
2020-10-28 14:10 ` [PATCH 06/11] afs: Fix page leak on afs_write_begin() failure David Howells
2020-10-28 14:10 ` [PATCH 07/11] afs: Fix where page->private is set during write David Howells
2020-10-28 14:10 ` [PATCH 08/11] afs: Wrap page->private manipulations in inline functions David Howells
2020-10-28 14:10 ` [PATCH 09/11] afs: Alter dirty range encoding in page->private David Howells
2020-10-28 14:10 ` [PATCH 10/11] afs: Fix afs_invalidatepage to adjust the dirty region David Howells
2020-10-28 14:11 ` [PATCH 11/11] afs: Fix dirty-region encoding on ppc32 with 64K pages David Howells
2020-10-28 14:34   ` Matthew Wilcox
2020-10-28 16:53   ` David Howells [this message]
2020-10-28 17:05   ` David Howells
2020-10-28 17:11     ` Matthew Wilcox
2020-10-28 17:27     ` David Howells
2020-10-28 22:22 [PATCH 00/11] AFS fixes [ver #3] David Howells
2020-10-28 22:23 ` [PATCH 11/11] afs: Fix dirty-region encoding on ppc32 with 64K pages David Howells
2020-10-29 11:48 ` David Howells

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=541369.1603903981@warthog.procyon.org.uk \
    --to=dhowells@redhat.com \
    --cc=linux-afs@lists.infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®