From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.5 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 84D75C282C5 for ; Thu, 24 Jan 2019 16:34:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 545B0218A2 for ; Thu, 24 Jan 2019 16:34:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=fomichev-me.20150623.gappssmtp.com header.i=@fomichev-me.20150623.gappssmtp.com header.b="mHisMfYu" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727786AbfAXQeZ (ORCPT ); Thu, 24 Jan 2019 11:34:25 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:40318 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727990AbfAXQeW (ORCPT ); Thu, 24 Jan 2019 11:34:22 -0500 Received: by mail-pf1-f195.google.com with SMTP id i12so3239418pfo.7 for ; Thu, 24 Jan 2019 08:34:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fomichev-me.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=4uwHqol2fxIMYaQ52vYuotHCFaiQdDgaTWYNFjYQgF4=; b=mHisMfYuK3adCrsvj3m6wd9dT2YT12hMu8zVD4y29G70ybAXtQmqwMJolkHncHc8iW QKYJFMpyGNiyDpUWbUdDUdCaWzw5tGjAoPZ6JmES6/SyMzooljg1T1y1xMtUACH72Wm2 2uxTaWp/ZZ5SRYz3/LNBydiiLpsAaggz7itG33Y72v5IkdT3fpcMl2FFc81hwpxmzPa/ XcyF9UnXtJqaEFYm1w9KeLKbWCuC9yzRSGXnfiWAttE8h0du2lxWySHR5xTCtN6g3s8f VfLAKMaB9tNk9al6Y412+opGs2c7O2Yz3iCd1rylOgXdnjBo1VVf1Vtl+jANk/iupPD9 nHzw== 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=4uwHqol2fxIMYaQ52vYuotHCFaiQdDgaTWYNFjYQgF4=; b=Wvr8mLBVxgXwRabR1BEiCTeyf9kvAPGkafmxAoJ0p1AvVdmfNO8ru6u5N1sawVTlIz 4fk7EYRz9kiVHU6eUIvasChgU3t//c0323Vrn8UHdqumO40/YXqJ5YrMSRq7nWLn3CQ7 qHcUWbQ3/npXI7M1Ru9Oy0RdUxB+D4M+j/BrhYVc4pbfB1SbsTYEhS6fpbiLw4U/Mi+4 vClqw+nlNr0S6QBtdUVvhekveTyiFICNZeNOJ05MxB/PhOYXXykF0+0iPI/JXnAljh8C ygT5ozxxVyiFSVp7dyV+FDZEb2BEAv9RRgK/udnyCbiAcj7jsB0QGfNScSntexUjmBYb fT0g== X-Gm-Message-State: AJcUuke6aRMGoI8D18HtsMe3hl+vgWW7vu+aqm3oSYLVJt2mBaE9U8oN gUSUY7LXSrLX6YRrko1hikUpWA== X-Google-Smtp-Source: ALg8bN4vGyJ4zm8GMLNYmFEuRb0PCfZkmT0pttDUFYBuDt6rUediILGefeYQN+qYR2Wz+jW9tYm8+A== X-Received: by 2002:a63:40c6:: with SMTP id n189mr6416958pga.355.1548347661671; Thu, 24 Jan 2019 08:34:21 -0800 (PST) Received: from localhost ([2601:646:8f00:18d9:d0fa:7a4b:764f:de48]) by smtp.gmail.com with ESMTPSA id d21sm26392023pgv.37.2019.01.24.08.34.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Jan 2019 08:34:20 -0800 (PST) Date: Thu, 24 Jan 2019 08:34:19 -0800 From: Stanislav Fomichev To: Alexei Starovoitov Cc: Stanislav Fomichev , netdev@vger.kernel.org, davem@davemloft.net, ast@kernel.org, daniel@iogearbox.net Subject: Re: [PATCH bpf-next 2/3] bpf: add BPF_PROG_TEST_RUN support for flow dissector Message-ID: <20190124163419.GD26773@mini-arch> References: <20190122212315.137291-1-sdf@google.com> <20190122212315.137291-3-sdf@google.com> <20190124035600.ag4d7glkyysiluuu@ast-mbp.dhcp.thefacebook.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190124035600.ag4d7glkyysiluuu@ast-mbp.dhcp.thefacebook.com> User-Agent: Mutt/1.11.2 (2019-01-07) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On 01/23, Alexei Starovoitov wrote: > On Tue, Jan 22, 2019 at 01:23:14PM -0800, Stanislav Fomichev wrote: > > The input is packet data, the output is struct bpf_flow_key. This should > > make it easy to test flow dissector programs without elaborate > > setup. > > > > Signed-off-by: Stanislav Fomichev > > --- > > include/linux/bpf.h | 3 ++ > > net/bpf/test_run.c | 75 ++++++++++++++++++++++++++++++++++++++++++++- > > net/core/filter.c | 1 + > > 3 files changed, 78 insertions(+), 1 deletion(-) > > > > diff --git a/include/linux/bpf.h b/include/linux/bpf.h > > index e734f163bd0b..701ef954a258 100644 > > --- a/include/linux/bpf.h > > +++ b/include/linux/bpf.h > > @@ -397,6 +397,9 @@ int bpf_prog_test_run_xdp(struct bpf_prog *prog, const union bpf_attr *kattr, > > union bpf_attr __user *uattr); > > int bpf_prog_test_run_skb(struct bpf_prog *prog, const union bpf_attr *kattr, > > union bpf_attr __user *uattr); > > +int bpf_prog_test_run_flow_dissector(struct bpf_prog *prog, > > + const union bpf_attr *kattr, > > + union bpf_attr __user *uattr); > > > > /* an array of programs to be executed under rcu_lock. > > * > > diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c > > index fa2644d276ef..ecad72885f23 100644 > > --- a/net/bpf/test_run.c > > +++ b/net/bpf/test_run.c > > @@ -16,12 +16,26 @@ > > static __always_inline u32 bpf_test_run_one(struct bpf_prog *prog, void *ctx, > > struct bpf_cgroup_storage *storage[MAX_BPF_CGROUP_STORAGE_TYPE]) > > { > > + struct bpf_skb_data_end *cb; > > + struct sk_buff *skb; > > u32 ret; > > > > preempt_disable(); > > rcu_read_lock(); > > bpf_cgroup_storage_set(storage); > > - ret = BPF_PROG_RUN(prog, ctx); > > + > > + switch (prog->type) { > > + case BPF_PROG_TYPE_FLOW_DISSECTOR: > > + skb = (struct sk_buff *)ctx; > > + cb = (struct bpf_skb_data_end *)skb->cb; > > + ret = __skb_flow_bpf_dissect(prog, ctx, &flow_keys_dissector, > > + cb->qdisc_cb.flow_keys); > > + break; > > + default: > > + ret = BPF_PROG_RUN(prog, ctx); > > + break; > > + } > > What is the benefit of this minimal code reuse? > It seems to me bpf_test_run_one() gets slower for all, > since prog type needs to be checked before every prog run. > The point of bpf_prog_ops->test_run was to avoid this overhead. > Are you somehow expecting flow_dissector prog using cgroup local storage? > I don't think that's possible. Agreed. Initially I didn't want to re-implement the logic of bpf_test_run. But now that you mention that it's mostly about cgroup local storage, I think I can do a simple loop inside of bpf_prog_test_run_flow_dissector. Thanks, will follow up with another series!