Hi Mark,

I love your patch! Perhaps something to improve:

[auto build test WARNING on tip/perf/core]
[also build test WARNING on v4.17-rc4 next-20180510]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:    
https://github.com/0day-ci/linux/commits/Mark-Rutland/perf-ring_buffer-ensure-atomicity-and-order-of-updates/20180511-070205
config: i386-randconfig-s1-201818 (attached as .config)
compiler: gcc-6 (Debian 6.4.0-9) 6.4.0 20171026
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All warnings (new ones prefixed by >>):

   In file included from include/uapi/linux/swab.h:6:0,
                    from include/linux/swab.h:5,
                    from include/uapi/linux/byteorder/little_endian.h:13,
                    from include/linux/byteorder/little_endian.h:5,
                    from arch/x86/include/uapi/asm/byteorder.h:5,
                    from include/uapi/linux/perf_event.h:20,
                    from include/linux/perf_event.h:17,
                    from kernel//events/ring_buffer.c:12:
   kernel//events/ring_buffer.c: In function 'perf_output_put_handle':
   include/linux/compiler.h:339:38: error: call to '__compiletime_assert_86' 
declared with attribute error: Need native word sized stores/loads for 
atomicity.
     _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
                                         ^
   include/linux/compiler.h:319:4: note: in definition of macro 
'__compiletime_assert'
       prefix ## suffix();    \
       ^~~~~~
   include/linux/compiler.h:339:2: note: in expansion of macro 
'_compiletime_assert'
     _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
     ^~~~~~~~~~~~~~~~~~~
