Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 356539
b: refs/heads/master
c: 27168d3
h: refs/heads/master
i:
  356537: fdfa022
  356535: 518e0d4
v: v3
  • Loading branch information
Tang Chen authored and Linus Torvalds committed Feb 24, 2013
1 parent fed912f commit e03c9e9
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e8d1955258091e4c92d5a975ebd7fd8a98f5d30f
refs/heads/master: 27168d38fa209073219abedbe6a9de7ba9acbfad
64 changes: 61 additions & 3 deletions trunk/arch/x86/mm/srat.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,65 @@ static inline int save_add_info(void) {return 1;}
static inline int save_add_info(void) {return 0;}
#endif

#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP
static void __init handle_movablemem(int node, u64 start, u64 end)
{
int overlap;
unsigned long start_pfn, end_pfn;

start_pfn = PFN_DOWN(start);
end_pfn = PFN_UP(end);

/*
* For movablecore_map=nn[KMG]@ss[KMG]:
*
* SRAT: |_____| |_____| |_________| |_________| ......
* node id: 0 1 1 2
* user specified: |__| |___|
* movablemem_map: |___| |_________| |______| ......
*
* Using movablemem_map, we can prevent memblock from allocating memory
* on ZONE_MOVABLE at boot time.
*/
overlap = movablemem_map_overlap(start_pfn, end_pfn);
if (overlap >= 0) {
/*
* If part of this range is in movablemem_map, we need to
* add the range after it to extend the range to the end
* of the node, because from the min address specified to
* the end of the node will be ZONE_MOVABLE.
*/
start_pfn = max(start_pfn,
movablemem_map.map[overlap].start_pfn);
insert_movablemem_map(start_pfn, end_pfn);

/*
* Set the nodemask, so that if the address range on one node
* is not continuse, we can add the subsequent ranges on the
* same node into movablemem_map.
*/
node_set(node, movablemem_map.numa_nodes_hotplug);
} else {
if (node_isset(node, movablemem_map.numa_nodes_hotplug))
/*
* Insert the range if we already have movable ranges
* on the same node.
*/
insert_movablemem_map(start_pfn, end_pfn);
}
}
#else /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */
static inline void handle_movablemem(int node, u64 start, u64 end)
{
}
#endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */

/* Callback for parsing of the Proximity Domain <-> Memory Area mappings */
int __init
acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma)
{
u64 start, end;
u32 hotpluggable;
int node, pxm;

if (srat_disabled())
Expand All @@ -154,7 +208,8 @@ acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma)
goto out_err_bad_srat;
if ((ma->flags & ACPI_SRAT_MEM_ENABLED) == 0)
goto out_err;
if ((ma->flags & ACPI_SRAT_MEM_HOT_PLUGGABLE) && !save_add_info())
hotpluggable = ma->flags & ACPI_SRAT_MEM_HOT_PLUGGABLE;
if (hotpluggable && !save_add_info())
goto out_err;

start = ma->base_address;
Expand All @@ -174,9 +229,12 @@ acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma)

node_set(node, numa_nodes_parsed);

printk(KERN_INFO "SRAT: Node %u PXM %u [mem %#010Lx-%#010Lx]\n",
printk(KERN_INFO "SRAT: Node %u PXM %u [mem %#010Lx-%#010Lx] %s\n",
node, pxm,
(unsigned long long) start, (unsigned long long) end - 1);
(unsigned long long) start, (unsigned long long) end - 1,
hotpluggable ? "Hot Pluggable": "");

handle_movablemem(node, start, end);

return 0;
out_err_bad_srat:
Expand Down
5 changes: 5 additions & 0 deletions trunk/include/linux/mm.h
Original file line number Diff line number Diff line change
Expand Up @@ -1368,8 +1368,13 @@ struct movablemem_entry {
struct movablemem_map {
int nr_map;
struct movablemem_entry map[MOVABLEMEM_MAP_MAX];
nodemask_t numa_nodes_hotplug; /* on which nodes we specify memory */
};

extern void __init insert_movablemem_map(unsigned long start_pfn,
unsigned long end_pfn);
extern int __init movablemem_map_overlap(unsigned long start_pfn,
unsigned long end_pfn);
#endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */

#if !defined(CONFIG_HAVE_MEMBLOCK_NODE_MAP) && \
Expand Down
34 changes: 32 additions & 2 deletions trunk/mm/page_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -5175,6 +5175,36 @@ static int __init cmdline_parse_movablecore(char *p)
early_param("kernelcore", cmdline_parse_kernelcore);
early_param("movablecore", cmdline_parse_movablecore);

/**
* movablemem_map_overlap() - Check if a range overlaps movablemem_map.map[].
* @start_pfn: start pfn of the range to be checked
* @end_pfn: end pfn of the range to be checked (exclusive)
*
* This function checks if a given memory range [start_pfn, end_pfn) overlaps
* the movablemem_map.map[] array.
*
* Return: index of the first overlapped element in movablemem_map.map[]
* or -1 if they don't overlap each other.
*/
int __init movablemem_map_overlap(unsigned long start_pfn,
unsigned long end_pfn)
{
int overlap;

if (!movablemem_map.nr_map)
return -1;

for (overlap = 0; overlap < movablemem_map.nr_map; overlap++)
if (start_pfn < movablemem_map.map[overlap].end_pfn)
break;

if (overlap == movablemem_map.nr_map ||
end_pfn <= movablemem_map.map[overlap].start_pfn)
return -1;

return overlap;
}

/**
* insert_movablemem_map - Insert a memory range in to movablemem_map.map.
* @start_pfn: start pfn of the range
Expand All @@ -5183,8 +5213,8 @@ early_param("movablecore", cmdline_parse_movablecore);
* This function will also merge the overlapped ranges, and sort the array
* by start_pfn in monotonic increasing order.
*/
static void __init insert_movablemem_map(unsigned long start_pfn,
unsigned long end_pfn)
void __init insert_movablemem_map(unsigned long start_pfn,
unsigned long end_pfn)
{
int pos, overlap;

Expand Down

0 comments on commit e03c9e9

Please sign in to comment.