Re: [PATCH 1/2] page-allocator: Split per-cpu list into one-list-per-migrate-type

From: Minchan Kim
Date: Fri Aug 28 2009 - 08:00:33 EST


On Fri, Aug 28, 2009 at 8:52 PM, Minchan Kim<minchan.kim@xxxxxxxxx> wrote:
> Hi, Mel.
>
> On Fri, 28 Aug 2009 09:44:26 +0100
> Mel Gorman <mel@xxxxxxxxx> wrote:
>
>> Currently the per-cpu page allocator searches the PCP list for pages of the
>> correct migrate-type to reduce the possibility of pages being inappropriate
>> placed from a fragmentation perspective. This search is potentially expensive
>> in a fast-path and undesirable. Splitting the per-cpu list into multiple
>> lists increases the size of a per-cpu structure and this was potentially
>> a major problem at the time the search was introduced. These problem has
>> been mitigated as now only the necessary number of structures is allocated
>> for the running system.
>>
>> This patch replaces a list search in the per-cpu allocator with one list per
>> migrate type. The potential snag with this approach is when bulk freeing
>> pages. We round-robin free pages based on migrate type which has little
>> bearing on the cache hotness of the page and potentially checks empty lists
>> repeatedly in the event the majority of PCP pages are of one type.
>>
>> Signed-off-by: Mel Gorman <mel@xxxxxxxxx>
>> Acked-by: Nick Piggin <npiggin@xxxxxxx>
>> ---
>> Âinclude/linux/mmzone.h | Â Â5 ++-
>> Âmm/page_alloc.c    Â| Â106 ++++++++++++++++++++++++++---------------------
>> Â2 files changed, 63 insertions(+), 48 deletions(-)
>>
>> diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
>> index 008cdcd..045348f 100644
>> --- a/include/linux/mmzone.h
>> +++ b/include/linux/mmzone.h
>> @@ -38,6 +38,7 @@
>> Â#define MIGRATE_UNMOVABLE Â Â 0
>> Â#define MIGRATE_RECLAIMABLE Â 1
>> Â#define MIGRATE_MOVABLE Â Â Â 2
>> +#define MIGRATE_PCPTYPES Â Â Â3 /* the number of types on the pcp lists */
>> Â#define MIGRATE_RESERVE Â Â Â 3
>> Â#define MIGRATE_ISOLATE Â Â Â 4 /* can't allocate from here */
>> Â#define MIGRATE_TYPES Â Â Â Â 5
>> @@ -169,7 +170,9 @@ struct per_cpu_pages {
>> Â Â Â int count; Â Â Â Â Â Â Â/* number of pages in the list */
>> Â Â Â int high; Â Â Â Â Â Â Â /* high watermark, emptying needed */
>> Â Â Â int batch; Â Â Â Â Â Â Â/* chunk size for buddy add/remove */
>> - Â Â struct list_head list; Â/* the list of pages */
>> +
>> + Â Â /* Lists of pages, one per migrate type stored on the pcp-lists */
>> + Â Â struct list_head lists[MIGRATE_PCPTYPES];
>> Â};
>>
>> Âstruct per_cpu_pageset {
>> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
>> index ac3afe1..65eedb5 100644
>> --- a/mm/page_alloc.c
>> +++ b/mm/page_alloc.c
>> @@ -522,7 +522,7 @@ static inline int free_pages_check(struct page *page)
>> Â}
>>
>> Â/*
>> - * Frees a list of pages.
>> + * Frees a number of pages from the PCP lists
>> Â * Assumes all pages on list are in same zone, and of same order.
>> Â * count is the number of pages to free.
>> Â *
>> @@ -532,23 +532,36 @@ static inline int free_pages_check(struct page *page)
>> Â * And clear the zone's pages_scanned counter, to hold off the "all pages are
>> Â * pinned" detection logic.
>> Â */
>> -static void free_pages_bulk(struct zone *zone, int count,
>> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â struct list_head *list, int order)
>> +static void free_pcppages_bulk(struct zone *zone, int count,
>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â struct per_cpu_pages *pcp)
>> Â{
>> + Â Â int migratetype = 0;
>> +
>
> How about caching the last sucess migratetype
> with 'per_cpu_pages->last_alloc_type'?
^^^^
free
> I think it could prevent a litte spinning empty list.

Anyway, Ignore me.
I didn't see your next patch.

--
Kind regards,
Minchan Kim
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/