From patchwork Thu Mar 14 09:40:45 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: 13592273 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 23DCBC5475B for ; Thu, 14 Mar 2024 09:40:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 814C780094; Thu, 14 Mar 2024 05:40:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7C52380073; Thu, 14 Mar 2024 05:40:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 68C7980094; Thu, 14 Mar 2024 05:40:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 5921E80073 for ; Thu, 14 Mar 2024 05:40:22 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 0698CA1374 for ; Thu, 14 Mar 2024 09:40:22 +0000 (UTC) X-FDA: 81895149084.17.3EA7F77 Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) by imf13.hostedemail.com (Postfix) with ESMTP id 77F452000A for ; Thu, 14 Mar 2024 09:40:20 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=collabora.com header.s=mail header.b=Fl4pEshf; dmarc=pass (policy=quarantine) header.from=collabora.com; spf=pass (imf13.hostedemail.com: domain of usama.anjum@collabora.com designates 46.235.227.194 as permitted sender) smtp.mailfrom=usama.anjum@collabora.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1710409220; 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:references:dkim-signature; bh=ExKCn0mfUwSxhEUCwdJyGQbNPNwn3OzCDeG+H5FWgss=; b=1Vy8b8m88QAvd2lx14G0UWTwFT9e1pb9gX1s4uvtHOLBsqfX+FKxSleNmAqVN2TNdqG6uV Y2Sg4iqw5gvzg8Zj/n6jCJ0V5O6gk+5dopR3Tr0eiZl/7i3PluJh0FB+Jvqv1wZK/0hus2 9kLhqgN4zXBdXynppZOXB4whROkIcpk= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=collabora.com header.s=mail header.b=Fl4pEshf; dmarc=pass (policy=quarantine) header.from=collabora.com; spf=pass (imf13.hostedemail.com: domain of usama.anjum@collabora.com designates 46.235.227.194 as permitted sender) smtp.mailfrom=usama.anjum@collabora.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1710409220; a=rsa-sha256; cv=none; b=GTPzgB8L0+WnMZu/ogXldBs6OPcuK5DOxpVtolprsiSz1l9nyGlLXpT1sgZzt9GV7MLmqk 7T2eJXvRFFSlPNM3UUVnO7e8b1amMc7zfcGHO0eG3zIsTu7rP02uFNylGyLucgm4hmfbwI Pwzuzj8g2LHpGW52MVL88Ui68Rh9qrQ= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1710409219; bh=Hl7jmLGK4iDneFMK0s8y3NXOTrwEV3hV/7n5zpdoeak=; h=From:To:Cc:Subject:Date:From; b=Fl4pEshfn7A20AORpI8jlcZZgtt8ypOPJ8u/pHZIuj3dO4UP9RXs3Ryt6663zPgMS Zfn5qk3IOJ/1PPhW24QJsdEj8YWGI5RMevBgXiN2FoRwP2Ny9eV33Q1B7zy5tWjqE4 eOmNxyYzDNnJ1tU4D2O7yIQU5nDJnYRZ4EyQOpRp/kSaghgeoKarTQFYF//ut9CC8S AwPUoBV1GBmvbFdskNNJLQFchj3jSnooiSEzVT6ZBXnWaJrM8BbXIARAbEd4wEKmAK PBWR2JSbeKD1urf75RGnIbpS1dEioRdfbbAfC+Zrek+j+DQNcg+62Y6HrRSvY8990p vPn1iZUM2b3vA== Received: from localhost.localdomain (broslavsky.collaboradmins.com [68.183.210.73]) (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 D99DD378148F; Thu, 14 Mar 2024 09:40:16 +0000 (UTC) From: Muhammad Usama Anjum To: Andrew Morton , Shuah Khan , Muhammad Usama Anjum Cc: kernel@collabora.com, Joey Gouly , linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] selftests: mm: restore settings from only parent process Date: Thu, 14 Mar 2024 14:40:45 +0500 Message-Id: <20240314094045.157149-1-usama.anjum@collabora.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 77F452000A X-Stat-Signature: 98d5pt33hsz76p893znwdcyngwy3oxni X-HE-Tag: 1710409220-308411 X-HE-Meta: U2FsdGVkX19JLasZUO04/3tBRTIyWrzzHmIfiyAtjgRjWPjde7cBuyCDN97xC9q5dbuHEx0sMUYLzzCaxeNnbdL0cuoW1ROK17mR8X52a3xcPbQpwZrLz9wKPOg0WusdgeHqo13kvrOdcxWnxGtmrPREjK9EmBDayuB20mqx1SLWnOZ8hmvB7H5C9pMCBMV1VkWYvHG0ZM3FFvYfBBbjLnAo647q6IjQPYDZjTCsOX7bocYRovhY8pS/dz7CsUO3OKpOAAmQ38FHTRnH3TkPFVF11YGzGwo8Jt8A+vPUL9umzOyoqLj22oQxdiKnYuPdVzwujtW2TTFbG2XOTfOQ3qu+blZF0UjXBZtVNILSCjKzFoYkj1tjwKan1rwnV2HuMnuPFOLkxN//UExYnY+9gBMZRbog6cZZnYGv8Ln9t6FVgRbzUVHcjUVI9CjMgetxghWCP4MUZfYseI8WfbixXpDaDQIanzkk/aqlwuOIIajekfzQMF5sdFH6COnrMUTsGCeB+TAOo+zgSdYVlK6O+9ISFxmFwBzAk5wTDS9kSqLxjwWR+y+nM6ojrIss1cwxXd3tHP9bAwnfaojW+dHKOkoGO9EAOJMPkmP74/SAsitiZAEhlvYs6+03X3Y4ZPqWwHFqg1+iicMOdzlAQP+Rx7jpXvA61p/WXd7aKJzGLux4CnACECqtVvwIIpZ8TH9cTG7CcE1B4NE6jtc+n9yzXPk9bAdly1V8sJ9KGr+QLV4rOGIk7OqWGInmvojnjRptcLujddBc/IZOSl3StTY5/f0HRxaSuproPxKkqiS3I+x45Vm5pXnwpTDJXkccL+eevfCo7zxE96w8KDcGmMI7Bms2HrVx4VV5Rkq2H3wSCPmC4+evEIxxaflSMhF3rzDjp8t4F5knahnEnSSenIqXJywUVo0g1jmR18c7eG2S87RdAx2KxIIDBQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000328, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: The atexit() is called from parent process as well as forked processes. Hence the child restores the settings at exit while the parent is still executing. Fix this by checking pid of atexit() calling process and only restore THP number from parent process. Fixes: c23ea61726d5 ("selftests/mm: protection_keys: save/restore nr_hugepages settings") Tested-by: Joey Gouly Signed-off-by: Muhammad Usama Anjum --- tools/testing/selftests/mm/protection_keys.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/mm/protection_keys.c b/tools/testing/selftests/mm/protection_keys.c index f822ae31af22e..374a308174d2b 100644 --- a/tools/testing/selftests/mm/protection_keys.c +++ b/tools/testing/selftests/mm/protection_keys.c @@ -1745,9 +1745,12 @@ void pkey_setup_shadow(void) shadow_pkey_reg = __read_pkey_reg(); } +pid_t parent_pid; + void restore_settings_atexit(void) { - cat_into_file(buf, "/proc/sys/vm/nr_hugepages"); + if (parent_pid == getpid()) + cat_into_file(buf, "/proc/sys/vm/nr_hugepages"); } void save_settings(void) @@ -1773,6 +1776,7 @@ void save_settings(void) exit(__LINE__); } + parent_pid = getpid(); atexit(restore_settings_atexit); close(fd); }