Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1906224rdb; Tue, 20 Feb 2024 10:21:31 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXdpvEzaVIiKMAUVIpzCPa/j+JiBjXOl0cQzc+40jUFRx9rDHLQBQFeE4hvjAQqYHwk5pr3ETMCk+XKLJIrP44cJ/el0tKHzA2WAm6ALg== X-Google-Smtp-Source: AGHT+IGOeMy0+JbiF+Z6m1sPL5wqnIWo2HspJIu1+DXe3Tqupkdej9hjbZVjldkqvYwcz+3JSnNd X-Received: by 2002:a05:6402:693:b0:564:56e0:5643 with SMTP id f19-20020a056402069300b0056456e05643mr4523862edy.27.1708453291355; Tue, 20 Feb 2024 10:21:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708453291; cv=pass; d=google.com; s=arc-20160816; b=my7jYwLxzLTSeSLl0dhxwC7VY/8hzzfN/Qck3Cvp37Bva4YkwAO3YIdbd+9v/z9jjB Ts3gGlogvZP8Re614GpOCR9TvxaJ26OUQMzqHLkyev73OlDKXqWvE1GWT2dIjM02lwcD JeA9Gd76f6lleHhDaBl4axiCkwEVjru9nUD6EQ+KsahPpLO5jiNSnH/Kz+3WurJjfxk4 U0dzmnJy7LIiy1CZ2eZrLpd5JRifquXWKUj4zr09aA0T0pe2MhveUgPVfNlLk4DVBQ+n qqqUVHMhx5b5OeE7THxQwy61RsL0l9PhtmgTuH4jm3zJ1G8HOJ6klhi1uj61clyxWb2F KedA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:in-reply-to:subject:cc:to:date:from :dkim-signature; bh=ILjlkk3CH/iql/7rPRaBP65rwU7YXTiv7/9OEEaVHqM=; fh=jU5jGJ5usTD08gfMkYbEKRhikPRGxP3z78On/gtBHH0=; b=Uf+7EQPi0dd59L/SxUr6tTk/npnY57FbgfI99tQsjXtO82U0AjIoNvv+vx7GBjmnGG ewfxP+5BwwwL7q7nbCNlxz5icfZJFjhEdTCkJeZfLk98YBC2sTPw57lHqpcv84MD0RZT /fY76tCQBN1YqqXR8pY7KCZ5GJLAKu89R2qEqD0wh6enO8Kv4GQP3GeYoPnOwiOAWRye Y3/uz+rFR33Ihc7tnyuDbGZKhKVZ8FO6MHfmMtWHG15Jw7RAW8ce0x5Leb0wbhOu6AtF PapZLGKsCer4N/Izkd7mUorGjJZ6Gg10gNURr0JQ74G11h+KrR/NyKLdbmZiztm8GcoA NYHw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=SiUIugk8; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-73174-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73174-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id p12-20020aa7cc8c000000b0055eef1ceb3dsi3728819edt.197.2024.02.20.10.21.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 10:21:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-73174-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=SiUIugk8; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-73174-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73174-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.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 am.mirrors.kernel.org (Postfix) with ESMTPS id 752A31F23D30 for ; Tue, 20 Feb 2024 14:21:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C2DD06BB24; Tue, 20 Feb 2024 14:21:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="SiUIugk8" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 671D86BB20; Tue, 20 Feb 2024 14:21:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708438904; cv=none; b=I8p0bI7ydx5rOoelJg9iZzfu7Fr4c6Lrix0vwGeGoyXVYmAjh3BH7V7fUMDElrpRaMAFH/QYBy3pw4DOjNQcMokzN1Bp3qrinkPfSFl3DmUOBAEt4a6RFw+AVqLSZFQtuwsGx03uL4GYL6zHfO2zTg2BQRdzUsZXti1Tq+g0jjY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708438904; c=relaxed/simple; bh=IEAY6VUhThvzKY+JFc2CbN1IsBoT7b3cE4kxZSwzYjQ=; h=From:Date:To:cc:Subject:In-Reply-To:Message-ID:References: MIME-Version:Content-Type; b=L+ZuFaOzvvIK5cSDowYa9+TQVcwHcjVqSTIDhDbuaqT/w/liXgRTMr13fzhztmmZX/RHI7PTTSS9InLE1IEUhnifNnsQEcROt+UoPJtBxO02npgJkO+9enNKSNfU+zaXuO8EbnMmNVUBWGpmxLjIpCIhJ8Gig1C0kd9lfr+doZI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=SiUIugk8; arc=none smtp.client-ip=192.198.163.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1708438902; x=1739974902; h=from:date:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=IEAY6VUhThvzKY+JFc2CbN1IsBoT7b3cE4kxZSwzYjQ=; b=SiUIugk8544FOnuwqJGghL5UzOx7fV3P4xb+xhAIFngxgJaT5fmA9+Av E6kzEzJfZdmd1RbAMKVxOfS2KT6cBIPuE2WncmoN6U9A15o2+46gsR8k+ lR4swWfe3VDQ5w+PxZZA5PcbKmU8xjFbyIp5OHsdLEV5nE/w+88fjOgs4 2ZhNPq/pTOWwFf1uWrfctqzlTPJDc8qu0tFootDkxHThTb7LaY9EelTae F75wm4N4zBKMmBNyXyWuyt8dJmvVXGrhp94dx9p/M7X3X57BrBfwgqJH6 TPHR+AYoKpm/h7D5t2J4XhRsDwPvBt9cgDPDFC3TJiC1ggn1JE+Hx1ci5 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10989"; a="13168008" X-IronPort-AV: E=Sophos;i="6.06,172,1705392000"; d="scan'208";a="13168008" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Feb 2024 06:21:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,172,1705392000"; d="scan'208";a="4834420" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.94.249.21]) by orviesa010-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Feb 2024 06:21:38 -0800 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Date: Tue, 20 Feb 2024 16:21:32 +0200 (EET) To: Maciej Wieczor-Retman cc: Fenghua Yu , Reinette Chatre , Shuah Khan , LKML , linux-kselftest@vger.kernel.org Subject: Re: [PATCH 2/3] selftests/resctrl: Simplify cleanup in ctrl-c handler In-Reply-To: Message-ID: References: <8c4fcfb6b4e38a0f0e400be88ecf1af0d20e12e7.1708434017.git.maciej.wieczor-retman@intel.com> <5f251bcd-a343-bb6e-a947-7605dc59f9ea@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="8323328-1414670152-1708438892=:1099" This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323328-1414670152-1708438892=:1099 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE On Tue, 20 Feb 2024, Maciej Wieczor-Retman wrote: > On 2024-02-20 at 15:45:23 +0200, Ilpo J=E4rvinen wrote: > >On Tue, 20 Feb 2024, Maciej Wieczor-Retman wrote: > > > >> Ctrl-c handler isn't aware of what test is currently running. Because = of > >> that it executes all cleanups even if they aren't necessary. Since the > >> ctrl-c handler uses the sigaction system no parameters can be passed > >> to it as function arguments. > >>=20 > >> Add a global variable to make ctrl-c handler aware of the currently ru= n > >> test and only execute the correct cleanup callback. > >>=20 > >> Signed-off-by: Maciej Wieczor-Retman > >> --- > >> tools/testing/selftests/resctrl/resctrl.h | 2 ++ > >> .../testing/selftests/resctrl/resctrl_tests.c | 20 +++++++++---------= - > >> tools/testing/selftests/resctrl/resctrl_val.c | 2 +- > >> 3 files changed, 13 insertions(+), 11 deletions(-) > >>=20 > >> diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing= /selftests/resctrl/resctrl.h > >> index 0f49df4961ea..79b45cbeb628 100644 > >> --- a/tools/testing/selftests/resctrl/resctrl.h > >> +++ b/tools/testing/selftests/resctrl/resctrl.h > >> @@ -128,6 +128,8 @@ extern pid_t bm_pid, ppid; > >> =20 > >> extern char llc_occup_path[1024]; > >> =20 > >> +extern struct resctrl_test current_test; > > > >Why this is not just a pointer? >=20 > I tried making this as a pointer but the 'test' in test_prepare() is of t= ype > 'const struct resctrl_test *' and there are warnings about dropping the c= onst > modifier. Why cannot the pointer be const too? The signal handler is not supposed to= =20 modify the contents of the resctrl_test struct. There are two types of constness in C. One (the most commonly used one)=20 relates to immutability of the contents of the struct the pointer (or char= =20 *) points to while the other enforces the pointer itself to remain=20 immutable. Usually, the former is what is useful and it's what you get=20 when you naturally write "const struct". > >> +=09current_test =3D *test; > > > >I'd prefer to keep this internal to signal handling functions so that=20 > >either the struct resctrl_test or just the cleanup handler is passed=20 > >to signal_handler_register(). >=20 > Okay, would moving this assignment to signal_handler_register() be okay t= hen? Yes, that's what I'm after here. Lets keep it internal to the signal=20 handling code. --=20 i. --8323328-1414670152-1708438892=:1099--