From patchwork Fri Oct 21 06:24:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Liang Z" X-Patchwork-Id: 684913 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3t0bc84YQDz9rxv for ; Fri, 21 Oct 2016 17:38:48 +1100 (AEDT) Received: from localhost ([::1]:58877 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bxTTZ-0007XY-FZ for incoming@patchwork.ozlabs.org; Fri, 21 Oct 2016 02:38:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37231) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bxTS5-0006Oz-Oa for qemu-devel@nongnu.org; Fri, 21 Oct 2016 02:37:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bxTS2-0006CA-MK for qemu-devel@nongnu.org; Fri, 21 Oct 2016 02:37:13 -0400 Received: from mga01.intel.com ([192.55.52.88]:30158) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1bxTS2-00065C-DY for qemu-devel@nongnu.org; Fri, 21 Oct 2016 02:37:10 -0400 Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP; 20 Oct 2016 23:37:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,375,1473145200"; d="scan'208";a="22396692" Received: from ll.sh.intel.com (HELO localhost) ([10.239.13.123]) by orsmga004.jf.intel.com with ESMTP; 20 Oct 2016 23:37:06 -0700 From: Liang Li To: mst@redhat.com Date: Fri, 21 Oct 2016 14:24:36 +0800 Message-Id: <1477031080-12616-4-git-send-email-liang.z.li@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1477031080-12616-1-git-send-email-liang.z.li@intel.com> References: <1477031080-12616-1-git-send-email-liang.z.li@intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.88 Subject: [Qemu-devel] [RESEND PATCH v3 kernel 3/7] mm: add a function to get the max pfn X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: virtio-dev@lists.oasis-open.org, kvm@vger.kernel.org, quintela@redhat.com, amit.shah@redhat.com, Liang Li , dave.hansen@intel.com, qemu-devel@nongnu.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, cornelia.huck@de.ibm.com, pbonzini@redhat.com, Andrew Morton , virtualization@lists.linux-foundation.org, Mel Gorman , dgilbert@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Expose the function to get the max pfn, so it can be used in the virtio-balloon device driver. Simply include the 'linux/bootmem.h' is not enough, if the device driver is built to a module, directly refer the max_pfn lead to build failed. Signed-off-by: Liang Li Cc: Andrew Morton Cc: Mel Gorman Cc: Michael S. Tsirkin Cc: Paolo Bonzini Cc: Cornelia Huck Cc: Amit Shah --- include/linux/mm.h | 1 + mm/page_alloc.c | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/include/linux/mm.h b/include/linux/mm.h index ffbd729..2a89da0e 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1776,6 +1776,7 @@ static inline spinlock_t *pmd_lock(struct mm_struct *mm, pmd_t *pmd) extern void free_area_init_node(int nid, unsigned long * zones_size, unsigned long zone_start_pfn, unsigned long *zholes_size); extern void free_initmem(void); +extern unsigned long get_max_pfn(void); /* * Free reserved pages within range [PAGE_ALIGN(start), end & PAGE_MASK) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 2b3bf67..e5f63a9 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -4426,6 +4426,16 @@ void show_free_areas(unsigned int filter) show_swap_cache_info(); } +/* + * The max_pfn can change because of memory hot plug, so it's only good + * as a hint. e.g. for sizing data structures. + */ +unsigned long get_max_pfn(void) +{ + return max_pfn; +} +EXPORT_SYMBOL(get_max_pfn); + static void zoneref_set_zone(struct zone *zone, struct zoneref *zoneref) { zoneref->zone = zone;