All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luca Fancellu <Luca.Fancellu@arm.com>
To: Stefano Stabellini <sstabellini@kernel.org>
Cc: Xen-devel <xen-devel@lists.xenproject.org>,
	Bertrand Marquis <Bertrand.Marquis@arm.com>,
	Wei Chen <Wei.Chen@arm.com>, Julien Grall <julien@xen.org>,
	Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	George Dunlap <george.dunlap@citrix.com>,
	Jan Beulich <jbeulich@suse.com>, Wei Liu <wl@xen.org>,
	Juergen Gross <jgross@suse.com>,
	Dario Faggioli <dfaggioli@suse.com>
Subject: Re: [PATCH v3 4/6] xen/cpupool: Create different cpupools at boot time
Date: Tue, 22 Mar 2022 08:49:31 +0000	[thread overview]
Message-ID: <27898878-F215-4993-805E-BAF04D2D07BC@arm.com> (raw)
In-Reply-To: <alpine.DEB.2.22.394.2203211541030.2910984@ubuntu-linux-20-04-desktop>


>> +- cpupool-sched (optional)
>> +
>> +    Must be a string having the name of a Xen scheduler, it has no effect when
>> +    used in conjunction of a cpupool-id equal to zero, in that case the
>> +    default Xen scheduler is selected (sched=<...> boot argument).
>> +    Check the sched=<...> boot argument for allowed values.
> 
> I am happy with this version of the device tree bindings, thanks for
> your efforts to update them. Only one comment left: please update the
> description not to include "cpupool-id" given that there is no
> cpupool-id property anymore :-)
> 

Hi Stefano,

Thank you for your review,

Yes I missed that! I will fix in the next serie.

>> 
>> +/*
>> + * pool_cpu_map:   Index is logical cpu number, content is cpupool id, (-1) for
>> + *                 unassigned.
>> + * pool_sched_map: Index is cpupool id, content is scheduler id, (-1) for
>> + *                 unassigned.
>> + */
>> +static int __initdata pool_cpu_map[NR_CPUS]   = { [0 ... NR_CPUS-1] = -1 };
>> +static int __initdata pool_sched_map[NR_CPUS] = { [0 ... NR_CPUS-1] = -1 };
>> +static unsigned int __initdata next_pool_id;
>> +
>> +#ifdef CONFIG_HAS_DEVICE_TREE
> 
> BOOT_TIME_CPUPOOLS depends on HAS_DEVICE_TREE, so it is not possible to
> have BOOT_TIME_CPUPOOLS but not HAS_DEVICE_TREE ?

Yes you are right, the ifdef is not needed at this stage since only arch with device tree are
using it, if x86 would like to implement a command line version then the code will be ifdef-ined
later.

> 
> 
>> +#define BTCPUPOOLS_DT_NODE_NO_REG     (-1)
>> +#define BTCPUPOOLS_DT_NODE_NO_LOG_CPU (-2)
>> +
>> +static int __init get_logical_cpu_from_hw_id(unsigned int hwid)
>> +{
>> +    unsigned int i;
>> +
>> +    for ( i = 0; i < nr_cpu_ids; i++ )
>> +        if ( cpu_physical_id(i) == hwid )
>> +            return i;
>> +
>> +    return -1;
>> +}
> 
> I wonder if there is a better way to implement this function but I am
> not sure. Also, it might be better to avoid premature optimizations.
> 
> That said, we could check first the simple case where hwid==i. Looking
> at various existing device tree, it seems to be the most common case.
> 
> This is not a requirement, just a hand-wavy suggestion. I think the
> patch is also OK as is.
> 

Not sure to understand here, at least on FVP (the first DT I have around), hwid != i,
Or maybe I didn’t understand what you mean

