kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Claudio Imbrenda <imbrenda@linux.ibm.com>
To: David Hildenbrand <david@redhat.com>
Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, thuth@redhat.com,
	nrb@linux.ibm.com, scgl@linux.ibm.com, seiden@linux.ibm.com
Subject: Re: [kvm-unit-tests PATCH v1 2/5] lib: s390x: smp: guarantee that boot CPU has index 0
Date: Thu, 3 Feb 2022 12:41:34 +0100	[thread overview]
Message-ID: <20220203124134.61547e2a@p-imbrenda> (raw)
In-Reply-To: <f99fc058-03fa-3bb7-7520-4cea7fd9a004@redhat.com>

On Mon, 31 Jan 2022 14:55:09 +0100
David Hildenbrand <david@redhat.com> wrote:

> On 28.01.22 19:54, Claudio Imbrenda wrote:
> > Guarantee that the boot CPU has index 0. This simplifies the
> > implementation of tests that require multiple CPUs.
> > 
> > Also fix a small bug in the allocation of the cpus array.
> > 
> > Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
> > Fixes: f77c0515 ("s390x: Add initial smp code")
> > Fixes: 52076a63 ("s390x: Consolidate sclp read info")
> > ---
> >  lib/s390x/smp.c | 16 ++++++++--------
> >  1 file changed, 8 insertions(+), 8 deletions(-)
> > 
> > diff --git a/lib/s390x/smp.c b/lib/s390x/smp.c
> > index 64c647ec..01f513f0 100644
> > --- a/lib/s390x/smp.c
> > +++ b/lib/s390x/smp.c
> > @@ -25,7 +25,6 @@
> >  #include "sclp.h"
> >  
> >  static struct cpu *cpus;
> > -static struct cpu *cpu0;
> >  static struct spinlock lock;
> >  
> >  extern void smp_cpu_setup_state(void);
> > @@ -81,7 +80,7 @@ static int smp_cpu_stop_nolock(uint16_t addr, bool store)
> >  	uint8_t order = store ? SIGP_STOP_AND_STORE_STATUS : SIGP_STOP;
> >  
> >  	cpu = smp_cpu_from_addr(addr);
> > -	if (!cpu || cpu == cpu0)
> > +	if (!cpu || addr == cpus[0].addr)
> >  		return -1;
> >  
> >  	if (sigp_retry(addr, order, 0, NULL))
> > @@ -205,7 +204,7 @@ int smp_cpu_setup(uint16_t addr, struct psw psw)
> >  	sigp_retry(cpu->addr, SIGP_SET_PREFIX, (unsigned long )lc, NULL);
> >  
> >  	/* Copy all exception psws. */
> > -	memcpy(lc, cpu0->lowcore, 512);
> > +	memcpy(lc, cpus[0].lowcore, 512);
> >  
> >  	/* Setup stack */
> >  	cpu->stack = (uint64_t *)alloc_pages(2);
> > @@ -263,15 +262,16 @@ void smp_setup(void)
> >  	if (num > 1)
> >  		printf("SMP: Initializing, found %d cpus\n", num);
> >  
> > -	cpus = calloc(num, sizeof(cpus));
> > +	cpus = calloc(num, sizeof(*cpus));
> >  	for (i = 0; i < num; i++) {
> >  		cpus[i].addr = entry[i].address;
> >  		cpus[i].active = false;
> >  		if (entry[i].address == cpu0_addr) {
> > -			cpu0 = &cpus[i];
> > -			cpu0->stack = stackptr;
> > -			cpu0->lowcore = (void *)0;
> > -			cpu0->active = true;
> > +			cpus[i].addr = cpus[0].addr;  
> 
> Might deserve a comment that we'll move the the boot CPU to index 0.

fair enough.

> 
> What's the expected behavior if i == 0?
> 

in that case, the boot CPU was already the one with index 0. The code
will do a few extra useless steps, but in the end everything should Just
Work™

  reply	other threads:[~2022-02-03 11:41 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-28 18:54 [kvm-unit-tests PATCH v1 0/5] s390x: smp: avoid hardcoded CPU addresses Claudio Imbrenda
2022-01-28 18:54 ` [kvm-unit-tests PATCH v1 1/5] lib: s390x: smp: add functions to work with CPU indexes Claudio Imbrenda
2022-01-31 13:50   ` David Hildenbrand
2022-02-02 16:55     ` Steffen Eiden
2022-02-03 13:33     ` Claudio Imbrenda
2022-01-28 18:54 ` [kvm-unit-tests PATCH v1 2/5] lib: s390x: smp: guarantee that boot CPU has index 0 Claudio Imbrenda
2022-01-31 13:55   ` David Hildenbrand
2022-02-03 11:41     ` Claudio Imbrenda [this message]
2022-01-28 18:54 ` [kvm-unit-tests PATCH v1 3/5] s390x: smp: avoid hardcoded CPU addresses Claudio Imbrenda
2022-01-28 18:54 ` [kvm-unit-tests PATCH v1 4/5] s390x: firq: " Claudio Imbrenda
2022-01-28 18:54 ` [kvm-unit-tests PATCH v1 5/5] s390x: skrf: " Claudio Imbrenda
2022-02-03  8:45 ` [kvm-unit-tests PATCH v1 0/5] s390x: smp: " Janosch Frank
2022-02-03 13:37   ` Claudio Imbrenda
2022-02-03 15:23     ` Janosch Frank
2022-02-03 15:48       ` Claudio Imbrenda
2022-02-04 15:01 ` Janosch Frank
2022-02-04 15:14   ` Claudio Imbrenda
2022-02-04 15:37     ` Janosch Frank

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=20220203124134.61547e2a@p-imbrenda \
    --to=imbrenda@linux.ibm.com \
    --cc=david@redhat.com \
    --cc=frankja@linux.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=nrb@linux.ibm.com \
    --cc=scgl@linux.ibm.com \
    --cc=seiden@linux.ibm.com \
    --cc=thuth@redhat.com \
    /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).