lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <550615.1603906072@warthog.procyon.org.uk>
Date:   Wed, 28 Oct 2020 17:27:52 +0000
From:   David Howells <dhowells@...hat.com>
To:     Matthew Wilcox <willy@...radead.org>
Cc:     dhowells@...hat.com, linux-afs@...ts.infradead.org,
        kernel test robot <lkp@...el.com>,
        linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 11/11] afs: Fix dirty-region encoding on ppc32 with 64K pages

Matthew Wilcox <willy@...radead.org> wrote:

> > > > +{
> > > > +	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.
> > 
> > Hmmm - actually, I want a shift size, not a number of bytes as I divide by it
> > twice in afs_page_dirty().
> 
> __AFS_PAGE_PRIV_MASK is a constant though.  If your compiler can't
> optimise a divide-by-a-constant-power-of-two into a shift-by-a-constant (*),
> it's time to get yourself a new compiler.
> 
> (*) assuming that's faster on the CPU it's targetting.

I'm dividing by the resolution, which is calculated from the page size - which
in a THP world is variable:

	static inline unsigned long afs_page_dirty(size_t from, size_t to)
	{
		size_t res = afs_page_dirty_resolution();
		from /= res; /* Round down */
		to = (to - 1) / res; /* Round up */
		return ((unsigned long)to << __AFS_PAGE_PRIV_SHIFT) | from;
	}

David

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