mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Luck, Tony" <tony.luck@intel.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: hdegoede@redhat.com, markgross@kernel.org, mingo@redhat.com,
	bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org,
	hpa@zytor.com, corbet@lwn.net, gregkh@linuxfoundation.org,
	andriy.shevchenko@linux.intel.com, jithu.joseph@intel.com,
	ashok.raj@intel.com, rostedt@goodmis.org,
	dan.j.williams@intel.com, linux-kernel@vger.kernel.org,
	linux-doc@vger.kernel.org, platform-driver-x86@vger.kernel.org,
	patches@lists.linux.dev, ravi.v.shankar@intel.com
Subject: Re: [PATCH v6 08/11] platform/x86/intel/ifs: Add scan test support
Date: Fri, 6 May 2022 11:49:32 -0700	[thread overview]
Message-ID: <YnVtvJgWU5KDnGSl@agluck-desk3.sc.intel.com> (raw)
In-Reply-To: <87r156hjpl.ffs@tglx>

On Fri, May 06, 2022 at 03:30:30PM +0200, Thomas Gleixner wrote:
> On Thu, May 05 2022 at 18:40, Tony Luck wrote:
> > +/*
> > + * Note all code and data in this file is protected by
> > + * ifs_sem. On HT systems all threads on a core will
> > + * execute together, but only the first thread on the
> > + * core will update results of the test.
> > + */
> > +struct workqueue_struct *ifs_wq;
> 
> Seems to be unused.

Missed deleting the definition after dropping all the users.
Deleted now.

> > +static bool oscan_enabled = true;
> 
> What changes this?

