Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp5092556ybc; Fri, 15 Nov 2019 14:44:35 -0800 (PST) X-Google-Smtp-Source: APXvYqydwEKjx/2XP0CE0MauCLc7j1SV2rf15a6exY2kWYnF/4Pyjy8Q8i/AtseUEgSvMqgbD04I X-Received: by 2002:a17:906:c789:: with SMTP id cw9mr4662669ejb.40.1573857875638; Fri, 15 Nov 2019 14:44:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573857875; cv=none; d=google.com; s=arc-20160816; b=jvPauPlEI+sWTXR7SqjWadqxJb4hSZces9jPNM1J/d26S8XbBAUmmZRyY0geCpjRpZ CAtsvfegl+Q6cNepSrbNG53RLmjERBlO3x8Ifsize0gkt5akoaRSgPUMH8xo8ezZP+1H A1g7gmnftPEWElhdgHQm7veRiaUnn1ueO0QmItq5775GNagUr0hG+I2cOrUV8YbbXrH8 FUlCreAXHsXKfWlm7rEHdYccIOkMOLJlxMZqpyIEWfw8TBf5HKowcXyNeI7IY7ehPr3V ezZjU0NOK9NT9cSAyFusY8tYbaxA3s1naYK7vA++bm+IhF0OpjRoBJR3v3ypVpaS7tas vLsA== 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=1Ljh/C9bOl+iw6pSFvN3eoLNKQmG6h31Yeu6UPqkFhQ=; b=sUpDCD5gXZssWXyP9WaCKmwrGKnz1F9eIW/VwtXp9ti3CZYxYpLHmtDKD3kfNC1o3I YzqfZmKqF62jxNJpS4t897Z5XVvBD4ntQrJh/7oTDQ9FFe2GCgvKBMCBnvRl/5bL+KKb K72fOK7+unU79A8RAzQOBSYvIEyO7qP5koMI8RZeEpKhMv5a9dKAcyQYyl9A2twNOu7G uFuqY8kzlbFqm9liS7w1DMbDlsLIhg643MFNjwmY4Zvt7rCP8IdSCv7GFpBlLP0zchRU fnjy0GQ6hlTqE9sWSP8m1e8n00+D/AO8qNp8pIL4nSAURVQl+SGsUocBfrvwf4R9Xxxm xpFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qTyktsT4; 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 ce16si6981958ejb.118.2019.11.15.14.44.07; Fri, 15 Nov 2019 14:44:35 -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=qTyktsT4; 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 S1727081AbfKOWmg (ORCPT + 99 others); Fri, 15 Nov 2019 17:42:36 -0500 Received: from mail-qt1-f196.google.com ([209.85.160.196]:35166 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726920AbfKOWmg (ORCPT ); Fri, 15 Nov 2019 17:42:36 -0500 Received: by mail-qt1-f196.google.com with SMTP id n4so12543133qte.2; Fri, 15 Nov 2019 14:42:35 -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=1Ljh/C9bOl+iw6pSFvN3eoLNKQmG6h31Yeu6UPqkFhQ=; b=qTyktsT4cDpAQOuWRvAREFnO06PUl5P+DdqgZm+lxHqH05GZI2qSuxSrvvBPdanQoL URI+YXs/LLv+nK0GkRAFNzSNYbBipDq1Hbt08kTHPTpcA92Cc+UaxSaCLIhPHQ7OMKc8 Cw9eqqoYH3rVjwSYxFU8rW3d0rClYqPQLkNu7UdD1JjEgK56fhBbOE9PXYG/ndHyBjlG SlseIWTzGRdJ94MYa95c+aTBf0b3yDAZK2UO8zs72iuNvX+5QraLP7zU/s2aHpPoq8Xo omyqG8D30tKykT7YpnQxkY4kIdYAzSkJpRaDsAdaR20562wr39KFzy83C/L9crO+tD95 4P8g== 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=1Ljh/C9bOl+iw6pSFvN3eoLNKQmG6h31Yeu6UPqkFhQ=; b=KCXSHrrhbBy0vlgA1/EWPksFHv9GWnMMnlcb7QcKDYSpTmqU9TanBN4/bJoFfJz3dN hz3Z9xF3Q96rubq1ug3ZOENRDF+45Nb35JfeqNRDZ7lGHO3MY0zLbBL1RjonlWOAB255 YWRtzsGRdsPckjtgdqYEekAw1rEVTiljbF1yhSijBIroqRBUV+omvVop64btVIwRhB5N LGjXcyOE76U3uWTLzF7VxJNlSKJsjqnjX2IQAPU3mlCYyV2GTuN2fXRV9PULe9czrrJv IVG/UDgrGLbtr+c+ZlCZqEccp4Dp8Q0VG8F7uNxMLosPYoQI2WhYfSVhsoxG0tCEXzWi R02Q== X-Gm-Message-State: APjAAAWyyhsUAIIOBIW/0hkVaumR0Grcf3FNgUpulytqv3XvTLUUU/Ec Cz/Q6Z1+KeutjfHtDBeyNwDbrKKsHkwjQgqQzz0= X-Received: by 2002:ac8:199d:: with SMTP id u29mr15886076qtj.93.1573857754983; Fri, 15 Nov 2019 14:42:34 -0800 (PST) MIME-Version: 1.0 References: <20191107212023.171208-1-brianvv@google.com> <20191107212023.171208-3-brianvv@google.com> In-Reply-To: <20191107212023.171208-3-brianvv@google.com> From: Andrii Nakryiko Date: Fri, 15 Nov 2019 14:42:24 -0800 Message-ID: Subject: Re: [RFC bpf-next 2/3] tools/bpf: test bpf_map_lookup_and_delete_batch() To: Brian Vazquez Cc: Brian Vazquez , Alexei Starovoitov , Daniel Borkmann , "David S . Miller" , Stanislav Fomichev , open list , Networking , bpf , Yonghong Song , Petar Penkov , Willem de Bruijn 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 Thu, Nov 7, 2019 at 1:23 PM 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( ... ) > > Tested bpf_map_lookup_and_delete_batch() and bpf_map_update_batch() > functionality. > $ ./test_maps > ... > test_map_lookup_and_delete_batch:PASS > ... > > Note that I clumped uapi header sync patch, libbpf patch > and tests patch together considering this is a RFC patch. > Will do proper formating once it is out of RFC stage. > > Signed-off-by: Yonghong Song > --- [...] > > + struct { /* struct used by BPF_MAP_*_BATCH commands */ > + __u64 batch; /* input/output: > + * input: start batch, > + * 0 to start from beginning. > + * output: next start batch, > + * 0 to end batching. > + */ > + __aligned_u64 keys; > + __aligned_u64 values; > + __u32 count; /* input/output: > + * input: # of elements keys/values. > + * output: # of filled elements. > + */ > + __u32 map_fd; > + __u64 elem_flags; > + __u64 flags; > + } batch; > + Describe what elem_flags and flags are here? [...] > +LIBBPF_API int bpf_map_delete_batch(int fd, __u64 *batch, __u32 *count, > + __u64 elem_flags, __u64 flags); > +LIBBPF_API int bpf_map_lookup_batch(int fd, __u64 *batch, void *keys, > + void *values, __u32 *count, > + __u64 elem_flags, __u64 flags); > +LIBBPF_API int bpf_map_lookup_and_delete_batch(int fd, __u64 *batch, > + void *keys, void *values, > + __u32 *count, __u64 elem_flags, > + __u64 flags); > +LIBBPF_API int bpf_map_update_batch(int fd, void *keys, void *values, > + __u32 *count, __u64 elem_flags, > + __u64 flags); Should we start using the same approach as with bpf_object__open_file (see LIBBPF_OPTS), so that we can keep adding extra fields without breaking ABI? The gist is: use function arguments for mandatory fields (as of right now, at least), and put all the optional fields into a xxx_opts struct, which can be NULL. Please see bpf_object__open_{file,mem} for details. > + > LIBBPF_API int bpf_obj_pin(int fd, const char *pathname); > LIBBPF_API int bpf_obj_get(const char *pathname); > LIBBPF_API int bpf_prog_attach(int prog_fd, int attachable_fd, > diff --git a/tools/lib/bpf/libbpf.map b/tools/lib/bpf/libbpf.map > index 86173cbb159d3..0529a770a04eb 100644 > --- a/tools/lib/bpf/libbpf.map > +++ b/tools/lib/bpf/libbpf.map > @@ -189,6 +189,10 @@ LIBBPF_0.0.4 { > LIBBPF_0.0.5 { > global: > bpf_btf_get_next_id; > + bpf_map_delete_batch; > + bpf_map_lookup_and_delete_batch; > + bpf_map_lookup_batch; > + bpf_map_update_batch; > } LIBBPF_0.0.4; This should be in 0.0.6 section now. > [...]