From: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
To: "Joseph, Jithu" <jithu.joseph@intel.com>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
Cc: Hans de Goede <hdegoede@redhat.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
x86@kernel.org, Steven Rostedt <rostedt@goodmis.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
Ashok Raj <ashok.raj@intel.com>, Tony Luck <tony.luck@intel.com>,
linux-trace-kernel@vger.kernel.org,
platform-driver-x86@vger.kernel.org,
Shankar Ravi V <ravi.v.shankar@intel.com>
Subject: Re: [PATCH v1 3/4] platform/x86/intel/ifs: Add SBAF test support
Date: Sat, 6 Jul 2024 16:47:19 -0700 [thread overview]
Message-ID: <9e33c98d-805a-4426-b7fb-3fba3d0f8fc7@linux.intel.com> (raw)
In-Reply-To: <35482322-8200-42c5-ba4f-8d50f1b1498d@intel.com>
On 7/6/24 10:20 AM, Joseph, Jithu wrote:
> Thanks very much for the review Ilpo,
>
> On 7/6/2024 6:19 PM, Ilpo Järvinen wrote:
>> On Thu, 27 Jun 2024, Kuppuswamy Sathyanarayanan wrote:
>>
>>> From: Jithu Joseph <jithu.joseph@intel.com>
>>>
>>> In a core, the SBAF test engine is shared between sibling CPUs.
>>>
>>> An SBAF test image contains multiple bundles. Each bundle is further
>>> composed of subunits called programs. When a SBAF test (for a particular
>>> core) is triggered by the user, each SBAF bundle from the loaded test
>>> image is executed sequentially on all the threads on the core using
>>> the stop_core_cpuslocked mechanism. Each bundle execution is initiated by
>>> writing to MSR_ACTIVATE_SBAF.
>>>
>>> SBAF test bundle execution may be aborted when an interrupt occurs or
>>> if the CPU does not have enough power budget for the test. In these
>>> cases the kernel restarts the test from the aborted bundle. SBAF
>>> execution is not retried if the test fails or if the test makes no
>>> forward progress after 5 retries.
>>>
>>> Reviewed-by: Ashok Raj <ashok.raj@intel.com>
>>> Reviewed-by: Tony Luck <tony.luck@intel.com>
>>> Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
>>> Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
>>> ---
>>> drivers/platform/x86/intel/ifs/ifs.h | 30 +++
>>> drivers/platform/x86/intel/ifs/runtest.c | 234 +++++++++++++++++++++++
>>> 2 files changed, 264 insertions(+)
>>>
> ...
>
>>> +
>>> +static void ifs_sbaf_test_core(int cpu, struct device *dev)
>>> +{
>>> + struct sbaf_run_params run_params;
>>> + union ifs_sbaf_status status;
>>> + union ifs_sbaf activate;
>>> + unsigned long timeout;
>>> + struct ifs_data *ifsd;
>>> + int stop_bundle;
>>> + int retries;
>>> +
>>> + ifsd = ifs_get_data(dev);
>>> +
>>> + activate.data = 0;
>>> + activate.delay = IFS_THREAD_WAIT;
>>> +
>>> + timeout = jiffies + (2 * HZ);
>>> + retries = MAX_IFS_RETRIES;
>>> + activate.bundle_idx = 0;
>>> + stop_bundle = ifsd->max_bundle;
>>> +
>>> + while (activate.bundle_idx <= stop_bundle) {
>>> + if (time_after(jiffies, timeout)) {
>>> + status.error_code = IFS_SW_TIMEOUT;
>>> + break;
>> If we take this branch on the first iteration...
>>
>>> + }
>>> +
>>> + atomic_set(&sbaf_cpus_in, 0);
>>> +
>>> + run_params.ifsd = ifsd;
>>> + run_params.activate = &activate;
>>> + run_params.retry_cnt = &retries;
>>> + stop_core_cpuslocked(cpu, dosbaf, &run_params);
>>> +
>>> + status = run_params.status;
>>> +
>>> + if (sbaf_bundle_completed(status)) {
>>> + activate.bundle_idx = status.bundle_idx + 1;
>>> + activate.pgm_idx = 0;
>>> + retries = MAX_IFS_RETRIES;
>>> + continue;
>>> + }
>>> +
>>> + /* Some cases can be retried, give up for others */
>>> + if (!sbaf_can_restart(status))
>>> + break;
>>> +
>>> + if (status.pgm_idx == activate.pgm_idx) {
>>> + /* If no progress retry */
>>> + if (--retries == 0) {
>>> + if (status.error_code == IFS_NO_ERROR)
>>> + status.error_code = IFS_SW_PARTIAL_COMPLETION;
>>> + break;
>>> + }
>>> + } else {
>>> + /* if some progress, more pgms remaining in bundle, reset retries */
>>> + retries = MAX_IFS_RETRIES;
>>> + activate.bundle_idx = status.bundle_idx;
>>> + activate.pgm_idx = status.pgm_idx;
>>> + }
>>> + }
>>> +
>>> + /* Update status for this core */
>>> + ifsd->scan_details = status.data;
>>> +
>>> + if (status.sbaf_status == SBAF_STATUS_SIGN_FAIL ||
>>> + status.sbaf_status == SBAF_STATUS_TEST_FAIL) {
>> ...is status.sbar_status uninitialized? (And perhaps other fields too
>> that are used after the loop?).
> Will initialize status.data to 0 (at function entry, prior to the loop) to ensure that in the unlikely scenario of taking
> the aforementioned branch (on the first iteration), all the status fields will be zeroed (apart from status.error_code,
> which would be set to IFS_SW_TIMEOUT at the branch)
Yes, it is better to initialize the status variable to 0. While moving the
timeout check to the end of the loop could also address this issue,
explicitly fixing it at the initialization is a cleaner solution.
--- a/drivers/platform/x86/intel/ifs/runtest.c
+++ b/drivers/platform/x86/intel/ifs/runtest.c
@@ -542,7 +542,7 @@ static int dosbaf(void *data)
static void ifs_sbaf_test_core(int cpu, struct device *dev)
{
struct sbaf_run_params run_params;
- union ifs_sbaf_status status;
+ union ifs_sbaf_status status = {};
I think there is a similar usage in ifs_test_core() as well. Will fix that in
a separate patch.
>
>> It could also be that the timeout check shouldn't be before the first real
>> iteration inside the loop to ensure that kind of shortcut cannot occur?
>>
> Thanks
> Jithu
--
Sathyanarayanan Kuppuswamy
Linux Kernel Developer
next prev parent reply other threads:[~2024-07-06 23:47 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-27 2:35 [PATCH v1 0/4] Add SBAF test to IFS Kuppuswamy Sathyanarayanan
2024-06-27 2:35 ` [PATCH v1 1/4] platform/x86/intel/ifs: Refactor MSR usage in IFS test code Kuppuswamy Sathyanarayanan
2024-06-27 2:35 ` [PATCH v1 2/4] platform/x86/intel/ifs: Add SBAF test image loading support Kuppuswamy Sathyanarayanan
2024-06-27 2:35 ` [PATCH v1 3/4] platform/x86/intel/ifs: Add SBAF test support Kuppuswamy Sathyanarayanan
2024-07-06 12:49 ` Ilpo Järvinen
2024-07-06 17:20 ` Joseph, Jithu
2024-07-06 23:47 ` Kuppuswamy Sathyanarayanan [this message]
2024-06-27 2:35 ` [PATCH v1 4/4] trace: platform/x86/intel/ifs: Add SBAF trace support Kuppuswamy Sathyanarayanan
2024-06-27 13:56 ` Steven Rostedt
2024-06-27 14:04 ` Kuppuswamy Sathyanarayanan
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=9e33c98d-805a-4426-b7fb-3fba3d0f8fc7@linux.intel.com \
--to=sathyanarayanan.kuppuswamy@linux.intel.com \
--cc=ashok.raj@intel.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hdegoede@redhat.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=jithu.joseph@intel.com \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=mingo@redhat.com \
--cc=platform-driver-x86@vger.kernel.org \
--cc=ravi.v.shankar@intel.com \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=tony.luck@intel.com \
--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;
as well as URLs for NNTP newsgroup(s).