Message ID | 1685968410-5412-2-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:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2652975vqr; Mon, 5 Jun 2023 05:37:39 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6srKCOkYIBv6XKzQZK1Gj9PBA9PtuAxCgKoFpun6ro5gRZFam/ehmZr47yvJEuw2ERukEF X-Received: by 2002:a05:6a00:23ca:b0:65b:a187:d433 with SMTP id g10-20020a056a0023ca00b0065ba187d433mr2619889pfc.6.1685968659242; Mon, 05 Jun 2023 05:37:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685968659; cv=none; d=google.com; s=arc-20160816; b=FvXq80e3wXxvv8B9PVyZ4YPtLDcD/tNK35Bo4tP3W51q9EHyEAKIatvB7DY4WNbOH1 wEbF1N/+cPLeJ9E55pEfr14TlaZ0B5JongvGeNLWSdnzAIhdIe7hTgsQGMdJ62lbPO2k HJpQqGGvM+YWMoCcBTUcStlNBZRY/tZJBXFA1stNxDpjO301qCapO11UoUj4nHh+UKT0 pF0+mY407oCF0Jw2Kq/FD8/dcMfh0D3li4gn0NB89PVhazfAu3GX7u0cWCWfVNyhB8wh mStOHU0ivNFEG434wcvvbepGFiJc4M4P65+aP/epw2lGE28Q1OC4XFERQbzMAZUNR8Un IYVQ== 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=btcF9jG77ZhNP1R3UjO/Y/7GTJ5BjfzrkNRuQ5io6BY=; b=SF7jLFfvXsO/sUpJGQWEM4vo+G092sANpu/va7jMLyN3NtroX2gCmG+jUO3FJBm4er de2bl3ebFNPRI3FOkXKT/TP6OdtA2qlGz/Zi81hlLsKzEURRlhAoZElswuDTyCoBF9eL Ek5d8Q5iSbFLBL0P9FoY1/yb8lyQ0r/IkSqKym2u47Ws/MqSOxLX8H6wlBBNTOo7Ti8d 1vWKx+erOxGeH1ewJ6B1TtsNlbg92LZGVv4jGXlRP30m6LdRCBDt74z7QNL2HWUqqa02 Ai0rNq+wtgOcBZ4T+lQgsM+ZcTi8uU4ncTY6StgrKyqoeYJhGhkJuRmXcxtVdOPKAzgx dcQg== 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 g15-20020aa79f0f000000b006501b3c2006si5255267pfr.61.2023.06.05.05.37.26; Mon, 05 Jun 2023 05:37:39 -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; 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 S232508AbjFEMfN (ORCPT <rfc822;pavtiger@gmail.com> + 99 others); Mon, 5 Jun 2023 08:35:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233768AbjFEMfI (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 5 Jun 2023 08:35:08 -0400 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 82B0598 for <linux-kernel@vger.kernel.org>; Mon, 5 Jun 2023 05:34:44 -0700 (PDT) Received: from loongson.cn (unknown [113.200.148.30]) by gateway (Coremail) with SMTP id _____8AxxvAm1n1kzxUAAA--.225S3; Mon, 05 Jun 2023 20:33:42 +0800 (CST) Received: from linux.localdomain (unknown [113.200.148.30]) by localhost.localdomain (Coremail) with SMTP id AQAAf8BxNeQk1n1ktncAAA--.1930S3; Mon, 05 Jun 2023 20:33:41 +0800 (CST) From: Tiezhu Yang <yangtiezhu@loongson.cn> To: Huacai Chen <chenhuacai@kernel.org>, Christian Brauner <brauner@kernel.org>, Andy Lutomirski <luto@kernel.org>, Thomas Gleixner <tglx@linutronix.de>, Vincenzo Frascino <vincenzo.frascino@arm.com> Cc: loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, loongson-kernel@lists.loongnix.cn Subject: [PATCH v4 1/2] selftests/clone3: Fix broken test under !CONFIG_TIME_NS Date: Mon, 5 Jun 2023 20:33:29 +0800 Message-Id: <1685968410-5412-2-git-send-email-yangtiezhu@loongson.cn> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1685968410-5412-1-git-send-email-yangtiezhu@loongson.cn> References: <1685968410-5412-1-git-send-email-yangtiezhu@loongson.cn> X-CM-TRANSID: AQAAf8BxNeQk1n1ktncAAA--.1930S3 X-CM-SenderInfo: p1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ X-Coremail-Antispam: 1Uk129KBj93XoWxGr1DJFWfCrWrZrW7WryDJwc_yoW5GF18pF yI9wnFkFWFgr17KFZrZ34qgrW5KF1kXrW0qF4xu34jyr1Sgry8Jr4xKa40yr13Kr40vrZY vayxGF4fZr1UX3gCm3ZEXasCq-sJn29KB7ZKAUJUUUUx529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUBab4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1Y6r17M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Cr0_Gr1UM28EF7xvwVC2z280aVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIEc7CjxVAF wI0_Gr1j6F4UJwAaw2AFwI0_JF0_Jw1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqjxCEc2 xF0cIa020Ex4CE44I27wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_ Jw0_WrylYx0Ex4A2jsIE14v26r4j6F4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x 0EwIxGrwCY1x0262kKe7AKxVWUAVWUtwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkE bVWUJVW8JwCFI7km07C267AKxVWUAVWUtwC20s026c02F40E14v26r1j6r18MI8I3I0E74 80Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0 I7IYx2IY67AKxVWUCVW8JwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04 k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7Cj xVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x07jz5lbUUUUU= X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,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: <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?1767866272800457773?= X-GMAIL-MSGID: =?utf-8?q?1767866272800457773?= |
Series |
Modify code about clone timens
|
|
Commit Message
Tiezhu Yang
June 5, 2023, 12:33 p.m. UTC
When execute the following command to test clone3 on LoongArch:
# cd tools/testing/selftests/clone3 && make && ./clone3
we can see the following error info:
# [5719] Trying clone3() with flags 0x80 (size 0)
# Invalid argument - Failed to create new process
# [5719] clone3() with flags says: -22 expected 0
not ok 18 [5719] Result (-22) is different than expected (0)
This is because if CONFIG_TIME_NS is not set, but the flag
CLONE_NEWTIME (0x80) is used to clone a time namespace, it
will return -EINVAL in copy_time_ns().
Here is the related code in include/linux/time_namespace.h:
#ifdef CONFIG_TIME_NS
...
struct time_namespace *copy_time_ns(unsigned long flags,
struct user_namespace *user_ns,
struct time_namespace *old_ns);
...
#else
...
static inline
struct time_namespace *copy_time_ns(unsigned long flags,
struct user_namespace *user_ns,
struct time_namespace *old_ns)
{
if (flags & CLONE_NEWTIME)
return ERR_PTR(-EINVAL);
return old_ns;
}
...
#endif
Here is the complete call stack:
clone3()
kernel_clone()
copy_process()
copy_namespaces()
create_new_namespaces()
copy_time_ns()
clone_time_ns()
If kernel does not support CONFIG_TIME_NS, /proc/self/ns/time
will be not exist, and then we should skip clone3() test with
CLONE_NEWTIME.
With this patch under !CONFIG_TIME_NS:
# cd tools/testing/selftests/clone3 && make && ./clone3
...
# Time namespaces are not supported
ok 18 # SKIP Skipping clone3() with CLONE_NEWTIME
# Totals: pass:17 fail:0 xfail:0 xpass:0 skip:1 error:0
Fixes: 515bddf0ec41 ("selftests/clone3: test clone3 with CLONE_NEWTIME")
Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
tools/testing/selftests/clone3/clone3.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
Comments
On Mon, Jun 05 2023 at 20:33, Tiezhu Yang wrote: > When execute the following command to test clone3 on LoongArch: > > # cd tools/testing/selftests/clone3 && make && ./clone3 > > we can see the following error info: > > # [5719] Trying clone3() with flags 0x80 (size 0) > # Invalid argument - Failed to create new process > # [5719] clone3() with flags says: -22 expected 0 > not ok 18 [5719] Result (-22) is different than expected (0) > > This is because if CONFIG_TIME_NS is not set, but the flag > CLONE_NEWTIME (0x80) is used to clone a time namespace, it > will return -EINVAL in copy_time_ns(). > > Here is the related code in include/linux/time_namespace.h: > > #ifdef CONFIG_TIME_NS > ... > struct time_namespace *copy_time_ns(unsigned long flags, > struct user_namespace *user_ns, > struct time_namespace *old_ns); > ... > #else > ... > static inline > struct time_namespace *copy_time_ns(unsigned long flags, > struct user_namespace *user_ns, > struct time_namespace *old_ns) > { > if (flags & CLONE_NEWTIME) > return ERR_PTR(-EINVAL); > > return old_ns; > } > ... > #endif There is really no point in copying that code into the changelog. The textual explanation that it returns -EINVAL is good enough. > Here is the complete call stack: > > clone3() > kernel_clone() > copy_process() > copy_namespaces() > create_new_namespaces() > copy_time_ns() > clone_time_ns() Uninteresting too. > If kernel does not support CONFIG_TIME_NS, /proc/self/ns/time > will be not exist, and then we should skip clone3() test with > CLONE_NEWTIME. Correct. > With this patch under !CONFIG_TIME_NS: > > # cd tools/testing/selftests/clone3 && make && ./clone3 > ... > # Time namespaces are not supported > ok 18 # SKIP Skipping clone3() with CLONE_NEWTIME > # Totals: pass:17 fail:0 xfail:0 xpass:0 skip:1 error:0 > Fixes: 515bddf0ec41 ("selftests/clone3: test clone3 with CLONE_NEWTIME") > Suggested-by: Thomas Gleixner <tglx@linutronix.de> > Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn> > --- > tools/testing/selftests/clone3/clone3.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/tools/testing/selftests/clone3/clone3.c b/tools/testing/selftests/clone3/clone3.c > index e495f89..c721f8a 100644 > --- a/tools/testing/selftests/clone3/clone3.c > +++ b/tools/testing/selftests/clone3/clone3.c > @@ -196,7 +196,12 @@ int main(int argc, char *argv[]) > CLONE3_ARGS_NO_TEST); > > /* Do a clone3() in a new time namespace */ > - test_clone3(CLONE_NEWTIME, 0, 0, CLONE3_ARGS_NO_TEST); > + if (access("/proc/self/ns/time", F_OK) == 0) { > + test_clone3(CLONE_NEWTIME, 0, 0, CLONE3_ARGS_NO_TEST); > + } else { > + ksft_print_msg("Time namespaces are not supported\n"); > + ksft_test_result_skip("Skipping clone3() with CLONE_NEWTIME\n"); > + } Patch looks good otherwise. Thanks, tglx
On 06/06/2023 04:18 PM, Thomas Gleixner wrote: > On Mon, Jun 05 2023 at 20:33, Tiezhu Yang wrote: >> When execute the following command to test clone3 on LoongArch: >> >> # cd tools/testing/selftests/clone3 && make && ./clone3 >> >> we can see the following error info: >> >> # [5719] Trying clone3() with flags 0x80 (size 0) >> # Invalid argument - Failed to create new process >> # [5719] clone3() with flags says: -22 expected 0 >> not ok 18 [5719] Result (-22) is different than expected (0) >> >> This is because if CONFIG_TIME_NS is not set, but the flag >> CLONE_NEWTIME (0x80) is used to clone a time namespace, it >> will return -EINVAL in copy_time_ns(). >> >> Here is the related code in include/linux/time_namespace.h: >> >> #ifdef CONFIG_TIME_NS >> ... >> struct time_namespace *copy_time_ns(unsigned long flags, >> struct user_namespace *user_ns, >> struct time_namespace *old_ns); >> ... >> #else >> ... >> static inline >> struct time_namespace *copy_time_ns(unsigned long flags, >> struct user_namespace *user_ns, >> struct time_namespace *old_ns) >> { >> if (flags & CLONE_NEWTIME) >> return ERR_PTR(-EINVAL); >> >> return old_ns; >> } >> ... >> #endif > > There is really no point in copying that code into the changelog. The > textual explanation that it returns -EINVAL is good enough. OK, let me remove the code in the commit message. >> Here is the complete call stack: >> >> clone3() >> kernel_clone() >> copy_process() >> copy_namespaces() >> create_new_namespaces() >> copy_time_ns() >> clone_time_ns() > > Uninteresting too. Will remove it too. > >> If kernel does not support CONFIG_TIME_NS, /proc/self/ns/time >> will be not exist, and then we should skip clone3() test with >> CLONE_NEWTIME. > > Correct. > >> With this patch under !CONFIG_TIME_NS: >> >> # cd tools/testing/selftests/clone3 && make && ./clone3 >> ... >> # Time namespaces are not supported >> ok 18 # SKIP Skipping clone3() with CLONE_NEWTIME >> # Totals: pass:17 fail:0 xfail:0 xpass:0 skip:1 error:0 > >> Fixes: 515bddf0ec41 ("selftests/clone3: test clone3 with CLONE_NEWTIME") >> Suggested-by: Thomas Gleixner <tglx@linutronix.de> >> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn> >> --- >> tools/testing/selftests/clone3/clone3.c | 7 ++++++- >> 1 file changed, 6 insertions(+), 1 deletion(-) >> >> diff --git a/tools/testing/selftests/clone3/clone3.c b/tools/testing/selftests/clone3/clone3.c >> index e495f89..c721f8a 100644 >> --- a/tools/testing/selftests/clone3/clone3.c >> +++ b/tools/testing/selftests/clone3/clone3.c >> @@ -196,7 +196,12 @@ int main(int argc, char *argv[]) >> CLONE3_ARGS_NO_TEST); >> >> /* Do a clone3() in a new time namespace */ >> - test_clone3(CLONE_NEWTIME, 0, 0, CLONE3_ARGS_NO_TEST); >> + if (access("/proc/self/ns/time", F_OK) == 0) { >> + test_clone3(CLONE_NEWTIME, 0, 0, CLONE3_ARGS_NO_TEST); >> + } else { >> + ksft_print_msg("Time namespaces are not supported\n"); >> + ksft_test_result_skip("Skipping clone3() with CLONE_NEWTIME\n"); >> + } > > Patch looks good otherwise. Thank you, I will send v5 on Friday with updated commit message if no more comments. Thanks, Tiezhu
diff --git a/tools/testing/selftests/clone3/clone3.c b/tools/testing/selftests/clone3/clone3.c index e495f89..c721f8a 100644 --- a/tools/testing/selftests/clone3/clone3.c +++ b/tools/testing/selftests/clone3/clone3.c @@ -196,7 +196,12 @@ int main(int argc, char *argv[]) CLONE3_ARGS_NO_TEST); /* Do a clone3() in a new time namespace */ - test_clone3(CLONE_NEWTIME, 0, 0, CLONE3_ARGS_NO_TEST); + if (access("/proc/self/ns/time", F_OK) == 0) { + test_clone3(CLONE_NEWTIME, 0, 0, CLONE3_ARGS_NO_TEST); + } else { + ksft_print_msg("Time namespaces are not supported\n"); + ksft_test_result_skip("Skipping clone3() with CLONE_NEWTIME\n"); + } ksft_finished(); }