Re: [PATCH v21 14/18] x86/resctrl: Fill out rmid_read structure for smp_call*() to read a counter
From: Tony Luck
Date: Wed Jun 26 2024 - 15:35:11 EST
> > diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c
> > index ff4e74594a19..877d898e8fd0 100644
> > --- a/arch/x86/kernel/cpu/resctrl/monitor.c
> > +++ b/arch/x86/kernel/cpu/resctrl/monitor.c
> > @@ -785,6 +785,7 @@ static void mbm_update(struct rdt_resource *r, struct rdt_mon_domain *d,
> > rr.first = false;
> > rr.r = r;
> > rr.d = d;
> > + rr.ci = NULL;
>
> This keeps using a struct rmid_read with random data from stack and initialize members based on
> knowledge about how the called functions use this struct. Could you please add initialization to
> all these places that use struct rmid_read with whatever is on the stack? This includes
> mon_add_all_files() introduced in this series.
> Something like below should do (in mon_add_all_files() - done as part of patch 10, mbm_update(),
> and mon_add_all_files():
> struct rmid_read rr = {0};
I'm making that change to the three places that struct rmid_read
is defined as a local variable.
Should I also remove "useless" assignments now that the structure
is zeroed by the compiler. I.e. in the above snip the rr.first = false;
and rr.ci = NULL;
I suspect there are others.
Or do they serve as useful hints to human readers of the code?
-Tony