From patchwork Tue Jan 23 07:36:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muhammad Usama Anjum X-Patchwork-Id: 13526930 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 43DB8C47258 for ; Tue, 23 Jan 2024 07:36:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A250C6B0082; Tue, 23 Jan 2024 02:36:25 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9AE096B0085; Tue, 23 Jan 2024 02:36:25 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 84E8C6B0087; Tue, 23 Jan 2024 02:36:25 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 7121F6B0082 for ; Tue, 23 Jan 2024 02:36:25 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 1DA3940685 for ; Tue, 23 Jan 2024 07:36:25 +0000 (UTC) X-FDA: 81709767930.07.6995878 Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) by imf02.hostedemail.com (Postfix) with ESMTP id 5D56E80004 for ; Tue, 23 Jan 2024 07:36:23 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=collabora.com header.s=mail header.b=yjpWZT5I; spf=pass (imf02.hostedemail.com: domain of usama.anjum@collabora.com designates 46.235.227.194 as permitted sender) smtp.mailfrom=usama.anjum@collabora.com; dmarc=pass (policy=quarantine) header.from=collabora.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1705995383; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=2asjm0ZjDvC80Vx/BmtTl2lfNKtG9TYBO3r55xTxbaM=; b=8eGBznSzJ0mTx3SHQ8hCntOgROj3yFHPgZDCKg6T64C8BAUuwHsZxpRtPwctskY/sq4DiO Ov3eN7dooGIlvXGOQVNKIchqREIu5SXZnnqGTSg1I6NKQNxCrBrSNZu6HcXjQgRTUuE36F 2ljTfn/N7jA+BCPL+sv3eusGmYjRKzI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1705995383; a=rsa-sha256; cv=none; b=kILGOXm83kiMbnqFaoLJVW3mLUCzC/pV72LwC1BcYIPGQqLj4zeqGx+bau3z7+6lwhfZ+P 88ccfoJUm0etbdVALC4LUVe1r2Z9oeQa1UzbvgsHLBBTRqbL3iQ9xDgsTxxUPXtVIvwd1k YrbR/099wH+nFtffv3L6c2q4aLUi4SY= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=collabora.com header.s=mail header.b=yjpWZT5I; spf=pass (imf02.hostedemail.com: domain of usama.anjum@collabora.com designates 46.235.227.194 as permitted sender) smtp.mailfrom=usama.anjum@collabora.com; dmarc=pass (policy=quarantine) header.from=collabora.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1705995382; bh=RONb+w30PwJfAdE6WvIlbcO0ThwKw/iY7UkyK1YT6Hk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yjpWZT5I4L21f59z0O8zIlh3zXmK/YWUjiAx/7ueI/Zd/8fzpzx9EyJkeF+KLQxpV vYU+3lqu8MSK6lbJK9tjM8HgnJNmO5eFLAAc+s9IbfiMyy7LdN76x1ZCccJ/NvAS9B 0sghzR1FFnrI6Td4+IGjpfqNHJQH1BFUmFBfwESp7vwo8WJknodVYqX03iQ+s+KQVE NPiR8VXkg0hH2iNY0461oBv9e9Spi5dpz8kIJTZud2qFLW5Jyip0Jueurt8qnEcqxH yhFrRSttKNvBTHS2ovlN8vB49CAVl4OQthwORC7KKiCJOvnQKPJKfC0nxTqjPQp2jK CEva9SZ+eibnA== Received: from localhost.localdomain (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: usama.anjum) by madrid.collaboradmins.com (Postfix) with ESMTPSA id D553F3782066; Tue, 23 Jan 2024 07:36:19 +0000 (UTC) From: Muhammad Usama Anjum To: Andrew Morton , Shuah Khan Cc: Muhammad Usama Anjum , kernel@collabora.com, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/2] selftests/mm: run_vmtests: remove sudo and conform to tap Date: Tue, 23 Jan 2024 12:36:14 +0500 Message-ID: <20240123073615.920324-2-usama.anjum@collabora.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240123073615.920324-1-usama.anjum@collabora.com> References: <20240123073615.920324-1-usama.anjum@collabora.com> MIME-Version: 1.0 X-Stat-Signature: g3wfu3ef1me9xdcumzsqyqe5scsyi54u X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 5D56E80004 X-Rspam-User: X-HE-Tag: 1705995383-241639 X-HE-Meta: U2FsdGVkX1/pY6n4xJlDGfqjWaHIfNy7iiHCx3j5otFwK4zjuzy/wqa8lGSB4texW3Rm8pIxy2Y0WQqNH1PM0zKeW3Lp90Jvxbq//Cd0Zs/zHpGkvWm+aw6NDykEcEnahXPNcUTgRBneknlPHG7UwX1D6yyydRO20GH42MHJ6CGYYSF3n+mQdLI0k1tXQA29BJv8JvgC09ESU4V1nzaU8QeyecOPQqgAW6gnkc1Z+n8o62p+4F7q4td+0v0+nDosgbNs6K53kpu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Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Remove sudo as some test running environments may not have sudo available. Instead skip the test if root privileges aren't available in the test. Signed-off-by: Muhammad Usama Anjum --- Changes since v1: - Added this patch in v2 We are allocating 2*RLIMIT_MEMLOCK.rlim_max memory and mmap() isn't failing. This seems like true bug in the kernel. Even the root user shouldn't be able to allocate more memory than allowed MEMLOCKed memory. Any ideas? --- tools/testing/selftests/mm/on-fault-limit.c | 36 ++++++++++----------- tools/testing/selftests/mm/run_vmtests.sh | 2 +- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/tools/testing/selftests/mm/on-fault-limit.c b/tools/testing/selftests/mm/on-fault-limit.c index b5888d613f34e..0ea98ffab3589 100644 --- a/tools/testing/selftests/mm/on-fault-limit.c +++ b/tools/testing/selftests/mm/on-fault-limit.c @@ -5,40 +5,38 @@ #include #include #include +#include "../kselftest.h" -static int test_limit(void) +static void test_limit(void) { - int ret = 1; struct rlimit lims; void *map; - if (getrlimit(RLIMIT_MEMLOCK, &lims)) { - perror("getrlimit"); - return ret; - } + if (getrlimit(RLIMIT_MEMLOCK, &lims)) + ksft_exit_fail_msg("getrlimit: %s\n", strerror(errno)); - if (mlockall(MCL_ONFAULT | MCL_FUTURE)) { - perror("mlockall"); - return ret; - } + if (mlockall(MCL_ONFAULT | MCL_FUTURE)) + ksft_exit_fail_msg("mlockall: %s\n", strerror(errno)); map = mmap(NULL, 2 * lims.rlim_max, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_POPULATE, -1, 0); + + ksft_test_result(map == MAP_FAILED, "Failed mmap\n"); + if (map != MAP_FAILED) - printf("mmap should have failed, but didn't\n"); - else { - ret = 0; munmap(map, 2 * lims.rlim_max); - } - munlockall(); - return ret; } int main(int argc, char **argv) { - int ret = 0; + ksft_print_header(); + ksft_set_plan(1); + + if (getuid()) + ksft_test_result_skip("Require root privileges to run\n"); + else + test_limit(); - ret += test_limit(); - return ret; + ksft_finished(); } diff --git a/tools/testing/selftests/mm/run_vmtests.sh b/tools/testing/selftests/mm/run_vmtests.sh index 12754af00b39c..863bbc2015332 100755 --- a/tools/testing/selftests/mm/run_vmtests.sh +++ b/tools/testing/selftests/mm/run_vmtests.sh @@ -294,7 +294,7 @@ echo "$nr_hugepgs" > /proc/sys/vm/nr_hugepages CATEGORY="compaction" run_test ./compaction_test -CATEGORY="mlock" run_test sudo -u nobody ./on-fault-limit +CATEGORY="mlock" run_test ./on-fault-limit CATEGORY="mmap" run_test ./map_populate