From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755126AbbLKXQ3 (ORCPT ); Fri, 11 Dec 2015 18:16:29 -0500 Received: from zeniv.linux.org.uk ([195.92.253.2]:42535 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753195AbbLKXQ1 (ORCPT ); Fri, 11 Dec 2015 18:16:27 -0500 Date: Fri, 11 Dec 2015 23:16:24 +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: <20151211231624.GM20997@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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87io45zapn.fsf@rasmusvillemoes.dk> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Dec 11, 2015 at 08:49:24AM +0100, Rasmus Villemoes wrote: > union delayed_call_fn { > void (*fn)(void *); > void (*kfree_like)(const void *); > } __attribute__((__transparent_union__)); > > void > set_delayed_call(struct delayed_call *call, union delayed_call_fn u, void *arg) > { > call->fn = u.fn; > call->arg = arg; > } Yecchhhh... If we are into that kind of gccisms, I'd rather use __builtin_choose_expr/__builtin_types_compatible_p. At least that is used elsewhere in the kernel; __transparent_union__ kludge isn't. Sure, it means having set_delayed_call() a macro, but IMO it's less nasty that way... FWIW, another possibility is to have #define CLOSURE_CALLBACK(f,type) \ static inline void __closure_##f(void *p) {return f((type)p);} #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?