From patchwork Fri Aug 30 13:24:06 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Srivatsa S. Bhat" X-Patchwork-Id: 2852058 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0763E9F313 for ; Fri, 30 Aug 2013 13:28:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C129A205E5 for ; Fri, 30 Aug 2013 13:28:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 87F91205DE for ; Fri, 30 Aug 2013 13:28:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756504Ab3H3N2J (ORCPT ); Fri, 30 Aug 2013 09:28:09 -0400 Received: from e37.co.us.ibm.com ([32.97.110.158]:33331 "EHLO e37.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756309Ab3H3N2H (ORCPT ); Fri, 30 Aug 2013 09:28:07 -0400 Received: from /spool/local by e37.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 30 Aug 2013 07:28:06 -0600 Received: from d03dlp01.boulder.ibm.com (9.17.202.177) by e37.co.us.ibm.com (192.168.1.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 30 Aug 2013 07:28:05 -0600 Received: from d03relay04.boulder.ibm.com (d03relay04.boulder.ibm.com [9.17.195.106]) by d03dlp01.boulder.ibm.com (Postfix) with ESMTP id 3830B1FF001C; Fri, 30 Aug 2013 07:28:04 -0600 (MDT) Received: from d03av03.boulder.ibm.com (d03av03.boulder.ibm.com [9.17.195.169]) by d03relay04.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r7UDS4Xv116034; Fri, 30 Aug 2013 07:28:04 -0600 Received: from d03av03.boulder.ibm.com (loopback [127.0.0.1]) by d03av03.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r7UDS1aw029798; Fri, 30 Aug 2013 07:28:04 -0600 Received: from srivatsabhat.in.ibm.com ([9.79.248.196]) by d03av03.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r7UDRq1Y029172; Fri, 30 Aug 2013 07:27:54 -0600 From: "Srivatsa S. Bhat" Subject: [RFC PATCH v3 32/35] mm: Modify move_freepages() to handle pages in the region allocator properly To: akpm@linux-foundation.org, mgorman@suse.de, hannes@cmpxchg.org, tony.luck@intel.com, matthew.garrett@nebula.com, dave@sr71.net, riel@redhat.com, arjan@linux.intel.com, srinivas.pandruvada@linux.intel.com, willy@linux.intel.com, kamezawa.hiroyu@jp.fujitsu.com, lenb@kernel.org, rjw@sisk.pl Cc: gargankita@gmail.com, paulmck@linux.vnet.ibm.com, svaidy@linux.vnet.ibm.com, andi@firstfloor.org, isimatu.yasuaki@jp.fujitsu.com, santosh.shilimkar@ti.com, kosaki.motohiro@gmail.com, srivatsa.bhat@linux.vnet.ibm.com, linux-pm@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Fri, 30 Aug 2013 18:54:06 +0530 Message-ID: <20130830132404.4947.36588.stgit@srivatsabhat.in.ibm.com> In-Reply-To: <20130830131221.4947.99764.stgit@srivatsabhat.in.ibm.com> References: <20130830131221.4947.99764.stgit@srivatsabhat.in.ibm.com> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13083013-7164-0000-0000-000001252FE4 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-9.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There are situations in which the memory management subsystem needs to move pages from one migratetype to another, such as when setting up the per-zone migrate reserves (where freepages are moved from MIGRATE_MOVABLE to MIGRATE_RESERVE freelists). But the existing code that does freepage movement is unaware of the region allocator. In other words, it always assumes that the freepages that it is moving are always in the buddy page allocator's freelists. But with the introduction of the region allocator, the freepages could instead reside in the region allocator as well. So teach move_freepages() to check whether the pages are in the buddy page allocator's freelists or the region allocator and handle the two cases appropriately. The region allocator is designed in such a way that it always allocates or receives entire memory regions as a single unit. To retain these semantics during freepage movement, we first move all the pages of that region from the region allocator to the MIGRATE_MOVABLE buddy freelist and then move the requested page(s) from MIGRATE_MOVABLE to the required migratetype. Signed-off-by: Srivatsa S. Bhat --- mm/page_alloc.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) -- 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/mm/page_alloc.c b/mm/page_alloc.c index fc530ff..3ce0c61 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1557,7 +1557,7 @@ int move_freepages(struct zone *zone, struct page *page; unsigned long order; struct free_area *area; - int pages_moved = 0, old_mt; + int pages_moved = 0, old_mt, region_id; #ifndef CONFIG_HOLES_IN_ZONE /* @@ -1584,7 +1584,23 @@ int move_freepages(struct zone *zone, continue; } + /* + * If the page is in the region allocator, we first move the + * region to the MIGRATE_MOVABLE buddy freelists and then move + * that page to the freelist of the requested migratetype. + * This is because the region allocator operates on whole region- + * sized chunks, whereas here we want to move pages in much + * smaller chunks. + */ order = page_order(page); + if (page_in_region_allocator(page)) { + region_id = page_zone_region_id(page); + __del_from_region_allocator(zone, order, MIGRATE_MOVABLE, + region_id); + + continue; /* Try this page again from the buddy-list */ + } + old_mt = get_freepage_migratetype(page); area = &zone->free_area[order]; move_page_freelist(page, &area->free_list[old_mt],