[bpf-next,3/3] selftests/bpf: Check __ARCH_WANT_SET_GET_RLIMIT before syscall(__NR_getrlimit)
Message ID | 1677066908-15224-4-git-send-email-yangtiezhu@loongson.cn |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp535960wrd; Wed, 22 Feb 2023 04:05:25 -0800 (PST) X-Google-Smtp-Source: AK7set9FKK1gof9EqwxYUREizOsrncHBgq/2KjRf2k+tPBm70Tz8xTpgQ95xL5avGYj0u86OXd57 X-Received: by 2002:a17:907:9627:b0:8d7:c649:635d with SMTP id gb39-20020a170907962700b008d7c649635dmr9803384ejc.37.1677067524934; Wed, 22 Feb 2023 04:05:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677067524; cv=none; d=google.com; s=arc-20160816; b=VQOcg67bTTOnsC8fhp9214WthzqSTrFVimb75p8swJuRbe8NvwkXcDsQp18y+IL7BQ +xSBkDL/GsEGxiXvNQxYwv12uRjmbiWPsJp7bz1drf1OfOZMryT70DPLn6Dj/gwkavvS I28QUjaNSnGWdjLX0U+doZiuLJfXlR2gzSRdCTb9vExEgSEoDnZUAmdtmC9XfriDAYW/ vOU11F0vg3WOSB4agEU1ndhQgPM+vOWj4jr+/8LtJ69MF+yAioKvu53SCCYqeyDmoPBT AoXe9nBun+4epklDhN0suVWKbz2O7btqVOuNvSeoBtST1llfx4FCqdUYYU5Sp1CEcYUA h52Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=L9fOLuPfpzoYPxZARZ3/MD5Talb/KvbVYf3AceWmhQM=; b=LQdnuVSxXl832EDKi+2c9bRato37+TQPQWicfwkgQquzVxGWpbBGVBEilkX9FVl8Bf rCqz0JPnLtB1ODvMLbePTpkvVv9oqA/5oU8LTCfAf3IZakbD2Ig/Ss29g3cp6wZIhi7Z c1T9Ulw5z3eLqgN65aAivghwokmg1CP0pEp7VZzlWj4+kuwSfzE1T1euQKV1tnaFf/PK Hu11E9wNUUEQetYlHrCjcCRDsXZApH0dKGFhSjwSb9HwSoeU9V0os8MZB6V1GamoRjCV ea20bOPiCiO4oQDiSF+dz6eTQ4JuV8F9sNVQyYVF5HkXkGZ1v7T02/8xfVDtqJmq9Xdo nxKQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mu17-20020a1709068a9100b008e0bd541c5asi4132243ejc.449.2023.02.22.04.05.01; Wed, 22 Feb 2023 04:05:24 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231474AbjBVLzc (ORCPT <rfc822;dengxinlin2429@gmail.com> + 99 others); Wed, 22 Feb 2023 06:55:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231341AbjBVLz0 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 22 Feb 2023 06:55:26 -0500 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 349612822E; Wed, 22 Feb 2023 03:55:22 -0800 (PST) Received: from loongson.cn (unknown [113.200.148.30]) by gateway (Coremail) with SMTP id _____8DxUOWpAvZj8ZEDAA--.1698S3; Wed, 22 Feb 2023 19:55:21 +0800 (CST) Received: from linux.localdomain (unknown [113.200.148.30]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Cx2r2nAvZjar04AA--.38065S5; Wed, 22 Feb 2023 19:55:21 +0800 (CST) From: Tiezhu Yang <yangtiezhu@loongson.cn> To: Alexei Starovoitov <ast@kernel.org>, Daniel Borkmann <daniel@iogearbox.net>, Andrii Nakryiko <andrii@kernel.org> Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH bpf-next 3/3] selftests/bpf: Check __ARCH_WANT_SET_GET_RLIMIT before syscall(__NR_getrlimit) Date: Wed, 22 Feb 2023 19:55:08 +0800 Message-Id: <1677066908-15224-4-git-send-email-yangtiezhu@loongson.cn> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1677066908-15224-1-git-send-email-yangtiezhu@loongson.cn> References: <1677066908-15224-1-git-send-email-yangtiezhu@loongson.cn> X-CM-TRANSID: AQAAf8Cx2r2nAvZjar04AA--.38065S5 X-CM-SenderInfo: p1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ X-Coremail-Antispam: 1Uk129KBjvJXoW7KF4kJw15ArW8ury3tw47Jwb_yoW8Aw17pa yrJa4Utr1SyF17tw10krW7ZryfJrs7ZFWFkF48Jr95Zw1DXa9aqryIgF4YgrsxKrZaqrsY v348Kas7Zr4UA37anT9S1TB71UUUUUDqnTZGkaVYY2UrUUUUj1kv1TuYvTs0mT0YCTnIWj qI5I8CrVACY4xI64kE6c02F40Ex7xfYxn0WfASr-VFAUDa7-sFnT9fnUUIcSsGvfJTRUUU b7AYFVCjjxCrM7AC8VAFwI0_Jr0_Gr1l1xkIjI8I6I8E6xAIw20EY4v20xvaj40_Wr0E3s 1l1IIY67AEw4v_Jrv_JF1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xv wVC0I7IYx2IY67AKxVW8JVW5JwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwA2z4 x0Y4vEx4A2jsIE14v26F4UJVW0owA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Cr1j6rxdM2AI xVAIcxkEcVAq07x20xvEncxIr21l57IF6xkI12xvs2x26I8E6xACxx1l5I8CrVACY4xI64 kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1q6rW5McIj6I8E87Iv67AKxVWxJVW8Jr1l Ox8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JMxAIw28IcxkI7VAKI48JMxC20s 026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_ JrI_JrWlx4CE17CEb7AF67AKxVWUAVWUtwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14 v26r4j6ryUMIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4v20xva j40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr0_Cr1lIxAIcVC2z280aVCY1x0267AKxVW8JV W8JrUvcSsGvfC2KfnxnUUI43ZEXa7IU8jZX5UUUUU== X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758532756945877674?= X-GMAIL-MSGID: =?utf-8?q?1758532756945877674?= |
Series |
Fix some build errors for bpf selftest on LoongArch
|
|
Commit Message
Tiezhu Yang
Feb. 22, 2023, 11:55 a.m. UTC
__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 <yangtiezhu@loongson.cn>
---
tools/testing/selftests/bpf/prog_tests/user_ringbuf.c | 2 ++
1 file changed, 2 insertions(+)
Comments
On Wed, Feb 22, 2023 at 3:55 AM Tiezhu Yang <yangtiezhu@loongson.cn> 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 <yangtiezhu@loongson.cn> > --- > 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.
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 Thanks, Mykola > On Feb 22, 2023, at 10:06 AM, Alexei Starovoitov <alexei.starovoitov@gmail.com> wrote: > > !-------------------------------------------------------------------| > This Message Is From an External Sender > > |-------------------------------------------------------------------! > > On Wed, Feb 22, 2023 at 3:55 AM Tiezhu Yang <yangtiezhu@loongson.cn> 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 <yangtiezhu@loongson.cn> >> --- >> 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.
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 <alexei.starovoitov@gmail.com> wrote: >> >> !-------------------------------------------------------------------| >> This Message Is From an External Sender >> >> |-------------------------------------------------------------------! >> >> On Wed, Feb 22, 2023 at 3:55 AM Tiezhu Yang <yangtiezhu@loongson.cn> 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 <yangtiezhu@loongson.cn> >>> --- >>> 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.
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 return NULL; }