Message ID | ef82268ef4a9ae263a17cd1a3533842271c5520c.1688750763.git.falcon@tinylab.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp3478134vqx; Fri, 7 Jul 2023 12:03:05 -0700 (PDT) X-Google-Smtp-Source: APBJJlFtIZH851JQYVMZLLRKVx5LKQ4924BHCgHAEtuu0yCw3CxBPquGYYm27M2dsZ4Yx/5Qh19M X-Received: by 2002:a17:90b:3b41:b0:263:43c6:69ac with SMTP id ot1-20020a17090b3b4100b0026343c669acmr4498217pjb.44.1688756585327; Fri, 07 Jul 2023 12:03:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688756585; cv=none; d=google.com; s=arc-20160816; b=UG14pBPlNq5Di3MEJsDrLsS0v3ggxX+XXLYKkM/ZicqNjKjDFBFFaFCkTy6oI7y/QV wliETDzzX9oVOWjQ47/xFFuJLSwLETLd4QliUz3Xm35SbAlQtU+w3Mq8DDnK6o+zw+1Q VJ7MudicW5PgHGBCpixmNcdL0EaFMUSM1dZDGWMbP+JbMCmy8YXp0DHos6uVq0HVdPbA qd3qxHhAo6LjITlH0t2YfCgpjqqhqrJwH2xlaD2acWyHDAZn/9BYjlWKREiUVvbvEYaa adKfGgSf/OPIs5h46KetynX4dKLoL5/YMdLSc2/c3nPv70jZoGBboxHOh43M5b6tcBsT 9BNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=6F0JRM2u3NMufw5Wwni2wrDqbVWaslXZyU4u1SgkXKA=; fh=+UJGAEU2Zd20Ffzlyw2DOtwfBiThnaWweXJeIpZW2cQ=; b=Vi8ZTMwbufOIG6Kg+EGezrwh/JbkAo0OI2AURXK0qZWiHobhE6ZfGom97WV6Vua2A2 q90bjB1qafA12CqwpXV7mgT5SOYUQLFWXrV8smFcGoogykgrGSvZL3iGyIe2RGUEFdS/ /61CufGDu/ksnBAdIU+D8o7ouw/MCxveutb+JojAXNRb5kIPMy/CTlTd331Eop8r4f23 4NTsVyr/zkhczX+WGtoGTXYDE7YkiFlJICZB73ApUEUWQkPSy2hl2MDIXJxO9aPVFXgc L+mIKx7OvXAUQfhxSRp2B6Cwz8bfSrEv6K+WVKCFISvghErh2gWkmBXVwbxyhSRld/lA x8ZA== 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 p15-20020a17090a0e4f00b0025653dc2881si2520132pja.23.2023.07.07.12.02.51; Fri, 07 Jul 2023 12:03:05 -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 S232501AbjGGSjT (ORCPT <rfc822;tebrre53rla2o@gmail.com> + 99 others); Fri, 7 Jul 2023 14:39:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229902AbjGGSjR (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 7 Jul 2023 14:39:17 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.155.65.254]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA4832684; Fri, 7 Jul 2023 11:39:14 -0700 (PDT) X-QQ-mid: bizesmtp62t1688755145t75gkm14 Received: from linux-lab-host.localdomain ( [116.30.131.119]) by bizesmtp.qq.com (ESMTP) with id ; Sat, 08 Jul 2023 02:39:04 +0800 (CST) X-QQ-SSF: 01200000000000D0W000000A0000000 X-QQ-FEAT: KvvwR/hcPA3zMYK1CcceBKsYTp/4/3pjRiGuKwCnZov/MPcdg6J8HujwWwHn5 /8+dmG2yvIOgNqB0jCgFmPi5Ha91Smk+4wKn891hXp8XbdYOjS79GGq20AcOIqAKxPAl8/0 4Cz0RXglli0Mvtl8Yq9J6jkbxTgmjSd16/syAnHj5NP8vI2kdNHnj4e5lM/CiJjdEv/GHL+ 97VoOznzLptB5D3ml4BUFJHo4EbLyPAS4mFOXcyXji3b9CNlU5SCnSwGILew7dI1cBLOl8y HhUDN+VuesWus3Y8xdcf3anZt6OUgJrj69kSKyIhv8LnqVl7ZK36w1QsGhaH42/m1v3jAcz gnjSZjbRmd4zusUN7+Bcc0TlLy63T2l89IpnXOhwe1rNEufsfDLVAoqfiFX6g== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 13821968345218044229 From: Zhangjin Wu <falcon@tinylab.org> To: w@1wt.eu Cc: falcon@tinylab.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, thomas@t-8ch.de, =?utf-8?q?Thomas_Wei?= =?utf-8?q?=C3=9Fschuh?= <linux@weissschuh.net> Subject: [PATCH v4 13/18] selftests/nolibc: prepare /tmp for tmpfs or ramfs Date: Sat, 8 Jul 2023 02:38:57 +0800 Message-Id: <ef82268ef4a9ae263a17cd1a3533842271c5520c.1688750763.git.falcon@tinylab.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <cover.1688750763.git.falcon@tinylab.org> References: <cover.1688750763.git.falcon@tinylab.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz5a-1 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,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?1770789625208099632?= X-GMAIL-MSGID: =?utf-8?q?1770789625208099632?= |
Series |
selftests/nolibc: allow run with minimal kernel config
|
|
Commit Message
Zhangjin Wu
July 7, 2023, 6:38 p.m. UTC
create a /tmp directory and mount tmpfs there, if tmpfs is not mountable, use ramfs as tmpfs. tmpfs will be used instead of procfs for some tests. Reviewed-by: Thomas Weißschuh <linux@weissschuh.net> Signed-off-by: Zhangjin Wu <falcon@tinylab.org> --- tools/testing/selftests/nolibc/nolibc-test.c | 4 ++++ 1 file changed, 4 insertions(+)
Comments
Hi Zhangjin, On Sat, Jul 08, 2023 at 02:38:57AM +0800, Zhangjin Wu wrote: > create a /tmp directory and mount tmpfs there, if tmpfs is not > mountable, use ramfs as tmpfs. > > tmpfs will be used instead of procfs for some tests. Just curious, in which cases do you need this ? We're building an initramfs for the root that's already read-write, so without mounting anything you already have write access. I'm taking it anyway for now, but if you figure it's not needed we can later drop it (or just drop the mount part and keep mkdir). Willy
Hi, Willy > Hi Zhangjin, > > On Sat, Jul 08, 2023 at 02:38:57AM +0800, Zhangjin Wu wrote: > > create a /tmp directory and mount tmpfs there, if tmpfs is not > > mountable, use ramfs as tmpfs. > > > > tmpfs will be used instead of procfs for some tests. > > Just curious, in which cases do you need this ? We're building an > initramfs for the root that's already read-write, so without mounting > anything you already have write access. I'm taking it anyway for now, > but if you figure it's not needed we can later drop it (or just drop > the mount part and keep mkdir). > This "/tmp" directory is originally created to check the 'TMPFS' existence for the old vfprintf/memfd_create (from old version of the minimal config support), it is used to skip the whole vfprintf tests if the TMPFS (or HUGETLBFS) is not there. BTW, Thomas's patch [1] shows, MEMFD_CREATE is able to work with ramfs too. And it is later used by the old chmod_tmpdir/chmod_tmpfile and chroot_tmpfile too (from old version of the minimal config support), so, it is important to align with the normal Linux systems to let "/tmp" means TMPFS mount. Now, we use "/tmp" directly in vfprintf, and we use argv0 for chmod_exe and chroot_exe, so, the only user of "/tmp" is vfprintf currently. In this case, it is a simple normal writable directory to allow create tmp files there, so, agree very much to only reserve the mkdir part: /* create /tmp if not there. Silently fail otherwise */ mkdir("/tmp", 0755); Another consideration before is whether it is required to be consistent with the normal Linux systems, let the "/tmp" directory mounted as tmpfs at most of the time, but "/tmp" means ramfs for CONFIG_TMPFS=n currently even mount it explicitly (ramfs is a fallback of tmpfs in such case), so, this assumption of "/tmp" means tmpfs is not true currently. What I'm worried about is people in the future assume "/tmp" as tmpfs at the first glance and use the features only provided by TMPFS but not provided by RAMFS (I'm not sure which one they will use). so, I even tried to create a "/tmp/tmpfs" flag for TMPFS and "/tmp/ramfs" flag for RAMFS before, since there is no user to explicitly prefer TMPFS to RAMFS currently, at last, I removed these flags from the sent patchsets. Based on the same logic, The removal of tmpfs mount is of course ok. So, Willy, is it ok for you to remove that mount line with corresponding update of the commit message (and the subject title), or require me to send a revision for this patch? Best regards, Zhangjin --- [1]: https://lore.kernel.org/lkml/20230703224803.GF4378@monkey/ > Willy
Hi Zhangjin, On Mon, Jul 10, 2023 at 01:06:00PM +0800, Zhangjin Wu wrote: > > On Sat, Jul 08, 2023 at 02:38:57AM +0800, Zhangjin Wu wrote: > > > create a /tmp directory and mount tmpfs there, if tmpfs is not > > > mountable, use ramfs as tmpfs. > > > > > > tmpfs will be used instead of procfs for some tests. > > > > Just curious, in which cases do you need this ? We're building an > > initramfs for the root that's already read-write, so without mounting > > anything you already have write access. I'm taking it anyway for now, > > but if you figure it's not needed we can later drop it (or just drop > > the mount part and keep mkdir). > > > > This "/tmp" directory is originally created to check the 'TMPFS' existence for > the old vfprintf/memfd_create (from old version of the minimal config support), > it is used to skip the whole vfprintf tests if the TMPFS (or HUGETLBFS) is not > there. BTW, Thomas's patch [1] shows, MEMFD_CREATE is able to work with ramfs > too. OK but here we're neither using it nor even checking its success. > And it is later used by the old chmod_tmpdir/chmod_tmpfile and chroot_tmpfile > too (from old version of the minimal config support), so, it is important to > align with the normal Linux systems to let "/tmp" means TMPFS mount. I think I didn't explain myself well. I'm not contesting a writable /tmp, I was asking why *tmpfs*, because we have a root on ramfs by default, so when you create /tmp, the sole fact that it succeeds implies that whatever you'll put into it will already work without having to remount a tmpfs inside. > Now, we use "/tmp" directly in vfprintf, and we use argv0 for chmod_exe and > chroot_exe, so, the only user of "/tmp" is vfprintf currently. In this case, it > is a simple normal writable directory to allow create tmp files there, so, > agree very much to only reserve the mkdir part: > > /* create /tmp if not there. Silently fail otherwise */ > mkdir("/tmp", 0755); OK, then I'll do that. > Another consideration before is whether it is required to be consistent with > the normal Linux systems, let the "/tmp" directory mounted as tmpfs at most of > the time, That's not what I'm seeing on most of the systems I'm having access to, where /tmp is on a plain file system (either / or link to /var/tmp but always on disk, likely due to the huge size of the stuff stored there that is rarely used and that should not eat memory). > but "/tmp" means ramfs for CONFIG_TMPFS=n currently even mount it > explicitly (ramfs is a fallback of tmpfs in such case), so, this assumption of > "/tmp" means tmpfs is not true currently. > > What I'm worried about is people in the future assume "/tmp" as tmpfs at the > first glance and use the features only provided by TMPFS but not provided by > RAMFS (I'm not sure which one they will use). so, I even tried to create a > "/tmp/tmpfs" flag for TMPFS and "/tmp/ramfs" flag for RAMFS before, since there > is no user to explicitly prefer TMPFS to RAMFS currently, at last, I removed > these flags from the sent patchsets. Based on the same logic, The removal of > tmpfs mount is of course ok. Indeed, and also, please keep in mind what the purpose of nolibc-test is: make sure that the syscalls wrappers we write do work as expected, in part by allowing us to compare against another libc to figure whether it's the libc, the test or the kernel that causes any difference. The rest is purely out of scope. Thus it's not this test's business to verify that a tmpfs is indeed present after trying to mount it under /tmp, however it's this test business to make sure that options passed to mount() do work as expected, and that when a writable area is needed for a test, a working one is assigned. Thus for the specific case you mention, we don't care. And I'd go further, there can and should be reasonable prerequisites to run this test. > So, Willy, is it ok for you to remove that mount line with corresponding update > of the commit message (and the subject title), or require me to send a revision > for this patch? No worries, I've modified it accordingly with the following commit message, just let me know if you want to change anything: commit 11fddb386bd663a554cc08c5950d9da2c87a7267 (HEAD) Author: Zhangjin Wu <falcon@tinylab.org> Date: Sat Jul 8 02:38:57 2023 +0800 selftests/nolibc: prepare /tmp for tests that need to write create a /tmp directory. If it succeeds, the directory is writable, which is normally the case when booted from an initramfs anyway. This will be used instead of procfs for some tests. Reviewed-by: Thomas WeiÃschuh <linux@weissschuh.net> Signed-off-by: Zhangjin Wu <falcon@tinylab.org> Link: https://lore.kernel.org/lkml/20230710050600.9697-1-falcon@tinylab.org/ [wt: removed the unneeded mount() call] Signed-off-by: Willy Tarreau <w@1wt.eu> Thanks! Willy
Hi, Willy > Hi Zhangjin, > > On Mon, Jul 10, 2023 at 01:06:00PM +0800, Zhangjin Wu wrote: > > > On Sat, Jul 08, 2023 at 02:38:57AM +0800, Zhangjin Wu wrote: [...] > > Now, we use "/tmp" directly in vfprintf, and we use argv0 for chmod_exe and > > chroot_exe, so, the only user of "/tmp" is vfprintf currently. In this case, it > > is a simple normal writable directory to allow create tmp files there, so, > > agree very much to only reserve the mkdir part: > > > > /* create /tmp if not there. Silently fail otherwise */ > > mkdir("/tmp", 0755); > > OK, then I'll do that. > Thanks. > > Another consideration before is whether it is required to be consistent with > > the normal Linux systems, let the "/tmp" directory mounted as tmpfs at most of > > the time, > > That's not what I'm seeing on most of the systems I'm having access to, > where /tmp is on a plain file system (either / or link to /var/tmp but > always on disk, likely due to the huge size of the stuff stored there > that is rarely used and that should not eat memory). > > > but "/tmp" means ramfs for CONFIG_TMPFS=n currently even mount it > > explicitly (ramfs is a fallback of tmpfs in such case), so, this assumption of > > "/tmp" means tmpfs is not true currently. > > > > What I'm worried about is people in the future assume "/tmp" as tmpfs at the > > first glance and use the features only provided by TMPFS but not provided by > > RAMFS (I'm not sure which one they will use). so, I even tried to create a > > "/tmp/tmpfs" flag for TMPFS and "/tmp/ramfs" flag for RAMFS before, since there > > is no user to explicitly prefer TMPFS to RAMFS currently, at last, I removed > > these flags from the sent patchsets. Based on the same logic, The removal of > > tmpfs mount is of course ok. > > Indeed, and also, please keep in mind what the purpose of nolibc-test is: > make sure that the syscalls wrappers we write do work as expected, in part > by allowing us to compare against another libc to figure whether it's > the libc, the test or the kernel that causes any difference. The rest is > purely out of scope. Thus it's not this test's business to verify that a > tmpfs is indeed present after trying to mount it under /tmp, however it's > this test business to make sure that options passed to mount() do work as > expected, and that when a writable area is needed for a test, a working > one is assigned. Thus for the specific case you mention, we don't care. > And I'd go further, there can and should be reasonable prerequisites to > run this test. > Ok. > > So, Willy, is it ok for you to remove that mount line with corresponding update > > of the commit message (and the subject title), or require me to send a revision > > for this patch? > > No worries, I've modified it accordingly with the following commit message, > just let me know if you want to change anything: > > commit 11fddb386bd663a554cc08c5950d9da2c87a7267 (HEAD) > Author: Zhangjin Wu <falcon@tinylab.org> > Date: Sat Jul 8 02:38:57 2023 +0800 > > selftests/nolibc: prepare /tmp for tests that need to write > > create a /tmp directory. If it succeeds, the directory is writable, > which is normally the case when booted from an initramfs anyway. > > This will be used instead of procfs for some tests. > > Reviewed-by: Thomas Weißschuh <linux@weissschuh.net> > Signed-off-by: Zhangjin Wu <falcon@tinylab.org> > Link: https://lore.kernel.org/lkml/20230710050600.9697-1-falcon@tinylab.org/ > [wt: removed the unneeded mount() call] > Signed-off-by: Willy Tarreau <w@1wt.eu> > Perfectly, Thanks a lot. Best regards, Zhangjin > Thanks! > Willy
diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 5497ee86cf40..6b863f7b677c 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -1063,6 +1063,10 @@ int prepare(void) } } + /* try to mount /tmp if not mounted, if not mountable, use ramfs as tmpfs */ + mkdir("/tmp", 0755); + mount("none", "/tmp", "tmpfs", 0, 0); + return 0; }