Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3544395pxb; Mon, 24 Jan 2022 11:52:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJzdEes1RPl2T9blIlziQFg/NTV/FJkBB3ZOr1BzGLSNpr/76xkP4e4FqLKadOhdIUYW/kvZ X-Received: by 2002:a17:902:8601:b0:149:ee23:890a with SMTP id f1-20020a170902860100b00149ee23890amr15756216plo.12.1643053954299; Mon, 24 Jan 2022 11:52:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643053954; cv=none; d=google.com; s=arc-20160816; b=GLCDftKR2MiOA7uI0g6ufGKqkhAL2cT4Mp8m/MZqkYnmGLkf2kqNCM2D9Sx0BLuWGt 52uCpSnhTShnmfjhLY/CjLVZPMjQWZ7SVCE3RgzSHj2CtwCvvanxCum+sTgkRZ0X4MPK zGd5Y6FqTHflK5LxCdyWdI1m1kwKv0PeI2MPlk98a+4uvLTEFDrwfmITawdP9Sm4sKA9 ckCZhGxBnN78N6t1HUtTRoOhhvoeTR/Bg+7sRXV6Fwgo5eU7bqrb3Ia6rfOTXJbPDclQ LASdK0uz5zdOAwoRHkjcw7Agvro0K0IEVdOP7j6JncXCRfdZmyUtKwMxITQrLxpzLeKb RROg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=K6etE/ly2g0VeXSdeIkDpJwMBD9Oa8SeCLG1zWSfgrU=; b=Yd9Hwmx65aXQ6TCn0IjufThJEcmXKgEXd1VGM6pzfUlPMguNqrYuPbGZ7nbKS1Fj/E vA4QRVuMzJ8cTfM3qRexv9pChbEidLAI0jObIgekmmpxrK9yiO8ucXWsrUihcfNw8L/Z v7JSRlDqEQMXEVWvwb7kj14+PYkJemPOdG+tCTlq63UthRMEHAPNF+8kHkElMa9x2vM/ nXCP25WyvZYlg5vlfasTqsR6ca0zWXv8t2yrQrCZ3gVc7ZPbWX1MhxhZsvrJwUkf9JOn 2PahOEEg7oyzrwQIpDuDGOQGAtN/trGtcEWB2hlzgVx9ezsVhd/LLRjvC8Nh8X7yLPlh UfWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Pcs1V+Cd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w125si13083602pfw.250.2022.01.24.11.52.22; Mon, 24 Jan 2022 11:52:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Pcs1V+Cd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245237AbiAXSZZ (ORCPT + 99 others); Mon, 24 Jan 2022 13:25:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245233AbiAXSZT (ORCPT ); Mon, 24 Jan 2022 13:25:19 -0500 Received: from mail-qk1-x732.google.com (mail-qk1-x732.google.com [IPv6:2607:f8b0:4864:20::732]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 857EAC061744 for ; Mon, 24 Jan 2022 10:25:19 -0800 (PST) Received: by mail-qk1-x732.google.com with SMTP id h2so21292962qkp.10 for ; Mon, 24 Jan 2022 10:25:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=K6etE/ly2g0VeXSdeIkDpJwMBD9Oa8SeCLG1zWSfgrU=; b=Pcs1V+CdhZCKff3WNADfaPdxie2c9AoWyjHN3xGrBOrslo+5Ry9Su4Wg81Yg58YjO+ e5PtYQEs05Ne337BKKtfad0inw/4ziYXpp3kIwYQVfkfLnKx3wJNjIuaMh/X2QszO+Zl 9kyxYlWKd3aiMhUU7Ow7VTonasdUwHVTJPUcv/aYE1uyGc9M2WJtUVTM5Y2vLsYjTIeJ z0087J0F1jlYYFkzLgeejHJCAqKyDFadvc5knPzsPD7nHcSIQl27ffC4veEliT7/PpD5 JjP/3wJ0hs7WCnfe1pNTb+rX5iQcEstoRA3wi8llqhD4Sp0J/82l7yfrEcGUOn3IaMTv ozQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=K6etE/ly2g0VeXSdeIkDpJwMBD9Oa8SeCLG1zWSfgrU=; b=q9+CUQRchxRE1Zwa5lMklgQ96tIinUt/wRYk0d4opm/BxARL5aR1SFLbLNNhzlOCmh hoZqUkKkpQKh4NAoDuMy+mZ49zEgG4nLigDaUS4Jgg/VBuaxbHaalJgtpNQ9zCRYWqP/ 7JGxUafAFmy5DuXhclv1Roxo07K+XkTUb3HEPEZ9LDuXYdtbH2M2TX1/AEPNdNXW67qH lQQ0g7dgpLoK73h93nlOkG5AdfNh/5c5m48gMwTtnl4lyLzGkr2jamLJgfsIU/lHCopS H3OwUDFvvom/R6mI2ABK9OIRkYFvYoNTdoqddIMNPDmQfv+uFo7zWKmYxBTOtL8rUA/p dfxw== X-Gm-Message-State: AOAM530+hv0TvilkcjM/PRK00LKImHwAvAx7uciYci/ZrKDNXUqVqg0X ynzV8V8i33sO7yV/vqRnCq3stbtuNxce0AT4x0PuvQ== X-Received: by 2002:a05:620a:4689:: with SMTP id bq9mr12401158qkb.496.1643048718462; Mon, 24 Jan 2022 10:25:18 -0800 (PST) MIME-Version: 1.0 References: <634c2c87-84c9-0254-3f12-7d993037495c@gmail.com> <92f69969-42dc-204a-4138-16fdaaebb78d@gmail.com> <7ca623df-73ed-9191-bec7-a4728f2f95e6@gmail.com> <20211216181449.p2izqxgzmfpknbsw@kafai-mbp.dhcp.thefacebook.com> <9b8632f9-6d7a-738f-78dc-0287d441d1cc@gmail.com> In-Reply-To: <9b8632f9-6d7a-738f-78dc-0287d441d1cc@gmail.com> From: Stanislav Fomichev Date: Mon, 24 Jan 2022 10:25:07 -0800 Message-ID: Subject: Re: [PATCH v3] cgroup/bpf: fast path skb BPF filtering To: Pavel Begunkov Cc: Martin KaFai Lau , netdev@vger.kernel.org, bpf@vger.kernel.org, Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Song Liu , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 24, 2022 at 7:49 AM Pavel Begunkov wrote: > > On 12/16/21 18:24, Stanislav Fomichev wrote: > > On Thu, Dec 16, 2021 at 10:14 AM Martin KaFai Lau wrote: > >> On Thu, Dec 16, 2021 at 01:21:26PM +0000, Pavel Begunkov wrote: > >>> On 12/15/21 22:07, Stanislav Fomichev wrote: > >>>>> I'm skeptical I'll be able to measure inlining one function, > >>>>> variability between boots/runs is usually greater and would hide it. > >>>> > >>>> Right, that's why I suggested to mirror what we do in set/getsockopt > >>>> instead of the new extra CGROUP_BPF_TYPE_ENABLED. But I'll leave it up > >>>> to you, Martin and the rest. > >> I also suggested to try to stay with one way for fullsock context in v2 > >> but it is for code readability reason. > >> > >> How about calling CGROUP_BPF_TYPE_ENABLED() just next to cgroup_bpf_enabled() > >> in BPF_CGROUP_RUN_PROG_*SOCKOPT_*() instead ? > > > > SG! > > > >> It is because both cgroup_bpf_enabled() and CGROUP_BPF_TYPE_ENABLED() > >> want to check if there is bpf to run before proceeding everything else > >> and then I don't need to jump to the non-inline function itself to see > >> if there is other prog array empty check. > >> > >> Stan, do you have concern on an extra inlined sock_cgroup_ptr() > >> when there is bpf prog to run for set/getsockopt()? I think > >> it should be mostly noise from looking at > >> __cgroup_bpf_run_filter_*sockopt()? > > > > Yeah, my concern is also mostly about readability/consistency. Either > > __cgroup_bpf_prog_array_is_empty everywhere or this new > > CGROUP_BPF_TYPE_ENABLED everywhere. I'm slightly leaning towards > > __cgroup_bpf_prog_array_is_empty because I don't believe direct > > function calls add any visible overhead and macros are ugly :-) But > > either way is fine as long as it looks consistent. > > Martin, Stanislav, do you think it's good to go? Any other concerns? > It feels it might end with bikeshedding and would be great to finally > get it done, especially since I find the issue to be pretty simple. I'll leave it up to the bpf maintainers/reviewers. Personally, I'd still prefer a respin with a consistent __cgroup_bpf_prog_array_is_empty or CGROUP_BPF_TYPE_ENABLED everywhere (shouldn't be a lot of effort?)