All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eduardo Habkost <ehabkost@redhat.com>
To: Like Xu <like.xu@linux.intel.com>
Cc: Igor Mammedov <imammedo@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-trivial] [Qemu-devel] [PATCH 2/9] cpu/topology: add general support for machine properties
Date: Thu, 2 May 2019 22:01:27 -0300	[thread overview]
Message-ID: <20190503010127.GP28722@habkost.net> (raw)
In-Reply-To: <a765e3ac-45e6-310e-aa66-7036b5717a26@linux.intel.com>

On Tue, Apr 30, 2019 at 03:30:31PM +0800, Like Xu wrote:
> 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

Will it?  cpus.o is compiled only on CONFIG_SOFTMMU.

> > 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.

I agree with Igor's goal, but let's do it one step at a time.
Replacing the smp_* globals with qdev_get_machine() is a step in
the right direction, IMO.


> 
> > 
> > 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.

I don't see why it should precede -smp refactoring.

We have a very specific user-visible goal here: making one extra
CPU topology option (CPU dies) available on PC only.  Asking the
author to refactor some code while implementing that is
reasonable.  Requiring the author to touch every single place
where a CPU object is created in QEMU just to avoid a
qdev_get_machine() call doesn't seem reasonable.


> > 
> 
> 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?

I believe we need a better CPU creation API that all machines can
use, otherwise all of them will have to duplicate the same code
between object_new() and object_propert_set_bool("realized", true).

But I really don't think designing and implementing this new API
should be a requirement to get useful work done.

-- 
Eduardo


WARNING: multiple messages have this Message-ID (diff)
From: Eduardo Habkost <ehabkost@redhat.com>
To: Like Xu <like.xu@linux.intel.com>
Cc: Igor Mammedov <imammedo@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: Thu, 2 May 2019 22:01:27 -0300	[thread overview]
Message-ID: <20190503010127.GP28722@habkost.net> (raw)
In-Reply-To: <a765e3ac-45e6-310e-aa66-7036b5717a26@linux.intel.com>

On Tue, Apr 30, 2019 at 03:30:31PM +0800, Like Xu wrote:
> 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

Will it?  cpus.o is compiled only on CONFIG_SOFTMMU.

> > 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.

I agree with Igor's goal, but let's do it one step at a time.
Replacing the smp_* globals with qdev_get_machine() is a step in
the right direction, IMO.


> 
> > 
> > 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.

I don't see why it should precede -smp refactoring.

We have a very specific user-visible goal here: making one extra
CPU topology option (CPU dies) available on PC only.  Asking the
author to refactor some code while implementing that is
reasonable.  Requiring the author to touch every single place
where a CPU object is created in QEMU just to avoid a
qdev_get_machine() call doesn't seem reasonable.


> > 
> 
> 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?

I believe we need a better CPU creation API that all machines can
use, otherwise all of them will have to duplicate the same code
between object_new() and object_propert_set_bool("realized", true).

But I really don't think designing and implementing this new API
should be a requirement to get useful work done.

-- 
Eduardo

WARNING: multiple messages have this Message-ID (diff)
From: Eduardo Habkost <ehabkost@redhat.com>
To: Like Xu <like.xu@linux.intel.com>
Cc: qemu-trivial@nongnu.org, qemu-devel@nongnu.org,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
	like.xu@intel.com, Paolo Bonzini <pbonzini@redhat.com>,
	Igor Mammedov <imammedo@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 2/9] cpu/topology: add general support for machine properties
Date: Thu, 2 May 2019 22:01:27 -0300	[thread overview]
Message-ID: <20190503010127.GP28722@habkost.net> (raw)
Message-ID: <20190503010127.KxHfpzwvRMJVJrSZgnUcez-aph9lAoI3neMwYmiG_y8@z> (raw)
In-Reply-To: <a765e3ac-45e6-310e-aa66-7036b5717a26@linux.intel.com>

On Tue, Apr 30, 2019 at 03:30:31PM +0800, Like Xu wrote:
> 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

Will it?  cpus.o is compiled only on CONFIG_SOFTMMU.

> > 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.

I agree with Igor's goal, but let's do it one step at a time.
Replacing the smp_* globals with qdev_get_machine() is a step in
the right direction, IMO.


> 
> > 
> > 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.

I don't see why it should precede -smp refactoring.

We have a very specific user-visible goal here: making one extra
CPU topology option (CPU dies) available on PC only.  Asking the
author to refactor some code while implementing that is
reasonable.  Requiring the author to touch every single place
where a CPU object is created in QEMU just to avoid a
qdev_get_machine() call doesn't seem reasonable.


> > 
> 
> 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?

I believe we need a better CPU creation API that all machines can
use, otherwise all of them will have to duplicate the same code
between object_new() and object_propert_set_bool("realized", true).

But I really don't think designing and implementing this new API
should be a requirement to get useful work done.

