linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/resctrl: Check monitoring static key in MBM overflow handler
@ 2019-12-11 17:41 Xiaochen Shen
  2019-12-11 19:18 ` Xiaochen Shen
  2019-12-11 20:05 ` [PATCH RESEND] " Xiaochen Shen
  0 siblings, 2 replies; 4+ messages in thread
From: Xiaochen Shen @ 2019-12-11 17:41 UTC (permalink / raw)
  To: tglx, mingo, bp, hpa, tony.luck, fenghua.yu, reinette.chatre
  Cc: x86, linux-kernel, pei.p.jia, xiaochen.shen

Currently, there are three static keys in resctrl file system:
rdt_mon_enable_key and rdt_alloc_enable_key indicate if monitoring
feature and allocation feature is enabled respectively. rdt_enable_key
is enabled when either monitoring feature or allocation feature is
enabled.

If no monitoring feature is supported (either hardware doesn't support
monitoring feature or the feature is disabled by kernel command line
option "rdt="), rdt_enable_key is still enabled but rdt_mon_enable_key
is disabled.

MBM is a monitoring feature. MBM overflow handler intends to check if
monitoring feature is not enabled for fast return. So the accurate check
here is to check rdt_mon_enable_key instead of rdt_enable_key.

Fixes: e33026831bdb ("x86/intel_rdt/mbm: Handle counter overflow")
Signed-off-by: Xiaochen Shen <xiaochen.shen@intel.com>
Reviewed-by: Fenghua Yu <fenghua.yu@intel.com>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
---
 arch/x86/kernel/cpu/resctrl/internal.h | 1 +
 arch/x86/kernel/cpu/resctrl/monitor.c  | 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h
index e49b77283924..181c992f448c 100644
--- a/arch/x86/kernel/cpu/resctrl/internal.h
+++ b/arch/x86/kernel/cpu/resctrl/internal.h
@@ -57,6 +57,7 @@ static inline struct rdt_fs_context *rdt_fc2context(struct fs_context *fc)
 }
 
 DECLARE_STATIC_KEY_FALSE(rdt_enable_key);
