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
| ||
|
Date: Wed, 28 Oct 2020 14:34:42 +0000 From: Matthew Wilcox <willy@...radead.org> To: David Howells <dhowells@...hat.com> Cc: 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 On Wed, Oct 28, 2020 at 02:11:06PM +0000, David Howells 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. > +{ > + 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. > 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'. > + 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;
Powered by blists - more mailing lists