Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1515669

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

From Vitaly Wool <vitalywool@gmail.com>
Newsgroups linux.kernel
Subject Re: [PATCH/RFC] z3fold: use per-page read/write lock
Date 2016-11-06 10:50 +0100
Message-ID <sAsfn-3Ir-5@gated-at.bofh.it> (permalink)
References <sA9FL-6I-9@gated-at.bofh.it> <sAiJ3-62O-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Sun, Nov 6, 2016 at 12:38 AM, Andi Kleen <andi@firstfloor.org> wrote:
> Vitaly Wool <vitalywool@gmail.com> 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 for some time. However, adding one directly to the
>> z3fold header makes the latter quite big on some systems so that
>> it won't fit in a signle chunk.
>
>> +     atomic_t page_lock;
>
> This doesnt make much sense. A standard spinlock is not bigger
> than 4 bytes either. Also reinventing locks is usually a bad
> idea: they are tricky to get right, you have no debugging support,
> hard to analyze, etc.

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 believe a DIY lock is justified here, since the variant with
rwlock_t actually caused complaints from kbuild test robot building
the previous version of this patch [1] with gcc-6.0 for x86_64:

 In file included from arch/x86/include/asm/atomic.h:4:0,
                    from include/linux/atomic.h:4,
                    from mm/z3fold.c:25:
   mm/z3fold.c: In function 'init_z3fold':
>> include/linux/compiler.h:518:38: error: call to '__compiletime_assert_808' declared with attribute error: BUILD_BUG_ON failed: sizeof(struct z3fold_header) > ZHDR_SIZE_ALIGNED

~vitaly

[1] https://patchwork.kernel.org/patch/9384871/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH/RFC] z3fold: use per-page read/write lock Vitaly Wool <vitalywool@gmail.com> - 2016-11-05 15:00 +0100
  Re: [PATCH/RFC] z3fold: use per-page read/write lock Andi Kleen <andi@firstfloor.org> - 2016-11-06 00:40 +0100
    Re: [PATCH/RFC] z3fold: use per-page read/write lock Vitaly Wool <vitalywool@gmail.com> - 2016-11-06 10:50 +0100
      Re: [PATCH/RFC] z3fold: use per-page read/write lock Andi Kleen <andi@firstfloor.org> - 2016-11-07 17:10 +0100
  Re: [PATCH/RFC] z3fold: use per-page read/write lock Peter Zijlstra <peterz@infradead.org> - 2016-11-10 20:40 +0100

csiph-web