Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 258931
b: refs/heads/master
c: 9d0ad8c
h: refs/heads/master
i:
  258929: c950895
  258927: a550dfd
v: v3
  • Loading branch information
Daniel Kiper authored and Linus Torvalds committed Jul 26, 2011
1 parent 5e3b5e1 commit 78e511b
Show file tree
Hide file tree
Showing 3 changed files with 75 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: ef22f6a70c9186c8e25f757b0e8f7374b37f69bf
refs/heads/master: 9d0ad8ca43ce8023bb834a409c2258bd7197fb05
11 changes: 9 additions & 2 deletions trunk/include/linux/memory_hotplug.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,19 @@ static inline void zone_seqlock_init(struct zone *zone)
extern int zone_grow_free_lists(struct zone *zone, unsigned long new_nr_pages);
extern int zone_grow_waitqueues(struct zone *zone, unsigned long nr_pages);
extern int add_one_highpage(struct page *page, int pfn, int bad_ppro);
/* need some defines for these for archs that don't support it */
extern void online_page(struct page *page);
/* VM interface that may be used by firmware interface */
extern int online_pages(unsigned long, unsigned long);
extern void __offline_isolated_pages(unsigned long, unsigned long);

typedef void (*online_page_callback_t)(struct page *page);

extern int set_online_page_callback(online_page_callback_t callback);
extern int restore_online_page_callback(online_page_callback_t callback);

extern void __online_page_set_limits(struct page *page);
extern void __online_page_increment_counters(struct page *page);
extern void __online_page_free(struct page *page);

#ifdef CONFIG_MEMORY_HOTREMOVE
extern bool is_pageblock_removable_nolock(struct page *page);
#endif /* CONFIG_MEMORY_HOTREMOVE */
Expand Down
68 changes: 65 additions & 3 deletions trunk/mm/memory_hotplug.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@

#include "internal.h"

/*
* online_page_callback contains pointer to current page onlining function.
* Initially it is generic_online_page(). If it is required it could be
* changed by calling set_online_page_callback() for callback registration
* and restore_online_page_callback() for generic callback restore.
*/

static void generic_online_page(struct page *page);

static online_page_callback_t online_page_callback = generic_online_page;

DEFINE_MUTEX(mem_hotplug_mutex);

void lock_memory_hotplug(void)
Expand Down Expand Up @@ -361,23 +372,74 @@ int __remove_pages(struct zone *zone, unsigned long phys_start_pfn,
}
EXPORT_SYMBOL_GPL(__remove_pages);

void online_page(struct page *page)
int set_online_page_callback(online_page_callback_t callback)
{
int rc = -EINVAL;

lock_memory_hotplug();

if (online_page_callback == generic_online_page) {
online_page_callback = callback;
rc = 0;
}

unlock_memory_hotplug();

return rc;
}
EXPORT_SYMBOL_GPL(set_online_page_callback);

int restore_online_page_callback(online_page_callback_t callback)
{
int rc = -EINVAL;

lock_memory_hotplug();

if (online_page_callback == callback) {
online_page_callback = generic_online_page;
rc = 0;
}

unlock_memory_hotplug();

return rc;
}
EXPORT_SYMBOL_GPL(restore_online_page_callback);

void __online_page_set_limits(struct page *page)
{
unsigned long pfn = page_to_pfn(page);

totalram_pages++;
if (pfn >= num_physpages)
num_physpages = pfn + 1;
}
EXPORT_SYMBOL_GPL(__online_page_set_limits);

void __online_page_increment_counters(struct page *page)
{
totalram_pages++;

#ifdef CONFIG_HIGHMEM
if (PageHighMem(page))
totalhigh_pages++;
#endif
}
EXPORT_SYMBOL_GPL(__online_page_increment_counters);

void __online_page_free(struct page *page)
{
ClearPageReserved(page);
init_page_count(page);
__free_page(page);
}
EXPORT_SYMBOL_GPL(__online_page_free);

static void generic_online_page(struct page *page)
{
__online_page_set_limits(page);
__online_page_increment_counters(page);
__online_page_free(page);
}

static int online_pages_range(unsigned long start_pfn, unsigned long nr_pages,
void *arg)
Expand All @@ -388,7 +450,7 @@ static int online_pages_range(unsigned long start_pfn, unsigned long nr_pages,
if (PageReserved(pfn_to_page(start_pfn)))
for (i = 0; i < nr_pages; i++) {
page = pfn_to_page(start_pfn + i);
online_page(page);
(*online_page_callback)(page);
onlined_pages++;
}
*(unsigned long *)arg = onlined_pages;
Expand Down

0 comments on commit 78e511b

Please sign in to comment.