[v9,06/13] x86/resctrl: Add __init attribute to rdt_get_mon_l3_config()

Message ID 166990900117.17806.4506067708943298894.stgit@bmoger-ubuntu
State New
Headers
Series Support for AMD QoS new features |

Commit Message

Moger, Babu Dec. 1, 2022, 3:36 p.m. UTC
  The function rdt_get_mon_l3_config() needs to call rdt_cpu_has() to
query the monitor related features. It cannot be called right now
because rdt_cpu_has() has the __init attribute but rdt_get_mon_l3_config()
doesn't. So, add the __init attribute to rdt_get_mon_l3_config() to
resolve it.

Also, make the function rdt_cpu_has() available outside core.c file.

Signed-off-by: Babu Moger <babu.moger@amd.com>
---
 arch/x86/kernel/cpu/resctrl/core.c     |    2 +-
 arch/x86/kernel/cpu/resctrl/internal.h |    1 +
 arch/x86/kernel/cpu/resctrl/monitor.c  |    2 +-
 3 files changed, 3 insertions(+), 2 deletions(-)
  

Comments

Reinette Chatre Dec. 15, 2022, 5:17 p.m. UTC | #1
Hi Babu,

On 12/1/2022 7:36 AM, Babu Moger wrote:
> The function rdt_get_mon_l3_config() needs to call rdt_cpu_has() to

No need to say "The function" ... by using () after a name it is clear
that it is a function.

To support this change it could perhaps be:
"In an upcoming change rdt_get_mon_l3_config() needs to call
rdt_cpu_has() to ..."

> query the monitor related features. It cannot be called right now
> because rdt_cpu_has() has the __init attribute but rdt_get_mon_l3_config()
> doesn't. So, add the __init attribute to rdt_get_mon_l3_config() to
> resolve it.

Please place the solution description in a new paragraph and drop the "So,".
The description could also be expanded to support this change. For example:

"Add the __init attribute to rdt_get_mon_l3_config() that is only called
by get_rdt_mon_resources() that already has the __init attribute. Also
make rdt_cpu_has() available to by rdt_get_mon_l3_config() via
the internal header file."


> 
> Also, make the function rdt_cpu_has() available outside core.c file.
> 
> Signed-off-by: Babu Moger <babu.moger@amd.com>
> ---
>  arch/x86/kernel/cpu/resctrl/core.c     |    2 +-
>  arch/x86/kernel/cpu/resctrl/internal.h |    1 +
>  arch/x86/kernel/cpu/resctrl/monitor.c  |    2 +-
>  3 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c
> index b4fc851f6489..030d3b409768 100644
> --- a/arch/x86/kernel/cpu/resctrl/core.c
> +++ b/arch/x86/kernel/cpu/resctrl/core.c
> @@ -728,7 +728,7 @@ static int __init set_rdt_options(char *str)
>  }
>  __setup("rdt", set_rdt_options);
>  
> -static bool __init rdt_cpu_has(int flag)
> +bool __init rdt_cpu_has(int flag)
>  {
>  	bool ret = boot_cpu_has(flag);
>  	struct rdt_options *o;
> diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h
> index fdbbf66312ec..7bbfc10094b6 100644
> --- a/arch/x86/kernel/cpu/resctrl/internal.h
> +++ b/arch/x86/kernel/cpu/resctrl/internal.h
> @@ -512,6 +512,7 @@ void closid_free(int closid);
>  int alloc_rmid(void);
>  void free_rmid(u32 rmid);
>  int rdt_get_mon_l3_config(struct rdt_resource *r);
> +bool rdt_cpu_has(int flag);

Please also add __init attribute here by using the same style as the other functions
in this file that need __init.

>  void mon_event_count(void *info);
>  int rdtgroup_mondata_show(struct seq_file *m, void *arg);
>  void mon_event_read(struct rmid_read *rr, struct rdt_resource *r,
> diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c
> index efe0c30d3a12..e33e8d8bd796 100644
> --- a/arch/x86/kernel/cpu/resctrl/monitor.c
> +++ b/arch/x86/kernel/cpu/resctrl/monitor.c
> @@ -746,7 +746,7 @@ static void l3_mon_evt_init(struct rdt_resource *r)
>  		list_add_tail(&mbm_local_event.list, &r->evt_list);
>  }
>  
> -int rdt_get_mon_l3_config(struct rdt_resource *r)
> +int __init rdt_get_mon_l3_config(struct rdt_resource *r)
>  {
>  	unsigned int mbm_offset = boot_cpu_data.x86_cache_mbm_width_offset;
>  	struct rdt_hw_resource *hw_res = resctrl_to_arch_res(r);
> 
> 

Thank you

Reinette
  
Moger, Babu Dec. 19, 2022, 3:51 p.m. UTC | #2
[AMD Official Use Only - General]

Hi Reinette,

> -----Original Message-----
> From: Reinette Chatre <reinette.chatre@intel.com>
> Sent: Thursday, December 15, 2022 11:17 AM
> To: Moger, Babu <Babu.Moger@amd.com>; corbet@lwn.net;
> tglx@linutronix.de; mingo@redhat.com; bp@alien8.de
> Cc: fenghua.yu@intel.com; dave.hansen@linux.intel.com; x86@kernel.org;
> hpa@zytor.com; paulmck@kernel.org; akpm@linux-foundation.org;
> quic_neeraju@quicinc.com; rdunlap@infradead.org;
> damien.lemoal@opensource.wdc.com; songmuchun@bytedance.com;
> peterz@infradead.org; jpoimboe@kernel.org; pbonzini@redhat.com;
> chang.seok.bae@intel.com; pawan.kumar.gupta@linux.intel.com;
> jmattson@google.com; daniel.sneddon@linux.intel.com; Das1, Sandipan
> <Sandipan.Das@amd.com>; tony.luck@intel.com; james.morse@arm.com;
> linux-doc@vger.kernel.org; linux-kernel@vger.kernel.org;
> bagasdotme@gmail.com; eranian@google.com; christophe.leroy@csgroup.eu;
> jarkko@kernel.org; adrian.hunter@intel.com; quic_jiles@quicinc.com;
> peternewman@google.com
> Subject: Re: [PATCH v9 06/13] x86/resctrl: Add __init attribute to
> rdt_get_mon_l3_config()
> 
> Hi Babu,
> 
> On 12/1/2022 7:36 AM, Babu Moger wrote:
> > The function rdt_get_mon_l3_config() needs to call rdt_cpu_has() to
> 
> No need to say "The function" ... by using () after a name it is clear that it is a
> function.

Ok
> 
> To support this change it could perhaps be:
> "In an upcoming change rdt_get_mon_l3_config() needs to call
> rdt_cpu_has() to ..."

Sure.
> 
> > query the monitor related features. It cannot be called right now
> > because rdt_cpu_has() has the __init attribute but
> > rdt_get_mon_l3_config() doesn't. So, add the __init attribute to
> > rdt_get_mon_l3_config() to resolve it.
> 
> Please place the solution description in a new paragraph and drop the "So,".
> The description could also be expanded to support this change. For example:
> 
> "Add the __init attribute to rdt_get_mon_l3_config() that is only called by
> get_rdt_mon_resources() that already has the __init attribute. Also make
> rdt_cpu_has() available to by rdt_get_mon_l3_config() via the internal header
> file."
> 
Sure.
> 
> >
> > Also, make the function rdt_cpu_has() available outside core.c file.
> >
> > Signed-off-by: Babu Moger <babu.moger@amd.com>
> > ---
> >  arch/x86/kernel/cpu/resctrl/core.c     |    2 +-
> >  arch/x86/kernel/cpu/resctrl/internal.h |    1 +
> >  arch/x86/kernel/cpu/resctrl/monitor.c  |    2 +-
> >  3 files changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/arch/x86/kernel/cpu/resctrl/core.c
> > b/arch/x86/kernel/cpu/resctrl/core.c
> > index b4fc851f6489..030d3b409768 100644
> > --- a/arch/x86/kernel/cpu/resctrl/core.c
> > +++ b/arch/x86/kernel/cpu/resctrl/core.c
> > @@ -728,7 +728,7 @@ static int __init set_rdt_options(char *str)  }
> > __setup("rdt", set_rdt_options);
> >
> > -static bool __init rdt_cpu_has(int flag)
> > +bool __init rdt_cpu_has(int flag)
> >  {
> >  	bool ret = boot_cpu_has(flag);
> >  	struct rdt_options *o;
> > diff --git a/arch/x86/kernel/cpu/resctrl/internal.h
> > b/arch/x86/kernel/cpu/resctrl/internal.h
> > index fdbbf66312ec..7bbfc10094b6 100644
> > --- a/arch/x86/kernel/cpu/resctrl/internal.h
> > +++ b/arch/x86/kernel/cpu/resctrl/internal.h
> > @@ -512,6 +512,7 @@ void closid_free(int closid);  int
> > alloc_rmid(void);  void free_rmid(u32 rmid);  int
> > rdt_get_mon_l3_config(struct rdt_resource *r);
> > +bool rdt_cpu_has(int flag);
> 
> Please also add __init attribute here by using the same style as the other
> functions in this file that need __init.
Ok
Thanks
Babu
> 
> >  void mon_event_count(void *info);
> >  int rdtgroup_mondata_show(struct seq_file *m, void *arg);  void
> > mon_event_read(struct rmid_read *rr, struct rdt_resource *r, diff
> > --git a/arch/x86/kernel/cpu/resctrl/monitor.c
> > b/arch/x86/kernel/cpu/resctrl/monitor.c
> > index efe0c30d3a12..e33e8d8bd796 100644
> > --- a/arch/x86/kernel/cpu/resctrl/monitor.c
> > +++ b/arch/x86/kernel/cpu/resctrl/monitor.c
> > @@ -746,7 +746,7 @@ static void l3_mon_evt_init(struct rdt_resource *r)
> >  		list_add_tail(&mbm_local_event.list, &r->evt_list);  }
> >
> > -int rdt_get_mon_l3_config(struct rdt_resource *r)
> > +int __init rdt_get_mon_l3_config(struct rdt_resource *r)
> >  {
> >  	unsigned int mbm_offset =
> boot_cpu_data.x86_cache_mbm_width_offset;
> >  	struct rdt_hw_resource *hw_res = resctrl_to_arch_res(r);
> >
> >
> 
> Thank you
> 
> Reinette
  

Patch

diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c
index b4fc851f6489..030d3b409768 100644
--- a/arch/x86/kernel/cpu/resctrl/core.c
+++ b/arch/x86/kernel/cpu/resctrl/core.c
@@ -728,7 +728,7 @@  static int __init set_rdt_options(char *str)
 }
 __setup("rdt", set_rdt_options);
 
-static bool __init rdt_cpu_has(int flag)
+bool __init rdt_cpu_has(int flag)
 {
 	bool ret = boot_cpu_has(flag);
 	struct rdt_options *o;
diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h
index fdbbf66312ec..7bbfc10094b6 100644
--- a/arch/x86/kernel/cpu/resctrl/internal.h
+++ b/arch/x86/kernel/cpu/resctrl/internal.h
@@ -512,6 +512,7 @@  void closid_free(int closid);
 int alloc_rmid(void);
 void free_rmid(u32 rmid);
 int rdt_get_mon_l3_config(struct rdt_resource *r);
+bool rdt_cpu_has(int flag);
 void mon_event_count(void *info);
 int rdtgroup_mondata_show(struct seq_file *m, void *arg);
 void mon_event_read(struct rmid_read *rr, struct rdt_resource *r,
diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c
index efe0c30d3a12..e33e8d8bd796 100644
--- a/arch/x86/kernel/cpu/resctrl/monitor.c
+++ b/arch/x86/kernel/cpu/resctrl/monitor.c
@@ -746,7 +746,7 @@  static void l3_mon_evt_init(struct rdt_resource *r)
 		list_add_tail(&mbm_local_event.list, &r->evt_list);
 }
 
-int rdt_get_mon_l3_config(struct rdt_resource *r)
+int __init rdt_get_mon_l3_config(struct rdt_resource *r)
 {
 	unsigned int mbm_offset = boot_cpu_data.x86_cache_mbm_width_offset;
 	struct rdt_hw_resource *hw_res = resctrl_to_arch_res(r);