> 
>> +void __init btcpupools_allocate_pools(void)
>> +{
>> +    unsigned int i;
>> +    bool add_extra_cpupool = false;
>> +
>> +    /*
>> +     * If there are no cpupools, the value of next_pool_id is zero, so the code
>> +     * below will assign every cpu to cpupool0 as the default behavior.
>> +     * When there are cpupools, the code below is assigning all the not
>> +     * assigned cpu to a new pool (next_pool_id value is the last id + 1).
>> +     * In the same loop we check if there is any assigned cpu that is not
>> +     * online.
>> +     */
>> +    for ( i = 0; i < nr_cpu_ids; i++ )
>> +        if ( cpumask_test_cpu(i, &cpu_online_map) )
> 
> Let me take this opportunity to explain the unfortunately unwritten
> coding style the way I understand it. I know this is tribal knowledge at
> the moment and I apologize for that.
> 
> If it is a single line statement, we skip the { }, we keep them in all
> other cases.
> 
> So:
> 
>  /* correct */
>  if ( xxx ) {
>      something;
>      something else;
>  }
> 
>  /* correct */
>  if ( xxx ) {
>      for ( yyy ) {
>      }
>  }
> 
>  /* correct */
>  if ( xxx )
>      something single line or 2 lines like a printk that go beyond 80
>      chars, never in case of nested ifs
> 
>  /* not correct */
>  if ( xxx )
>      something
>      multi
>      line;
> 
>  /* not correct */
>  if ( xxx )
>      if ( yyy )
>          something;
> 
> So basically we would keep the { } here but we would skip them ...

Ok this clarifies a lot, thank you, I will check the code and I will fix it where it’s not
compliant.

> 
>> +#ifdef CONFIG_HAS_DEVICE_TREE
>> +void btcpupools_dtb_parse(void);
>> +#else
>> +static inline void btcpupools_dtb_parse(void) {}
>> +#endif
> 
> same comment about !CONFIG_HAS_DEVICE_TREE

Yes I will fix it in the next serie.

Cheers,
Luca


  reply	other threads:[~2022-03-22  8:50 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-18 15:25 [PATCH v3 0/6] Boot time cpupools Luca Fancellu
2022-03-18 15:25 ` [PATCH v3 1/6] tools/cpupools: Give a name to unnamed cpupools Luca Fancellu
2022-03-18 15:25 ` [PATCH v3 2/6] xen/sched: create public function for cpupools creation Luca Fancellu
2022-03-18 15:25 ` [PATCH v3 3/6] xen/sched: retrieve scheduler id by name Luca Fancellu
2022-03-18 15:25 ` [PATCH v3 4/6] xen/cpupool: Create different cpupools at boot time Luca Fancellu
2022-03-18 16:12   ` Julien Grall
2022-03-21 15:58     ` Luca Fancellu
2022-03-21 16:36       ` Julien Grall
2022-03-21 17:19         ` Bertrand Marquis
2022-03-21 17:44           ` Julien Grall
2022-03-22  8:35             ` Bertrand Marquis
2022-03-22  8:47               ` Bertrand Marquis
2022-03-22  9:16                 ` Julien Grall
2022-03-22  9:28                   ` Bertrand Marquis
2022-03-22  9:52         ` Luca Fancellu
2022-03-22 14:01           ` Julien Grall
2022-03-23 13:58             ` Luca Fancellu
2022-03-23 18:53               ` Julien Grall
2022-03-21  9:10   ` Jan Beulich
2022-03-21 15:51     ` Luca Fancellu
2022-03-21 23:45   ` Stefano Stabellini
2022-03-22  8:49     ` Luca Fancellu [this message]
2022-03-22 17:40       ` Stefano Stabellini
2022-03-18 15:25 ` [PATCH v3 5/6] arm/dom0less: assign dom0less guests to cpupools Luca Fancellu
2022-03-18 16:18   ` Julien Grall
2022-03-22 17:19     ` Luca Fancellu
2022-03-21  9:04   ` Jan Beulich
2022-03-21 23:45   ` Stefano Stabellini
2022-03-18 15:25 ` [PATCH v3 6/6] xen/cpupool: Allow cpupool0 to use different scheduler Luca Fancellu

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=27898878-F215-4993-805E-BAF04D2D07BC@arm.com \
    --to=luca.fancellu@arm.com \
    --cc=Bertrand.Marquis@arm.com \
    --cc=Volodymyr_Babchuk@epam.com \
    --cc=Wei.Chen@arm.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=dfaggioli@suse.com \
    --cc=george.dunlap@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=jgross@suse.com \
    --cc=julien@xen.org \
    --cc=sstabellini@kernel.org \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.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.