Linux MIPS Architecture development
 help / color / mirror / Atom feed
From: Andreas Herrmann <herrmann.der.user@googlemail.com>
To: Huacai Chen <chenhc@lemote.com>
Cc: Ralf Baechle <ralf@linux-mips.org>,
	John Crispin <john@phrozen.org>,
	"Steven J. Hill" <Steven.Hill@imgtec.com>,
	Aurelien Jarno <aurelien@aurel32.net>,
	linux-mips@linux-mips.org, Fuxin Zhang <zhangfx@lemote.com>,
	Zhangjin Wu <wuzhangjin@gmail.com>,
	Andreas Herrmann <andreas.herrmann@caviumnetworks.com>
Subject: Re: [PATCH V2 2/8] MIPS: Support CPU topology files in sysfs
Date: Mon, 14 Apr 2014 17:04:13 +0200	[thread overview]
Message-ID: <20140414150413.GB10997@alberich> (raw)
In-Reply-To: <1397348662-22502-3-git-send-email-chenhc@lemote.com>

On Sun, Apr 13, 2014 at 08:24:16AM +0800, Huacai Chen wrote:
> This patch is prepared for Loongson's NUMA support, it offer meaningful
> sysfs files such as physical_package_id, core_id, core_siblings and
> thread_siblings in /sys/devices/system/cpu/cpu?/topology.
> 
> Signed-off-by: Huacai Chen <chenhc@lemote.com>

Reviewed-by: Andreas Herrmann <andreas.herrmann@caviumnetworks.com>


Thanks,
Andreas

