mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Reinette Chatre <reinette.chatre@intel.com>
To: Tony Luck <tony.luck@intel.com>
Cc: "Wieczor-Retman, Maciej" <maciej.wieczor-retman@intel.com>,
	"shuah@kernel.org" <shuah@kernel.org>,
	"Yu, Fenghua" <fenghua.yu@intel.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-kselftest@vger.kernel.org"
	<linux-kselftest@vger.kernel.org>,
	"ilpo.jarvinen@linux.intel.com" <ilpo.jarvinen@linux.intel.com>
Subject: Re: [PATCH v3 2/2] selftests/resctrl: Adjust SNC support messages
Date: Tue, 2 Jul 2024 15:01:57 -0700	[thread overview]
Message-ID: <a206cbfe-83a1-4c9d-8cc9-5cff1598a6d2@intel.com> (raw)
In-Reply-To: <ZoR1GSV4_IWrNMK3@agluck-desk3.sc.intel.com>

Hi Tony,

On 7/2/24 2:46 PM, Tony Luck wrote:
> On Tue, Jul 02, 2024 at 02:26:25PM -0700, Reinette Chatre wrote:
>> Hi Tony,
>>
>> On 7/1/24 9:04 AM, Luck, Tony wrote:
>>> +static bool cpus_offline_empty(void)
>>> +{
>>> +	char offline_cpus_str[64];
>>> +	FILE *fp;
>>> +
>>> +	fp = fopen("/sys/devices/system/cpu/offline", "r");
>>>
>>> Check for fp == NULL before using it.
>>>
>>> +	if (fscanf(fp, "%s", offline_cpus_str) < 0) {
>>>
>>> fscanf() seems like a heavy hammer.
>>
>> Do you perhaps have any recommendations that should be used instead of
>> fscanf()? I checked with stat() but could not see a difference between
>> file with a CPU and a file without. Other alternative is
>> open()/read()/close()? Looks like when there are no offline CPUs then
>> the file will only contain '\n' so it may be possible to read one byte
>> from the file and confirm it is '\n' as a check for "cpus_offline_empty()".
> 
> Sorry. I replied with Outlook and didn't quote things properly
> so my alternate suggestion didn't stand out. Here it is again:
> 
> 	if (fgets(offline_cpus_str, sizeof(offline_cpus_str), fp) == NULL) {
> 		fclose(fp);
> 		return true;
> 	}

Apologies, missed this.

> 
> But that was with the assumption that /sys/devices/system/cpu/offline
> would be empty. Not that it would conatain a single "\n" as you say
> above.
> 
> So fgets( ...) followed with "if (offline_cpus_str[0] == '\n') "?

How about simplifying it more to "if (fgetc(fp) == '\n')" ?

Reinette

  reply	other threads:[~2024-07-02 22:02 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-01 14:17 [PATCH v3 0/2] selftests/resctrl: SNC kernel support discovery Maciej Wieczor-Retman
2024-07-01 14:18 ` [PATCH v3 1/2] selftests/resctrl: Adjust effective L3 cache size with SNC enabled Maciej Wieczor-Retman
2024-07-02 22:20   ` Reinette Chatre
2024-07-03  6:43     ` Maciej Wieczor-Retman
2024-07-01 14:18 ` [PATCH v3 2/2] selftests/resctrl: Adjust SNC support messages Maciej Wieczor-Retman
2024-07-01 16:04   ` Luck, Tony
2024-07-02 21:26     ` Reinette Chatre
2024-07-02 21:46       ` Tony Luck
2024-07-02 22:01         ` Reinette Chatre [this message]
2024-07-02 22:03           ` Luck, Tony
2024-07-03  6:44             ` Maciej Wieczor-Retman
2024-07-03  6:50     ` Maciej Wieczor-Retman
2024-07-02 22:21   ` Reinette Chatre
2024-07-03  7:43     ` Maciej Wieczór-Retman
2024-07-03 20:51       ` Reinette Chatre
2024-07-04  7:23         ` Maciej Wieczor-Retman
2024-07-08 16:39           ` Reinette Chatre
2024-07-09  7:49             ` Maciej Wieczor-Retman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a206cbfe-83a1-4c9d-8cc9-5cff1598a6d2@intel.com \
    --to=reinette.chatre@intel.com \
    --cc=fenghua.yu@intel.com \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=maciej.wieczor-retman@intel.com \
    --cc=shuah@kernel.org \
    --cc=tony.luck@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®