Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp8064601ybi; Tue, 9 Jul 2019 08:35:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqybE8nS1vuUL9gONphgE8OdyftfrMugpt0TLnpoHwKFUENxQ8j9s0bMikUFK0CXPMEV68Iq X-Received: by 2002:a63:fc52:: with SMTP id r18mr31179890pgk.378.1562686529543; Tue, 09 Jul 2019 08:35:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562686529; cv=none; d=google.com; s=arc-20160816; b=CKuUnl6SU5A3y9u2g01Rye82n5rrlYhUsT/fCuHxC1P+IMBS/5xXNB6BcR3h2Sj4y0 qzUujanUcHjDdItEkiph8imWmwcvaex3JXhsmJ8OJ/CkWGnuix9IalaTnUHPM2F2yPlv TsGLCJ2/Fj66w74eHSShS3uBeJ3dTTM4efPKi0I2BFOsdxjDkABXTQBgx97C/9zLjOwd Qs5lXjN1XJ/VtMu7yyni5yipGMZx9M1AwmoijyMuhDRYD3B4lnUEzewJVM2+4S+fuIPy BWq5vRcfoxoEY5B9LpekBCQmqfCYdPptzrszy/lAJercq7h44sV8j9CQnWA0WdfSY/so tNeg== 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=XldrumkAgmzEzxgr2Bcv/W7MnrtFEO21Trg6QIY5k84=; b=Vxr8216tiksiyS/39+ultbGLTvGFb9jGugvyLKLwucgRtHxBnL9ANAzmU9636/7VIo eoXrZNSOArNsQixjikd4QAzQARIrnc0yv2dxu2irMX+SM9uweOjVDxk5IhO5OD6qsgWl xuGJ38O9OOVlWGpFPPApbRYC/qrB1vvQRY9BvI0bRSRT/i0BQ3z6wPTK2uUIlSzVGSe/ SBqaqg6BquB9hRY8YP45s6i2vhcAWXPuEYY7lPiLC9TXYSRpLswomaa12JYEvj09KQ4h ay0LdnGbeLrTu0mXG2yz4Np8an0F5hw/5UJMRDRJSxzDf6crgOgqWF0Z7Bop/TrJceEs 8I9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=BVh3b0bB; 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 f34si21816666plf.305.2019.07.09.08.35.12; Tue, 09 Jul 2019 08:35:29 -0700 (PDT) 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=BVh3b0bB; 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 S1726346AbfGIPeZ (ORCPT + 99 others); Tue, 9 Jul 2019 11:34:25 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:45239 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726060AbfGIPeY (ORCPT ); Tue, 9 Jul 2019 11:34:24 -0400 Received: by mail-lf1-f66.google.com with SMTP id u10so13716557lfm.12; Tue, 09 Jul 2019 08:34:23 -0700 (PDT) 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=XldrumkAgmzEzxgr2Bcv/W7MnrtFEO21Trg6QIY5k84=; b=BVh3b0bBJ8vh+cbfAE1PPxlD2zb/+DWuI9G4Wtyh3ITaGL2D9FqMGozHfb1aaI02WV ZTlXfMRbRIaF9f3x4uz3kUZHECth7ftSAK7Jrerx5Psp6tVSStd+0UCW41LnbUREBKxt vAhywaDHaaHaItpu7fXme4HVUKJtcQz2fS0CmcRab8SfYlBpHCejckEK0GeSFZgasyQQ CYyZoLpkS4Fn93kNK4uw7bxmnbbkpLAl99vL2A3vkrh5cQbCjK6iI0RicvAie7ayQJKY EywTtOe5759BFFnumbj2P+z7DQYnU2QfTF/wqyJjbEDl1b0gsje/3phHX/QKj6QugLwA FZ+Q== 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=XldrumkAgmzEzxgr2Bcv/W7MnrtFEO21Trg6QIY5k84=; b=cgmvdi0OO7tCcVOHicu0WvZADhDtZ5ld8O8MvoJcxzPTs1u1gm5riYY0S3LjsGk4i4 4g0Bo2ILNkN58wZIIydrH1JSBjQ49y7qMUACqmSWk9Qy7kMxN9Cm9GPhuZOVi+3OXUaO Iwu1VP7dz8SoBgGw+J4UjP10mBhAeJ2xBvOZFogsL25SFIg3JU9zTg2fQ0ayFTXYEupz kNgacxO6WrAV28iUg/5xZndlceB3GD436Nw5b3MnkAoFS8Ce7+KrWEM2U8S9Drnh7IZv vnao1ijSOV6UPpI47fxfJa6R4I7E1HY4Df3OGFmJFhLWyHChPQeZQd6OGT/mvFg6DPrZ nu0g== X-Gm-Message-State: APjAAAXfaPoXg4S3IuUC/Ieo7nNoHTBZnj6iIugwLHSJJhhBvIJLlQkX /B7wYflJM8l4BJLxPqrnWkGuyc1jHrCxvYr+UrM= X-Received: by 2002:a19:6b0e:: with SMTP id d14mr11779539lfa.174.1562686462634; Tue, 09 Jul 2019 08:34:22 -0700 (PDT) MIME-Version: 1.0 References: <20190703170118.196552-1-brianvv@google.com> <20190703170118.196552-3-brianvv@google.com> In-Reply-To: From: Brian Vazquez Date: Tue, 9 Jul 2019 08:34:11 -0700 Message-ID: Subject: Re: [PATCH bpf-next RFC v3 2/6] bpf: add BPF_MAP_DUMP command to dump more than one entry per call To: Y Song Cc: Brian Vazquez , Alexei Starovoitov , Daniel Borkmann , "David S . Miller" , Stanislav Fomichev , Willem de Bruijn , Petar Penkov , LKML , netdev , 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 > Maybe you can swap map_fd and flags? > This way, you won't have hole right after map_fd? Makes sense. > > + attr->flags = 0; > Why do you want attr->flags? This is to modify anonumous struct used by > BPF_MAP_*_ELEM commands. Nice catch! This was a mistake I forgot to delete that line. > In bcc, we have use cases like this. At a certain time interval (e.g., > every 2 seconds), > we get all key/value pairs for a map, we format and print out map > key/values on the screen, > and then delete all key/value pairs we retrieved earlier. > > Currently, bpf_get_next_key() is used to get all key/value pairs, and > deletion also happened > at each key level. > > Your batch dump command should help retrieving map key/value pairs. > What do you think deletions of those just retrieved map entries? > With an additional flag and fold into BPF_MAP_DUMP? > or implement a new BPF_MAP_DUMP_AND_DELETE? > > I mentioned this so that we can start discussion now. > You do not need to implement batch deletion part, but let us > have a design extensible for that. > > Thanks. With a additional flag, code could be racy where you copy an old value and delete the newest one. So maybe we could implement BPF_MAP_DUMP_AND_DELETE as a wrapper of map_get_next_key + map_lookup_and_delete_elem. Last function already exists but it has not been implemented for maps other than stack and queue. Thanks for reviewing it!