[patch 3/3] [v2] powerpc: make the CMM memory hotplug aware

Robert Jennings rcj at linux.vnet.ibm.com
Sat Nov 21 03:10:42 EST 2009


* Andrew Morton (akpm at linux-foundation.org) wrote:
> On Wed, 18 Nov 2009 12:59:08 -0600
> Robert Jennings <rcj at linux.vnet.ibm.com> wrote:
> 
> > The Collaborative Memory Manager (CMM) module allocates individual pages
> > over time that are not migratable.  On a long running system this can
> > severely impact the ability to find enough pages to support a hotplug
> > memory remove operation.
> > 
> > This patch adds a memory isolation notifier and a memory hotplug notifier.
<snip>
> : @@ -563,6 +565,37 @@ static int cmm_mem_going_offline(void *a
> :  		}
> :  		pa_curr = pa_curr->next;
> :  	}
> : +
> : +	/* Search for page list structures in the range to be offlined */
> : +	pa_last = NULL;
> : +	pa_curr = cmm_page_list;
> : +	while (pa_curr) {
> : +		if (((unsigned long)pa_curr >= start_page) &&
> : +				((unsigned long)pa_curr < end_page)) {
> : +			npa = (struct cmm_page_array *)__get_free_page(
> : +					GFP_NOIO | __GFP_NOWARN |
> : +					__GFP_NORETRY | __GFP_NOMEMALLOC);
> : +			if (!npa) {
> : +				spin_unlock(&cmm_lock);
> : +				cmm_dbg("Failed to allocate memory for list "
> : +						"management. Memory hotplug "
> : +						"failed.\n");
> : +				return ENOMEM;
> : +			}
> : +			memcpy(npa, pa_curr, PAGE_SIZE);
> : +			if (pa_curr == cmm_page_list)
> : +				cmm_page_list = npa;
> : +			if (pa_last)
> : +				pa_last->next = npa;
> : +			free_page((unsigned long) pa_curr);
> : +			freed++;
> : +			pa_curr = npa;
> : +		}
> : +
> : +		pa_last = pa_curr;
> : +		pa_curr = pa_curr->next;
> : +	}
> : +
> :  	spin_unlock(&cmm_lock);
> :  	cmm_dbg("Released %ld pages in the search range.\n", freed);
> :  
> 
> I'm wondering what is the maximum hold time of cmm_lock.  Rounded to
> the nearest fortnight :)

I've optimized this for sub-fortnight performance, but the maximum
hold time is a function of the number of pages in the balloon and in the
infreqent case that we try to migrate a page array page it will attempt
a page allocation.  I'm calling __get_free_pages with __GFP_NORETRY and
the offline fails quickly if we don't get the page.  Additionally, the
cmm_lock could be held by either the balloon allocation or deallocation
functions when the hotplug handler is called; I've addressed this as well.

For the allocation path the locking granularity is quite good and
a hotplug event will cause the allocation function to exit early to
minimize memory pressure.

The balloon deallocation path was not altered, it will hold the lock
and free all of the pages it was attempting to free before releasing the
lock.  The thought here is that by allowing it to complete we reduce
memory pressure and reduce the number of list entries we'll need to
search for each memory segment being offlined.


More information about the Linuxppc-dev mailing list