Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp301971pxb; Thu, 9 Sep 2021 01:00:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwuEK1dQH4vJh1IIvya+iGSHrxzccJ//YwFsbZ9UAsFyDWZl/xXKplRA2QPSyRHHn6TZUwx X-Received: by 2002:a6b:5c0c:: with SMTP id z12mr1599617ioh.171.1631174419551; Thu, 09 Sep 2021 01:00:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631174419; cv=none; d=google.com; s=arc-20160816; b=gxLEi18yYR47fGBmALrsyHyYZ22ng80ZiEf7GzXOLCP/QhTPYGBr8RtOorZ6qQ3z5y bioAm7Y5W8F0OoqnR70QNPZy81qzl0CL3Ywb+NKX4r6edkfrbApMUdQTYmiqV0q/VV7Q oJNic3OcvfW2ZYrV3PhJOtRRp7PJj37T7qoL0X92h8FCM5E2E8aTigkqT0l8i2wdVuY0 GqWnOKR1zSV0mrqFkd/nSu5+HHgNDtvrXjNVz0Df+JHcoqrGDc4yqD7p9Qrry075ELnT qR3/T9FspgqdAQb81tOUgYtfXAOD+afvuUHJxcqdxCUkVhINK7jm6ElSePBkthAzJXRK J0lQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=BtSsvkvaEb75FOTh07dMfsLUzaeiPHk596iKbvRa6mI=; b=GPJ3KrQBm3lLGdUg+H+2Yzw6YV5F5Mnjbol6gfu1+OMxq7WMCNjHjKyVhB3RnJtWkz /98FKpOD5YZJYytg2x84p5cTX0dKURHMpJL1vcrXjpd/Zm4RUGkTkTb/mjjpSeDxIPmW dvUvpDsOdd3kncm3XWOJrMjsgcLjj5Hc4OusMToTpZcyB4lMrfA+2/LGmkBgx3Gd1wHM gHqL1lLHQl34eFF46Go3nRvUhynV/Mmel/u9JYSBRqAvrmAmnY8DG0PxCir6NgOCUFr8 yDfmSNMSB06K0rTV0Qlv6gmADzvZydNcFdl3ZaODEj6GwAyBYCw7pTo3z4159YsA9aG4 1iMg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m2si1319830ili.39.2021.09.09.01.00.08; Thu, 09 Sep 2021 01:00:19 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230071AbhIIH6v (ORCPT + 99 others); Thu, 9 Sep 2021 03:58:51 -0400 Received: from www62.your-server.de ([213.133.104.62]:59298 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229609AbhIIH6r (ORCPT ); Thu, 9 Sep 2021 03:58:47 -0400 Received: from sslproxy01.your-server.de ([78.46.139.224]) by www62.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92.3) (envelope-from ) id 1mOEvf-0001T3-P1; Thu, 09 Sep 2021 09:57:03 +0200 Received: from [85.5.47.65] (helo=linux.home) by sslproxy01.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mOEvf-000H3n-3x; Thu, 09 Sep 2021 09:57:03 +0200 Subject: Re: [PATCH bpf-next] bpf: Change value of MAX_TAIL_CALL_CNT from 32 to 33 To: Andrii Nakryiko , Tiezhu Yang Cc: Shubham Bansal , Russell King , Alexei Starovoitov , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Zi Shen Lim , Catalin Marinas , Will Deacon , Paul Burton , Thomas Bogendoerfer , naveen.n.rao@linux.ibm.com, Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Luke Nelson , Xi Wang , Paul Walmsley , Palmer Dabbelt , Albert Ou , =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?= , "David S. Miller" , Johan Almbladh , Paul Chaignon , Networking , bpf , linux-arm-kernel , open list , linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, sparclinux@vger.kernel.org References: <1631158350-3661-1-git-send-email-yangtiezhu@loongson.cn> From: Daniel Borkmann Message-ID: Date: Thu, 9 Sep 2021 09:57:02 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Authenticated-Sender: daniel@iogearbox.net X-Virus-Scanned: Clear (ClamAV 0.103.2/26288/Wed Sep 8 10:22:21 2021) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/9/21 7:50 AM, Andrii Nakryiko wrote: > On Wed, Sep 8, 2021 at 8:33 PM Tiezhu Yang wrote: >> >> In the current code, the actual max tail call count is 33 which is greater >> than MAX_TAIL_CALL_CNT (defined as 32), the actual limit is not consistent >> with the meaning of MAX_TAIL_CALL_CNT, there is some confusion and need to >> spend some time to think the reason at the first glance. > > think *about* the reason > >> We can see the historical evolution from commit 04fd61ab36ec ("bpf: allow >> bpf programs to tail-call other bpf programs") and commit f9dabe016b63 >> ("bpf: Undo off-by-one in interpreter tail call count limit"). >> >> In order to avoid changing existing behavior, the actual limit is 33 now, >> this is resonable. > > typo: reasonable > >> After commit 874be05f525e ("bpf, tests: Add tail call test suite"), we can >> see there exists failed testcase. >> >> On all archs when CONFIG_BPF_JIT_ALWAYS_ON is not set: >> # echo 0 > /proc/sys/net/core/bpf_jit_enable >> # modprobe test_bpf >> # dmesg | grep -w FAIL >> Tail call error path, max count reached jited:0 ret 34 != 33 FAIL >> >> On some archs: >> # echo 1 > /proc/sys/net/core/bpf_jit_enable >> # modprobe test_bpf >> # dmesg | grep -w FAIL >> Tail call error path, max count reached jited:1 ret 34 != 33 FAIL >> >> So it is necessary to change the value of MAX_TAIL_CALL_CNT from 32 to 33, >> then do some small changes of the related code. >> >> With this patch, it does not change the current limit, MAX_TAIL_CALL_CNT >> can reflect the actual max tail call count, and the above failed testcase >> can be fixed. >> >> Signed-off-by: Tiezhu Yang >> --- > > This change breaks selftests ([0]), please fix them at the same time > as you are changing the kernel behavior: The below selftests shouldn't have to change given there is no change in behavior intended (MAX_TAIL_CALL_CNT is bumped to 33 but counter inc'ed prior to the comparison). It just means that /all/ JITs must be changed and in particular properly _tested_. > test_tailcall_2:PASS:tailcall 128 nsec > test_tailcall_2:PASS:tailcall 128 nsec > test_tailcall_2:FAIL:tailcall err 0 errno 2 retval 4 > #135/2 tailcalls/tailcall_2:FAIL > test_tailcall_3:PASS:tailcall 128 nsec > test_tailcall_3:FAIL:tailcall count err 0 errno 2 count 34 > test_tailcall_3:PASS:tailcall 128 nsec > #135/3 tailcalls/tailcall_3:FAIL > #135/4 tailcalls/tailcall_4:OK > #135/5 tailcalls/tailcall_5:OK > #135/6 tailcalls/tailcall_bpf2bpf_1:OK > test_tailcall_bpf2bpf_2:PASS:tailcall 128 nsec > test_tailcall_bpf2bpf_2:FAIL:tailcall count err 0 errno 2 count 34 > test_tailcall_bpf2bpf_2:PASS:tailcall 128 nsec > #135/7 tailcalls/tailcall_bpf2bpf_2:FAIL > #135/8 tailcalls/tailcall_bpf2bpf_3:OK > test_tailcall_bpf2bpf_4:PASS:tailcall 54 nsec > test_tailcall_bpf2bpf_4:FAIL:tailcall count err 0 errno 2 count 32 > #135/9 tailcalls/tailcall_bpf2bpf_4:FAIL > test_tailcall_bpf2bpf_4:PASS:tailcall 54 nsec > test_tailcall_bpf2bpf_4:FAIL:tailcall count err 0 errno 2 count 32 > #135/10 tailcalls/tailcall_bpf2bpf_5:FAIL > #135 tailcalls:FAIL > > [0] https://github.com/kernel-patches/bpf/pull/1747/checks?check_run_id=3552002906 > >> arch/arm/net/bpf_jit_32.c | 11 ++++++----- >> arch/arm64/net/bpf_jit_comp.c | 7 ++++--- >> arch/mips/net/ebpf_jit.c | 4 ++-- >> arch/powerpc/net/bpf_jit_comp32.c | 4 ++-- >> arch/powerpc/net/bpf_jit_comp64.c | 12 ++++++------ >> arch/riscv/net/bpf_jit_comp32.c | 4 ++-- >> arch/riscv/net/bpf_jit_comp64.c | 4 ++-- >> arch/sparc/net/bpf_jit_comp_64.c | 8 ++++---- >> include/linux/bpf.h | 2 +- >> kernel/bpf/core.c | 4 ++-- >> 10 files changed, 31 insertions(+), 29 deletions(-) >> > > [...] >