From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Sat, 12 Dec 2015 02:00:27 +0000 From: Al Viro To: Rasmus Villemoes Cc: Linus Torvalds , Linux Kernel Mailing List , linux-fsdevel , Neil Brown Subject: Re: [PATCHSET v2] ->follow_link() without dropping from RCU mode Message-ID: <20151212020027.GN20997@ZenIV.linux.org.uk> References: <20151117225752.GZ22011@ZenIV.linux.org.uk> <20151209053209.GV20997@ZenIV.linux.org.uk> <20151209182309.GZ20997@ZenIV.linux.org.uk> <20151210001012.GA20997@ZenIV.linux.org.uk> <20151210024049.GC20997@ZenIV.linux.org.uk> <20151211015425.GH20997@ZenIV.linux.org.uk> <87io45zapn.fsf@rasmusvillemoes.dk> <20151211231624.GM20997@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20151211231624.GM20997@ZenIV.linux.org.uk> Sender: linux-kernel-owner@vger.kernel.org List-ID: On Fri, Dec 11, 2015 at 11:16:24PM +0000, Al Viro wrote: > #define set_delayed_type(call, f, arg) \ > sizeof(f(arg),0), \ > __set_delayed_type(call, __closure_##f, (void *)arg) > > That could be reused for timers with typechecking - we have a lot of timer > callbacks that start with casting the argument (unsigned long, not void *, > but that's not a big deal) to whatever it is that callback really wants, > with setup_timer() callers explicitly casting that whatever the callback > really wants to unsigned long. Which, of course, defeats the typechecking > by both cc(1) and sparse(1)... > > I still hope for better solution, though... Comments? Hmm... #define set_delayed_type(call, f, arg) \ (sizeof(f(arg),0), \ __set_delayed_type(call, ({ \ void _(void *__) {f((typeof(arg))(unsigned long)__);} \ _;}), (void *)arg)) woult do nicely, but it's a gccism, and the one clang doesn't support ;-/ gcc support goes back at least to 4.1, not sure about the earlier branches (and not at all sure how flaky it was/is, obviously). But this thing works for e.g. f being void(char) and arg being char, and AFAICS generates correct code - we end up with a stub like _.1765: movsbl %dil, %edi jmp f and its address gets stored in call->fn, which should DTRT on call...