>> include/linux/compiler.h:342:2: note: in expansion of macro 
>> 'compiletime_assert'
     compiletime_assert(__native_word(t),    \
     ^~~~~~~~~~~~~~~~~~
>> include/asm-generic/barrier.h:181:2: note: in expansion of macro 
>> 'compiletime_assert_atomic_type'
     compiletime_assert_atomic_type(*p);    \
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> kernel//events/ring_buffer.c:86:2: note: in expansion of macro 
>> 'smp_store_release'
     smp_store_release(&rb->user_page->data_head, head); /* B, matches C */
     ^~~~~~~~~~~~~~~~~
   kernel//events/ring_buffer.c: In function 'perf_aux_output_skip':
   include/linux/compiler.h:339:38: error: call to '__compiletime_assert_498' 
declared with attribute error: Need native word sized stores/loads for 
atomicity.
     _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
                                         ^
   include/linux/compiler.h:319:4: note: in definition of macro 
'__compiletime_assert'
       prefix ## suffix();    \
       ^~~~~~
   include/linux/compiler.h:339:2: note: in expansion of macro 
'_compiletime_assert'
     _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
     ^~~~~~~~~~~~~~~~~~~
>> include/linux/compiler.h:342:2: note: in expansion of macro 
>> 'compiletime_assert'
     compiletime_assert(__native_word(t),    \
     ^~~~~~~~~~~~~~~~~~
>> include/asm-generic/barrier.h:181:2: note: in expansion of macro 
>> 'compiletime_assert_atomic_type'
     compiletime_assert_atomic_type(*p);    \
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   kernel//events/ring_buffer.c:498:2: note: in expansion of macro 
'smp_store_release'
     smp_store_release(&rb->user_page->aux_head, rb->aux_head);
     ^~~~~~~~~~~~~~~~~
   kernel//events/ring_buffer.c: In function 'perf_aux_output_end':
   include/linux/compiler.h:339:38: error: call to '__compiletime_assert_466' 
declared with attribute error: Need native word sized stores/loads for 
atomicity.
     _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
                                         ^
   include/linux/compiler.h:319:4: note: in definition of macro 
'__compiletime_assert'
       prefix ## suffix();    \
       ^~~~~~
   include/linux/compiler.h:339:2: note: in expansion of macro 
'_compiletime_assert'
     _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
     ^~~~~~~~~~~~~~~~~~~
>> include/linux/compiler.h:342:2: note: in expansion of macro 
>> 'compiletime_assert'
     compiletime_assert(__native_word(t),    \
     ^~~~~~~~~~~~~~~~~~
>> include/asm-generic/barrier.h:181:2: note: in expansion of macro 
>> 'compiletime_assert_atomic_type'
     compiletime_assert_atomic_type(*p);    \
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   kernel//events/ring_buffer.c:466:2: note: in expansion of macro 
'smp_store_release'
     smp_store_release(&rb->user_page->aux_head, rb->aux_head);
     ^~~~~~~~~~~~~~~~~
--
   In file included from include/uapi/linux/swab.h:6:0,
                    from include/linux/swab.h:5,
                    from include/uapi/linux/byteorder/little_endian.h:13,
                    from include/linux/byteorder/little_endian.h:5,
                    from arch/x86/include/uapi/asm/byteorder.h:5,
                    from include/uapi/linux/perf_event.h:20,
                    from include/linux/perf_event.h:17,
                    from kernel/events/ring_buffer.c:12:
   kernel/events/ring_buffer.c: In function 'perf_output_put_handle':
   include/linux/compiler.h:339:38: error: call to '__compiletime_assert_86' 
declared with attribute error: Need native word sized stores/loads for 
atomicity.
     _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
                                         ^
   include/linux/compiler.h:319:4: note: in definition of macro 
'__compiletime_assert'
       prefix ## suffix();    \
       ^~~~~~
   include/linux/compiler.h:339:2: note: in expansion of macro 
'_compiletime_assert'
     _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
     ^~~~~~~~~~~~~~~~~~~
>> include/linux/compiler.h:342:2: note: in expansion of macro 
>> 'compiletime_assert'
     compiletime_assert(__native_word(t),    \
     ^~~~~~~~~~~~~~~~~~
>> include/asm-generic/barrier.h:181:2: note: in expansion of macro 
>> 'compiletime_assert_atomic_type'
     compiletime_assert_atomic_type(*p);    \
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   kernel/events/ring_buffer.c:86:2: note: in expansion of macro 
'smp_store_release'
     smp_store_release(&rb->user_page->data_head, head); /* B, matches C */
     ^~~~~~~~~~~~~~~~~
   kernel/events/ring_buffer.c: In function 'perf_aux_output_skip':
   include/linux/compiler.h:339:38: error: call to '__compiletime_assert_498' 
declared with attribute error: Need native word sized stores/loads for 
atomicity.
     _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
                                         ^
   include/linux/compiler.h:319:4: note: in definition of macro 
'__compiletime_assert'
       prefix ## suffix();    \
       ^~~~~~
   include/linux/compiler.h:339:2: note: in expansion of macro 
'_compiletime_assert'
     _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
     ^~~~~~~~~~~~~~~~~~~
>> include/linux/compiler.h:342:2: note: in expansion of macro 
>> 'compiletime_assert'
     compiletime_assert(__native_word(t),    \
     ^~~~~~~~~~~~~~~~~~
>> include/asm-generic/barrier.h:181:2: note: in expansion of macro 
>> 'compiletime_assert_atomic_type'
     compiletime_assert_atomic_type(*p);    \
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   kernel/events/ring_buffer.c:498:2: note: in expansion of macro 
'smp_store_release'
     smp_store_release(&rb->user_page->aux_head, rb->aux_head);
     ^~~~~~~~~~~~~~~~~
   kernel/events/ring_buffer.c: In function 'perf_aux_output_end':
   include/linux/compiler.h:339:38: error: call to '__compiletime_assert_466' 
declared with attribute error: Need native word sized stores/loads for 
atomicity.
     _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
                                         ^
   include/linux/compiler.h:319:4: note: in definition of macro 
'__compiletime_assert'
       prefix ## suffix();    \
       ^~~~~~
   include/linux/compiler.h:339:2: note: in expansion of macro 
'_compiletime_assert'
     _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
     ^~~~~~~~~~~~~~~~~~~
>> include/linux/compiler.h:342:2: note: in expansion of macro 
>> 'compiletime_assert'
     compiletime_assert(__native_word(t),    \
     ^~~~~~~~~~~~~~~~~~
>> include/asm-generic/barrier.h:181:2: note: in expansion of macro 
>> 'compiletime_assert_atomic_type'
     compiletime_assert_atomic_type(*p);    \
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   kernel/events/ring_buffer.c:466:2: note: in expansion of macro 
'smp_store_release'
     smp_store_release(&rb->user_page->aux_head, rb->aux_head);
     ^~~~~~~~~~~~~~~~~

vim +/smp_store_release +86 kernel//events/ring_buffer.c

    44  
    45  static void perf_output_put_handle(struct perf_output_handle *handle)
    46  {
    47          struct ring_buffer *rb = handle->rb;
    48          unsigned long head;
    49  
    50  again:
    51          head = local_read(&rb->head);
    52  
    53          /*
    54           * IRQ/NMI can happen here, which means we can miss a head 
update.
    55           */
    56  
    57          if (!local_dec_and_test(&rb->nest))
    58                  goto out;
    59  
    60          /*
    61           * Since the mmap() consumer (userspace) can run on a different 
CPU:
    62           *
    63           *   kernel                             user
    64           *
    65           *   if (LOAD ->data_tail) {            LOAD ->data_head
    66           *                              (A)     smp_rmb()       (C)
    67           *      STORE $data                     LOAD $data
    68           *                                      smp_mb()        (D)
    69           *      RELEASE ->data_head     (B)     STORE ->data_tail
    70           *   }
    71           *
    72           * Where A pairs with D, and B pairs with C.
    73           *
    74           * In our case (A) is a control dependency that separates the 
load of
    75           * the ->data_tail and the stores of $data. In case ->data_tail
    76           * indicates there is no room in the buffer to store $data we 
do not.
    77           *
    78           * D needs to be a full barrier since it separates the data READ
    79           * from the tail WRITE.
    80           *
    81           * For B a WMB is sufficient since it separates two WRITEs, and 
for C
    82           * an RMB is sufficient since it separates two READs.
    83           *
    84           * See perf_output_begin().
    85           */
  > 86          smp_store_release(&rb->user_page->data_head, head); /* B, 
matches C */
    87  
    88          /*
    89           * Now check if we missed an update -- rely on previous implied
    90           * compiler barriers to force a re-read.
    91           */
    92          if (unlikely(head != local_read(&rb->head))) {
    93                  local_inc(&rb->nest);
    94                  goto again;
    95          }
    96  
    97          if (handle->wakeup != local_read(&rb->wakeup))
    98                  perf_output_wakeup(handle);
    99  
   100  out:
   101          preempt_enable();
   102  }
   103  

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

Attachment: .config.gz
Description: application/gzip

Reply via email to