Message ID | 20230207051105.11575-15-ricardo.neri-calderon@linux.intel.com (mailing list archive) |
---|---|
State | Handled Elsewhere, archived |
Headers | show |
Series | sched: Introduce classes of tasks for load balance | expand |
On Tue, Feb 7, 2023 at 6:02 AM Ricardo Neri <ricardo.neri-calderon@linux.intel.com> wrote: > > Use Intel Thread Director classification to update the IPC class of a > task. Implement the arch_update_ipcc() interface of the scheduler. > > Cc: Ben Segall <bsegall@google.com> > Cc: Daniel Bristot de Oliveira <bristot@redhat.com> > Cc: Dietmar Eggemann <dietmar.eggemann@arm.com> > Cc: Ionela Voinescu <ionela.voinescu@arm.com> > Cc: Joel Fernandes (Google) <joel@joelfernandes.org> > Cc: Len Brown <len.brown@intel.com> > Cc: Lukasz Luba <lukasz.luba@arm.com> > Cc: Mel Gorman <mgorman@suse.de> > Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> > Cc: Steven Rostedt <rostedt@goodmis.org> > Cc: Tim C. Chen <tim.c.chen@intel.com> > Cc: Valentin Schneider <vschneid@redhat.com> > Cc: x86@kernel.org > Cc: linux-pm@vger.kernel.org > Cc: linux-kernel@vger.kernel.org > Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com> > --- > Changes since v2: > * Removed the implementation of arch_has_ipc_classes(). > > Changes since v1: > * Adjusted the result the classification of Intel Thread Director to start > at class 1. Class 0 for the scheduler means that the task is > unclassified. > * Redefined union hfi_thread_feedback_char_msr to ensure all > bit-fields are packed. (PeterZ) > * Removed CONFIG_INTEL_THREAD_DIRECTOR. (PeterZ) > * Shortened the names of the functions that implement IPC classes. > * Removed argument smt_siblings_idle from intel_hfi_update_ipcc(). > (PeterZ) > --- > arch/x86/include/asm/topology.h | 6 ++++++ > drivers/thermal/intel/intel_hfi.c | 32 +++++++++++++++++++++++++++++++ > 2 files changed, 38 insertions(+) > > diff --git a/arch/x86/include/asm/topology.h b/arch/x86/include/asm/topology.h > index 458c891a8273..ffcdac3f398f 100644 > --- a/arch/x86/include/asm/topology.h > +++ b/arch/x86/include/asm/topology.h > @@ -227,4 +227,10 @@ void init_freq_invariance_cppc(void); > #define arch_init_invariance_cppc init_freq_invariance_cppc > #endif > > +#if defined(CONFIG_IPC_CLASSES) && defined(CONFIG_INTEL_HFI_THERMAL) > +void intel_hfi_update_ipcc(struct task_struct *curr); > + > +#define arch_update_ipcc intel_hfi_update_ipcc > +#endif /* defined(CONFIG_IPC_CLASSES) && defined(CONFIG_INTEL_HFI_THERMAL) */ > + > #endif /* _ASM_X86_TOPOLOGY_H */ > diff --git a/drivers/thermal/intel/intel_hfi.c b/drivers/thermal/intel/intel_hfi.c > index b06021828892..530dcf57e06e 100644 > --- a/drivers/thermal/intel/intel_hfi.c > +++ b/drivers/thermal/intel/intel_hfi.c > @@ -72,6 +72,17 @@ union cpuid6_edx { > u32 full; > }; > > +#ifdef CONFIG_IPC_CLASSES > +union hfi_thread_feedback_char_msr { > + struct { > + u64 classid : 8; > + u64 __reserved : 55; > + u64 valid : 1; > + } split; > + u64 full; > +}; > +#endif > + > /** > * struct hfi_cpu_data - HFI capabilities per CPU > * @perf_cap: Performance capability > @@ -174,6 +185,27 @@ static struct workqueue_struct *hfi_updates_wq; > #ifdef CONFIG_IPC_CLASSES > static int __percpu *hfi_ipcc_scores; > > +void intel_hfi_update_ipcc(struct task_struct *curr) > +{ > + union hfi_thread_feedback_char_msr msr; > + > + /* We should not be here if ITD is not supported. */ > + if (!cpu_feature_enabled(X86_FEATURE_ITD)) { > + pr_warn_once("task classification requested but not supported!"); > + return; > + } > + > + rdmsrl(MSR_IA32_HW_FEEDBACK_CHAR, msr.full); > + if (!msr.split.valid) > + return; > + > + /* > + * 0 is a valid classification for Intel Thread Director. A scheduler > + * IPCC class of 0 means that the task is unclassified. Adjust. > + */ > + curr->ipcc = msr.split.classid + 1; > +} Wouldn't it be better to return the adjusted value from this function and let the caller store it where appropriate? It doesn't look like it is necessary to pass the task_struct pointer to it. > + > static int alloc_hfi_ipcc_scores(void) > { > if (!cpu_feature_enabled(X86_FEATURE_ITD)) > --
On Mon, Mar 27, 2023 at 06:42:28PM +0200, Rafael J. Wysocki wrote: > On Tue, Feb 7, 2023 at 6:02 AM Ricardo Neri > <ricardo.neri-calderon@linux.intel.com> wrote: > > > > Use Intel Thread Director classification to update the IPC class of a > > task. Implement the arch_update_ipcc() interface of the scheduler. > > > > Cc: Ben Segall <bsegall@google.com> > > Cc: Daniel Bristot de Oliveira <bristot@redhat.com> > > Cc: Dietmar Eggemann <dietmar.eggemann@arm.com> > > Cc: Ionela Voinescu <ionela.voinescu@arm.com> > > Cc: Joel Fernandes (Google) <joel@joelfernandes.org> > > Cc: Len Brown <len.brown@intel.com> > > Cc: Lukasz Luba <lukasz.luba@arm.com> > > Cc: Mel Gorman <mgorman@suse.de> > > Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > > Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> > > Cc: Steven Rostedt <rostedt@goodmis.org> > > Cc: Tim C. Chen <tim.c.chen@intel.com> > > Cc: Valentin Schneider <vschneid@redhat.com> > > Cc: x86@kernel.org > > Cc: linux-pm@vger.kernel.org > > Cc: linux-kernel@vger.kernel.org > > Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com> > > --- > > Changes since v2: > > * Removed the implementation of arch_has_ipc_classes(). > > > > Changes since v1: > > * Adjusted the result the classification of Intel Thread Director to start > > at class 1. Class 0 for the scheduler means that the task is > > unclassified. > > * Redefined union hfi_thread_feedback_char_msr to ensure all > > bit-fields are packed. (PeterZ) > > * Removed CONFIG_INTEL_THREAD_DIRECTOR. (PeterZ) > > * Shortened the names of the functions that implement IPC classes. > > * Removed argument smt_siblings_idle from intel_hfi_update_ipcc(). > > (PeterZ) > > --- > > arch/x86/include/asm/topology.h | 6 ++++++ > > drivers/thermal/intel/intel_hfi.c | 32 +++++++++++++++++++++++++++++++ > > 2 files changed, 38 insertions(+) > > > > diff --git a/arch/x86/include/asm/topology.h b/arch/x86/include/asm/topology.h > > index 458c891a8273..ffcdac3f398f 100644 > > --- a/arch/x86/include/asm/topology.h > > +++ b/arch/x86/include/asm/topology.h > > @@ -227,4 +227,10 @@ void init_freq_invariance_cppc(void); > > #define arch_init_invariance_cppc init_freq_invariance_cppc > > #endif > > > > +#if defined(CONFIG_IPC_CLASSES) && defined(CONFIG_INTEL_HFI_THERMAL) > > +void intel_hfi_update_ipcc(struct task_struct *curr); > > + > > +#define arch_update_ipcc intel_hfi_update_ipcc > > +#endif /* defined(CONFIG_IPC_CLASSES) && defined(CONFIG_INTEL_HFI_THERMAL) */ > > + > > #endif /* _ASM_X86_TOPOLOGY_H */ > > diff --git a/drivers/thermal/intel/intel_hfi.c b/drivers/thermal/intel/intel_hfi.c > > index b06021828892..530dcf57e06e 100644 > > --- a/drivers/thermal/intel/intel_hfi.c > > +++ b/drivers/thermal/intel/intel_hfi.c > > @@ -72,6 +72,17 @@ union cpuid6_edx { > > u32 full; > > }; > > > > +#ifdef CONFIG_IPC_CLASSES > > +union hfi_thread_feedback_char_msr { > > + struct { > > + u64 classid : 8; > > + u64 __reserved : 55; > > + u64 valid : 1; > > + } split; > > + u64 full; > > +}; > > +#endif > > + > > /** > > * struct hfi_cpu_data - HFI capabilities per CPU > > * @perf_cap: Performance capability > > @@ -174,6 +185,27 @@ static struct workqueue_struct *hfi_updates_wq; > > #ifdef CONFIG_IPC_CLASSES > > static int __percpu *hfi_ipcc_scores; > > > > +void intel_hfi_update_ipcc(struct task_struct *curr) > > +{ > > + union hfi_thread_feedback_char_msr msr; > > + > > + /* We should not be here if ITD is not supported. */ > > + if (!cpu_feature_enabled(X86_FEATURE_ITD)) { > > + pr_warn_once("task classification requested but not supported!"); > > + return; > > + } > > + > > + rdmsrl(MSR_IA32_HW_FEEDBACK_CHAR, msr.full); > > + if (!msr.split.valid) > > + return; > > + > > + /* > > + * 0 is a valid classification for Intel Thread Director. A scheduler > > + * IPCC class of 0 means that the task is unclassified. Adjust. > > + */ > > + curr->ipcc = msr.split.classid + 1; > > +} > > Wouldn't it be better to return the adjusted value from this function > and let the caller store it where appropriate? > > It doesn't look like it is necessary to pass the task_struct pointer to it. Judging from this patch alone, yes, it does not make much sense to pass a task_struct as argument. In patch 21, however, this function uses various members of task_struct and makes it more convenient to have it as argument, no? > > > + > > static int alloc_hfi_ipcc_scores(void) > > { > > if (!cpu_feature_enabled(X86_FEATURE_ITD)) > > --
On Wed, Mar 29, 2023 at 1:31 AM Ricardo Neri <ricardo.neri-calderon@linux.intel.com> wrote: > > On Mon, Mar 27, 2023 at 06:42:28PM +0200, Rafael J. Wysocki wrote: > > On Tue, Feb 7, 2023 at 6:02 AM Ricardo Neri > > <ricardo.neri-calderon@linux.intel.com> wrote: > > > > > > Use Intel Thread Director classification to update the IPC class of a > > > task. Implement the arch_update_ipcc() interface of the scheduler. > > > > > > Cc: Ben Segall <bsegall@google.com> > > > Cc: Daniel Bristot de Oliveira <bristot@redhat.com> > > > Cc: Dietmar Eggemann <dietmar.eggemann@arm.com> > > > Cc: Ionela Voinescu <ionela.voinescu@arm.com> > > > Cc: Joel Fernandes (Google) <joel@joelfernandes.org> > > > Cc: Len Brown <len.brown@intel.com> > > > Cc: Lukasz Luba <lukasz.luba@arm.com> > > > Cc: Mel Gorman <mgorman@suse.de> > > > Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > > > Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> > > > Cc: Steven Rostedt <rostedt@goodmis.org> > > > Cc: Tim C. Chen <tim.c.chen@intel.com> > > > Cc: Valentin Schneider <vschneid@redhat.com> > > > Cc: x86@kernel.org > > > Cc: linux-pm@vger.kernel.org > > > Cc: linux-kernel@vger.kernel.org > > > Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com> > > > --- > > > Changes since v2: > > > * Removed the implementation of arch_has_ipc_classes(). > > > > > > Changes since v1: > > > * Adjusted the result the classification of Intel Thread Director to start > > > at class 1. Class 0 for the scheduler means that the task is > > > unclassified. > > > * Redefined union hfi_thread_feedback_char_msr to ensure all > > > bit-fields are packed. (PeterZ) > > > * Removed CONFIG_INTEL_THREAD_DIRECTOR. (PeterZ) > > > * Shortened the names of the functions that implement IPC classes. > > > * Removed argument smt_siblings_idle from intel_hfi_update_ipcc(). > > > (PeterZ) > > > --- > > > arch/x86/include/asm/topology.h | 6 ++++++ > > > drivers/thermal/intel/intel_hfi.c | 32 +++++++++++++++++++++++++++++++ > > > 2 files changed, 38 insertions(+) > > > > > > diff --git a/arch/x86/include/asm/topology.h b/arch/x86/include/asm/topology.h > > > index 458c891a8273..ffcdac3f398f 100644 > > > --- a/arch/x86/include/asm/topology.h > > > +++ b/arch/x86/include/asm/topology.h > > > @@ -227,4 +227,10 @@ void init_freq_invariance_cppc(void); > > > #define arch_init_invariance_cppc init_freq_invariance_cppc > > > #endif > > > > > > +#if defined(CONFIG_IPC_CLASSES) && defined(CONFIG_INTEL_HFI_THERMAL) > > > +void intel_hfi_update_ipcc(struct task_struct *curr); > > > + > > > +#define arch_update_ipcc intel_hfi_update_ipcc > > > +#endif /* defined(CONFIG_IPC_CLASSES) && defined(CONFIG_INTEL_HFI_THERMAL) */ > > > + > > > #endif /* _ASM_X86_TOPOLOGY_H */ > > > diff --git a/drivers/thermal/intel/intel_hfi.c b/drivers/thermal/intel/intel_hfi.c > > > index b06021828892..530dcf57e06e 100644 > > > --- a/drivers/thermal/intel/intel_hfi.c > > > +++ b/drivers/thermal/intel/intel_hfi.c > > > @@ -72,6 +72,17 @@ union cpuid6_edx { > > > u32 full; > > > }; > > > > > > +#ifdef CONFIG_IPC_CLASSES > > > +union hfi_thread_feedback_char_msr { > > > + struct { > > > + u64 classid : 8; > > > + u64 __reserved : 55; > > > + u64 valid : 1; > > > + } split; > > > + u64 full; > > > +}; > > > +#endif > > > + > > > /** > > > * struct hfi_cpu_data - HFI capabilities per CPU > > > * @perf_cap: Performance capability > > > @@ -174,6 +185,27 @@ static struct workqueue_struct *hfi_updates_wq; > > > #ifdef CONFIG_IPC_CLASSES > > > static int __percpu *hfi_ipcc_scores; > > > > > > +void intel_hfi_update_ipcc(struct task_struct *curr) > > > +{ > > > + union hfi_thread_feedback_char_msr msr; > > > + > > > + /* We should not be here if ITD is not supported. */ > > > + if (!cpu_feature_enabled(X86_FEATURE_ITD)) { > > > + pr_warn_once("task classification requested but not supported!"); > > > + return; > > > + } > > > + > > > + rdmsrl(MSR_IA32_HW_FEEDBACK_CHAR, msr.full); > > > + if (!msr.split.valid) > > > + return; > > > + > > > + /* > > > + * 0 is a valid classification for Intel Thread Director. A scheduler > > > + * IPCC class of 0 means that the task is unclassified. Adjust. > > > + */ > > > + curr->ipcc = msr.split.classid + 1; > > > +} > > > > Wouldn't it be better to return the adjusted value from this function > > and let the caller store it where appropriate? > > > > It doesn't look like it is necessary to pass the task_struct pointer to it. > > Judging from this patch alone, yes, it does not make much sense to pass a > task_struct as argument. In patch 21, however, this function uses various > members of task_struct and makes it more convenient to have it as argument, > no? I'm not convinced about this, but anyway it is better to combine the two patches in such cases IMO. The way it is done now confuses things from my perspective. > > > > > + > > > static int alloc_hfi_ipcc_scores(void) > > > { > > > if (!cpu_feature_enabled(X86_FEATURE_ITD)) > > > --
On Wed, Mar 29, 2023 at 02:13:29PM +0200, Rafael J. Wysocki wrote: > On Wed, Mar 29, 2023 at 1:31 AM Ricardo Neri > <ricardo.neri-calderon@linux.intel.com> wrote: > > > > On Mon, Mar 27, 2023 at 06:42:28PM +0200, Rafael J. Wysocki wrote: > > > On Tue, Feb 7, 2023 at 6:02 AM Ricardo Neri > > > <ricardo.neri-calderon@linux.intel.com> wrote: > > > > > > > > Use Intel Thread Director classification to update the IPC class of a > > > > task. Implement the arch_update_ipcc() interface of the scheduler. > > > > > > > > Cc: Ben Segall <bsegall@google.com> > > > > Cc: Daniel Bristot de Oliveira <bristot@redhat.com> > > > > Cc: Dietmar Eggemann <dietmar.eggemann@arm.com> > > > > Cc: Ionela Voinescu <ionela.voinescu@arm.com> > > > > Cc: Joel Fernandes (Google) <joel@joelfernandes.org> > > > > Cc: Len Brown <len.brown@intel.com> > > > > Cc: Lukasz Luba <lukasz.luba@arm.com> > > > > Cc: Mel Gorman <mgorman@suse.de> > > > > Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > > > > Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> > > > > Cc: Steven Rostedt <rostedt@goodmis.org> > > > > Cc: Tim C. Chen <tim.c.chen@intel.com> > > > > Cc: Valentin Schneider <vschneid@redhat.com> > > > > Cc: x86@kernel.org > > > > Cc: linux-pm@vger.kernel.org > > > > Cc: linux-kernel@vger.kernel.org > > > > Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com> > > > > --- > > > > Changes since v2: > > > > * Removed the implementation of arch_has_ipc_classes(). > > > > > > > > Changes since v1: > > > > * Adjusted the result the classification of Intel Thread Director to start > > > > at class 1. Class 0 for the scheduler means that the task is > > > > unclassified. > > > > * Redefined union hfi_thread_feedback_char_msr to ensure all > > > > bit-fields are packed. (PeterZ) > > > > * Removed CONFIG_INTEL_THREAD_DIRECTOR. (PeterZ) > > > > * Shortened the names of the functions that implement IPC classes. > > > > * Removed argument smt_siblings_idle from intel_hfi_update_ipcc(). > > > > (PeterZ) > > > > --- > > > > arch/x86/include/asm/topology.h | 6 ++++++ > > > > drivers/thermal/intel/intel_hfi.c | 32 +++++++++++++++++++++++++++++++ > > > > 2 files changed, 38 insertions(+) > > > > > > > > diff --git a/arch/x86/include/asm/topology.h b/arch/x86/include/asm/topology.h > > > > index 458c891a8273..ffcdac3f398f 100644 > > > > --- a/arch/x86/include/asm/topology.h > > > > +++ b/arch/x86/include/asm/topology.h > > > > @@ -227,4 +227,10 @@ void init_freq_invariance_cppc(void); > > > > #define arch_init_invariance_cppc init_freq_invariance_cppc > > > > #endif > > > > > > > > +#if defined(CONFIG_IPC_CLASSES) && defined(CONFIG_INTEL_HFI_THERMAL) > > > > +void intel_hfi_update_ipcc(struct task_struct *curr); > > > > + > > > > +#define arch_update_ipcc intel_hfi_update_ipcc > > > > +#endif /* defined(CONFIG_IPC_CLASSES) && defined(CONFIG_INTEL_HFI_THERMAL) */ > > > > + > > > > #endif /* _ASM_X86_TOPOLOGY_H */ > > > > diff --git a/drivers/thermal/intel/intel_hfi.c b/drivers/thermal/intel/intel_hfi.c > > > > index b06021828892..530dcf57e06e 100644 > > > > --- a/drivers/thermal/intel/intel_hfi.c > > > > +++ b/drivers/thermal/intel/intel_hfi.c > > > > @@ -72,6 +72,17 @@ union cpuid6_edx { > > > > u32 full; > > > > }; > > > > > > > > +#ifdef CONFIG_IPC_CLASSES > > > > +union hfi_thread_feedback_char_msr { > > > > + struct { > > > > + u64 classid : 8; > > > > + u64 __reserved : 55; > > > > + u64 valid : 1; > > > > + } split; > > > > + u64 full; > > > > +}; > > > > +#endif > > > > + > > > > /** > > > > * struct hfi_cpu_data - HFI capabilities per CPU > > > > * @perf_cap: Performance capability > > > > @@ -174,6 +185,27 @@ static struct workqueue_struct *hfi_updates_wq; > > > > #ifdef CONFIG_IPC_CLASSES > > > > static int __percpu *hfi_ipcc_scores; > > > > > > > > +void intel_hfi_update_ipcc(struct task_struct *curr) > > > > +{ > > > > + union hfi_thread_feedback_char_msr msr; > > > > + > > > > + /* We should not be here if ITD is not supported. */ > > > > + if (!cpu_feature_enabled(X86_FEATURE_ITD)) { > > > > + pr_warn_once("task classification requested but not supported!"); > > > > + return; > > > > + } > > > > + > > > > + rdmsrl(MSR_IA32_HW_FEEDBACK_CHAR, msr.full); > > > > + if (!msr.split.valid) > > > > + return; > > > > + > > > > + /* > > > > + * 0 is a valid classification for Intel Thread Director. A scheduler > > > > + * IPCC class of 0 means that the task is unclassified. Adjust. > > > > + */ > > > > + curr->ipcc = msr.split.classid + 1; > > > > +} > > > > > > Wouldn't it be better to return the adjusted value from this function > > > and let the caller store it where appropriate? > > > > > > It doesn't look like it is necessary to pass the task_struct pointer to it. > > > > Judging from this patch alone, yes, it does not make much sense to pass a > > task_struct as argument. In patch 21, however, this function uses various > > members of task_struct and makes it more convenient to have it as argument, > > no? > > I'm not convinced about this, but anyway it is better to combine the > two patches in such cases IMO. > > The way it is done now confuses things from my perspective. Right, I structured the patchset to have the additions to task_struct in separate patches. This made it less clear for intel_hfi.c Would it be acceptable if I kept void intel_hfi_update_ipcc(struct task_struct *curr) and added a static function u32 intel_hfi_get_ipcc(void) to return the hardware classification? Otherwise, I would need to add three different accessors for task_struct so that the HFI driver can retrieve the auxiliary members from patch 21. Thanks and BR, Ricardo
diff --git a/arch/x86/include/asm/topology.h b/arch/x86/include/asm/topology.h index 458c891a8273..ffcdac3f398f 100644 --- a/arch/x86/include/asm/topology.h +++ b/arch/x86/include/asm/topology.h @@ -227,4 +227,10 @@ void init_freq_invariance_cppc(void); #define arch_init_invariance_cppc init_freq_invariance_cppc #endif +#if defined(CONFIG_IPC_CLASSES) && defined(CONFIG_INTEL_HFI_THERMAL) +void intel_hfi_update_ipcc(struct task_struct *curr); + +#define arch_update_ipcc intel_hfi_update_ipcc +#endif /* defined(CONFIG_IPC_CLASSES) && defined(CONFIG_INTEL_HFI_THERMAL) */ + #endif /* _ASM_X86_TOPOLOGY_H */ diff --git a/drivers/thermal/intel/intel_hfi.c b/drivers/thermal/intel/intel_hfi.c index b06021828892..530dcf57e06e 100644 --- a/drivers/thermal/intel/intel_hfi.c +++ b/drivers/thermal/intel/intel_hfi.c @@ -72,6 +72,17 @@ union cpuid6_edx { u32 full; }; +#ifdef CONFIG_IPC_CLASSES +union hfi_thread_feedback_char_msr { + struct { + u64 classid : 8; + u64 __reserved : 55; + u64 valid : 1; + } split; + u64 full; +}; +#endif + /** * struct hfi_cpu_data - HFI capabilities per CPU * @perf_cap: Performance capability @@ -174,6 +185,27 @@ static struct workqueue_struct *hfi_updates_wq; #ifdef CONFIG_IPC_CLASSES static int __percpu *hfi_ipcc_scores; +void intel_hfi_update_ipcc(struct task_struct *curr) +{ + union hfi_thread_feedback_char_msr msr; + + /* We should not be here if ITD is not supported. */ + if (!cpu_feature_enabled(X86_FEATURE_ITD)) { + pr_warn_once("task classification requested but not supported!"); + return; + } + + rdmsrl(MSR_IA32_HW_FEEDBACK_CHAR, msr.full); + if (!msr.split.valid) + return; + + /* + * 0 is a valid classification for Intel Thread Director. A scheduler + * IPCC class of 0 means that the task is unclassified. Adjust. + */ + curr->ipcc = msr.split.classid + 1; +} + static int alloc_hfi_ipcc_scores(void) { if (!cpu_feature_enabled(X86_FEATURE_ITD))
Use Intel Thread Director classification to update the IPC class of a task. Implement the arch_update_ipcc() interface of the scheduler. Cc: Ben Segall <bsegall@google.com> Cc: Daniel Bristot de Oliveira <bristot@redhat.com> Cc: Dietmar Eggemann <dietmar.eggemann@arm.com> Cc: Ionela Voinescu <ionela.voinescu@arm.com> Cc: Joel Fernandes (Google) <joel@joelfernandes.org> Cc: Len Brown <len.brown@intel.com> Cc: Lukasz Luba <lukasz.luba@arm.com> Cc: Mel Gorman <mgorman@suse.de> Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Tim C. Chen <tim.c.chen@intel.com> Cc: Valentin Schneider <vschneid@redhat.com> Cc: x86@kernel.org Cc: linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com> --- Changes since v2: * Removed the implementation of arch_has_ipc_classes(). Changes since v1: * Adjusted the result the classification of Intel Thread Director to start at class 1. Class 0 for the scheduler means that the task is unclassified. * Redefined union hfi_thread_feedback_char_msr to ensure all bit-fields are packed. (PeterZ) * Removed CONFIG_INTEL_THREAD_DIRECTOR. (PeterZ) * Shortened the names of the functions that implement IPC classes. * Removed argument smt_siblings_idle from intel_hfi_update_ipcc(). (PeterZ) --- arch/x86/include/asm/topology.h | 6 ++++++ drivers/thermal/intel/intel_hfi.c | 32 +++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+)