Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5063609rwd; Sun, 4 Jun 2023 19:56:30 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7UKNuMFFwhvqfmkrPqRlmXI49q6w6v5iay1YzzGa9glwgTsL6pN0+kPriGK6+GcxecfS4U X-Received: by 2002:a05:6830:169a:b0:6ab:1c78:d5e with SMTP id k26-20020a056830169a00b006ab1c780d5emr9111864otr.5.1685933789878; Sun, 04 Jun 2023 19:56:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685933789; cv=none; d=google.com; s=arc-20160816; b=S2L2xh7TQShPORH0xMh0IGpVEgVX9oI8Wx4Z5j+MvBB+HVxpWxvby9PUpTk7ehEESk Fr7ehvuvEEW4SpA2MzcsYnfq/ExFGBLJ6bjeYoK1JnfZa+Vj4zsHMwXqG29bNEUnFf1X v+zN6Za145NBJtWDwFFnIqzOWyhePNCRDY75sA+U7B+u7UjP5b2G/ZINtCiE2sV+iWuR eTz33MZiJ7r1muhX+xRTg5beRhmt1zMhIzUzzsE10s15ZPLiIx4Kp64VsDB493bUvCsM K3buk9Qkcz4FBzJnMpMWvjAGv2OB1xhG77OT5VffRp9W/o4A6gp6/LfYZntIJp6+NaQC 9bsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=6KhfVPYZ7vtB0w+jSRd90gM6VmUDM45T4v5y5RR1xVo=; b=ZhxWNyQGTO00mSP6MeOmUItlE/FuCKJ3thuWz5F2c1F17zZtVdeyXVOtBUpkQTEmZs 0JEQLybtI7oxDl7A0HwVe8cgGnlzgpXdshSUUt5qR5Zqzy3KAVj81TTTDXq+VDhe+bvQ i1sI1kyb39z3XDWFehGf9Ejx1qV8YPigmrGwxK1njo/ewdzniH9KHCCL8CuedQMVnShy JZZxVB9/9UgC6M4teemXUT57kGQQCP3RRq5HyB2POCSn/M6S+NNtItYacN2Z6glrp8XI sJzcUL6zMs7gN6UiqTMbmibBl8cnhjQkzi/hQ/dtnPnBfWmPxWnhgv7F3fivMNm+pC42 Kk5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=bPRbKmPn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x3-20020aa79563000000b006462cc07d9esi4561485pfq.300.2023.06.04.19.56.17; Sun, 04 Jun 2023 19:56:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=bPRbKmPn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S232163AbjFECuI (ORCPT + 99 others); Sun, 4 Jun 2023 22:50:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230437AbjFECuH (ORCPT ); Sun, 4 Jun 2023 22:50:07 -0400 Received: from mail-yb1-xb43.google.com (mail-yb1-xb43.google.com [IPv6:2607:f8b0:4864:20::b43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 533E0BC; Sun, 4 Jun 2023 19:50:06 -0700 (PDT) Received: by mail-yb1-xb43.google.com with SMTP id 3f1490d57ef6-ba86ea269e0so5303305276.1; Sun, 04 Jun 2023 19:50:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685933405; x=1688525405; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=6KhfVPYZ7vtB0w+jSRd90gM6VmUDM45T4v5y5RR1xVo=; b=bPRbKmPnQH58sMcv8MdpzwRbB4HT9uLs4Y1b9vbCYHaVMI5fVqA0UbOhVBdZUKVLwL 474L+1gaDfOxkB5SM7VhDEjtpAXYAQeoyfGucp0hQ6P5k9vt/6LujP0M1+SAAiBTzOYS whC7qWxHmjevNdG/6xnEyJU4h4A6USgsJ+lgMElD8Pcn5zwjL1LzQvwC+kTnbuBnehmA LKgzQq3T2ALRXU9YAhmRbv0PLKC0iLwiq2/yjl0NYeb44AC1Rf+L7PWlWdO6wUpwm0tO rvRWMni7+yIwkFxgx+Cx5Q0mS4d9yPGuTuWC6U8M72487CdKYVvdmQeXtVSgg7H1TwIG z7Aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685933405; x=1688525405; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6KhfVPYZ7vtB0w+jSRd90gM6VmUDM45T4v5y5RR1xVo=; b=ANJ9zfjPrIwAOgbzMnY6oUDhp/mPVAMHeNvY6ujMhvvoDDAqTl40z7ksaYCVN5JI+C 7ASoL1g8dkqUgPIknMEZ0xIoFSMtL800uiBQ1DMsuR3aZ/TjnEhmLnBJJY1AkM4qg8T3 5eJRsfFsNkf8Q0wD9dQiBRSKaav1hvpJBoUhYrNV6xp92GuL5hZUxFJRwzR1IXTr0Ksy A2MikQwGZqTz0U4Z3ATPT0VXymknoWFk6t4LzCLYZaysGBXlZGmRxE8XNNoAECiAR7jM D97sZ6AKqvmdA8ZV75OxTHV4BKgN9gauoMvzcWsQFAQ4QYDI5GN91RCwjrLXCUqX/bE/ QEhQ== X-Gm-Message-State: AC+VfDz5uzaEuYkjH52/3YpfuKvrElzXkoJvGeNA8i7sW/uuemG8BS5k HzTm++LXkRRJo4EgqEpFlVu9nTyOCiljnXnervI= X-Received: by 2002:a25:84d2:0:b0:b96:1c8c:9d8c with SMTP id x18-20020a2584d2000000b00b961c8c9d8cmr10752423ybm.46.1685933405500; Sun, 04 Jun 2023 19:50:05 -0700 (PDT) MIME-Version: 1.0 References: <20230602065958.2869555-1-imagedong@tencent.com> <20230602065958.2869555-2-imagedong@tencent.com> In-Reply-To: From: Menglong Dong Date: Mon, 5 Jun 2023 10:49:54 +0800 Message-ID: Subject: Re: [PATCH bpf-next v2 1/5] bpf: make MAX_BPF_FUNC_ARGS 14 To: Alexei Starovoitov Cc: Jiri Olsa , "David S. Miller" , David Ahern , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , KP Singh , Jiri Olsa , X86 ML , Biao Jiang , Network Development , bpf , LKML , "open list:KERNEL SELFTEST FRAMEWORK" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jun 3, 2023 at 2:17=E2=80=AFAM Alexei Starovoitov wrote: > > On Fri, Jun 2, 2023 at 12:01=E2=80=AFAM wrote: > > > > From: Menglong Dong > > > > According to the current kernel version, below is a statistics of the > > function arguments count: > > > > argument count | FUNC_PROTO count > > 7 | 367 > > 8 | 196 > > 9 | 71 > > 10 | 43 > > 11 | 22 > > 12 | 10 > > 13 | 15 > > 14 | 4 > > 15 | 0 > > 16 | 1 > > > > It's hard to statisics the function count, so I use FUNC_PROTO in the b= tf > > of vmlinux instead. The function with 16 arguments is ZSTD_buildCTable(= ), > > which I think can be ignored. > > > > Therefore, let's make the maximum of function arguments count 14. It us= ed > > to be 12, but it seems that there is no harm to make it big enough. > > I think we're just fine at 12. > People need to fix their code. ZSTD_buildCTable should be first in line. > Passing arguments on the stack is not efficient from performance pov. But we still need to keep this part: @@ -2273,7 +2273,8 @@ bool btf_ctx_access(int off, int size, enum bpf_access_type type, static inline bool bpf_tracing_ctx_access(int off, int size, enum bpf_access_type type) { - if (off < 0 || off >=3D sizeof(__u64) * MAX_BPF_FUNC_ARGS) + /* "+1" here is for FEXIT return value. */ + if (off < 0 || off >=3D sizeof(__u64) * (MAX_BPF_FUNC_ARGS + 1)) return false; if (type !=3D BPF_READ) return false; Isn't it? Otherwise, it will make that the maximum arguments is 12 for FENTRY, but 11 for FEXIT, as FEXIT needs to store the return value in ctx. How about that we change bpf_tracing_ctx_access() into: static inline bool bpf_tracing_ctx_access(int off, int size, enum bpf_access_type type, int max_args) And the caller can pass MAX_BPF_FUNC_ARGS to it on no-FEXIT, and 'MAX_BPF_FUNC_ARGS + 1' on FEXIT. What do you think? Thanks! Menglong Dong