From patchwork Wed Sep 25 23:13:48 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: 2945971 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 D8BD69F288 for ; Wed, 25 Sep 2013 23:30:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DC55520360 for ; Wed, 25 Sep 2013 23:30:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D2F3820378 for ; Wed, 25 Sep 2013 23:30:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754614Ab3IYXSE (ORCPT ); Wed, 25 Sep 2013 19:18:04 -0400 Received: from e28smtp02.in.ibm.com ([122.248.162.2]:48553 "EHLO e28smtp02.in.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754528Ab3IYXSC (ORCPT ); Wed, 25 Sep 2013 19:18:02 -0400 Received: from /spool/local by e28smtp02.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 26 Sep 2013 04:47:59 +0530 Received: from d28dlp02.in.ibm.com (9.184.220.127) by e28smtp02.in.ibm.com (192.168.1.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 26 Sep 2013 04:47:58 +0530 Received: from d28relay04.in.ibm.com (d28relay04.in.ibm.com [9.184.220.61]) by d28dlp02.in.ibm.com (Postfix) with ESMTP id E9169394003F; Thu, 26 Sep 2013 04:47:41 +0530 (IST) Received: from d28av02.in.ibm.com (d28av02.in.ibm.com [9.184.220.64]) by d28relay04.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r8PNHsxg30343380; Thu, 26 Sep 2013 04:47:54 +0530 Received: from d28av02.in.ibm.com (localhost [127.0.0.1]) by d28av02.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id r8PNHsfZ015458; Thu, 26 Sep 2013 04:47:56 +0530 Received: from srivatsabhat.in.ibm.com ([9.79.250.85]) by d28av02.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id r8PNHorE015356; Thu, 26 Sep 2013 04:47:51 +0530 From: "Srivatsa S. Bhat" Subject: [RFC PATCH v4 01/40] mm: Introduce memory regions data-structure to capture region boundaries within nodes To: akpm@linux-foundation.org, mgorman@suse.de, dave@sr71.net, hannes@cmpxchg.org, tony.luck@intel.com, matthew.garrett@nebula.com, 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: Thu, 26 Sep 2013 04:43:48 +0530 Message-ID: <20130925231346.26184.65521.stgit@srivatsabhat.in.ibm.com> In-Reply-To: <20130925231250.26184.31438.stgit@srivatsabhat.in.ibm.com> References: <20130925231250.26184.31438.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: 13092523-5816-0000-0000-00000A148233 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00,KHOP_BIG_TO_CC, 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 The memory within a node can be divided into regions of memory that can be independently power-managed. That is, chunks of memory can be transitioned (manually or automatically) to low-power states based on the frequency of references to that region. For example, if a memory chunk is not referenced for a given threshold amount of time, the hardware (memory controller) can decide to put that piece of memory into a content-preserving low-power state. And of course, on the next reference to that chunk of memory, it will be transitioned back to full-power for read/write operations. So, the Linux MM can take advantage of this feature by managing the available memory with an eye towards power-savings - ie., by keeping the memory allocations/references consolidated to a minimum no. of such power-manageable memory regions. In order to do so, the first step is to teach the MM about the boundaries of these regions - and to capture that info, we introduce a new data-structure called "Memory Regions". [Also, the concept of memory regions could potentially be extended to work with different classes of memory like PCM (Phase Change Memory) etc and hence, it is not limited to just power management alone]. We already sub-divide a node's memory into zones, based on some well-known constraints. So the question is, where do we fit in memory regions in this hierarchy. Instead of artificially trying to fit it into the hierarchy one way or the other, we choose to simply capture the region boundaries in a parallel data-structure, since most likely the region boundaries won't naturally fit inside the zone boundaries or vice-versa. But of course, memory regions are sub-divisions *within* a node, so it makes sense to keep the data-structures in the node's struct pglist_data. (Thus this placement makes memory regions parallel to zones in that node). Once we capture the region boundaries in the memory regions data-structure, we can influence MM decisions at various places, such as page allocation, reclamation etc, in order to perform power-aware memory management. Signed-off-by: Srivatsa S. Bhat --- include/linux/mmzone.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) -- 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 bd791e4..d3288b0 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -35,6 +35,8 @@ */ #define PAGE_ALLOC_COSTLY_ORDER 3 +#define MAX_NR_NODE_REGIONS 512 + enum { MIGRATE_UNMOVABLE, MIGRATE_RECLAIMABLE, @@ -708,6 +710,14 @@ struct node_active_region { extern struct page *mem_map; #endif +struct node_mem_region { + unsigned long start_pfn; + unsigned long end_pfn; + unsigned long present_pages; + unsigned long spanned_pages; + struct pglist_data *pgdat; +}; + /* * The pg_data_t structure is used in machines with CONFIG_DISCONTIGMEM * (mostly NUMA machines?) to denote a higher-level memory zone than the @@ -724,6 +734,8 @@ typedef struct pglist_data { struct zone node_zones[MAX_NR_ZONES]; struct zonelist node_zonelists[MAX_ZONELISTS]; int nr_zones; + struct node_mem_region node_regions[MAX_NR_NODE_REGIONS]; + int nr_node_regions; #ifdef CONFIG_FLAT_NODE_MEM_MAP /* means !SPARSEMEM */ struct page *node_mem_map; #ifdef CONFIG_MEMCG