-- 
Eduardo


  parent reply	other threads:[~2019-05-03  1:01 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-29  8:48 [Qemu-trivial] [Qemu-devel] [PATCH 0/9] refactor cpu topo into machine properties Like Xu
2019-03-29  8:48 ` [Qemu-trivial] [Qemu-devel] [PATCH 1/9] cpu/topology: add struct CpuTopology to MachineState Like Xu
2019-03-29  9:22   ` Alex Bennée
2019-04-01  2:07     ` Like Xu
2019-04-04 11:37   ` Igor Mammedov
2019-04-04 11:37     ` Igor Mammedov
2019-03-29  8:48 ` [Qemu-trivial] [Qemu-devel] [PATCH 2/9] cpu/topology: add general support for machine properties Like Xu
2019-04-04 14:25   ` Igor Mammedov
2019-04-04 14:25     ` Igor Mammedov
2019-04-04 16:21     ` [Qemu-trivial] " Dr. David Alan Gilbert
2019-04-04 16:21       ` Dr. David Alan Gilbert
2019-04-30  7:30     ` [Qemu-trivial] " Like Xu
2019-04-30  7:30       ` Like Xu
2019-04-30  7:30       ` Like Xu
2019-05-02 15:09       ` [Qemu-trivial] " Igor Mammedov
2019-05-02 15:09         ` Igor Mammedov
2019-05-02 15:09         ` Igor Mammedov
2019-05-03  1:08         ` [Qemu-trivial] " Eduardo Habkost
2019-05-03  1:08           ` Eduardo Habkost
2019-05-03  1:01       ` Eduardo Habkost [this message]
2019-05-03  1:01         ` Eduardo Habkost
2019-05-03  1:01         ` Eduardo Habkost
2019-03-29  8:48 ` [Qemu-trivial] [Qemu-devel] [PATCH 3/9] cpu/topology: add uncommon arch support for smp " Like Xu
2019-04-08 12:54   ` Igor Mammedov
2019-04-08 12:54     ` Igor Mammedov
2019-04-08 12:54     ` Igor Mammedov
2019-04-16  8:47     ` [Qemu-trivial] " Like Xu
2019-04-16  8:47       ` Like Xu
2019-04-16  8:47       ` Like Xu
2019-04-16 12:00       ` [Qemu-trivial] " Igor Mammedov
2019-04-16 12:00         ` Igor Mammedov
2019-04-16 12:00         ` Igor Mammedov
2019-03-29  8:48 ` [Qemu-trivial] [Qemu-devel] [PATCH 4/9] cpu/topology: add ARM " Like Xu
2019-03-29  9:27   ` Alex Bennée
2019-03-29 11:20     ` Philippe Mathieu-Daudé
2019-04-01  2:27       ` Like Xu
2019-04-01  2:56     ` Like Xu
2019-04-01 23:38       ` Eduardo Habkost
2019-04-01 23:38         ` Eduardo Habkost
2019-04-02  2:35         ` [Qemu-trivial] " Like Xu
2019-04-02  2:35           ` Like Xu
2019-04-02  4:45           ` [Qemu-trivial] " Peter Maydell
2019-04-02  4:45             ` Peter Maydell
2019-04-02  5:20             ` [Qemu-trivial] " Like Xu
2019-04-02  5:20               ` Like Xu
2019-04-02  5:27               ` [Qemu-trivial] " Peter Maydell
2019-04-02  5:27                 ` Peter Maydell
2019-04-08 13:11   ` [Qemu-trivial] " Igor Mammedov
2019-04-08 13:11     ` Igor Mammedov
2019-04-08 13:11     ` Igor Mammedov
2019-03-29  8:48 ` [Qemu-trivial] [Qemu-devel] [PATCH 5/9] cpu/topology: add i386 " Like Xu
2019-03-29  8:48 ` [Qemu-trivial] [Qemu-devel] [PATCH 6/9] cpu/topology: add PPC " Like Xu
2019-03-29  8:48 ` [Qemu-trivial] [Qemu-devel] [PATCH 7/9] cpu/topology: add riscv " Like Xu
     [not found]   ` <CAKmqyKPqKqdBpeyJMbrZq3b2pe5V-yHJAsNDugOEWrdKr0buqg@mail.gmail.com>
2019-04-01  2:10     ` Like Xu
2019-03-29  8:48 ` [Qemu-trivial] [Qemu-devel] [PATCH 8/9] cpu/topology: add s390x " Like Xu
2019-03-29  8:48 ` [Qemu-trivial] [Qemu-devel] [PATCH 9/9] cpu/topology: replace smp global variables with machine propertie Like Xu
2019-03-29  9:07 ` [Qemu-trivial] [Qemu-devel] [PATCH 0/9] refactor cpu topo into machine properties no-reply
2019-03-29 10:21 ` Igor Mammedov
2019-04-04  3:26   ` Like Xu
2019-04-04  3:26     ` Like Xu
2019-04-08 13:26     ` [Qemu-trivial] " Igor Mammedov
2019-04-08 13:26       ` Igor Mammedov
2019-04-08 13:26       ` Igor Mammedov
2019-04-08 14:38       ` [Qemu-trivial] " Like Xu
2019-04-08 14:38         ` Like Xu
2019-04-08 14:38         ` Like Xu

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=20190503010127.GP28722@habkost.net \
    --to=ehabkost@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=like.xu@intel.com \
    --cc=like.xu@linux.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.