From: Mike Travis <travis@sgi.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Thomas Gleixner <tglx@linutronix.de>,
Christoph Lameter <clameter@sgi.com>
Subject: Re: [PATCH 01/10] x86_64: Cleanup non-smp usage of cpu maps v2
Date: Mon, 07 Apr 2008 13:36:52 -0700 [thread overview]
Message-ID: <47FA85E4.5010005@sgi.com> (raw)
In-Reply-To: <20080326064045.GF18301@elte.hu>
Ingo Molnar wrote:
> * Mike Travis <travis@sgi.com> wrote:
>
>> Cleanup references to the early cpu maps for the non-SMP configuration
>> and remove some functions called for SMP configurations only.
>
> thanks, applied.
>
> one observation:
>
>> +#ifdef CONFIG_SMP
>> extern int x86_cpu_to_node_map_init[];
>> extern void *x86_cpu_to_node_map_early_ptr;
>> +#else
>> +#define x86_cpu_to_node_map_early_ptr NULL
>> +#endif
>
> Right now all these early_ptrs are in essence open-coded "early
> per-cpu", right? But shouldnt we solve that in a much cleaner way: by
> explicitly adding an early-per-cpu types and accessors, and avoid all
> that #ifdeffery?
>
> Ingo
How about something like the below? (I haven't tried compiling it yet.)
[I also thought about not restricting it to only NR_CPUS type variables
to allow for example, node-local node maps/variables.]
Thanks,
Mike
------------------------------------------------------------
include/linux/percpu.h:
#ifdef CONFIG_SMP
#define DEFINE_EARLY_PER_CPU(type, name, initvalue) \
DEFINE_PER_CPU(type, name) = initvalue; \
type name##_early_map[NR_CPUS] __initdata = \
{ [0 ... NR_CPUS-1] = initvalue; } \
type *name##_early_ptr = name##_early_map
#define DECLARE_EARLY_PER_CPU(type, name) \
DECLARE_PER_CPU(type, name); \
extern type *name##_early_ptr; \
extern type name##_early_map[]
#define EXPORT_EARLY_PER_CPU(name) \
EXPORT_PER_CPU(name)
/* rvalue only */
#define early_per_cpu(name, cpu) \
(name##ptr? name##ptr[cpu] : per_cpu(name, cpu))
#define early_per_cpu_ptr(name) (name##_early_ptr)
#define early_per_cpu_map(name, idx) (name##_early_map[idx])
#else /* !CONFIG_SMP */
#define DEFINE_EARLY_PER_CPU(type, name, initvalue) \
DEFINE_PER_CPU(type, name) = initvalue
#define DECLARE_EARLY_PER_CPU(name) \
DECLARE_PER_CPU(name)
#define EXPORT_EARLY_PER_CPU(name) \
EXPORT_PER_CPU(name)
#define early_per_cpu(name, cpu) per_cpu(name, cpu)
#define early_per_cpu_ptr(name) NULL
/* no early_per_cpu_map() */
#endif /* !CONFIG_SMP */
------------------------------------------------------------
include/asm-x86/smp.h:
DECLARE_EARLY_PER_CPU(u16, x86_cpu_to_apicid);
DECLARE_EARLY_PER_CPU(u16, x86_bios_cpu_apicid);
------------------------------------------------------------
arch/x86/kernel/setup.c:
/* which logical CPU number maps to which CPU (physical APIC ID) */
DEFINE_EARLY_PER_CPU(u16, x86_cpu_to_apicid, BAD_APICID);
DEFINE_EARLY_PER_CPU(u16, x86_bios_cpu_apicid, BAD_APICID);
EXPORT_EARLY_PER_CPU(x86_cpu_to_apicid);
EXPORT_EARLY_PER_CPU(x86_bios_cpu_apicid);
#ifdef CONFIG_NUMA
DEFINE_EARLY_PER_CPU(int, x86_cpu_to_node, NUMA_NO_NODE);
EXPORT_EARLY_PER_CPU(x86_cpu_to_node);
#endif
...
#if defined(CONFIG_HAVE_SETUP_PER_CPU_AREA) && defined(CONFIG_SMP)
/*
* Copy data used in early init routines from the initial arrays to the
* per cpu data areas. These arrays then become expendable and the
* *_early_ptr's are zeroed indicating that the static arrays are gone.
*/
static void __init setup_per_cpu_maps(void)
{
int cpu;
for_each_possible_cpu(cpu) {
per_cpu(x86_cpu_to_apicid, cpu) =
early_per_cpu_map(x86_cpu_to_apicid, cpu);
per_cpu(x86_bios_cpu_apicid, cpu) =
early_per_cpu_map(x86_bios_cpu_apicid, cpu);
#ifdef CONFIG_NUMA
per_cpu(x86_cpu_to_node_map, cpu) =
early_per_cpu_map(x86_cpu_to_node_map, cpu);
#endif
}
/* indicate the early static arrays will soon be gone */
early_per_cpu_ptr(x86_cpu_to_apicid) = NULL;
early_per_cpu_ptr(x86_bios_cpu_apicid) = NULL;
#ifdef CONFIG_NUMA
early_per_cpu_ptr(x86_cpu_to_node_map) = NULL;
#endif
...
------------------------------------------------------------
arch/x86/mm/numa_64.c:
void __cpuinit numa_set_node(int cpu, int node)
{
int *cpu_to_node_map = early_per_cpu_ptr(x86_cpu_to_node_map);
if(cpu_to_node_map)
cpu_to_node_map[cpu] = node;
else if(per_cpu_offset(cpu))
per_cpu(x86_cpu_to_node_map, cpu) = node;
...
void __init init_cpu_to_node(void)
{
int i;
for (i = 0; i < NR_CPUS; i++) {
int node;
u16 apicid = early_per_cpu(x86_cpu_to_apicid, i);
if (apicid == BAD_APICID)
continue;
...
------------------------------------------------------------
next prev parent reply other threads:[~2008-04-07 20:36 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-25 22:06 [PATCH 00/10] NR_CPUS: third reduction of NR_CPUS memory usage x86-version v2 Mike Travis
2008-03-25 22:06 ` [PATCH 01/10] x86_64: Cleanup non-smp usage of cpu maps v2 Mike Travis
2008-03-26 6:40 ` Ingo Molnar
2008-03-26 16:11 ` Mike Travis
2008-04-07 20:36 ` Mike Travis [this message]
2008-04-07 21:32 ` Ingo Molnar
2008-03-25 22:06 ` [PATCH 02/10] init: move setup of nr_cpu_ids to as early as possible v2 Mike Travis
2008-03-26 6:27 ` Ingo Molnar
2008-03-26 15:43 ` Mike Travis
2008-03-26 17:09 ` Ingo Molnar
2008-03-26 18:22 ` Mike Travis
2008-03-25 22:06 ` [PATCH 03/10] cpufreq: change cpu freq arrays to per_cpu variables Mike Travis
2008-03-25 22:06 ` [PATCH 04/10] acpi: change processors from array to per_cpu variable Mike Travis
2008-03-25 22:06 ` [PATCH 05/10] cpumask: Add cpumask_scnprintf_len function Mike Travis
2008-03-25 22:06 ` [PATCH 06/10] x86: reduce memory and stack usage in intel_cacheinfo Mike Travis
2008-03-26 6:50 ` Ingo Molnar
2008-03-26 15:41 ` Mike Travis
2008-03-26 16:13 ` Jeremy Fitzhardinge
2008-03-26 16:27 ` Mike Travis
2008-03-26 16:59 ` Jeremy Fitzhardinge
2008-03-26 18:15 ` Mike Travis
2008-03-26 17:12 ` Ingo Molnar
2008-03-26 17:28 ` H. Peter Anvin
2008-03-26 17:35 ` Ingo Molnar
2008-03-26 18:20 ` Mike Travis
2008-03-25 22:06 ` [PATCH 07/10] cpu: change cpu_sys_devices from array to per_cpu variable Mike Travis
2008-03-25 22:06 ` [PATCH 08/10] net: remove NR_CPUS arrays in net/core/dev.c v2 Mike Travis
2008-03-25 22:06 ` [PATCH 09/10] x86: oprofile: remove NR_CPUS arrays in arch/x86/oprofile/nmi_int.c Mike Travis
2008-03-26 6:53 ` Ingo Molnar
2008-03-25 22:07 ` [PATCH 10/10] sched: Remove fixed NR_CPUS sized arrays in kernel_sched.c Mike Travis
2008-03-26 6:34 ` [PATCH 00/10] NR_CPUS: third reduction of NR_CPUS memory usage x86-version v2 Ingo Molnar
2008-03-26 15:48 ` Mike Travis
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=47FA85E4.5010005@sgi.com \
--to=travis@sgi.com \
--cc=akpm@linux-foundation.org \
--cc=clameter@sgi.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mingo@elte.hu \
--cc=tglx@linutronix.de \
/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