From patchwork Fri Apr 4 16:42:32 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 14038681 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3EFBDC36010 for ; Fri, 4 Apr 2025 16:43:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8C3A76B0008; Fri, 4 Apr 2025 12:42:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 86F0E6B000A; Fri, 4 Apr 2025 12:42:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 735C96B000E; Fri, 4 Apr 2025 12:42:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 4FC236B0008 for ; Fri, 4 Apr 2025 12:42:59 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 21A121C8E24 for ; Fri, 4 Apr 2025 16:43:00 +0000 (UTC) X-FDA: 83296930920.09.7E6D349 Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by imf09.hostedemail.com (Postfix) with ESMTP id 631E5140004 for ; Fri, 4 Apr 2025 16:42:58 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Eh1y12kG; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf09.hostedemail.com: domain of broonie@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=broonie@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1743784978; a=rsa-sha256; cv=none; b=c4c0yhDDqouj+A0VBCzQ87RSPAAuRL49jw9crvOVcGbczfNWPbNmcFple48fb3ep4QyZBG W642pmusas0BnGuTitRiAmCPLIdqq5sJumPPo3UNcldXcdgACMf8UyriU+ZVmax3n5aRFq SeXVf8MSGQIGrYNa7MzsK/KRdfGf8+A= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Eh1y12kG; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf09.hostedemail.com: domain of broonie@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=broonie@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1743784978; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=+rDhadScYfRJMy/elQ5TDQhe0z2YtcD3QtsurKl5wQc=; b=k/LBkLpqsMRoOnWyPJpKYgBb7lrXF2mwbVIvUNjwU+RhJSUL87bnf82VRN9Q+MJH92b/ie 6iSSPFeXE1JgRmZEHgRKJEpkBtkpOEMj7RY+e1FNG4pvw7bRcqo3vhZsLHeZaLu06JHh9Y PVV2UOPEpgpY2yEAnCt7FLUr+IJllvU= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id 6002E6116B; Fri, 4 Apr 2025 16:42:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AE18AC4CEDD; Fri, 4 Apr 2025 16:42:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743784977; bh=TNi4PEbptWpWAlp9afnYThvYme8MQTL7nzY/LKJbojI=; h=From:Date:Subject:To:Cc:From; b=Eh1y12kGzKjDxw0EkmsgbNYFzE08H2x4rsUZnyy8S71w9uTKa/P+KY4QRolfBjrK7 bcqayUG+NPAWRgE5EhqkVH9so4ME2yldi2gyQodwOKfTPIZF1C96uVuSMrcyIo7q/h IgCm+Ph3l4MEDTZoPC9FfEOti2DqnyS0/WVOBR/Vh/jferLLYJFM+nRYiUwGklMgud V52sIpivx3bqzfFDO56QTCeUXmcBHXkpQ1ePsESZD+uo/XwihiAwNDBsKDC3USEyWn eRueNckknRYgNzNckqGo8fhodTsHIY6dVQT2G2BC3aituW3xEWwu0TlocAS9MXt+px 7U9L1NTKv0nfA== From: Mark Brown Date: Fri, 04 Apr 2025 17:42:32 +0100 Subject: [PATCH] selftests/mm: Generate a temporary mountpoint for cgroup filesystem MIME-Version: 1.0 Message-Id: <20250404-kselftest-mm-cgroup2-detection-v1-1-3dba6d32ba8c@kernel.org> X-B4-Tracking: v=1; b=H4sIAPgL8GcC/x2NzQ6CMBAGX4Xs2U3KIhh9FcMB26+4UX7SLcaE8 O42HucwMzsZksLoVu2U8FHTZS5Qnyryz2EewRoKkzhp3dk1/DK8Y4Zlnib2Y1q2VTggw+ei8uP S1TFII/EaqETWhKjf/+DeH8cPJ76eMnAAAAA= X-Change-ID: 20250403-kselftest-mm-cgroup2-detection-b761fd232f9d To: Andrew Morton , Shuah Khan , Mina Almasry , Waiman Long Cc: Aishwarya TCV , linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Mark Brown X-Mailer: b4 0.15-dev-c25d1 X-Developer-Signature: v=1; a=openpgp-sha256; l=2925; i=broonie@kernel.org; h=from:subject:message-id; bh=TNi4PEbptWpWAlp9afnYThvYme8MQTL7nzY/LKJbojI=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBn8AwOxx3xtn4/NlyZcqctIQ64Hba9efHA8DBEgtnn T/6cCqyJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZ/AMDgAKCRAk1otyXVSH0J5LB/ 9A9GmrE3YSF6/3xP/0Z3gw87wadfRJCRggdPL5wF887+qubzuV6aHED/VV4NVO32LZv6DB6QsxNC+/ 0t/csSQoNgDoM+IAObBxovJSpAIXBQ0aGGoFtbuMfH2oi49ZiFv+grQg42IPIRm5JkzxbycX4fJqxs KrueY1X8axR9rMR1BplRj2KLrlUGDerPLqCaaiFRWJ/9VsJbtMH8XJK+7ay7PwyQziELA5xVLwKK4i vJ0mep9INEG0252n+hnbJX7G2RxzuZlXYqQcV/35IEF155DvZqHMMc97rQBytHewE3VgYCXo2vx6Z4 +lWd1TsINKu0ItLq2wPwf8xp9X4/Nu X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-Rspamd-Queue-Id: 631E5140004 X-Stat-Signature: m9xk6qmdf4z3jh4pbxpzfo6urr6j9so9 X-Rspam-User: X-Rspamd-Server: rspam06 X-HE-Tag: 1743784978-622919 X-HE-Meta: U2FsdGVkX1+97oWKfLHfR6cssa16XcdN7vIV5TRXgZEu1maNFxuUYsBvHZph7By5GEW3nPE2pFfBDtl4PAImVY0jBo1NGXqTVJYLCK6fMirYJP0Y2UudDMUNXpJz3AU5uxbMfJO8VE2u7AqtL2S4LzQwkGyO+MWL4+tRk2JqGodHPEW59TrQcOXhsJdg5hDG4xwmm+WxqgwGPmU+jg9USSxFmskg6QIN5sJ3r9NiKx/FvGzA1tCfVtWgwoTpIBy4soO+upy0hphDkFvIt0327NKwzWHIBEvRm9KL8h5Q3CfY/i3q7oIirrFnedTZRljbIOBtWXj6BNFOTccGTyyNi6Qlqmfgq0er1ucVpqhszJjqFAJHyZA0AE1f6/Pmy4GB2N1LTf68etk8CwkuG7O/4kKAPFMxMzVUF+v/h/xwliWubz/pnN1MFnqebf7Dxhp0y0Ltr6g/pDOgY1CLtWbEVx/cicX3i6ThTKFK7OKoPdbFtdx3JrgJuBIYM+cB4U9ien/nM5eEZ5G4BJ/U74QTuLeUf1YKL17Hpi3hpxP2SSOFRSyyi/rZnvREiuW4xSmWAycT+PdlO7FsD2MwJ0tN6SuZDth36SYsZNhAykhLL7uRGi5kyz0efI9739QtuPY5+XC4+xDajT0lteGftpYPw0r6d9X/48VTmamtGu+Shl4+3oV9xpqJ6nbKakhFqB7it+kpZlvfoznJ7fo9U7IJdtiiSm7UWvEvvbx11QMfcwwiCwVQfPyePRlD2Gd8bb+DEP0hISchOM2X3uYqQ++jIG4vYvAubzwLHmImjNM+VmCm7dn255fsopaJkj/ThFCar8qI1FrxWuulUDBbxC3oYNTHRJAQF9UkpKf6bRbDoiJBSxOOfolNq/ROED/f4gTmC0zAZX9x3b+oWF8KFFN5QoVZ3ca/Xs1qWYJjawjbaYwWitwXUlhDtJyejX1ZjnbELFsCyEX6JDyjIsrzrvN jq1VgIhS JTl5S8+aNIkmYAqwkAW1/2hyZ0pr9b7Kua5AYJIov/scJ6igwNkb571VtpAwQ6vx8ojx1MT1J7ItjaD2Vbxv+idY2OY486C0nM/AlmoYkLzfTsJjiWZKRPL/3QWgM4fd/m6XZRV3swmB5HskTOjjTiwXUYZ7tvVSM5pEb8HP2ImC5UEIB0ilRYt+ft45WwkC2ysVKAMPE1fHsSmqiEzv1ks6PMsyeO8+q96k8rL41mudj0cC/AbHV1TWrvQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Currently if the filesystem for the cgroups version it wants to use is not mounted charge_reserved_hugetlb.sh and hugetlb_reparenting_test.sh tests will attempt to mount it on the hard coded path /dev/cgroup/memory, deleting that directory when the test finishes. This will fail if there is not a preexisting directory at that path, and since the directory is deleted subsequent runs of the test will fail. Instead of relying on this hard coded directory name use mktemp to generate a temporary directory to use as a mountpoint, fixing both the assumption and the disruption caused by deleting a preexisting directory. This means that if the relevant cgroup filesystem is not already mounted then we rely on having coreutils (which provides mktemp) installed. I suspect that many current users are relying on having things automounted by default, and given that the script relies on bash it's probably not an unreasonable requirement. Fixes: 209376ed2a84 ("selftests/vm: make charge_reserved_hugetlb.sh work with existing cgroup setting") Signed-off-by: Mark Brown --- tools/testing/selftests/mm/charge_reserved_hugetlb.sh | 4 ++-- tools/testing/selftests/mm/hugetlb_reparenting_test.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) --- base-commit: a4cda136f021ad44b8b52286aafd613030a6db5f change-id: 20250403-kselftest-mm-cgroup2-detection-b761fd232f9d Best regards, diff --git a/tools/testing/selftests/mm/charge_reserved_hugetlb.sh b/tools/testing/selftests/mm/charge_reserved_hugetlb.sh index 67df7b47087f..e1fe16bcbbe8 100755 --- a/tools/testing/selftests/mm/charge_reserved_hugetlb.sh +++ b/tools/testing/selftests/mm/charge_reserved_hugetlb.sh @@ -29,7 +29,7 @@ fi if [[ $cgroup2 ]]; then cgroup_path=$(mount -t cgroup2 | head -1 | awk '{print $3}') if [[ -z "$cgroup_path" ]]; then - cgroup_path=/dev/cgroup/memory + cgroup_path=$(mktemp -d) mount -t cgroup2 none $cgroup_path do_umount=1 fi @@ -37,7 +37,7 @@ if [[ $cgroup2 ]]; then else cgroup_path=$(mount -t cgroup | grep ",hugetlb" | awk '{print $3}') if [[ -z "$cgroup_path" ]]; then - cgroup_path=/dev/cgroup/memory + cgroup_path=$(mktemp -d) mount -t cgroup memory,hugetlb $cgroup_path do_umount=1 fi diff --git a/tools/testing/selftests/mm/hugetlb_reparenting_test.sh b/tools/testing/selftests/mm/hugetlb_reparenting_test.sh index 11f9bbe7dc22..0b0d4ba1af27 100755 --- a/tools/testing/selftests/mm/hugetlb_reparenting_test.sh +++ b/tools/testing/selftests/mm/hugetlb_reparenting_test.sh @@ -23,7 +23,7 @@ fi if [[ $cgroup2 ]]; then CGROUP_ROOT=$(mount -t cgroup2 | head -1 | awk '{print $3}') if [[ -z "$CGROUP_ROOT" ]]; then - CGROUP_ROOT=/dev/cgroup/memory + CGROUP_ROOT=$(mktemp -d) mount -t cgroup2 none $CGROUP_ROOT do_umount=1 fi