From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934327AbcAKTIo (ORCPT ); Mon, 11 Jan 2016 14:08:44 -0500 Received: from mail-pf0-f182.google.com ([209.85.192.182]:34620 "EHLO mail-pf0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934275AbcAKTIm (ORCPT ); Mon, 11 Jan 2016 14:08:42 -0500 Date: Mon, 11 Jan 2016 11:08:39 -0800 From: Alexei Starovoitov To: Ming Lei Cc: linux-kernel@vger.kernel.org, Alexei Starovoitov , "David S. Miller" , netdev@vger.kernel.org, Daniel Borkmann , Martin KaFai Lau Subject: Re: [PATCH 2/9] bpf: array map: use pre-defined nop map function Message-ID: <20160111190839.GB26495@ast-mbp.thefacebook.com> References: <1452527821-12276-1-git-send-email-tom.leiming@gmail.com> <1452527821-12276-3-git-send-email-tom.leiming@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1452527821-12276-3-git-send-email-tom.leiming@gmail.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 11, 2016 at 11:56:54PM +0800, Ming Lei wrote: > So that we can remove the per-map nop map fucntions. > > Signed-off-by: Ming Lei > --- > kernel/bpf/arraymap.c | 19 +++++-------------- > 1 file changed, 5 insertions(+), 14 deletions(-) > > diff --git a/kernel/bpf/arraymap.c b/kernel/bpf/arraymap.c > index b0799bc..9ad9031 100644 > --- a/kernel/bpf/arraymap.c > +++ b/kernel/bpf/arraymap.c > @@ -17,6 +17,8 @@ > #include > #include > > +#include "bpf_map.h" > + > /* Called from syscall */ > static struct bpf_map *array_map_alloc(union bpf_attr *attr) > { > @@ -115,12 +117,6 @@ static int array_map_update_elem(struct bpf_map *map, void *key, void *value, > return 0; > } > > -/* Called from syscall or from eBPF program */ > -static int array_map_delete_elem(struct bpf_map *map, void *key) > -{ > - return -EINVAL; > -} > - > /* Called when map->refcnt goes to zero, either from workqueue or from syscall */ > static void array_map_free(struct bpf_map *map) > { > @@ -142,7 +138,7 @@ static const struct bpf_map_ops array_ops = { > .map_get_next_key = array_map_get_next_key, > .map_lookup_elem = array_map_lookup_elem, > .map_update_elem = array_map_update_elem, > - .map_delete_elem = array_map_delete_elem, > + .map_delete_elem = map_delete_elem_nop, I think moving these two callbacks into separate file only reduces readbility. It doesn't look like that we save any .text this way.