> ---
>  arch/mips/include/asm/cpu-info.h |    1 +
>  arch/mips/include/asm/smp.h      |    6 ++++++
>  arch/mips/kernel/proc.c          |    1 +
>  arch/mips/kernel/smp.c           |   26 +++++++++++++++++++++++++-
>  4 files changed, 33 insertions(+), 1 deletions(-)
> 
> diff --git a/arch/mips/include/asm/cpu-info.h b/arch/mips/include/asm/cpu-info.h
> index dc2135b..2dfa00b 100644
> --- a/arch/mips/include/asm/cpu-info.h
> +++ b/arch/mips/include/asm/cpu-info.h
> @@ -61,6 +61,7 @@ struct cpuinfo_mips {
>  	struct cache_desc	scache; /* Secondary cache */
>  	struct cache_desc	tcache; /* Tertiary/split secondary cache */
>  	int			srsets; /* Shadow register sets */
> +	int			package;/* physical package number */
>  	int			core;	/* physical core number */
>  #ifdef CONFIG_64BIT
>  	int			vmbits; /* Virtual memory size in bits */
> diff --git a/arch/mips/include/asm/smp.h b/arch/mips/include/asm/smp.h
> index efa02ac..fea4051 100644
> --- a/arch/mips/include/asm/smp.h
> +++ b/arch/mips/include/asm/smp.h
> @@ -22,6 +22,7 @@
>  
>  extern int smp_num_siblings;
>  extern cpumask_t cpu_sibling_map[];
> +extern cpumask_t cpu_core_map[];
>  
>  #define raw_smp_processor_id() (current_thread_info()->cpu)
>  
> @@ -36,6 +37,11 @@ extern int __cpu_logical_map[NR_CPUS];
>  
>  #define NO_PROC_ID	(-1)
>  
> +#define topology_physical_package_id(cpu)	(cpu_data[cpu].package)
> +#define topology_core_id(cpu)			(cpu_data[cpu].core)
> +#define topology_core_cpumask(cpu)		(&cpu_core_map[cpu])
> +#define topology_thread_cpumask(cpu)		(&cpu_sibling_map[cpu])
> +
>  #define SMP_RESCHEDULE_YOURSELF 0x1	/* XXX braindead */
>  #define SMP_CALL_FUNCTION	0x2
>  /* Octeon - Tell another core to flush its icache */
> diff --git a/arch/mips/kernel/proc.c b/arch/mips/kernel/proc.c
> index 037a44d..62c4439 100644
> --- a/arch/mips/kernel/proc.c
> +++ b/arch/mips/kernel/proc.c
> @@ -123,6 +123,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
>  		      cpu_data[n].srsets);
>  	seq_printf(m, "kscratch registers\t: %d\n",
>  		      hweight8(cpu_data[n].kscratch_mask));
> +	seq_printf(m, "package\t\t\t: %d\n", cpu_data[n].package);
>  	seq_printf(m, "core\t\t\t: %d\n", cpu_data[n].core);
>  
>  	sprintf(fmt, "VCE%%c exceptions\t\t: %s\n",
> diff --git a/arch/mips/kernel/smp.c b/arch/mips/kernel/smp.c
> index 0a022ee..0fa5429 100644
> --- a/arch/mips/kernel/smp.c
> +++ b/arch/mips/kernel/smp.c
> @@ -63,9 +63,16 @@ EXPORT_SYMBOL(smp_num_siblings);
>  cpumask_t cpu_sibling_map[NR_CPUS] __read_mostly;
>  EXPORT_SYMBOL(cpu_sibling_map);
>  
> +/* representing the core map of multi-core chips of each logical CPU */
> +cpumask_t cpu_core_map[NR_CPUS] __read_mostly;
> +EXPORT_SYMBOL(cpu_core_map);
> +
>  /* representing cpus for which sibling maps can be computed */
>  static cpumask_t cpu_sibling_setup_map;
>  
> +/* representing cpus for which core maps can be computed */
> +static cpumask_t cpu_core_setup_map;
> +
>  static inline void set_cpu_sibling_map(int cpu)
>  {
>  	int i;
> @@ -74,7 +81,8 @@ static inline void set_cpu_sibling_map(int cpu)
>  
>  	if (smp_num_siblings > 1) {
>  		for_each_cpu_mask(i, cpu_sibling_setup_map) {
> -			if (cpu_data[cpu].core == cpu_data[i].core) {
> +			if (cpu_data[cpu].package == cpu_data[i].package &&
> +				    cpu_data[cpu].core == cpu_data[i].core) {
>  				cpu_set(i, cpu_sibling_map[cpu]);
>  				cpu_set(cpu, cpu_sibling_map[i]);
>  			}
> @@ -83,6 +91,20 @@ static inline void set_cpu_sibling_map(int cpu)
>  		cpu_set(cpu, cpu_sibling_map[cpu]);
>  }
>  
> +static inline void set_cpu_core_map(int cpu)
> +{
> +	int i;
> +
> +	cpu_set(cpu, cpu_core_setup_map);
> +
> +	for_each_cpu_mask(i, cpu_core_setup_map) {
> +		if (cpu_data[cpu].package == cpu_data[i].package) {
> +			cpu_set(i, cpu_core_map[cpu]);
> +			cpu_set(cpu, cpu_core_map[i]);
> +		}
> +	}
> +}
> +
>  struct plat_smp_ops *mp_ops;
>  EXPORT_SYMBOL(mp_ops);
>  
> @@ -129,6 +151,7 @@ asmlinkage void start_secondary(void)
>  	set_cpu_online(cpu, true);
>  
>  	set_cpu_sibling_map(cpu);
> +	set_cpu_core_map(cpu);
>  
>  	cpu_set(cpu, cpu_callin_map);
>  
> @@ -183,6 +206,7 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
>  	current_thread_info()->cpu = 0;
>  	mp_ops->prepare_cpus(max_cpus);
>  	set_cpu_sibling_map(0);
> +	set_cpu_core_map(0);
>  #ifndef CONFIG_HOTPLUG_CPU
>  	init_cpu_present(cpu_possible_mask);
>  #endif
> -- 
> 1.7.7.3
> 
> 

  reply	other threads:[~2014-04-14 15:04 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-13  0:24 [PATCH V2 0/8] MIPS: Loongson-3: Add NUMA and Loongson-3B support Huacai Chen
2014-04-13  0:24 ` [PATCH V2 1/8] MIPS: Support hard limit of cpu count (nr_cpu_ids) Huacai Chen
2014-04-14 14:48   ` Andreas Herrmann
2014-04-13  0:24 ` [PATCH V2 2/8] MIPS: Support CPU topology files in sysfs Huacai Chen
2014-04-14 15:04   ` Andreas Herrmann [this message]
2014-04-13  0:24 ` [PATCH V2 3/8] MIPS: Loongson: Modify ChipConfig register definition Huacai Chen
2014-04-13  0:24 ` [PATCH V2 4/8] MIPS: Add NUMA support for Loongson-3 Huacai Chen
2014-06-03 22:47   ` Ralf Baechle
2014-06-03 23:47     ` David Daney
2014-06-04  6:46       ` Ralf Baechle
2014-06-04 17:22         ` David Daney
2014-06-05  9:15           ` Huacai Chen
2014-04-13  0:24 ` [PATCH V2 5/8] MIPS: Add numa api support Huacai Chen
2014-04-13  0:24 ` [PATCH V2 6/8] MIPS: Add Loongson-3B support Huacai Chen
2014-04-13  0:24 ` [PATCH V2 7/8] MIPS: Loongson-3: Enable the COP2 usage Huacai Chen
2014-04-13  0:24 ` [PATCH V2 8/8] MIPS: Loongson: Rename CONFIG_LEMOTE_MACH3A to CONFIG_LOONGSON_MACH3X Huacai Chen

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=20140414150413.GB10997@alberich \
    --to=herrmann.der.user@googlemail.com \
    --cc=Steven.Hill@imgtec.com \
    --cc=andreas.herrmann@caviumnetworks.com \
    --cc=aurelien@aurel32.net \
    --cc=chenhc@lemote.com \
    --cc=john@phrozen.org \
    --cc=linux-mips@linux-mips.org \
    --cc=ralf@linux-mips.org \
    --cc=wuzhangjin@gmail.com \
    --cc=zhangfx@lemote.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