[Public] > -----Original Message----- > From: Jan Beulich <jbeul...@suse.com> > Sent: Monday, May 12, 2025 11:45 PM > To: Penny, Zheng <penny.zh...@amd.com> > Cc: Huang, Ray <ray.hu...@amd.com>; Andrew Cooper > <andrew.coop...@citrix.com>; Anthony PERARD <anthony.per...@vates.tech>; > Orzel, Michal <michal.or...@amd.com>; Julien Grall <jul...@xen.org>; Roger Pau > Monné <roger....@citrix.com>; Stefano Stabellini <sstabell...@kernel.org>; > xen- > de...@lists.xenproject.org > Subject: Re: [PATCH v4 02/15] xen/cpufreq: extract _PSD info from "struct > xen_processor_performance" > > On 06.05.2025 09:22, Penny, Zheng wrote: > >> -----Original Message----- > >> From: Jan Beulich <jbeul...@suse.com> > >> Sent: Monday, April 28, 2025 11:32 PM > >> > >> On 14.04.2025 09:40, Penny Zheng wrote: > >>> --- a/xen/drivers/cpufreq/cpufreq.c > >>> +++ b/xen/drivers/cpufreq/cpufreq.c > >>> + { > >>> + case XEN_PX_INIT: > >>> + if ( shared_type ) > >>> + *shared_type = processor_pminfo[cpu]->perf.shared_type; > >>> + if ( domain_info ) > >>> + *domain_info = processor_pminfo[cpu]->perf.domain_info; > >> > >> Does this need to be a structure copy? Can't you hand back just a > >> pointer, with the function parameter being const struct xen_psd_package **? > >> > > > > I've considered handing backing a pointer, then maybe we need to > > allocate space for "struct xen_psd_package **domain_info = > > xvzalloc(struct xen_psd_package *);", and XVFREE(xxx) it in each exit, > especially cpufreq_add_cpu() has a lot exits, which could be a few code churn. > > So I chose the struct copy to have the smallest change. > > I fear I don't see why such allocations (of space holding a single pointer) > would be > necessary. Afaict all you need is a local variable of the specific > (pointer) type, the address of which you pass into here. >
``` struct xen_psd_package *domain_info; struct xen_psd_package **domain_info_ptr = &domain_info; ``` Oh, right, I could create a local variable to avoid nullptr initialization. > Jan