Code that changed this has been deleted (was to deal with a "can't
happen" case where the kernel threads didn't set completion).

Variable (and the remaing place that checked it) now deleted.

> > +static void message_not_tested(struct device *dev, int cpu, union ifs_status status)
> > +{
> > +	if (status.error_code < ARRAY_SIZE(scan_test_status))
> 
> Please add curly brackets as these are not one-line statements.

Done.

> > +		dev_info(dev, "CPU(s) %*pbl: SCAN operation did not start. %s\n",
> > +			 cpumask_pr_args(topology_sibling_cpumask(cpu)),
> > +			 scan_test_status[status.error_code]);
> > +/*
> > + * Execute the scan. Called "simultaneously" on all threads of a core
> > + * at high priority using the stop_cpus mechanism.
> > + */
> > +static int doscan(void *data)
> > +{
> > +	int cpu = smp_processor_id();
> > +	u64 *msrs = data;
> > +	int first;
> > +
> > +	/* Only the first logical CPU on a core reports result */
> > +	first = cpumask_first(topology_sibling_cpumask(cpu));
> 
> Shouldn't that be cpu_smt_mask()?

I guess so. It seems part of a maze of CONFIG options and #defines.
The code worked because (except on power) cpu_smt_mask() is just
an inline funtion that calls topology_sibling_cpumask().

I've changed this (and the other places that use
topology_sibling_cpumask() to cpu_smt_mask(). Will probably save
me from a randconfig build error some time in the future.

> > +	/*
> > +	 * This WRMSR will wait for other HT threads to also write
> > +	 * to this MSR (at most for activate.delay cycles). Then it
> > +	 * starts scan of each requested chunk. The core scan happens
> > +	 * during the "execution" of the WRMSR. This instruction can
> > +	 * take up to 200 milliseconds before it retires.
> 
> 200ms per test chunk?

Updated comment to say that 200 ms is the time for all chunks.

Note that the loop that calls here tries to do all (remaining)
chunks on each iteration. Doing them 1 at a time would reduce
the time each spends in stomp_machine(), but not as much as you'd
like. Each WRMSR(ACTIVATE_SCAN)) has to save/restore the whole
state of the core (similar to a C6 entry+exit). 

> > +	 */
> > +	wrmsrl(MSR_ACTIVATE_SCAN, msrs[0]);
> > +
> 
> > +	while (activate.start <= activate.stop) {
> > +		if (time_after(jiffies, timeout)) {
> > +			status.error_code = IFS_SW_TIMEOUT;
> > +			break;
> > +		}
> > +
> > +		msrvals[0] = activate.data;
> > +		stop_core_cpuslocked(cpu, doscan, msrvals);
> > +
> > +		status.data = msrvals[1];
> > +
> > +		/* Some cases can be retried, give up for others */
> > +		if (!can_restart(status))
> > +			break;
> > +
> > +		if (status.chunk_num == activate.start) {
> > +			/* Check for forward progress */
> > +			if (retries-- == 0) {
> > +				if (status.error_code == IFS_NO_ERROR)
> > +					status.error_code = IFS_SW_PARTIAL_COMPLETION;
> > +				break;
> > +			}
> > +		} else {
> > +			retries = MAX_IFS_RETRIES;
> > +			activate.start = status.chunk_num;
> > +		}
> > +	}
> 
> Looks way better now.

Thanks to you!

> > +}
> > +/*
> > + * Initiate per core test. It wakes up work queue threads on the target cpu and
> > + * its sibling cpu. Once all sibling threads wake up, the scan test gets executed and
> > + * wait for all sibling threads to finish the scan test.
> > + */
> > +int do_core_test(int cpu, struct device *dev)
> > +{
> > +	int ret = 0;
> > +
> > +	if (!scan_enabled)
> > +		return -ENXIO;
> > +
> > +	/* Prevent CPUs from being taken offline during the scan test */
> > +	cpus_read_lock();
> > +
> > +	if (!cpu_online(cpu)) {
> > +		dev_info(dev, "cannot test on the offline cpu %d\n", cpu);
> > +		ret = -EINVAL;
> > +		goto out;
> > +	}
> 
> Coming back to my points from the previous round:
> 
> 1) How is that supposed to work on a system which has HT enabled in BIOS,
>    but disabled on the kernel command line or via /sys/..../smt/control or
>    when a HT sibling is offlined temporarily?
> 
>    I assume it cannot work, but I can't see anything which handles those
>    cases.

Correct. If HT is disabled in BIOS, then there is no other thread, so
core tests just use a single thread.

If a logical CPU is "offline" due to Linux actions, then core test will
fail. In an earlier version we did attempt to detect this before trying
to run the test. But we didn't find a simple way to determine that a
core has one thread online, and another offline. Rather than a bunch of
code to detect an operator error it seemed better to let it run & fail.

Here is what the user will see:

# echo 45 > run_test
# cat status
untested
# cat details
0x100008000

Console will see this message:
misc intel_ifs_0: CPU(s) 45: SCAN operation did not start. Other thread could not join.

If the user debugs using the trace point I included in the code they will see:

              sh-411499  [067] ..... 61260.698969: ifs_status: cpu: 45, start: 00, stop: 80, status: 100008000
              sh-411499  [067] ..... 61260.699968: ifs_status: cpu: 45, start: 00, stop: 80, status: 100008000
              sh-411499  [067] ..... 61260.700076: ifs_status: cpu: 45, start: 00, stop: 80, status: 100008000
              sh-411499  [067] ..... 61260.700187: ifs_status: cpu: 45, start: 00, stop: 80, status: 100008000
              sh-411499  [067] ..... 61260.700334: ifs_status: cpu: 45, start: 00, stop: 80, status: 100008000
              sh-411499  [067] ..... 61260.700437: ifs_status: cpu: 45, start: 00, stop: 80, status: 100008000

Hmmm ... looks like I have an off-by one error in the retry check.

/* Max retries on the same chunk */
#define MAX_IFS_RETRIES  5

But it tried SIX times before giving up.  Will fix.

> 2) That documentation for the admin/user got eaten by the gremlins in
>    the intertubes again.

GregKH wasn't a fan of this itty bitty driver cluttering up
Documentation/x86. He said:

   I don't know which is better, it's just that creating a whole new
   documentation file for a single tiny driver feels very odd as it will
   get out of date and is totally removed from the driver itself.

   I'd prefer that drivers be self-contained, including the documentation,
   as it is much more obvious what is happening with that.  Spreading stuff
   around the tree only causes stuff to get out of sync easier.

So the documentation patch was dropped after v3. Last version here:

https://lore.kernel.org/r/20220419163859.2228874-3-tony.luck@intel.com

That doc would need pathnames updated to match the move from a platform
device to a virtual misc device. But otherwise seems still accurate.

Does that cover what you want from documentation for this driver
(wherever it gets located in the tree)? Are you looking for more?

-Tony

  reply	other threads:[~2022-05-06 18:49 UTC|newest]

Thread overview: 152+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-07 19:13 [PATCH v2 00/10] Introduce In Field Scan driver Jithu Joseph
2022-04-07 19:13 ` [PATCH v2 01/10] x86/microcode/intel: expose collect_cpu_info_early() for IFS Jithu Joseph
2022-04-08  8:34   ` Borislav Petkov
2022-04-21 14:56     ` Thomas Gleixner
2022-04-07 19:13 ` [PATCH v2 02/10] Documentation: In-Field Scan Jithu Joseph
2022-04-07 19:13 ` [PATCH v2 03/10] platform/x86/intel/ifs: Add driver for " Jithu Joseph
2022-04-07 19:13 ` [PATCH v2 04/10] platform/x86/intel/ifs: Load IFS Image Jithu Joseph
2022-04-08  5:02   ` Greg KH
2022-04-08  5:04   ` Greg KH
2022-04-07 19:13 ` [PATCH v2 05/10] platform/x86/intel/ifs: Check IFS Image sanity Jithu Joseph
2022-04-07 19:13 ` [PATCH v2 06/10] platform/x86/intel/ifs: Authenticate and copy to secured memory Jithu Joseph
2022-04-07 19:13 ` [PATCH v2 07/10] platform/x86/intel/ifs: Add scan test support Jithu Joseph
2022-04-07 19:13 ` [PATCH v2 08/10] platform/x86/intel/ifs: Add IFS sysfs interface Jithu Joseph
2022-04-08  4:59   ` Greg KH
2022-04-07 19:13 ` [PATCH v2 09/10] platform/x86/intel/ifs: add ABI documentation for IFS Jithu Joseph
2022-04-08  5:02   ` Greg KH
2022-04-07 19:13 ` [PATCH v2 10/10] trace: platform/x86/intel/ifs: Add trace point to track Intel IFS operations Jithu Joseph
2022-04-19 16:38 ` [PATCH v3 00/11] Introduce In Field Scan driver Tony Luck
2022-04-19 16:38   ` [PATCH v3 01/11] x86/microcode/intel: Expose collect_cpu_info_early() for IFS Tony Luck
2022-04-19 16:38   ` [PATCH v3 02/11] Documentation: In-Field Scan Tony Luck
2022-04-19 16:48     ` Greg KH
2022-04-19 19:45       ` Dan Williams
2022-04-20  7:48         ` Greg KH
2022-04-19 16:38   ` [PATCH v3 03/11] platform/x86/intel/ifs: Create device for Intel IFS (In Field Scan) Tony Luck
2022-04-19 16:47     ` Greg KH
2022-04-19 18:09       ` Dan Williams
2022-04-19 22:28         ` Dan Williams
2022-04-20  7:49           ` Greg KH
2022-04-20  7:48         ` Greg KH
2022-04-20 15:27           ` Luck, Tony
2022-04-20 17:46             ` Greg KH
2022-04-20 17:57               ` Luck, Tony
2022-04-20 18:04                 ` Greg KH
2022-04-20 18:08                   ` Luck, Tony
2022-04-20 19:04                     ` Greg KH
2022-04-19 16:38   ` [PATCH v3 04/11] platform/x86/intel/ifs: Add stub driver for In-Field Scan Tony Luck
2022-04-19 16:38   ` [PATCH v3 05/11] platform/x86/intel/ifs: Read IFS firmware image Tony Luck
2022-04-19 17:14     ` Greg KH
2022-04-19 16:38   ` [PATCH v3 06/11] platform/x86/intel/ifs: Check IFS Image sanity Tony Luck
2022-04-19 17:16     ` Greg KH
2022-04-19 16:38   ` [PATCH v3 07/11] platform/x86/intel/ifs: Authenticate and copy to secured memory Tony Luck
2022-04-19 16:38   ` [PATCH v3 08/11] platform/x86/intel/ifs: Add scan test support Tony Luck
2022-04-19 16:38   ` [PATCH v3 09/11] platform/x86/intel/ifs: Add IFS sysfs interface Tony Luck
2022-04-19 17:20     ` Greg KH
2022-04-19 17:35       ` Luck, Tony
2022-04-19 17:58         ` Greg KH
2022-04-19 18:15           ` Dan Williams
2022-04-19 18:24       ` Dan Williams
2022-04-19 16:38   ` [PATCH v3 10/11] trace: platform/x86/intel/ifs: Add trace point to track Intel IFS operations Tony Luck
2022-04-20 23:38     ` Steven Rostedt
2022-04-21  4:26       ` Luck, Tony
2022-04-21 12:41         ` Steven Rostedt
2022-04-19 16:38   ` [PATCH v3 11/11] platform/x86/intel/ifs: add ABI documentation for IFS Tony Luck
2022-04-22 20:02   ` [PATCH v4 00/10] Introduce In Field Scan driver Tony Luck
2022-04-22 20:02     ` [PATCH v4 01/10] x86/microcode/intel: Expose collect_cpu_info_early() for IFS Tony Luck
2022-04-22 20:02     ` [PATCH v4 02/10] x86/msr-index: Define INTEGRITY_CAPABILITIES MSR Tony Luck
2022-04-22 20:02     ` [PATCH v4 03/10] platform/x86/intel/ifs: Add stub driver for In-Field Scan Tony Luck
2022-04-22 20:02     ` [PATCH v4 04/10] platform/x86/intel/ifs: Read IFS firmware image Tony Luck
2022-04-26 10:45       ` Greg KH
2022-04-26 16:12         ` Luck, Tony
2022-04-26 16:36           ` Greg KH
2022-04-26 18:47             ` Luck, Tony
2022-04-22 20:02     ` [PATCH v4 05/10] platform/x86/intel/ifs: Check IFS Image sanity Tony Luck
2022-04-22 20:02     ` [PATCH v4 06/10] platform/x86/intel/ifs: Authenticate and copy to secured memory Tony Luck
2022-04-22 20:02     ` [PATCH v4 07/10] platform/x86/intel/ifs: Add scan test support Tony Luck
2022-04-22 20:02     ` [PATCH v4 08/10] platform/x86/intel/ifs: Add IFS sysfs interface Tony Luck
2022-04-22 20:02     ` [PATCH v4 09/10] trace: platform/x86/intel/ifs: Add trace point to track Intel IFS operations Tony Luck
2022-04-25 14:52       ` Steven Rostedt
2022-04-25 16:49         ` Luck, Tony
2022-04-26  1:49           ` Steven Rostedt
2022-04-26 23:53             ` Luck, Tony
2022-04-27  2:42               ` Steven Rostedt
2022-04-22 20:02     ` [PATCH v4 10/10] platform/x86/intel/ifs: add ABI documentation for IFS Tony Luck
2022-04-28 15:38     ` [PATCH v5 00/10] Introduce In Field Scan driver Tony Luck
2022-04-28 15:38       ` [PATCH v5 01/10] x86/microcode/intel: Expose collect_cpu_info_early() for IFS Tony Luck
2022-05-03 15:29         ` Borislav Petkov
2022-05-04 10:28         ` Thomas Gleixner
2022-04-28 15:38       ` [PATCH v5 02/10] x86/msr-index: Define INTEGRITY_CAPABILITIES MSR Tony Luck
2022-04-28 15:38       ` [PATCH v5 03/10] platform/x86/intel/ifs: Add stub driver for In-Field Scan Tony Luck
2022-05-04 10:35         ` Thomas Gleixner
2022-05-04 16:24           ` Luck, Tony
2022-05-04 16:28             ` Borislav Petkov
2022-04-28 15:38       ` [PATCH v5 04/10] platform/x86/intel/ifs: Read IFS firmware image Tony Luck
2022-05-04 10:37         ` Thomas Gleixner
2022-05-04 16:49           ` Luck, Tony
2022-04-28 15:38       ` [PATCH v5 05/10] platform/x86/intel/ifs: Check IFS Image sanity Tony Luck
2022-04-28 15:38       ` [PATCH v5 06/10] platform/x86/intel/ifs: Authenticate and copy to secured memory Tony Luck
2022-05-04 10:48         ` Thomas Gleixner
2022-04-28 15:38       ` [PATCH v5 07/10] platform/x86/intel/ifs: Add scan test support Tony Luck
2022-05-04 12:29         ` Thomas Gleixner
2022-05-04 18:52           ` Luck, Tony
2022-05-04 23:15             ` Thomas Gleixner
2022-05-05  8:28               ` Peter Zijlstra
2022-05-05  9:01                 ` Thomas Gleixner
2022-05-05 18:32                   ` Luck, Tony
2022-05-05 20:21                     ` Peter Zijlstra
2022-04-28 15:38       ` [PATCH v5 08/10] platform/x86/intel/ifs: Add IFS sysfs interface Tony Luck
2022-04-28 15:38       ` [PATCH v5 09/10] trace: platform/x86/intel/ifs: Add trace point to track Intel IFS operations Tony Luck
2022-04-28 15:38       ` [PATCH v5 10/10] platform/x86/intel/ifs: add ABI documentation for IFS Tony Luck
2022-04-28 15:58       ` [PATCH v5 00/10] Introduce In Field Scan driver Greg KH
2022-04-28 16:07         ` Luck, Tony
2022-05-02 15:15       ` Hans de Goede
2022-05-02 17:23         ` Luck, Tony
2022-05-03 15:32         ` Borislav Petkov
2022-05-03 16:04           ` Luck, Tony
2022-05-03 16:26             ` Luck, Tony
2022-05-06 14:19           ` Hans de Goede
2022-05-06 15:53             ` Luck, Tony
2022-05-06 18:41               ` Hans de Goede
2022-05-09 17:05                 ` Luck, Tony
2022-05-09 18:12                   ` Hans de Goede
2022-05-06  1:40       ` [PATCH v6 00/11] " Tony Luck
2022-05-06  1:40         ` [PATCH v6 01/11] x86/microcode/intel: Expose collect_cpu_info_early() for IFS Tony Luck
2022-05-06  1:40         ` [PATCH v6 02/11] x86/msr-index: Define INTEGRITY_CAPABILITIES MSR Tony Luck
2022-05-06  8:19           ` Thomas Gleixner
2022-05-06  1:40         ` [PATCH v6 03/11] stop_machine: Add stop_core_cpuslocked() for per-core operations Tony Luck
2022-05-06  8:20           ` Thomas Gleixner
2022-05-06  1:40         ` [PATCH v6 04/11] platform/x86/intel/ifs: Add stub driver for In-Field Scan Tony Luck
2022-05-06  8:23           ` Thomas Gleixner
2022-05-06  1:40         ` [PATCH v6 05/11] platform/x86/intel/ifs: Read IFS firmware image Tony Luck
2022-05-06  1:40         ` [PATCH v6 06/11] platform/x86/intel/ifs: Check IFS Image sanity Tony Luck
2022-05-06  1:40         ` [PATCH v6 07/11] platform/x86/intel/ifs: Authenticate and copy to secured memory Tony Luck
2022-05-06  1:40         ` [PATCH v6 08/11] platform/x86/intel/ifs: Add scan test support Tony Luck
2022-05-06 13:30           ` Thomas Gleixner
2022-05-06 18:49             ` Luck, Tony [this message]
2022-05-06 19:06               ` Thomas Gleixner
2022-05-06  1:40         ` [PATCH v6 09/11] platform/x86/intel/ifs: Add IFS sysfs interface Tony Luck
2022-05-06  1:40         ` [PATCH v6 10/11] trace: platform/x86/intel/ifs: Add trace point to track Intel IFS operations Tony Luck
2022-05-06  1:40         ` [PATCH v6 11/11] platform/x86/intel/ifs: add ABI documentation for IFS Tony Luck
2022-05-06 22:53         ` [PATCH v7 00/12] Introduce In Field Scan driver Tony Luck
2022-05-06 22:53           ` [PATCH v7 01/12] x86/microcode/intel: Expose collect_cpu_info_early() for IFS Tony Luck
2022-05-06 22:54           ` [PATCH v7 02/12] x86/msr-index: Define INTEGRITY_CAPABILITIES MSR Tony Luck
2022-05-06 22:54           ` [PATCH v7 03/12] stop_machine: Add stop_core_cpuslocked() for per-core operations Tony Luck
2022-05-06 22:54           ` [PATCH v7 04/12] platform/x86/intel/ifs: Add stub driver for In-Field Scan Tony Luck
2022-05-06 22:54           ` [PATCH v7 05/12] platform/x86/intel/ifs: Read IFS firmware image Tony Luck
2022-05-09 12:11             ` Thomas Gleixner
2022-05-06 22:54           ` [PATCH v7 06/12] platform/x86/intel/ifs: Check IFS Image sanity Tony Luck
2022-05-09 12:11             ` Thomas Gleixner
2022-05-09 16:31             ` Borislav Petkov
2022-05-09 16:51               ` Luck, Tony
2022-05-09 16:56                 ` Borislav Petkov
2022-05-06 22:54           ` [PATCH v7 07/12] platform/x86/intel/ifs: Authenticate and copy to secured memory Tony Luck
2022-05-09 12:11             ` Thomas Gleixner
2022-05-06 22:54           ` [PATCH v7 08/12] platform/x86/intel/ifs: Add scan test support Tony Luck
2022-05-09 12:11             ` Thomas Gleixner
2022-05-06 22:54           ` [PATCH v7 09/12] platform/x86/intel/ifs: Add IFS sysfs interface Tony Luck
2022-05-09 12:12             ` Thomas Gleixner
2022-05-06 22:54           ` [PATCH v7 10/12] trace: platform/x86/intel/ifs: Add trace point to track Intel IFS operations Tony Luck
2022-05-06 22:54           ` [PATCH v7 11/12] platform/x86/intel/ifs: add ABI documentation for IFS Tony Luck
2022-05-06 22:54           ` [PATCH v7 12/12] Documentation: In-Field Scan Tony Luck
2022-05-09 12:16             ` Thomas Gleixner
2022-05-11 15:51           ` [PATCH v7 00/12] Introduce In Field Scan driver Hans de Goede

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=YnVtvJgWU5KDnGSl@agluck-desk3.sc.intel.com \
    --to=tony.luck@intel.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=ashok.raj@intel.com \
    --cc=bp@alien8.de \
    --cc=corbet@lwn.net \
    --cc=dan.j.williams@intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hdegoede@redhat.com \
    --cc=hpa@zytor.com \
    --cc=jithu.joseph@intel.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=markgross@kernel.org \
    --cc=mingo@redhat.com \
    --cc=patches@lists.linux.dev \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=ravi.v.shankar@intel.com \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /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®