From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752525AbcEVSur (ORCPT ); Sun, 22 May 2016 14:50:47 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:33422 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752434AbcEVSup (ORCPT ); Sun, 22 May 2016 14:50:45 -0400 Date: Sun, 22 May 2016 21:50:40 +0300 From: Alexey Dobriyan To: Peter Zijlstra Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org, Paul McKenney Subject: Re: [PATCH] seqlock: fix raw_read_seqcount_latch() Message-ID: <20160522185040.GA23664@p183.telecom.by> References: <20160521201448.GA7429@p183.telecom.by> <20160522104827.GP3193@twins.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160522104827.GP3193@twins.programming.kicks-ass.net> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, May 22, 2016 at 12:48:27PM +0200, Peter Zijlstra wrote: > On Sat, May 21, 2016 at 11:14:49PM +0300, Alexey Dobriyan wrote: > > lockless_dereference() is supposed to take pointer not integer. > > Urgh :/ > > Is there any way we can make lockless_dereference() issue a warning if > we don't feed it a pointer? > > Would something like so work? All pointer types should silently cast to > void * while integer (and others) should refuse to. This works (and spammy enough in case of seqlock, which is good) but not for "unsigned long": include/linux/percpu-refcount.h:146:36: warning: initialization makes pointer from integer without a cast [-Wint-conversion] percpu_ptr = lockless_dereference(ref->percpu_count_ptr); > --- a/include/linux/compiler.h > +++ b/include/linux/compiler.h > @@ -544,6 +544,7 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s > */ > #define lockless_dereference(p) \ > ({ \ > + __maybe_unused void * _________p2 = p; \ > typeof(p) _________p1 = READ_ONCE(p); \ > smp_read_barrier_depends(); /* Dependency order vs. p above. */ \ > (_________p1); \