mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 19:21:31 -04:00
memory-hotplug: add sysfs valid_zones attribute
Currently memory-hotplug has two limits: 1. If the memory block is in ZONE_NORMAL, you can change it to ZONE_MOVABLE, but this memory block must be adjacent to ZONE_MOVABLE. 2. If the memory block is in ZONE_MOVABLE, you can change it to ZONE_NORMAL, but this memory block must be adjacent to ZONE_NORMAL. With this patch, we can easy to know a memory block can be onlined to which zone, and don't need to know the above two limits. Updated the related Documentation. [[email protected]: use conventional comment layout] [[email protected]: fix build with CONFIG_MEMORY_HOTREMOVE=n] [[email protected]: remove unused local zone_prev] Signed-off-by: Zhang Zhen <[email protected]> Cc: Dave Hansen <[email protected]> Cc: David Rientjes <[email protected]> Cc: Toshi Kani <[email protected]> Cc: Yasuaki Ishimatsu <[email protected]> Cc: Naoya Horiguchi <[email protected]> Cc: Wang Nan <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
cc71aba348
commit
ed2f240094
5 changed files with 62 additions and 2 deletions
|
|
@ -373,6 +373,45 @@ static ssize_t show_phys_device(struct device *dev,
|
|||
return sprintf(buf, "%d\n", mem->phys_device);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_MEMORY_HOTREMOVE
|
||||
static ssize_t show_valid_zones(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct memory_block *mem = to_memory_block(dev);
|
||||
unsigned long start_pfn, end_pfn;
|
||||
unsigned long nr_pages = PAGES_PER_SECTION * sections_per_block;
|
||||
struct page *first_page;
|
||||
struct zone *zone;
|
||||
|
||||
start_pfn = section_nr_to_pfn(mem->start_section_nr);
|
||||
end_pfn = start_pfn + nr_pages;
|
||||
first_page = pfn_to_page(start_pfn);
|
||||
|
||||
/* The block contains more than one zone can not be offlined. */
|
||||
if (!test_pages_in_a_zone(start_pfn, end_pfn))
|
||||
return sprintf(buf, "none\n");
|
||||
|
||||
zone = page_zone(first_page);
|
||||
|
||||
if (zone_idx(zone) == ZONE_MOVABLE - 1) {
|
||||
/*The mem block is the last memoryblock of this zone.*/
|
||||
if (end_pfn == zone_end_pfn(zone))
|
||||
return sprintf(buf, "%s %s\n",
|
||||
zone->name, (zone + 1)->name);
|
||||
}
|
||||
|
||||
if (zone_idx(zone) == ZONE_MOVABLE) {
|
||||
/*The mem block is the first memoryblock of ZONE_MOVABLE.*/
|
||||
if (start_pfn == zone->zone_start_pfn)
|
||||
return sprintf(buf, "%s %s\n",
|
||||
zone->name, (zone - 1)->name);
|
||||
}
|
||||
|
||||
return sprintf(buf, "%s\n", zone->name);
|
||||
}
|
||||
static DEVICE_ATTR(valid_zones, 0444, show_valid_zones, NULL);
|
||||
#endif
|
||||
|
||||
static DEVICE_ATTR(phys_index, 0444, show_mem_start_phys_index, NULL);
|
||||
static DEVICE_ATTR(state, 0644, show_mem_state, store_mem_state);
|
||||
static DEVICE_ATTR(phys_device, 0444, show_phys_device, NULL);
|
||||
|
|
@ -523,6 +562,9 @@ static struct attribute *memory_memblk_attrs[] = {
|
|||
&dev_attr_state.attr,
|
||||
&dev_attr_phys_device.attr,
|
||||
&dev_attr_removable.attr,
|
||||
#ifdef CONFIG_MEMORY_HOTREMOVE
|
||||
&dev_attr_valid_zones.attr,
|
||||
#endif
|
||||
NULL
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue