qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Like Xu <like.xu@linux.intel.com>
To: Igor Mammedov <imammedo@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>,
	qemu-trivial@nongnu.org, qemu-devel@nongnu.org,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
	like.xu@intel.com, Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 2/9] cpu/topology: add general support for machine properties
Date: Tue, 30 Apr 2019 15:30:31 +0800	[thread overview]
Message-ID: <a765e3ac-45e6-310e-aa66-7036b5717a26@linux.intel.com> (raw)
In-Reply-To: <20190404162555.0a2267ee@redhat.com>

On 2019/4/4 22:25, Igor Mammedov wrote:
> On Fri, 29 Mar 2019 16:48:38 +0800
> Like Xu <like.xu@linux.intel.com> wrote:
> 

<snipp>
> 
>> diff --git a/cpus.c b/cpus.c
>> index e83f72b..834a697 100644
>> --- a/cpus.c
>> +++ b/cpus.c
>> @@ -2067,6 +2067,10 @@ static void qemu_dummy_start_vcpu(CPUState *cpu)
>>   
>>   void qemu_init_vcpu(CPUState *cpu)
>>   {
>> +    MachineState *ms = MACHINE(qdev_get_machine());
>> +    unsigned int smp_cores = ms->topo.smp_cores;
>> +    unsigned int smp_threads = ms->topo.smp_threads;
> 
> (***)
> for once it probably will crash *-user builds
> and secondly the purpose of getting rid of smp_foo globals
> is disentangle layer violations and not replace it with another global
> (qdev_get_machine()).

I am happy to follow this rule on cpu-topo refactoring work, but 
sometimes calling qdev_get_machine() is inevitable.

> 
> What should be done is to make a properties of nr_cores/nr_threads and set
> them from the parent object that creates CPUs. The point is CPUs shouldn't
> reach out outside itself to fish out data bits it needs, it's responsibility
> of creator to feed to being create CPU needed properties.
> 
> This kind of refactoring probably deserves its own series and should precede
> -smp refactoring as it doesn't depend on CpuTopology at all.
> 

The division of responsibility for this case (refactoring 
qemu_init_vcpu) seems to be a poisonous apple.

The prerequisite for setting cpu-> nr_cores / nr_threads from the parent 
is that the CPU has been created, so if any process during 
initialization needs this topo information, it will use the default 
values form cpu_common_initfn() instead of user-configured parameters.

We may not want to repeat those assignment operations using the new 
values and what do you think, Igor?

<snipp>

WARNING: multiple messages have this Message-ID (diff)
From: Like Xu <like.xu@linux.intel.com>
To: Igor Mammedov <imammedo@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>,
	qemu-trivial@nongnu.org,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
	qemu-devel@nongnu.org, like.xu@intel.com,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 2/9] cpu/topology: add general support for machine properties
Date: Tue, 30 Apr 2019 15:30:31 +0800	[thread overview]
Message-ID: <a765e3ac-45e6-310e-aa66-7036b5717a26@linux.intel.com> (raw)
Message-ID: <20190430073031.aU3xkZWN3GH9ZbncSf9imNBVk3XmBQC5s7SF7WDc8io@z> (raw)
In-Reply-To: <20190404162555.0a2267ee@redhat.com>

On 2019/4/4 22:25, Igor Mammedov wrote:
> On Fri, 29 Mar 2019 16:48:38 +0800
> Like Xu <like.xu@linux.intel.com> wrote:
> 

<snipp>
> 
>> diff --git a/cpus.c b/cpus.c
>> index e83f72b..834a697 100644
>> --- a/cpus.c
>> +++ b/cpus.c
>> @@ -2067,6 +2067,10 @@ static void qemu_dummy_start_vcpu(CPUState *cpu)
>>   
>>   void qemu_init_vcpu(CPUState *cpu)
>>   {
>> +    MachineState *ms = MACHINE(qdev_get_machine());
>> +    unsigned int smp_cores = ms->topo.smp_cores;
>> +    unsigned int smp_threads = ms->topo.smp_threads;
> 
> (***)
> for once it probably will crash *-user builds
> and secondly the purpose of getting rid of smp_foo globals
> is disentangle layer violations and not replace it with another global
> (qdev_get_machine()).

I am happy to follow this rule on cpu-topo refactoring work, but 
sometimes calling qdev_get_machine() is inevitable.

> 
> What should be done is to make a properties of nr_cores/nr_threads and set
> them from the parent object that creates CPUs. The point is CPUs shouldn't
> reach out outside itself to fish out data bits it needs, it's responsibility
> of creator to feed to being create CPU needed properties.
> 
> This kind of refactoring probably deserves its own series and should precede
> -smp refactoring as it doesn't depend on CpuTopology at all.
> 

The division of responsibility for this case (refactoring 
qemu_init_vcpu) seems to be a poisonous apple.

The prerequisite for setting cpu-> nr_cores / nr_threads from the parent 
is that the CPU has been created, so if any process during 
initialization needs this topo information, it will use the default 
values form cpu_common_initfn() instead of user-configured parameters.

We may not want to repeat those assignment operations using the new 
values and what do you think, Igor?

<snipp>


  parent reply	other threads:[~2019-04-30  7:31 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1553849325-44201-1-git-send-email-like.xu@linux.intel.com>
     [not found] ` <20190329112152.0c7ad147@redhat.com>
2019-04-04  3:26   ` [Qemu-devel] [PATCH 0/9] refactor cpu topo into machine properties Like Xu
2019-04-08 13:26     ` Igor Mammedov
2019-04-08 13:26       ` Igor Mammedov
2019-04-08 14:38       ` Like Xu
2019-04-08 14:38         ` Like Xu
     [not found] ` <1553849325-44201-2-git-send-email-like.xu@linux.intel.com>
2019-04-04 11:37   ` [Qemu-devel] [PATCH 1/9] cpu/topology: add struct CpuTopology to MachineState Igor Mammedov
     [not found] ` <1553849325-44201-3-git-send-email-like.xu@linux.intel.com>
2019-04-04 14:25   ` [Qemu-devel] [PATCH 2/9] cpu/topology: add general support for machine properties Igor Mammedov
2019-04-04 16:21     ` Dr. David Alan Gilbert
2019-04-30  7:30     ` Like Xu [this message]
2019-04-30  7:30       ` Like Xu
2019-05-02 15:09       ` Igor Mammedov
2019-05-02 15:09         ` Igor Mammedov
2019-05-03  1:08         ` Eduardo Habkost
2019-05-03  1:08           ` Eduardo Habkost
2019-05-03  1:01       ` Eduardo Habkost
2019-05-03  1:01         ` Eduardo Habkost
     [not found] ` <1553849325-44201-4-git-send-email-like.xu@linux.intel.com>
2019-04-08 12:54   ` [Qemu-devel] [PATCH 3/9] cpu/topology: add uncommon arch support for smp " Igor Mammedov
2019-04-08 12:54     ` Igor Mammedov
2019-04-16  8:47     ` Like Xu
2019-04-16  8:47       ` Like Xu
2019-04-16 12:00       ` Igor Mammedov
2019-04-16 12:00         ` Igor Mammedov
     [not found] ` <1553849325-44201-5-git-send-email-like.xu@linux.intel.com>
     [not found]   ` <87h8bmuj2d.fsf@zen.linaroharston>
     [not found]     ` <2546bf3e-2009-5a76-bc63-0ad73d333a78@linux.intel.com>
2019-04-01 23:38       ` [Qemu-devel] [PATCH 4/9] cpu/topology: add ARM " Eduardo Habkost
2019-04-02  2:35         ` Like Xu
2019-04-02  4:45           ` Peter Maydell
2019-04-02  5:20             ` Like Xu
2019-04-02  5:27               ` Peter Maydell
2019-04-08 13:11   ` Igor Mammedov
2019-04-08 13:11     ` Igor Mammedov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a765e3ac-45e6-310e-aa66-7036b5717a26@linux.intel.com \
    --to=like.xu@linux.intel.com \
    --cc=dgilbert@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=like.xu@intel.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).