Received: by 10.223.176.46 with SMTP id f43csp1632726wra; Wed, 24 Jan 2018 20:44:42 -0800 (PST) X-Google-Smtp-Source: AH8x227FSzHBZDqj+Ds0fRzUQC6v6qux2h1gW8cn2qY0mRoUngLtE5CGUtE9ZikEsAXMDHB3o3+J X-Received: by 2002:a17:902:71c6:: with SMTP id t6-v6mr10580988plm.318.1516855482075; Wed, 24 Jan 2018 20:44:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516855482; cv=none; d=google.com; s=arc-20160816; b=L45rDvjtaLovyEX2fPHH/zijKUIL3HH+QBtSWd2C0+CWfx7KtB4SroeeOiSWtanPnw hsHMxDa6+xtvo+6TJKaIG0mAP7d0svdd1t/5LMLeci2Iym2P/SWLW/8NhKiF2VsTqmSM 2G/IUHYJ+vcgxoKm2vjXBP4xkRgtawnYzr2Nhg7o8DFVltJ7x8XEOT75yohzE0TUrkKn nhRFxAeBXi6OSUySAm+8J3UgyhzmGYfHW860RZ5f7Gz1nOtUwD6Da0Q2Ur+3/DzdXj0O Y7g4q9+QpibjCjig8GKw+AdGdfFNywmD0OtBwg7UNLznTcU9H7SvT80xnF7mRLMgy+KC Vzzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=wKLr3/YQA6ChBeWCAFPBkvdiI7AJxVl2uEVQF2QDYJ4=; b=FrHOfpNSHIGMgy1WF5YYY3a5Yq2gWTUBZecRt9uCDxRXGMB1HBO3uIuIx29+sK1Xry GRjBqAo7ltCTrgoR+Ex8TS7tg2tkm6sfwW/a1z00CCnURr7OJ/rVfurHN9K6KYRmO2Cn FFxKgdVFaotOrGnlz0x0G4tqsJXmR+fSfMlLBJopIlE5fd/fxAOc2foWUScWlZ9Aki4N PoHDZbWW/+KPlftHGNdfDW+DQFWuDnrgJsqKnLi2A/D9c8H0kz4KU0Yw+wlLFrJr1BV3 kgGthu/qGoiofk8onJRXeII6zJCDjmVq3glMimORH+aFaw77ik5rUY2OyXvcXiNRnhon cYOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qQIoNfJr; 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=NONE 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 x25si1037625pgc.643.2018.01.24.20.44.27; Wed, 24 Jan 2018 20:44:42 -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=qQIoNfJr; 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=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933470AbeAYEmU (ORCPT + 99 others); Wed, 24 Jan 2018 23:42:20 -0500 Received: from mail-pg0-f66.google.com ([74.125.83.66]:33882 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933369AbeAYEmT (ORCPT ); Wed, 24 Jan 2018 23:42:19 -0500 Received: by mail-pg0-f66.google.com with SMTP id r19so4336520pgn.1 for ; Wed, 24 Jan 2018 20:42:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=wKLr3/YQA6ChBeWCAFPBkvdiI7AJxVl2uEVQF2QDYJ4=; b=qQIoNfJrxY8jj2+Xn6/r6D0hTBCGw1pThd4txuruIytM0kH2o9r7armBqetFtRSd4C 9FA7DdWV4bq8LOD//+MD9vmBqJ86DT5EOFXtkmwZNylqLXwLEw32Y6z60sR6t2upJaSW 0BoNnj0P7rHUbASmd2SCtjzmrLYpOIGz+SDrxGHYQCaOZ1ci0nPiKw6Ue1MclKmTnFpl ns8XVsMiL5DkINopz8SO1TflewHQ4QWykrMMWia+7mCj7gWxkaWF8TTOIXM/GIemUXM5 kBVQOC0BoZ0ROecEBhbB99FCLeGCbxkIK/ezFRSKVkbcmBRjGJLDP6G3GG2Y1MOMrCDH 2aMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=wKLr3/YQA6ChBeWCAFPBkvdiI7AJxVl2uEVQF2QDYJ4=; b=YhifuskjEDbKRDgdj1oRihUNrFHIssIRF1mb7JTivwG/InLLT5rjA6znqprWkPZRoS EXjjXBKIBsj0yDaTwnfmQeLosK1XuAnL8ttqtAxQakVdOJo1ETOFTAFfLktL2oew+6Uz 5+5slpiHSIiYeM8jQddjAZPjV57RyLMQFvo1qPoUWxxfdEq+W4D/ZFRUtHKo0dlE6oXJ Gf1QLVmXUsv/NQ7Go9YVjA2HMgnPdiF3FnIoeuofUgQLzJrQ7MqVyiZ9tJscqzbEvlCh K+jBClPNFvIhB/84uB2okPgFj4pIpRumuFZVMSadtjN9ZmlU4Kr+EePbxjSgE95IKp+D tF9w== X-Gm-Message-State: AKwxytd9g9JheItydrBbnScsYcM2SOfcLOsWiKrf3punvauPa+WOHQ0G HbL2V27ufiGuLAoeFXdk7vw= X-Received: by 10.99.55.65 with SMTP id g1mr3289692pgn.284.1516855339063; Wed, 24 Jan 2018 20:42:19 -0800 (PST) Received: from ast-mbp ([2620:10d:c090:180::14e5]) by smtp.gmail.com with ESMTPSA id t22sm12430328pfi.118.2018.01.24.20.42.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Jan 2018 20:42:18 -0800 (PST) Date: Wed, 24 Jan 2018 20:42:14 -0800 From: Alexei Starovoitov To: Joel Fernandes Cc: linux-kernel@vger.kernel.org, kernel-team@android.com, Daniel Borkmann , Brendan Gregg Subject: Re: [PATCH] bpf/stackmap: Implement bpf_get_next_key Message-ID: <20180125044213.xwd3v5guj5xiim2l@ast-mbp> References: <20180125043752.35179-1-joelaf@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180125043752.35179-1-joelaf@google.com> User-Agent: NeoMutt/20170421 (1.8.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 24, 2018 at 08:37:52PM -0800, Joel Fernandes wrote: > Currently stackmaps can't be iterated over. The keys are obtained > through other maps and look ups have to be performed. In new usecases, > its useful to be able to iterate over the stackmap independently. > Implement bpf_get_next_key to make this possible. > > More details of use case: > Currently iterating over stack maps is done like so, for example > in BCC tools offcputime script: > 1. Obtain keys from the 'counts' hash map. > 2. Look up stackmap with each of the keys obtained from step 1. > > This makes the iteration of stackmap dependent on the counts map. > In a new tool I'm working on called BPFd [1], it gives a huge speed > up when I dump entire maps before transmitting them to BCC tools > on a different machine [2]. This patch makes it possible to dump > stackmaps independent of other maps. > > Tested on x86 and arm64 machines. > > [1] https://lwn.net/Articles/744522/ > [2] https://github.com/joelagnel/bpfd/issues/8 > > Cc: Alexei Starovoitov > Cc: Daniel Borkmann > Cc: Brendan Gregg > Cc: Brenden Blanco > Signed-off-by: Joel Fernandes > --- > kernel/bpf/stackmap.c | 18 +++++++++++++++++- > 1 file changed, 17 insertions(+), 1 deletion(-) > > diff --git a/kernel/bpf/stackmap.c b/kernel/bpf/stackmap.c > index a15bc636cc98..b0bf7d009f76 100644 > --- a/kernel/bpf/stackmap.c > +++ b/kernel/bpf/stackmap.c > @@ -228,7 +228,23 @@ int bpf_stackmap_copy(struct bpf_map *map, void *key, void *value) > > static int stack_map_get_next_key(struct bpf_map *map, void *key, void *next_key) > { > - return -EINVAL; > + struct bpf_stack_map *smap = container_of(map, struct bpf_stack_map, map); > + u32 id = 0; did you check net-next tree before sending the patch? Also please see Documentation/bpf/bpf_devel_QA.txt