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 18:12:36 +0000 Message-ID: <06adfcdf-3535-eebc-dd32-e6d945c13825@solarflare.com> References: <4b3d364077091ad23415894e74a212d1168425cc.1543836966.git.pabeni@redhat.com> <8a3c6447-96a0-3c03-dae3-e7d6bbf42d49@solarflare.com> <40cb1de12da8742e32da03b50d7729b2eeec0a04.camel@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]:57076 "EHLO dispatch1-us1.ppe-hosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725797AbeLDSMn (ORCPT ); Tue, 4 Dec 2018 13:12:43 -0500 In-Reply-To: <40cb1de12da8742e32da03b50d7729b2eeec0a04.camel@redhat.com> Content-Language: en-GB Sender: netdev-owner@vger.kernel.org List-ID: On 04/12/18 17:44, Paolo Abeni wrote: > On Tue, 2018-12-04 at 17:13 +0000, Edward Cree wrote: >> 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 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. > Thank you for the review! > > As some of the builtin symbols are static, we would still need some > macro wrappers to properly specify the scope when retpoline is enabled. Ah I see, it hadn't occurred to me that static callees might not be  available at the callsite.  Makes sense now.  In that case, have my  Acked-By for this patch, if you want it. > This: > https://lore.kernel.org/lkml/cover.1543200841.git.jpoimboe@redhat.com/T/#ma30f6b2aa655c99e93cfb267fef75b8fe9fca29b > > is possibly related to what you are planning. Yes!  That looks like exactly the sort of machinery I need, thanks. My idea is to build on that something that counts stats of where each  indirect call goes, then every now and then patches in a new list of  possible targets to an INDIRECT_CALL_*()-style jump tree, based on  the N callees that were seen the most often. (Such a solution could even cope with callees in modules: the jump  table doesn't need a reference on the module because it only calls  the function (from the module) if the function pointer is pointing at  it, in which case (hopefully) whoever supplied the function pointer  has a reference to the module.) But I'm not sure I have the mad hacker skillz to make it work. -Ed