[PATCH] numa placement for dynamically added memory

Nathan Lynch ntl at pobox.com
Fri Dec 2 14:02:30 EST 2005


Hi Mike-

Mike Kravetz wrote:
> This patch places dynamically added memory within the appropriate
> numa node.  A new routine hot_add_scn_to_nid() replicates most of
> the memory scanning code in parse_numa_properties().
> 

<snip>

> +#ifdef CONFIG_MEMORY_HOTPLUG
> +static unsigned long read_n_cells(int n, unsigned int **buf)
> +#else
>  static unsigned long __init read_n_cells(int n, unsigned int **buf)
> +#endif

Any reason not to use __devinit here?  Or maybe look into devising a
macro like __cpuinit for memory hotplug.

<snip>

> +#ifdef CONFIG_MEMORY_HOTPLUG
> +/*
> + * Find the node associated with a hot added memory section.  Section
> + * corresponds to a SPARSEMEM section, not an LMB.  It is assumed that
> + * sections are fully contained within a single LMB.
> + */
> +int hot_add_scn_to_nid(unsigned long scn_addr)
> +{
> +	struct device_node *memory = NULL;
> +
> +	if (!numa_enabled || (min_common_depth < 0))
> +		return 0;
> +
> +	while ((memory = of_find_node_by_type(memory, "memory")) != NULL) {
> +		unsigned long start, size;
> +		int numa_domain, ranges;
> +		unsigned int *memcell_buf;
> +		unsigned int len;
> +
> +		memcell_buf = (unsigned int *)get_property(memory, "reg", &len);
> +		if (!memcell_buf || len <= 0)
> +			continue;
> +
> +		ranges = memory->n_addrs;	/* ranges in cell */
> +ha_new_range:
> +		start = read_n_cells(n_mem_addr_cells, &memcell_buf);
> +		size = read_n_cells(n_mem_size_cells, &memcell_buf);
> +		numa_domain = of_node_numa_domain(memory);
> +
> +		/* Domains not present at boot default to 0 */
> +		if (!node_online(numa_domain))
> +			numa_domain = 0;

Nope, 0 is not always a valid node on pSeries lpar.  I suggest using
any_online_node(), or revisiting the idea of logical<->physical
mapping of node/domain ids.  I tried the latter a few months ago but
I've been working on other stuff lately and haven't been able to
revisit it.

<snip>

> +#ifdef CONFIG_NUMA
> +extern int hot_add_scn_to_nid(unsigned long scn_addr);
> +#else
> +#define hot_add_scn_to_nid(scn_addr) (0)
> +#endif

Make hot_add_scn_to_nid a static inline in the !CONFIG_NUMA case,
please.


Nathan



More information about the Linuxppc64-dev mailing list