Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 588B6C61DA4 for ; Thu, 23 Feb 2023 02:49:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233544AbjBWCtP (ORCPT ); Wed, 22 Feb 2023 21:49:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233471AbjBWCtF (ORCPT ); Wed, 22 Feb 2023 21:49:05 -0500 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3103C3A841; Wed, 22 Feb 2023 18:48:53 -0800 (PST) Received: from loongson.cn (unknown [113.200.148.30]) by gateway (Coremail) with SMTP id _____8BxttgU1PZjkPMDAA--.7504S3; Thu, 23 Feb 2023 10:48:52 +0800 (CST) Received: from [10.130.0.149] (unknown [113.200.148.30]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Ax97wQ1PZjL2E5AA--.38714S3; Thu, 23 Feb 2023 10:48:48 +0800 (CST) Subject: Re: [PATCH bpf-next 3/3] selftests/bpf: Check __ARCH_WANT_SET_GET_RLIMIT before syscall(__NR_getrlimit) To: Mykola Lysenko References: <1677066908-15224-1-git-send-email-yangtiezhu@loongson.cn> <1677066908-15224-4-git-send-email-yangtiezhu@loongson.cn> Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , bpf , LKML , Alexei Starovoitov From: Tiezhu Yang Message-ID: Date: Thu, 23 Feb 2023 10:48:48 +0800 User-Agent: Mozilla/5.0 (X11; Linux mips64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding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c7CjxVAFwI0_Jr0_Gr1lIxAIcVCF04k26cxKx2IYs7xG6r 1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Jr0_GrUv cSsGvfC2KfnxnUUI43ZEXa7IU8hiSPUUUUU== Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/23/2023 04:03 AM, Mykola Lysenko wrote: > Hi Tiezhu, > > You can run BPF CI tests on your patch before sending it out by following these instructions: > https://docs.kernel.org/bpf/bpf_devel_QA.html#q-how-do-i-run-bpf-ci-on-my-changes-before-sending-them-out-for-review OK, thank you. After commit 80d7da1cac62 ("asm-generic: Drop getrlimit and setrlimit syscalls from default list"), new architectures won't need to include getrlimit and setrlimit, they are superseded with prlimit64. In order to maintain compatibility for the new architectures, such as LoongArch which does not define __NR_getrlimit, it is better to use __NR_prlimit64 instead of __NR_getrlimit in user_ringbuf.c to fix the build error. diff --git a/tools/testing/selftests/bpf/prog_tests/user_ringbuf.c b/tools/testing/selftests/bpf/prog_tests/user_ringbuf.c index 3a13e10..e51721d 100644 --- a/tools/testing/selftests/bpf/prog_tests/user_ringbuf.c +++ b/tools/testing/selftests/bpf/prog_tests/user_ringbuf.c @@ -590,7 +590,7 @@ static void *kick_kernel_cb(void *arg) /* Kick the kernel, causing it to drain the ring buffer and then wake * up the test thread waiting on epoll. */ - syscall(__NR_getrlimit); + syscall(__NR_prlimit64); return NULL; } I will test it and then send v2. If you have more suggestions, please let me know. Thanks, Tiezhu > > Thanks, > Mykola > >> On Feb 22, 2023, at 10:06 AM, Alexei Starovoitov wrote: >> >> !-------------------------------------------------------------------| >> This Message Is From an External Sender >> >> |-------------------------------------------------------------------! >> >> On Wed, Feb 22, 2023 at 3:55 AM Tiezhu Yang wrote: >>> >>> __NR_getrlimit is defined only if __ARCH_WANT_SET_GET_RLIMIT is defined: >>> >>> #ifdef __ARCH_WANT_SET_GET_RLIMIT >>> /* getrlimit and setrlimit are superseded with prlimit64 */ >>> #define __NR_getrlimit 163 >>> ... >>> #endif >>> >>> Some archs do not define __ARCH_WANT_SET_GET_RLIMIT, it should check >>> __ARCH_WANT_SET_GET_RLIMIT before syscall(__NR_getrlimit) to fix the >>> following build error: >>> >>> TEST-OBJ [test_progs] user_ringbuf.test.o >>> tools/testing/selftests/bpf/prog_tests/user_ringbuf.c: In function 'kick_kernel_cb': >>> tools/testing/selftests/bpf/prog_tests/user_ringbuf.c:593:17: error: '__NR_getrlimit' undeclared (first use in this function) >>> 593 | syscall(__NR_getrlimit); >>> | ^~~~~~~~~~~~~~ >>> tools/testing/selftests/bpf/prog_tests/user_ringbuf.c:593:17: note: each undeclared identifier is reported only once for each function it appears in >>> make: *** [Makefile:573: tools/testing/selftests/bpf/user_ringbuf.test.o] Error 1 >>> make: Leaving directory 'tools/testing/selftests/bpf' >>> >>> Signed-off-by: Tiezhu Yang >>> --- >>> tools/testing/selftests/bpf/prog_tests/user_ringbuf.c | 2 ++ >>> 1 file changed, 2 insertions(+) >>> >>> diff --git a/tools/testing/selftests/bpf/prog_tests/user_ringbuf.c b/tools/testing/selftests/bpf/prog_tests/user_ringbuf.c >>> index 3a13e10..0550307 100644 >>> --- a/tools/testing/selftests/bpf/prog_tests/user_ringbuf.c >>> +++ b/tools/testing/selftests/bpf/prog_tests/user_ringbuf.c >>> @@ -590,7 +590,9 @@ static void *kick_kernel_cb(void *arg) >>> /* Kick the kernel, causing it to drain the ring buffer and then wake >>> * up the test thread waiting on epoll. >>> */ >>> +#ifdef __ARCH_WANT_SET_GET_RLIMIT >>> syscall(__NR_getrlimit); >>> +#endif >> >> This is clearly breaks user_ringbuf test on x86: >> https://github.com/kernel-patches/bpf/actions/runs/4242660318/jobs/7374845859 >> >> Please do not send patches that make selftest compile on your favorite arch. >> Make sure the patches work correctly on other archs too.