linux-riscv.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Nick Kossifidis <mick@ics.forth.gr>
To: Atish Patra <atish.patra@wdc.com>
Cc: mark.rutland@arm.com, devicetree@vger.kernel.org,
	Damien Le Moal <Damien.LeMoal@wdc.com>,
	alankao@andestech.com, zong@andestech.com, anup@brainfault.org,
	palmer@sifive.com, linux-kernel@vger.kernel.org,
	hch@infradead.org, robh+dt@kernel.org,
	Nick Kossifidis <mick@ics.forth.gr>,
	linux-riscv@lists.infradead.org, tglx@linutronix.de
Subject: Re: [RFC 0/2] Add RISC-V cpu topology
Date: Sat, 03 Nov 2018 00:18:31 +0200	[thread overview]
Message-ID: <ffc68a79af6e981654bef5bcdb283161@mailhost.ics.forth.gr> (raw)
Message-ID: <20181102221831.JrbTAFn027Y8Qyv6ZRLn7VIM2ACshlOzyp34newJtpU@z> (raw)
In-Reply-To: <9385b2eb-4729-8247-b0ae-1540793d078b@wdc.com>

Στις 2018-11-02 23:14, Atish Patra έγραψε:
> On 11/2/18 11:59 AM, Nick Kossifidis wrote:
>> Hello All,
>> 
>> Στις 2018-11-02 01:04, Atish Patra έγραψε:
>>> This patch series adds the cpu topology for RISC-V. It contains
>>> both the DT binding and actual source code. It has been tested on
>>> QEMU & Unleashed board.
>>> 
>>> The idea is based on cpu-map in ARM with changes related to how
>>> we define SMT systems. The reason for adopting a similar approach
>>> to ARM as I feel it provides a very clear way of defining the
>>> topology compared to parsing cache nodes to figure out which cpus
>>> share the same package or core.  I am open to any other idea to
>>> implement cpu-topology as well.
>>> 
>> 
>> I was also about to start a discussion about CPU topology on RISC-V
>> after the last swtools group meeting. The goal is to provide the
>> scheduler with hints on how to distribute tasks more efficiently
>> between harts, by populating the scheduling domain topology levels
>> (https://elixir.bootlin.com/linux/v4.19/ident/sched_domain_topology_level).
>> What we want to do is define cpu groups and assign them to
>> scheduling domains with the appropriate SD_ flags
>> (https://github.com/torvalds/linux/blob/master/include/linux/sched/topology.h#L16).
>> 
> 
> Scheduler domain topology is already getting all the hints in the 
> following way.
> 
> static struct sched_domain_topology_level default_topology[] = {
> #ifdef CONFIG_SCHED_SMT
>         { cpu_smt_mask, cpu_smt_flags, SD_INIT_NAME(SMT) },
> #endif
> #ifdef CONFIG_SCHED_MC
>         { cpu_coregroup_mask, cpu_core_flags, SD_INIT_NAME(MC) },
> #endif
>         { cpu_cpu_mask, SD_INIT_NAME(DIE) },
>         { NULL, },
> };
> 
> #ifdef CONFIG_SCHED_SMT
> static inline const struct cpumask *cpu_smt_mask(int cpu)
> {
>         return topology_sibling_cpumask(cpu);
> }
> #endif
> 
> const struct cpumask *cpu_coregroup_mask(int cpu)
> {
>         return &cpu_topology[cpu].core_sibling;
> }
> 
> 

That's a static definition of two scheduling domains that only deal
with SMT and MC, the only difference between them is the
SD_SHARE_PKG_RESOURCES flag. You can't even have multiple levels
of shared resources this way, whatever you have larger than a core
is ignored (it just goes to the MC domain). There is also no handling
of SD_SHARE_POWERDOMAIN or SD_SHARE_CPUCAPACITY.

>> So the cores that belong to a scheduling domain may share:
>> CPU capacity (SD_SHARE_CPUCAPACITY / SD_ASYM_CPUCAPACITY)
>> Package resources -e.g. caches, units etc- (SD_SHARE_PKG_RESOURCES)
>> Power domain (SD_SHARE_POWERDOMAIN)
>> 
>> In this context I believe using words like "core", "package",
>> "socket" etc can be misleading. For example the sample topology you
>> use on the documentation says that there are 4 cores that are part
>> of a package, however "package" has a different meaning to the
>> scheduler. Also we don't say anything in case they share a power
>> domain or if they have the same capacity or not. This mapping deals
>> only with cache hierarchy or other shared resources.
>> 
>> How about defining a dt scheme to describe the scheduler domain
>> topology levels instead ? e.g:
>> 
>> 2 sets (or clusters if you prefer) of 2 SMT cores, each set with
>> a different capacity and power domain:
>> 
>> sched_topology {
>>    level0 { // SMT
>>     shared = "power", "capacity", "resources";
>>     group0 {
>>      members = <&hart0>, <&hart1>;
>>     }
>>     group1 {
>>      members = <&hart2>, <&hart3>;
>>     }
>>     group2 {
>>      members = <&hart4>, <&hart5>;
>>     }
>>     group3 {
>>      members = <&hart6>, <&hart7>;
>>     }
>>    }
>>    level1 { // MC
>>     shared = "power", "capacity"
>>     group0 {
>>      members = <&hart0>, <&hart1>, <&hart2>, <&hart3>;
>>     }
>>     group1 {
>>      members = <&hart4>, <&hart5>, <&hart6>, <&hart7>;
>>     }
>>    }
>>    top_level { // A group with all harts in it
>>     shared = "" // There is nothing common for ALL harts, we could 
>> have
>> capacity here
>>    }
>> }
>> 
> 
> I agree that naming could have been better in the past. But it is what
> it is now. I don't see any big advantages in this approach compared to
> the existing approach where DT specifies what hardware looks like and
> scheduler sets up it's domain based on different cpumasks.
> 

It is what it is on ARM, it doesn't have to be the same on RISC-V, 
anyway
the name is a minor issue. The advantage of this approach is that you 
define the
scheduling domains on the device tree without needing a "translation" of 
a
topology map to scheduling domains. It can handle any scenario the 
scheduler
can handle, using all the available flags. In your approach no matter 
what
gets put to the device tree, the only hint the scheduler will get is one
level of SMT, one level of MC and the rest of the system. No power 
domain
sharing, no asymmetric scheduling, no multiple levels possible. Many 
features
of the scheduler remain unused. This approach can also get extended more 
easily
to e.g. support NUMA nodes and associate memory regions with groups.

Regards,
Nick


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

  parent reply	other threads:[~2018-11-02 22:19 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-01 23:04 [RFC 0/2] Add RISC-V cpu topology Atish Patra
2018-11-01 23:04 ` Atish Patra
2018-11-01 23:04 ` [RFC 1/2] dt-bindings: topology: " Atish Patra
2018-11-01 23:04   ` Atish Patra
2018-11-02 13:09   ` Rob Herring
2018-11-02 13:09     ` Rob Herring
2018-11-02 13:31     ` Sudeep Holla
2018-11-02 13:31       ` Sudeep Holla
2018-11-02 15:11       ` Rob Herring
2018-11-02 15:11         ` Rob Herring
2018-11-02 15:50         ` Sudeep Holla
2018-11-02 15:50           ` Sudeep Holla
2018-11-02 20:53           ` Atish Patra
2018-11-02 20:53             ` Atish Patra
2018-11-02 21:08             ` Rob Herring
2018-11-02 21:08               ` Rob Herring
2018-11-02 20:34     ` Atish Patra
2018-11-02 20:34       ` Atish Patra
2018-11-05 19:38     ` Palmer Dabbelt
2018-11-05 19:38       ` Palmer Dabbelt
2018-11-05 20:10       ` Rob Herring
2018-11-05 20:10         ` Rob Herring
2018-11-06  0:12         ` Atish Patra
2018-11-06  0:12           ` Atish Patra
2018-11-06 10:03       ` Nick Kossifidis
2018-11-06 10:03         ` Nick Kossifidis
2018-11-06 11:37         ` Mark Rutland
2018-11-06 11:37           ` Mark Rutland
2018-11-01 23:04 ` [RFC 2/2] RISC-V: Introduce " Atish Patra
2018-11-01 23:04   ` Atish Patra
2018-11-02 18:58 ` [RFC 0/2] Add RISC-V " Nick Kossifidis
2018-11-02 18:58   ` Nick Kossifidis
2018-11-02 21:14   ` Atish Patra
2018-11-02 21:14     ` Atish Patra
2018-11-02 22:18     ` Nick Kossifidis [this message]
2018-11-02 22:18       ` Nick Kossifidis
2018-11-06 14:13   ` Sudeep Holla
2018-11-06 14:13     ` Sudeep Holla
2018-11-06 15:26     ` Nick Kossifidis
2018-11-06 15:26       ` Nick Kossifidis
2018-11-06 15:50       ` Sudeep Holla
2018-11-06 15:50         ` Sudeep Holla
2018-11-06 16:20       ` Mark Rutland
2018-11-06 16:20         ` Mark Rutland
2018-11-07  2:31         ` Nick Kossifidis
2018-11-07  2:31           ` Nick Kossifidis
2018-11-07 12:06           ` Mark Rutland
2018-11-07 12:06             ` Mark Rutland
2018-11-08 13:45             ` Nick Kossifidis
2018-11-08 13:45               ` Nick Kossifidis
2018-11-08 15:54               ` Mark Rutland
2018-11-08 15:54                 ` Mark Rutland
2018-11-09  3:55                 ` Nick Kossifidis
2018-11-09  3:55                   ` Nick Kossifidis
2018-11-07 12:28           ` Sudeep Holla
2018-11-07 12:28             ` Sudeep Holla
2018-11-08 14:52             ` Nick Kossifidis
2018-11-08 14:52               ` Nick Kossifidis
2018-11-08 16:48               ` Sudeep Holla
2018-11-08 16:48                 ` Sudeep Holla
2018-11-09  2:36                 ` Nick Kossifidis
2018-11-09  2:36                   ` Nick Kossifidis
2018-11-09 12:33                   ` Sudeep Holla
2018-11-09 12:33                     ` Sudeep Holla

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=ffc68a79af6e981654bef5bcdb283161@mailhost.ics.forth.gr \
    --to=mick@ics.forth.gr \
    --cc=Damien.LeMoal@wdc.com \
    --cc=alankao@andestech.com \
    --cc=anup@brainfault.org \
    --cc=atish.patra@wdc.com \
    --cc=devicetree@vger.kernel.org \
    --cc=hch@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=mark.rutland@arm.com \
    --cc=palmer@sifive.com \
    --cc=robh+dt@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=zong@andestech.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).