From: Reinette Chatre <reinette.chatre@intel.com>
To: Kohei Tarumizu <tarumizu.kohei@fujitsu.com>,
<catalin.marinas@arm.com>, <will@kernel.org>,
<tglx@linutronix.de>, <mingo@redhat.com>, <bp@alien8.de>,
<dave.hansen@linux.intel.com>, <x86@kernel.org>, <hpa@zytor.com>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>, <fenghua.yu@intel.com>
Subject: Re: [PATCH v3 6/9] x86: resctrl: pseudo_lock: Fix to restore to original value when re-enabling hardware prefetch register
Date: Mon, 25 Apr 2022 16:17:46 -0700 [thread overview]
Message-ID: <d1998eb4-296f-f1ac-8deb-1b6d4fbdc1fa@intel.com> (raw)
In-Reply-To: <20220420030223.689259-7-tarumizu.kohei@fujitsu.com>
Hi Kohei,
Thank you very much for catching this issue. This fix is not specific to
or required by the driver you are creating in this series so you could also
extract this patch and submit it separately as a fix to resctrl.
When you do resubmit there are a few style related points that I highlight here,
the fix itself looks good.
For the subject, please use "x86/resctrl:" prefix in the subject.
On 4/19/2022 8:02 PM, Kohei Tarumizu wrote:
> The current pseudo_lock.c code overwrittes the value of the
overwrittes -> overwrites
> MSR_MISC_FEATURE_CONTROL to 0 even if the original value is not 0.
> Therefore, modify it to save and restore the original values.
>
This needs a Fixes tag. A few patches are impacted by this fix:
Fixes: 018961ae5579 ("x86/intel_rdt: Pseudo-lock region creation/removal core")
Fixes: 443810fe6160 ("x86/intel_rdt: Create debugfs files for pseudo-locking testing")
Fixes: 8a2fc0e1bc0c ("x86/intel_rdt: More precise L2 hit/miss measurements")
> Signed-off-by: Kohei Tarumizu <tarumizu.kohei@fujitsu.com>
> ---
> arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 12 +++++++++---
> 1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/arch/x86/kernel/cpu/resctrl/pseudo_lock.c b/arch/x86/kernel/cpu/resctrl/pseudo_lock.c
> index db813f819ad6..2d713c20f55f 100644
> --- a/arch/x86/kernel/cpu/resctrl/pseudo_lock.c
> +++ b/arch/x86/kernel/cpu/resctrl/pseudo_lock.c
> @@ -420,6 +420,7 @@ static int pseudo_lock_fn(void *_rdtgrp)
> struct pseudo_lock_region *plr = rdtgrp->plr;
> u32 rmid_p, closid_p;
> unsigned long i;
> + u64 saved_msr;
> #ifdef CONFIG_KASAN
> /*
> * The registers used for local register variables are also used
> @@ -463,6 +464,7 @@ static int pseudo_lock_fn(void *_rdtgrp)
> * the buffer and evict pseudo-locked memory read earlier from the
> * cache.
> */
> + saved_msr = __rdmsr(MSR_MISC_FEATURE_CONTROL);
> __wrmsr(MSR_MISC_FEATURE_CONTROL, prefetch_disable_bits, 0x0);
> closid_p = this_cpu_read(pqr_state.cur_closid);
> rmid_p = this_cpu_read(pqr_state.cur_rmid);
> @@ -514,7 +516,7 @@ static int pseudo_lock_fn(void *_rdtgrp)
> __wrmsr(IA32_PQR_ASSOC, rmid_p, closid_p);
>
> /* Re-enable the hardware prefetcher(s) */
> - wrmsr(MSR_MISC_FEATURE_CONTROL, 0x0, 0x0);
> + wrmsrl(MSR_MISC_FEATURE_CONTROL, saved_msr);
> local_irq_enable();
>
> plr->thread_done = 1;
> @@ -873,12 +875,14 @@ static int measure_cycles_lat_fn(void *_plr)
> struct pseudo_lock_region *plr = _plr;
> unsigned long i;
> u64 start, end;
> + u32 saved_low, saved_high;
> void *mem_r;
Please do follow the current style of using "reverse fir tree order".
More information in:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/maintainer-tip.rst#n587
>
> local_irq_disable();
> /*
> * Disable hardware prefetchers.
> */
> + rdmsr(MSR_MISC_FEATURE_CONTROL, saved_low, saved_high);
> wrmsr(MSR_MISC_FEATURE_CONTROL, prefetch_disable_bits, 0x0);
> mem_r = READ_ONCE(plr->kmem);
> /*
> @@ -895,7 +899,7 @@ static int measure_cycles_lat_fn(void *_plr)
> end = rdtsc_ordered();
> trace_pseudo_lock_mem_latency((u32)(end - start));
> }
> - wrmsr(MSR_MISC_FEATURE_CONTROL, 0x0, 0x0);
> + wrmsr(MSR_MISC_FEATURE_CONTROL, saved_low, saved_high);
> local_irq_enable();
> plr->thread_done = 1;
> wake_up_interruptible(&plr->lock_thread_wq);
> @@ -945,6 +949,7 @@ static int measure_residency_fn(struct perf_event_attr *miss_attr,
> unsigned long i;
> void *mem_r;
> u64 tmp;
> + u32 saved_low, saved_high;
Same as above.
>
> miss_event = perf_event_create_kernel_counter(miss_attr, plr->cpu,
> NULL, NULL, NULL);
> @@ -973,6 +978,7 @@ static int measure_residency_fn(struct perf_event_attr *miss_attr,
> /*
> * Disable hardware prefetchers.
> */
> + rdmsr(MSR_MISC_FEATURE_CONTROL, saved_low, saved_high);
> wrmsr(MSR_MISC_FEATURE_CONTROL, prefetch_disable_bits, 0x0);
>
> /* Initialize rest of local variables */
> @@ -1031,7 +1037,7 @@ static int measure_residency_fn(struct perf_event_attr *miss_attr,
> */
> rmb();
> /* Re-enable hardware prefetchers */
> - wrmsr(MSR_MISC_FEATURE_CONTROL, 0x0, 0x0);
> + wrmsr(MSR_MISC_FEATURE_CONTROL, saved_low, saved_high);
> local_irq_enable();
> out_hit:
> perf_event_release_kernel(hit_event);
Thank you very much.
Reinette
next prev parent reply other threads:[~2022-04-25 23:17 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-20 3:02 [PATCH v3 0/9] Add hardware prefetch control driver for A64FX and x86 Kohei Tarumizu
2022-04-20 3:02 ` [PATCH v3 1/9] drivers: base: Add hardware prefetch control core driver Kohei Tarumizu
2022-04-20 21:40 ` Thomas Gleixner
2022-04-22 12:10 ` tarumizu.kohei
2022-04-21 6:18 ` Greg KH
2022-04-22 12:30 ` tarumizu.kohei
2022-04-20 3:02 ` [PATCH v3 2/9] drivers: base: Add Kconfig/Makefile to build " Kohei Tarumizu
2022-04-20 3:02 ` [PATCH v3 3/9] soc: fujitsu: Add hardware prefetch control support for A64FX Kohei Tarumizu
2022-04-20 3:02 ` [PATCH v3 4/9] soc: fujitsu: Add Kconfig/Makefile to build hardware prefetch control driver Kohei Tarumizu
2022-04-20 22:14 ` Thomas Gleixner
2022-04-20 3:02 ` [PATCH v3 5/9] arm64: Create cache sysfs directory without ACPI PPTT for hardware prefetch control Kohei Tarumizu
2022-04-20 3:02 ` [PATCH v3 6/9] x86: resctrl: pseudo_lock: Fix to restore to original value when re-enabling hardware prefetch register Kohei Tarumizu
2022-04-20 20:56 ` Dave Hansen
2022-04-22 12:01 ` tarumizu.kohei
2022-04-25 23:17 ` Reinette Chatre [this message]
2022-04-27 2:51 ` tarumizu.kohei
2022-04-20 3:02 ` [PATCH v3 7/9] x86: Add hardware prefetch control support for x86 Kohei Tarumizu
2022-04-20 22:27 ` Thomas Gleixner
2022-04-22 12:16 ` tarumizu.kohei
2022-04-20 3:02 ` [PATCH v3 8/9] x86: Add Kconfig/Makefile to build hardware prefetch control driver Kohei Tarumizu
2022-04-20 3:02 ` [PATCH v3 9/9] docs: ABI: Add sysfs documentation interface of " Kohei Tarumizu
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=d1998eb4-296f-f1ac-8deb-1b6d4fbdc1fa@intel.com \
--to=reinette.chatre@intel.com \
--cc=bp@alien8.de \
--cc=catalin.marinas@arm.com \
--cc=dave.hansen@linux.intel.com \
--cc=fenghua.yu@intel.com \
--cc=hpa@zytor.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tarumizu.kohei@fujitsu.com \
--cc=tglx@linutronix.de \
--cc=will@kernel.org \
--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®