From patchwork Tue Nov 6 19:53:30 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Srivatsa S. Bhat" X-Patchwork-Id: 1706611 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id A2EBB3FCDF for ; Tue, 6 Nov 2012 19:56:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752651Ab2KFTyq (ORCPT ); Tue, 6 Nov 2012 14:54:46 -0500 Received: from e23smtp09.au.ibm.com ([202.81.31.142]:53003 "EHLO e23smtp09.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752637Ab2KFTyo (ORCPT ); Tue, 6 Nov 2012 14:54:44 -0500 Received: from /spool/local by e23smtp09.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 7 Nov 2012 05:51:02 +1000 Received: from d23relay03.au.ibm.com (202.81.31.245) by e23smtp09.au.ibm.com (202.81.31.206) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 7 Nov 2012 05:51:00 +1000 Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139]) by d23relay03.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id qA6Jsd9a53477420; Wed, 7 Nov 2012 06:54:39 +1100 Received: from d23av04.au.ibm.com (loopback [127.0.0.1]) by d23av04.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id qA6Jsb4Q019823; Wed, 7 Nov 2012 06:54:39 +1100 Received: from srivatsabhat.in.ibm.com ([9.77.92.145]) by d23av04.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id qA6JsV5I019764; Wed, 7 Nov 2012 06:54:32 +1100 From: "Srivatsa S. Bhat" Subject: [RFC PATCH 5/8] mm: Add data-structures to describe memory regions within the zones' freelists To: akpm@linux-foundation.org, mgorman@suse.de, mjg59@srcf.ucam.org, paulmck@linux.vnet.ibm.com, dave@linux.vnet.ibm.com, maxime.coquelin@stericsson.com, loic.pallardy@stericsson.com, arjan@linux.intel.com, kmpark@infradead.org, kamezawa.hiroyu@jp.fujitsu.com, lenb@kernel.org, rjw@sisk.pl Cc: gargankita@gmail.com, amit.kachhap@linaro.org, svaidy@linux.vnet.ibm.com, thomas.abraham@linaro.org, santosh.shilimkar@ti.com, srivatsa.bhat@linux.vnet.ibm.com, linux-pm@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Wed, 07 Nov 2012 01:23:30 +0530 Message-ID: <20121106195326.6941.95816.stgit@srivatsabhat.in.ibm.com> In-Reply-To: <20121106195026.6941.24662.stgit@srivatsabhat.in.ibm.com> References: <20121106195026.6941.24662.stgit@srivatsabhat.in.ibm.com> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 x-cbid: 12110619-3568-0000-0000-000002B99D1F Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org In order to influence page allocation decisions (i.e., to make page-allocation region-aware), we need to be able to distinguish pageblocks belonging to different zone memory regions within the zones' freelists. So, within every freelist in a zone, provide pointers to describe the boundaries of zone memory regions and counters to track the number of free pageblocks within each region. Also, fixup the references to the freelist's list_head inside struct free_area. Signed-off-by: Srivatsa S. Bhat --- include/linux/mmzone.h | 17 ++++++++++++++++- mm/compaction.c | 8 ++++---- mm/page_alloc.c | 21 +++++++++++---------- mm/vmstat.c | 2 +- 4 files changed, 32 insertions(+), 16 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 3982354..aba4d68 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -82,8 +82,23 @@ static inline int get_pageblock_migratetype(struct page *page) #define MAX_NR_REGIONS 256 +struct mem_region_list { + struct list_head *page_block; + unsigned long nr_free; +}; + +struct free_list { + struct list_head list; + + /* + * Demarcates pageblocks belonging to different regions within + * this freelist. + */ + struct mem_region_list mr_list[MAX_NR_REGIONS]; +}; + struct free_area { - struct list_head free_list[MIGRATE_TYPES]; + struct free_list free_list[MIGRATE_TYPES]; unsigned long nr_free; }; diff --git a/mm/compaction.c b/mm/compaction.c index 9eef558..95f5c92 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -247,14 +247,14 @@ static void compact_capture_page(struct compact_control *cc) struct page *page; struct free_area *area; area = &(cc->zone->free_area[order]); - if (list_empty(&area->free_list[mtype])) + if (list_empty(&area->free_list[mtype].list)) continue; /* Take the lock and attempt capture of the page */ if (!compact_trylock_irqsave(&cc->zone->lock, &flags, cc)) return; - if (!list_empty(&area->free_list[mtype])) { - page = list_entry(area->free_list[mtype].next, + if (!list_empty(&area->free_list[mtype].list)) { + page = list_entry(area->free_list[mtype].list.next, struct page, lru); if (capture_free_page(page, cc->order, mtype)) { spin_unlock_irqrestore(&cc->zone->lock, @@ -866,7 +866,7 @@ static int compact_finished(struct zone *zone, for (order = cc->order; order < MAX_ORDER; order++) { struct free_area *area = &zone->free_area[cc->order]; /* Job done if page is free of the right migratetype */ - if (!list_empty(&area->free_list[cc->migratetype])) + if (!list_empty(&area->free_list[cc->migratetype].list)) return COMPACT_PARTIAL; /* Job done if allocation would set block type */ diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 7fd89cd..62d0a9a 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -588,12 +588,13 @@ static inline void __free_one_page(struct page *page, higher_buddy = higher_page + (buddy_idx - combined_idx); if (page_is_buddy(higher_page, higher_buddy, order + 1)) { list_add_tail(&page->lru, - &zone->free_area[order].free_list[migratetype]); + &zone->free_area[order].free_list[migratetype].list); goto out; } } - list_add(&page->lru, &zone->free_area[order].free_list[migratetype]); + list_add(&page->lru, + &zone->free_area[order].free_list[migratetype].list); out: zone->free_area[order].nr_free++; } @@ -811,7 +812,7 @@ static inline void expand(struct zone *zone, struct page *page, continue; } #endif - list_add(&page[size].lru, &area->free_list[migratetype]); + list_add(&page[size].lru, &area->free_list[migratetype].list); area->nr_free++; set_page_order(&page[size], high); } @@ -873,10 +874,10 @@ struct page *__rmqueue_smallest(struct zone *zone, unsigned int order, /* Find a page of the appropriate size in the preferred list */ for (current_order = order; current_order < MAX_ORDER; ++current_order) { area = &(zone->free_area[current_order]); - if (list_empty(&area->free_list[migratetype])) + if (list_empty(&area->free_list[migratetype].list)) continue; - page = list_entry(area->free_list[migratetype].next, + page = list_entry(area->free_list[migratetype].list.next, struct page, lru); list_del(&page->lru); rmv_page_order(page); @@ -946,7 +947,7 @@ int move_freepages(struct zone *zone, order = page_order(page); list_move(&page->lru, - &zone->free_area[order].free_list[migratetype]); + &zone->free_area[order].free_list[migratetype].list); set_freepage_migratetype(page, migratetype); page += 1 << order; pages_moved += 1 << order; @@ -1007,10 +1008,10 @@ __rmqueue_fallback(struct zone *zone, int order, int start_migratetype) break; area = &(zone->free_area[current_order]); - if (list_empty(&area->free_list[migratetype])) + if (list_empty(&area->free_list[migratetype].list)) continue; - page = list_entry(area->free_list[migratetype].next, + page = list_entry(area->free_list[migratetype].list.next, struct page, lru); area->nr_free--; @@ -1274,7 +1275,7 @@ void mark_free_pages(struct zone *zone) } for_each_migratetype_order(order, t) { - list_for_each(curr, &zone->free_area[order].free_list[t]) { + list_for_each(curr, &zone->free_area[order].free_list[t].list) { unsigned long i; pfn = page_to_pfn(list_entry(curr, struct page, lru)); @@ -3859,7 +3860,7 @@ static void __meminit zone_init_free_lists(struct zone *zone) { int order, t; for_each_migratetype_order(order, t) { - INIT_LIST_HEAD(&zone->free_area[order].free_list[t]); + INIT_LIST_HEAD(&zone->free_area[order].free_list[t].list); zone->free_area[order].nr_free = 0; } } diff --git a/mm/vmstat.c b/mm/vmstat.c index c737057..8183331 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -847,7 +847,7 @@ static void pagetypeinfo_showfree_print(struct seq_file *m, area = &(zone->free_area[order]); - list_for_each(curr, &area->free_list[mtype]) + list_for_each(curr, &area->free_list[mtype].list) freecount++; seq_printf(m, "%6lu ", freecount); }