Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp6921931ybl; Wed, 15 Jan 2020 12:23:22 -0800 (PST) X-Google-Smtp-Source: APXvYqyf3fUiBZSJkd0GXnl6BjX0pnUDFXlbWo8uMoxheYQ9xOSO9+rb8UqoKN6L67Ds0VUduf3f X-Received: by 2002:a05:6808:b13:: with SMTP id s19mr1257622oij.119.1579119802782; Wed, 15 Jan 2020 12:23:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579119802; cv=none; d=google.com; s=arc-20160816; b=CDOMDTzeCjiR1ZvCmGFzxyKTMJj8OvWdat/rMP7liOacrYQ6NYN5sD69IwbNQ1v03Z B3ffh+PY/LEzj1NkwAijXOVFKklrEtnUvR38ruOYk3GF1YQefuIeAPr+hQpqK5D7IFSp InwZYRaE7zTok09AJi4HvJnnGyT7kcpVuRFFRu85jFnC2IXMP2S2dGYzHSVWZ2o5KvgQ +Zf/yy92Xr2Oe3E19bHHP7J+FwqCnGNZhGLF7k3ZvjWcTy0KuoQe05Ej4Ys3TqTGe6r7 eAUB0cvH9NFMVTWI8GxsvdbXqjZbUShznlE8LQvKrHIjFZzqheo+Pwfvao0oZa7OwZcY LwaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=gQDIp0O9QnAxX4WU+TXGscN8NS1YVLXeb9VJm6V5OoY=; b=MQwC/8KIXxc06bM9Zy/bMFfzzZV+V0bqO8uIAED2Ske/vHr2LKrHaTwgkKGjtIMF0/ G5cjEWgK/e6JY6zpx4MAo2NSXwCoQJy7zg2P7sZ6i0hKcEsMnET7gK3uBA3fs0YPXcHu 8BbdaTrhuwRFnkmSffILcU2HjfcJ+w5r93JGRGu8Oz0F6H08OBydDzTBc84jf+qzFnWw iSbNQB/G9WB5B3zP5m/bg15ZgcwT6Ey1NUU7Bu3DTQTc7+Lwu06sYTNQJrvQeYd4qX8G ox7+U6czjObIoZovL07BqJ4V+EVA0C+mCkAEUnBvV8N5Qwen4e9I8zdXNiKgKBMTcqs0 X38A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=lXvNNSN9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a14si10142327oid.58.2020.01.15.12.23.10; Wed, 15 Jan 2020 12:23:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=lXvNNSN9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729133AbgAOUVF (ORCPT + 99 others); Wed, 15 Jan 2020 15:21:05 -0500 Received: from mail-qt1-f195.google.com ([209.85.160.195]:44524 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726018AbgAOUVE (ORCPT ); Wed, 15 Jan 2020 15:21:04 -0500 Received: by mail-qt1-f195.google.com with SMTP id w8so2528452qts.11; Wed, 15 Jan 2020 12:21:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=gQDIp0O9QnAxX4WU+TXGscN8NS1YVLXeb9VJm6V5OoY=; b=lXvNNSN9x27eKkpEf42K5E/i5sPyZRkW3eo3LqB4FkqRL2DhMZDY/WSoEBtIzsiIFO 6hTeNRtROe0iU6UQnNsb3TtKEAH1mMcRnHXMLyL97Jbd+QORixgkcbrPsQzGsw+E6G4a 9S2+ztvLWxDhaAW9qLhFHdkT10B8r0eqytUvsi1g0rAGTqXJK5NkmMnMcW+Jii3vrKhO QQoRSyT9nKrjDX8A/nLJ9V6K5K3GaGSANPXsfn2cVCR+qxVOBPDq0ryBazMq/JbgFueH mHF6bEYqdyfW5gSH385AJ//uXNwc192o4gekyY38rOcPNZRRpQy0XJOSxA3Vx0AdLWCD 1f2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=gQDIp0O9QnAxX4WU+TXGscN8NS1YVLXeb9VJm6V5OoY=; b=P3YuTSfG4YvtFJxf2O7zi3zcjvEk4rxY8GC/0vZsMfqMjAyJOtl3O+3NvkaKIfrk9n kYJ+DtcfEs5cVQ0nxqpU7wgEO1r1g0qmXtxMs9jAoqtbpp70GWZp+ZKJwZUxkzWSWUny JdBq4cAWbt+LbRoaKlFwRcJA1SaV8zpctT8f5hlabxQHk3auMiX0NPihSkRJBtUdvSNx a2/22KlxdP9lXPv296Vjbe8mdCAa4sOcOjnusHe9o3bAAQBuLJfQLCBC6R20yfo67ZS/ 3f4ryh+M4riAtXql7alZW1h8SJpXXm5UNh1Da/qVxWRW+oQnCNio9jY5k5S159frSimg O4nA== X-Gm-Message-State: APjAAAWfEf/AJG6GHR42QR/sseAQl3suvh0KxO0JdFRaJT6usJUGFjgy gubfTmEILb21nkX5EBgjKfsBeJZRWoFPD8tu3Mw= X-Received: by 2002:ac8:4050:: with SMTP id j16mr367798qtl.171.1579119663256; Wed, 15 Jan 2020 12:21:03 -0800 (PST) MIME-Version: 1.0 References: <20200115184308.162644-1-brianvv@google.com> <20200115184308.162644-8-brianvv@google.com> In-Reply-To: <20200115184308.162644-8-brianvv@google.com> From: Andrii Nakryiko Date: Wed, 15 Jan 2020 12:20:52 -0800 Message-ID: Subject: Re: [PATCH v5 bpf-next 7/9] libbpf: add libbpf support to batch ops To: Brian Vazquez Cc: Brian Vazquez , Alexei Starovoitov , Daniel Borkmann , "David S . Miller" , Yonghong Song , Stanislav Fomichev , Petar Penkov , Willem de Bruijn , open list , Networking , bpf Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 15, 2020 at 10:43 AM Brian Vazquez wrote: > > From: Yonghong Song > > Added four libbpf API functions to support map batch operations: > . int bpf_map_delete_batch( ... ) > . int bpf_map_lookup_batch( ... ) > . int bpf_map_lookup_and_delete_batch( ... ) > . int bpf_map_update_batch( ... ) > > Signed-off-by: Yonghong Song > --- > tools/lib/bpf/bpf.c | 58 ++++++++++++++++++++++++++++++++++++++++ > tools/lib/bpf/bpf.h | 22 +++++++++++++++ > tools/lib/bpf/libbpf.map | 4 +++ > 3 files changed, 84 insertions(+) > > diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c > index 500afe478e94a..317727d612149 100644 > --- a/tools/lib/bpf/bpf.c > +++ b/tools/lib/bpf/bpf.c > @@ -452,6 +452,64 @@ int bpf_map_freeze(int fd) > return sys_bpf(BPF_MAP_FREEZE, &attr, sizeof(attr)); > } > > +static int bpf_map_batch_common(int cmd, int fd, void *in_batch, > + void *out_batch, void *keys, void *values, > + __u32 *count, > + const struct bpf_map_batch_opts *opts) > +{ > + union bpf_attr attr = {}; this is not a big issue and I don't want to delay landing your patches, so maybe you can follow up with another patch. But this '= {}' part is a complete waste because you do memset below. > + int ret; > + > + if (!OPTS_VALID(opts, bpf_map_batch_opts)) > + return -EINVAL; > + > + memset(&attr, 0, sizeof(attr)); > + attr.batch.map_fd = fd; > + attr.batch.in_batch = ptr_to_u64(in_batch); > + attr.batch.out_batch = ptr_to_u64(out_batch); > + attr.batch.keys = ptr_to_u64(keys); > + attr.batch.values = ptr_to_u64(values); > + attr.batch.count = *count; > + attr.batch.elem_flags = OPTS_GET(opts, elem_flags, 0); > + attr.batch.flags = OPTS_GET(opts, flags, 0); > + > + ret = sys_bpf(cmd, &attr, sizeof(attr)); > + *count = attr.batch.count; > + > + return ret; > +} > + [...]