Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp120407rdb; Thu, 1 Feb 2024 04:06:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IG45M1ai95jgJEl13EHG2yeW9nMC/V0PfxDYFeCL0wJol0t78+ZkJijQS2K8LqI0uClumzB X-Received: by 2002:a05:622a:15d0:b0:42b:fbaf:761b with SMTP id d16-20020a05622a15d000b0042bfbaf761bmr460930qty.58.1706789216035; Thu, 01 Feb 2024 04:06:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706789216; cv=pass; d=google.com; s=arc-20160816; b=cNI3UUI1pZ1qxViWd4Fhchke4WpacLFidjaUHAwXauc1ZgAYsMtXKesvpFoXSy3T5z k2q1pQrNge7JOOO8eLIhr9xHkNaeMqyQeRNdBn1yT8yHbP7y3c20WeXkUKrvw7FX7FWk a0xriZu1zmbMx1num9iauvfbw8sIjbLGsZs2DCuxJj+rGiiCMAxdU/hb03jGTkGxhrB/ zpLCNEQCGI51ojD1TofSJRMd33q0nP3jt3WX+gMr1KbGOT2poL55SHqpGoZW6uPlaSDb osf9JTkomLRkNE1hwKTDVjELPktsRgqXQKuTp1f8Aa+tMp4oeqS3FzaLER/b6TvbcZ/o 6KRQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=AF0w1R1yGqfEd38zuP5v7S20TE+unYDg1ZxXrcmHr3I=; fh=TnDSGNM6SLGmpAnq3l+xfBgDe8Nl/+U0aGbbSKH7gCE=; b=u4rtaOqjsOEzraSckMSBuPsxYshCyuKc4o/X+rlWMcSRnKlPkDMwpZlWeBaJDSMpcK 7AyaRODZ50HHH/6Lfk4VU6+ms9zq8pNXqHosg8cShprGbtkMtO3ayCV3Lar2FcOOv5I+ n8g9lJWOv24b7HVLW5MBcw2MJg8BW1FJpikzj6z5KUqntVfiHzM0OZVGIqgSwzcXL7gU WqLmMeDi+loMzTO3AvsOqCEPr79im/WgO5EPLz4asV/ALLiJWVTMZNeEq8Hq+B0Bld4l Ut2lJ5e+w7WLXRTVRj9A26HseVn8QUVCQu+A0V7Gc5f2sH/DcousL5KNB2Ai7CqfVGmo 6y3w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-48073-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48073-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com X-Forwarded-Encrypted: i=1; AJvYcCWaCJdAvwH9xRIIxldoo6gSGOv83KeMZquDCbB/H4zvvnMBFhdex6jgaf9u/ORhTPU5KUOjis0hJyL5S7pSnXWKRbqHThXsyRODhLddjg== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 10-20020ac8574a000000b0042bf252be97si1359119qtx.171.2024.02.01.04.06.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 04:06:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-48073-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-48073-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48073-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id A55151C22615 for ; Thu, 1 Feb 2024 12:06:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9A32D15D5DF; Thu, 1 Feb 2024 12:04:29 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9790F15D5DB; Thu, 1 Feb 2024 12:04:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706789069; cv=none; b=hwK51EDv1p/LElblwUKA2Hi6vo9TsNLMWSjEYR8U81rkLM9zSDC1WPlKgOE9rrqEmKLIPLTotWKTZGLVQiH6C1dck3xLF30YRQImsWB+uvr9unxaGLq9ga8FEYNul4bwmboJXHelOsRDXpVXOGogpTd/ABGqwYm/vj0wMfPBLNY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706789069; c=relaxed/simple; bh=qo7pwrQdY7fIkZ8m5MR220PWKc/kV4xPGU2nyh1wI3Q=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=j7cgFyVPJ+R344NPiqgBQEDIrkatbbL1sTTj87+oZV8AXNgTSEtj0I5zAn2lmpdYHZDwWaAyUH5H/qoxRFqLDhkwJoi3OobAMjqWpVsv9ydKaD85cqO4Kx+PRqDdEIz+Y9+En0NeCEjII+oZd4XbtBozwNSt2nqliEhndr3ocqc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id AFBC6DA7; Thu, 1 Feb 2024 04:05:08 -0800 (PST) Received: from [10.57.79.60] (unknown [10.57.79.60]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id EE8DB3F762; Thu, 1 Feb 2024 04:04:24 -0800 (PST) Message-ID: Date: Thu, 1 Feb 2024 12:04:23 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 2/5] selftests/mm: run_vmtests: remove sudo and conform to tap To: Muhammad Usama Anjum , Andrew Morton , Shuah Khan Cc: kernel@collabora.com, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org References: <20240125154608.720072-1-usama.anjum@collabora.com> <20240125154608.720072-3-usama.anjum@collabora.com> Content-Language: en-GB From: Ryan Roberts In-Reply-To: <20240125154608.720072-3-usama.anjum@collabora.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 25/01/2024 15:46, Muhammad Usama Anjum wrote: > 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 246d53a5d7f28..e373d592dbf5c 100755 > --- a/tools/testing/selftests/mm/run_vmtests.sh > +++ b/tools/testing/selftests/mm/run_vmtests.sh > @@ -291,7 +291,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 I think changing this is going to give unintended results. run_vmtests.sh must already be running as root. "sudo -u nobody" is deprivieging the test to run as nobody. The rlimit is not enforced for root so this test must run unprivileged to work. See man page for getrlimit(): Since Linux 2.6.9, no limits are placed on the amount of memory that a privileged process may lock, and this limit instead governs the amount of memory that an unprivileged process may lock So I think the correct fix is actually to install sudo on your CI. > > CATEGORY="mmap" run_test ./map_populate >