From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jesper Dangaard Brouer Subject: Re: [PATCH bpf-next 05/11] bpf: avoid retpoline for lookup/update/delete calls on maps Date: Tue, 29 May 2018 19:23:24 +0200 Message-ID: <20180529192324.7a1db7ee@redhat.com> References: <20180528004344.3606-1-daniel@iogearbox.net> <20180528004344.3606-6-daniel@iogearbox.net> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: brouer@redhat.com, netdev@vger.kernel.org To: Daniel Borkmann Return-path: Received: from mx3-rdu2.redhat.com ([66.187.233.73]:43274 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S965068AbeE2RX1 (ORCPT ); Tue, 29 May 2018 13:23:27 -0400 In-Reply-To: <20180528004344.3606-6-daniel@iogearbox.net> Sender: netdev-owner@vger.kernel.org List-ID: On Mon, 28 May 2018 02:43:38 +0200 Daniel Borkmann wrote: > While some of the BPF map lookup helpers provide a ->map_gen_lookup() > callback for inlining the map lookup altogether it is not available > for every map, so the remaining ones have to call bpf_map_lookup_elem() > helper which does a dispatch to map->ops->map_lookup_elem(). In > times of retpolines, this will control and trap speculative execution > rather than letting it do its work for the indirect call and will > therefore cause a slowdown. Likewise, bpf_map_update_elem() and > bpf_map_delete_elem() do not have an inlined version and need to call > into their map->ops->map_update_elem() resp. map->ops->map_delete_elem() > handlers. > > Before: > > # bpftool p d x i 1 I would really appreciate if we can use the long options in these kind of examples. It makes the command "self-documenting" and searchable by google. Here it would be: # bpftool prog dump xlated id 1 > 0: (bf) r2 = r10 > 1: (07) r2 += -8 > 2: (7a) *(u64 *)(r2 +0) = 0 > 3: (18) r1 = map[id:1] > 5: (85) call __htab_map_lookup_elem#232656 > 6: (15) if r0 == 0x0 goto pc+4 > 7: (71) r1 = *(u8 *)(r0 +35) > 8: (55) if r1 != 0x0 goto pc+1 > 9: (72) *(u8 *)(r0 +35) = 1 > 10: (07) r0 += 56 > 11: (15) if r0 == 0x0 goto pc+4 > 12: (bf) r2 = r0 > 13: (18) r1 = map[id:1] > 15: (85) call bpf_map_delete_elem#215008 <-- indirect call via > 16: (95) exit helper > > After: > > # bpftool p d x i 1 Same here > 0: (bf) r2 = r10 > 1: (07) r2 += -8 > 2: (7a) *(u64 *)(r2 +0) = 0 > 3: (18) r1 = map[id:1] > 5: (85) call __htab_map_lookup_elem#233328 > 6: (15) if r0 == 0x0 goto pc+4 > 7: (71) r1 = *(u8 *)(r0 +35) > 8: (55) if r1 != 0x0 goto pc+1 > 9: (72) *(u8 *)(r0 +35) = 1 > 10: (07) r0 += 56 > 11: (15) if r0 == 0x0 goto pc+4 > 12: (bf) r2 = r0 > 13: (18) r1 = map[id:1] > 15: (85) call htab_lru_map_delete_elem#238240 <-- direct call > 16: (95) exit > -- Best regards, Jesper Dangaard Brouer MSc.CS, Principal Kernel Engineer at Red Hat LinkedIn: http://www.linkedin.com/in/brouer