Re: [PATCH/RFC] z3fold: use per-page read/write lock

2016-11-10 Thread Peter Zijlstra
On Sat, Nov 05, 2016 at 02:49:46PM +0100, Vitaly Wool wrote: > +/* Read-lock a z3fold page */ > +static void z3fold_page_rlock(struct z3fold_header *zhdr) > +{ > + while (!atomic_add_unless(&zhdr->page_lock, 1, Z3FOLD_PAGE_WRITE_FLAG)) > + cpu_relax(); > + smp_mb(); > +} > + > +

Re: [PATCH/RFC] z3fold: use per-page read/write lock

2016-11-07 Thread Andi Kleen
> I understand the reinvention part but you're not quite accurate here > with the numbers. > > E. g. on x86_64: > (gdb) p sizeof(rwlock_t) > $1 = 8 I was talking about spinlocks which are 4 bytes. Just use a spinlock then. rwlocks are usually a bad idea anyways because they often scale far wors

Re: [PATCH/RFC] z3fold: use per-page read/write lock

2016-11-06 Thread Vitaly Wool
On Sun, Nov 6, 2016 at 12:38 AM, Andi Kleen wrote: > Vitaly Wool writes: > >> Most of z3fold operations are in-page, such as modifying z3fold >> page header or moving z3fold objects within a page. Taking >> per-pool spinlock to protect per-page objects is therefore >> suboptimal, and the idea of

Re: [PATCH/RFC] z3fold: use per-page read/write lock

2016-11-05 Thread Andi Kleen
Vitaly Wool writes: > Most of z3fold operations are in-page, such as modifying z3fold > page header or moving z3fold objects within a page. Taking > per-pool spinlock to protect per-page objects is therefore > suboptimal, and the idea of having a per-page spinlock (or rwlock) > has been around fo

[PATCH/RFC] z3fold: use per-page read/write lock

2016-11-05 Thread Vitaly Wool
Most of z3fold operations are in-page, such as modifying z3fold page header or moving z3fold objects within a page. Taking per-pool spinlock to protect per-page objects is therefore suboptimal, and the idea of having a per-page spinlock (or rwlock) has been around for some time. However, adding on