+DECLARE_STATIC_KEY_FALSE(rdt_mon_enable_key);
 
 /**
  * struct mon_evt - Entry in the event list of a resource
diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c
index 397206f23d14..773124b0e18a 100644
--- a/arch/x86/kernel/cpu/resctrl/monitor.c
+++ b/arch/x86/kernel/cpu/resctrl/monitor.c
@@ -514,7 +514,7 @@ void mbm_handle_overflow(struct work_struct *work)
 
 	mutex_lock(&rdtgroup_mutex);
 
-	if (!static_branch_likely(&rdt_enable_key))
+	if (!static_branch_likely(&rdt_mon_enable_key))
 		goto out_unlock;
 
 	d = get_domain_from_cpu(cpu, &rdt_resources_all[RDT_RESOURCE_L3]);
@@ -543,7 +543,7 @@ void mbm_setup_overflow_handler(struct rdt_domain *dom, unsigned long delay_ms)
 	unsigned long delay = msecs_to_jiffies(delay_ms);
 	int cpu;
 
-	if (!static_branch_likely(&rdt_enable_key))
+	if (!static_branch_likely(&rdt_mon_enable_key))
 		return;
 	cpu = cpumask_any(&dom->cpu_mask);
 	dom->mbm_work_cpu = cpu;
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] x86/resctrl: Check monitoring static key in MBM overflow handler
  2019-12-11 17:41 [PATCH] x86/resctrl: Check monitoring static key in MBM overflow handler Xiaochen Shen
@ 2019-12-11 19:18 ` Xiaochen Shen
  2019-12-11 20:05 ` [PATCH RESEND] " Xiaochen Shen
  1 sibling, 0 replies; 4+ messages in thread
From: Xiaochen Shen @ 2019-12-11 19:18 UTC (permalink / raw)
  To: tglx, mingo, bp, hpa, tony.luck, fenghua.yu, reinette.chatre
  Cc: x86, linux-kernel, pei.p.jia, Xiaochen Shen

Hi,

I am sorry I sent out a wrong version of patch.
Please ignore this patch. I will resend soon.


On 12/12/2019 1:41, Xiaochen Shen wrote:
> Currently, there are three static keys in resctrl file system:
> rdt_mon_enable_key and rdt_alloc_enable_key indicate if monitoring
> feature and allocation feature is enabled respectively. rdt_enable_key
> is enabled when either monitoring feature or allocation feature is
> enabled.
> 
> If no monitoring feature is supported (either hardware doesn't support
> monitoring feature or the feature is disabled by kernel command line
> option "rdt="), rdt_enable_key is still enabled but rdt_mon_enable_key
> is disabled.
> 
> MBM is a monitoring feature. MBM overflow handler intends to check if
> monitoring feature is not enabled for fast return. So the accurate check
> here is to check rdt_mon_enable_key instead of rdt_enable_key.
> 
> Fixes: e33026831bdb ("x86/intel_rdt/mbm: Handle counter overflow")
> Signed-off-by: Xiaochen Shen <xiaochen.shen@intel.com>
> Reviewed-by: Fenghua Yu <fenghua.yu@intel.com>
> Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
> ---
>   arch/x86/kernel/cpu/resctrl/internal.h | 1 +
>   arch/x86/kernel/cpu/resctrl/monitor.c  | 4 ++--
>   2 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h
> index e49b77283924..181c992f448c 100644
> --- a/arch/x86/kernel/cpu/resctrl/internal.h
> +++ b/arch/x86/kernel/cpu/resctrl/internal.h
> @@ -57,6 +57,7 @@ static inline struct rdt_fs_context *rdt_fc2context(struct fs_context *fc)
>   }
>   
>   DECLARE_STATIC_KEY_FALSE(rdt_enable_key);
> +DECLARE_STATIC_KEY_FALSE(rdt_mon_enable_key);
>   
>   /**
>    * struct mon_evt - Entry in the event list of a resource
> diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c
> index 397206f23d14..773124b0e18a 100644
> --- a/arch/x86/kernel/cpu/resctrl/monitor.c
> +++ b/arch/x86/kernel/cpu/resctrl/monitor.c
> @@ -514,7 +514,7 @@ void mbm_handle_overflow(struct work_struct *work)
>   
>   	mutex_lock(&rdtgroup_mutex);
>   
> -	if (!static_branch_likely(&rdt_enable_key))
> +	if (!static_branch_likely(&rdt_mon_enable_key))
>   		goto out_unlock;
>   
>   	d = get_domain_from_cpu(cpu, &rdt_resources_all[RDT_RESOURCE_L3]);
> @@ -543,7 +543,7 @@ void mbm_setup_overflow_handler(struct rdt_domain *dom, unsigned long delay_ms)
>   	unsigned long delay = msecs_to_jiffies(delay_ms);
>   	int cpu;
>   
> -	if (!static_branch_likely(&rdt_enable_key))
> +	if (!static_branch_likely(&rdt_mon_enable_key))
>   		return;
>   	cpu = cpumask_any(&dom->cpu_mask);
>   	dom->mbm_work_cpu = cpu;
> 

-- 
Best regards,
Xiaochen

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH RESEND] x86/resctrl: Check monitoring static key in MBM overflow handler
  2019-12-11 17:41 [PATCH] x86/resctrl: Check monitoring static key in MBM overflow handler Xiaochen Shen
  2019-12-11 19:18 ` Xiaochen Shen
@ 2019-12-11 20:05 ` Xiaochen Shen
  2020-01-17 18:41   ` [tip: x86/cache] x86/resctrl: Check monitoring static key in the " tip-bot2 for Xiaochen Shen
  1 sibling, 1 reply; 4+ messages in thread
From: Xiaochen Shen @ 2019-12-11 20:05 UTC (permalink / raw)
  To: tglx, mingo, bp, hpa, tony.luck, fenghua.yu, reinette.chatre
  Cc: x86, linux-kernel, pei.p.jia, xiaochen.shen

Currently, there are three static keys in resctrl file system:
rdt_mon_enable_key and rdt_alloc_enable_key indicate if monitoring
feature and allocation feature is enabled respectively. rdt_enable_key
is enabled when either monitoring feature or allocation feature is
enabled.

If no monitoring feature is supported (either hardware doesn't support
monitoring feature or the feature is disabled by kernel command line
option "rdt="), rdt_enable_key is still enabled but rdt_mon_enable_key
is disabled.

MBM is a monitoring feature. MBM overflow handler intends to check if
monitoring feature is not enabled for fast return. So the accurate check
here is to check rdt_mon_enable_key instead of rdt_enable_key.

Fixes: e33026831bdb ("x86/intel_rdt/mbm: Handle counter overflow")
Signed-off-by: Xiaochen Shen <xiaochen.shen@intel.com>
---
 arch/x86/kernel/cpu/resctrl/internal.h | 1 +
 arch/x86/kernel/cpu/resctrl/monitor.c  | 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h
index e49b77283924..181c992f448c 100644
--- a/arch/x86/kernel/cpu/resctrl/internal.h
+++ b/arch/x86/kernel/cpu/resctrl/internal.h
@@ -57,6 +57,7 @@ static inline struct rdt_fs_context *rdt_fc2context(struct fs_context *fc)
 }
 
 DECLARE_STATIC_KEY_FALSE(rdt_enable_key);
+DECLARE_STATIC_KEY_FALSE(rdt_mon_enable_key);
 
 /**
  * struct mon_evt - Entry in the event list of a resource
diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c
index 397206f23d14..773124b0e18a 100644
--- a/arch/x86/kernel/cpu/resctrl/monitor.c
+++ b/arch/x86/kernel/cpu/resctrl/monitor.c
@@ -514,7 +514,7 @@ void mbm_handle_overflow(struct work_struct *work)
 
 	mutex_lock(&rdtgroup_mutex);
 
-	if (!static_branch_likely(&rdt_enable_key))
+	if (!static_branch_likely(&rdt_mon_enable_key))
 		goto out_unlock;
 
 	d = get_domain_from_cpu(cpu, &rdt_resources_all[RDT_RESOURCE_L3]);
@@ -543,7 +543,7 @@ void mbm_setup_overflow_handler(struct rdt_domain *dom, unsigned long delay_ms)
 	unsigned long delay = msecs_to_jiffies(delay_ms);
 	int cpu;
 
-	if (!static_branch_likely(&rdt_enable_key))
+	if (!static_branch_likely(&rdt_mon_enable_key))
 		return;
 	cpu = cpumask_any(&dom->cpu_mask);
 	dom->mbm_work_cpu = cpu;
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [tip: x86/cache] x86/resctrl: Check monitoring static key in the MBM overflow handler
  2019-12-11 20:05 ` [PATCH RESEND] " Xiaochen Shen
@ 2020-01-17 18:41   ` tip-bot2 for Xiaochen Shen
  0 siblings, 0 replies; 4+ messages in thread
From: tip-bot2 for Xiaochen Shen @ 2020-01-17 18:41 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: Xiaochen Shen, Borislav Petkov, x86, LKML

The following commit has been merged into the x86/cache branch of tip:

Commit-ID:     536a0d8e79fb928f2735db37dda95682b6754f9a
Gitweb:        https://git.kernel.org/tip/536a0d8e79fb928f2735db37dda95682b6754f9a
Author:        Xiaochen Shen <xiaochen.shen@intel.com>
AuthorDate:    Thu, 12 Dec 2019 04:05:05 +08:00
Committer:     Borislav Petkov <bp@suse.de>
CommitterDate: Fri, 17 Jan 2020 19:32:32 +01:00

x86/resctrl: Check monitoring static key in the MBM overflow handler

Currently, there are three static keys in the resctrl file system:
rdt_mon_enable_key and rdt_alloc_enable_key indicate if the monitoring
feature and the allocation feature are enabled, respectively. The
rdt_enable_key is enabled when either the monitoring feature or the
allocation feature is enabled.

If no monitoring feature is present (either hardware doesn't support a
monitoring feature or the feature is disabled by the kernel command line
option "rdt="), rdt_enable_key is still enabled but rdt_mon_enable_key
is disabled.

MBM is a monitoring feature. The MBM overflow handler intends to
check if the monitoring feature is not enabled for fast return.

So check the rdt_mon_enable_key in it instead of the rdt_enable_key as
former is the more accurate check.

 [ bp: Massage commit message. ]

Fixes: e33026831bdb ("x86/intel_rdt/mbm: Handle counter overflow")
Signed-off-by: Xiaochen Shen <xiaochen.shen@intel.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/1576094705-13660-1-git-send-email-xiaochen.shen@intel.com
---
 arch/x86/kernel/cpu/resctrl/internal.h | 1 +
 arch/x86/kernel/cpu/resctrl/monitor.c  | 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h
index e49b772..181c992 100644
--- a/arch/x86/kernel/cpu/resctrl/internal.h
+++ b/arch/x86/kernel/cpu/resctrl/internal.h
@@ -57,6 +57,7 @@ static inline struct rdt_fs_context *rdt_fc2context(struct fs_context *fc)
 }
 
 DECLARE_STATIC_KEY_FALSE(rdt_enable_key);
+DECLARE_STATIC_KEY_FALSE(rdt_mon_enable_key);
 
 /**
  * struct mon_evt - Entry in the event list of a resource
diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c
index 397206f..773124b 100644
--- a/arch/x86/kernel/cpu/resctrl/monitor.c
+++ b/arch/x86/kernel/cpu/resctrl/monitor.c
@@ -514,7 +514,7 @@ void mbm_handle_overflow(struct work_struct *work)
 
 	mutex_lock(&rdtgroup_mutex);
 
-	if (!static_branch_likely(&rdt_enable_key))
+	if (!static_branch_likely(&rdt_mon_enable_key))
 		goto out_unlock;
 
 	d = get_domain_from_cpu(cpu, &rdt_resources_all[RDT_RESOURCE_L3]);
@@ -543,7 +543,7 @@ void mbm_setup_overflow_handler(struct rdt_domain *dom, unsigned long delay_ms)
 	unsigned long delay = msecs_to_jiffies(delay_ms);
 	int cpu;
 
-	if (!static_branch_likely(&rdt_enable_key))
+	if (!static_branch_likely(&rdt_mon_enable_key))
 		return;
 	cpu = cpumask_any(&dom->cpu_mask);
 	dom->mbm_work_cpu = cpu;

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-01-17 18:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-11 17:41 [PATCH] x86/resctrl: Check monitoring static key in MBM overflow handler Xiaochen Shen
2019-12-11 19:18 ` Xiaochen Shen
2019-12-11 20:05 ` [PATCH RESEND] " Xiaochen Shen
2020-01-17 18:41   ` [tip: x86/cache] x86/resctrl: Check monitoring static key in the " tip-bot2 for Xiaochen Shen

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).