linux-riscv.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: hch@infradead.org (Christoph Hellwig)
To: linux-riscv@lists.infradead.org
Subject: [PATCH v2 1/3] RISC-V: Add logical CPU indexing for RISC-V
Date: Thu, 30 Aug 2018 23:03:52 -0700	[thread overview]
Message-ID: <20180831060352.GA19292@infradead.org> (raw)
In-Reply-To: <1535445370-19004-2-git-send-email-atish.patra@wdc.com>

On Tue, Aug 28, 2018 at 01:36:08AM -0700, Atish Patra wrote:
> Currently, both linux cpu id and hardware cpu id are same.
> This is not recommended as it will lead to discontinuous cpu
> indexing in Linux. Moreover, kdump kernel will run from CPU0
> which would be absent if we follow existing scheme.
> 
> Implement a logical mapping between Linux cpu id and hardware
> cpuid to decouple these two. Always mark the boot processor as
> cpu0 and all other cpus get the logical cpu id based on their
> booting order.
> 
> Signed-off-by: Atish Patra <atish.patra@wdc.com>
> ---
>  arch/riscv/include/asm/smp.h | 18 +++++++++++++++++-
>  arch/riscv/kernel/setup.c    |  2 ++
>  arch/riscv/kernel/smp.c      | 19 +++++++++++++++++++
>  3 files changed, 38 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/riscv/include/asm/smp.h b/arch/riscv/include/asm/smp.h
> index 36016845..a5c257b3 100644
> --- a/arch/riscv/include/asm/smp.h
> +++ b/arch/riscv/include/asm/smp.h
> @@ -22,6 +22,13 @@
>  #include <linux/cpumask.h>
>  #include <linux/irqreturn.h>
>  
> +#define INVALID_HARTID -1
> +/*
> + * Mapping between linux logical cpu index and hartid.
> + */
> +extern unsigned long __cpu_logical_map[NR_CPUS];
> +#define cpu_logical_map(cpu)    __cpu_logical_map[cpu]

How about naming this cpuid_to_hardid_map to make things a little
more obvious?  Also shouldn't this be signed given your INVALID_HARTID
definition above.

> +static inline int riscv_hartid_to_cpuid(int hartid) { return 0 ; }
> +static inline void riscv_cpuid_to_hartid_mask(const struct cpumask *in,
> +				       struct cpumask *out) {
> +	cpumask_set_cpu(cpu_logical_map(0), out);
> +}

Please use normal coding style even for stubs:

static inline int riscv_hartid_to_cpuid(int hartid)
{
	return 0;
}

static inline void riscv_cpuid_to_hartid_mask(const struct cpumask *in,
			struct cpumask *out)
{
	cpumask_set_cpu(cpu_logical_map(0), out);
}

> +unsigned long __cpu_logical_map[NR_CPUS] = { [0 ... NR_CPUS-1] = INVALID_HARTID };

Please break the line into the usual format:

unsigned long __cpu_logical_map[NR_CPUS] = {
	[0 ... NR_CPUS-1]	= INVALID_HARTID,
};

  parent reply	other threads:[~2018-08-31  6:03 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1535445370-19004-1-git-send-email-atish.patra@wdc.com>
2018-08-30 13:53 ` [PATCH v2 0/3] RISC-V: Add new smp features Anup Patel
2018-08-30 14:11   ` Christoph Hellwig
2018-08-30 14:15     ` Anup Patel
2018-08-30 14:18     ` Anup Patel
2018-08-30 16:04       ` Atish Patra
     [not found] ` <1535445370-19004-2-git-send-email-atish.patra@wdc.com>
2018-08-31  6:03   ` Christoph Hellwig [this message]
2018-09-04 17:59     ` [PATCH v2 1/3] RISC-V: Add logical CPU indexing for RISC-V Atish Patra
     [not found] ` <1535445370-19004-3-git-send-email-atish.patra@wdc.com>
2018-08-31  6:11   ` [PATCH v2 2/3] RISC-V: Use Linux logical cpu number instead of hartid Christoph Hellwig
2018-09-04 20:35     ` Atish Patra
2018-09-04 21:36       ` Christoph Hellwig
2018-09-04 21:43         ` Atish Patra
2018-09-05 19:03           ` Christoph Hellwig
     [not found] ` <1535445370-19004-4-git-send-email-atish.patra@wdc.com>
2018-08-31  6:18   ` [PATCH v2 3/3] RISC-V: Support cpu hotplug Christoph Hellwig
2018-09-04 18:08     ` Atish Patra
2018-09-04 21:36       ` Christoph Hellwig
2018-09-04 21:40         ` Atish Patra

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=20180831060352.GA19292@infradead.org \
    --to=hch@infradead.org \
    --cc=linux-riscv@lists.infradead.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).