From mboxrd@z Thu Jan 1 00:00:00 1970 From: Edward Cree Subject: Re: [PATCH net-next 1/4] indirect call wrappers: helpers to speed-up indirect calls of builtin Date: Tue, 4 Dec 2018 17:13:01 +0000 Message-ID: <8a3c6447-96a0-3c03-dae3-e7d6bbf42d49@solarflare.com> References: <4b3d364077091ad23415894e74a212d1168425cc.1543836966.git.pabeni@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Cc: "David S. Miller" , Eric Dumazet To: Paolo Abeni , Return-path: Received: from dispatch1-us1.ppe-hosted.com ([67.231.154.164]:33908 "EHLO dispatch1-us1.ppe-hosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726421AbeLDRNJ (ORCPT ); Tue, 4 Dec 2018 12:13:09 -0500 In-Reply-To: <4b3d364077091ad23415894e74a212d1168425cc.1543836966.git.pabeni@redhat.com> Content-Language: en-GB Sender: netdev-owner@vger.kernel.org List-ID: On 03/12/18 11:40, Paolo Abeni wrote: > This header define a bunch of helpers that allow avoiding the > retpoline overhead when calling builtin functions via function pointers. > It boils down to explicitly comparing the function pointers to > known builtin functions and eventually invoke directly the latter. > > The macros defined here implement the boilerplate for the above schema > and will be used by the next patches. > > rfc -> v1: > - use branch prediction hint, as suggested by Eric > > Suggested-by: Eric Dumazet > Signed-off-by: Paolo Abeni > --- I'm not sure I see the reason why this is done with numbers and  'name ## NR', adding extra distance between the callsite and the  list of callees.  In particular it means that each callable needs  to specify its index. Wouldn't it be simpler just to have     #define INDIRECT_CALL_1(f, f1, ...) \         (likely(f == f1) ? f1(__VA_ARGS__) : f(__VA_ARGS__))     #define INDIRECT_CALL_2(f, f2, f1, ...) \         (likely(f == f2) ? f2(__VA_ARGS__) : INDIRECT_CALL_1(f, f1, __VA_ARGS__)) etc.?  Removing the need for INDIRECT_CALLABLE_DECLARE_* entirely. At least the commit message should explain the rationale for not  doing things this way. -Ed PS: this has reminded me of my desire to try runtime creation of  these kinds of branch tables with self-modifying code; is there  any documentation on how to go about writing to kernel .text at  runtime?  Last time I had a try at it I got very confused.