{"id":663679,"url":"http://patchwork.ozlabs.org/api/patches/663679/?format=json","web_url":"http://patchwork.ozlabs.org/project/linuxppc-dev/patch/1472476010-4709-2-git-send-email-srikar@linux.vnet.ibm.com/","project":{"id":2,"url":"http://patchwork.ozlabs.org/api/projects/2/?format=json","name":"Linux PPC development","link_name":"linuxppc-dev","list_id":"linuxppc-dev.lists.ozlabs.org","list_email":"linuxppc-dev@lists.ozlabs.org","web_url":"https://github.com/linuxppc/wiki/wiki","scm_url":"https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git","webscm_url":"https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/","list_archive_url":"https://lore.kernel.org/linuxppc-dev/","list_archive_url_format":"https://lore.kernel.org/linuxppc-dev/{}/","commit_url_format":"https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/commit/?id={}"},"msgid":"<1472476010-4709-2-git-send-email-srikar@linux.vnet.ibm.com>","list_archive_url":"https://lore.kernel.org/linuxppc-dev/1472476010-4709-2-git-send-email-srikar@linux.vnet.ibm.com/","date":"2016-08-29T13:06:48","name":"[v3,1/3] mm: Introduce arch_reserved_kernel_pages()","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"0f40b5bae912ad31c35de68fecf59f9cfe88d851","submitter":{"id":11795,"url":"http://patchwork.ozlabs.org/api/people/11795/?format=json","name":"Srikar Dronamraju","email":"srikar@linux.vnet.ibm.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linuxppc-dev/patch/1472476010-4709-2-git-send-email-srikar@linux.vnet.ibm.com/mbox/","series":[],"comments":"http://patchwork.ozlabs.org/api/patches/663679/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/663679/checks/","tags":{},"related":[],"headers":{"Return-Path":"<linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org>","X-Original-To":["patchwork-incoming@ozlabs.org","linuxppc-dev@lists.ozlabs.org"],"Delivered-To":["patchwork-incoming@ozlabs.org","linuxppc-dev@lists.ozlabs.org"],"Received":["from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3sNBpC2tQmz9s9W\n\tfor <patchwork-incoming@ozlabs.org>;\n\tMon, 29 Aug 2016 23:10:11 +1000 (AEST)","from ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 3sNBpC1xTTzDsFv\n\tfor <patchwork-incoming@ozlabs.org>;\n\tMon, 29 Aug 2016 23:10:11 +1000 (AEST)","from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com\n\t[148.163.156.1])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby lists.ozlabs.org (Postfix) with ESMTPS id 3sNBlg5B0XzDrJq\n\tfor <linuxppc-dev@lists.ozlabs.org>;\n\tMon, 29 Aug 2016 23:07:59 +1000 (AEST)","from pps.filterd (m0098396.ppops.net [127.0.0.1])\n\tby mx0a-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id\n\tu7TD4T16048311\n\tfor <linuxppc-dev@lists.ozlabs.org>; Mon, 29 Aug 2016 09:07:57 -0400","from e23smtp02.au.ibm.com (e23smtp02.au.ibm.com [202.81.31.144])\n\tby mx0a-001b2d01.pphosted.com with ESMTP id 25356ft0r4-1\n\t(version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT)\n\tfor <linuxppc-dev@lists.ozlabs.org>; Mon, 29 Aug 2016 09:07:57 -0400","from localhost\n\tby e23smtp02.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use\n\tOnly! Violators will be prosecuted\n\tfor <linuxppc-dev@lists.ozlabs.org> from <srikar@linux.vnet.ibm.com>; \n\tMon, 29 Aug 2016 23:07:55 +1000","from d23dlp01.au.ibm.com (202.81.31.203)\n\tby e23smtp02.au.ibm.com (202.81.31.208) with IBM ESMTP SMTP Gateway:\n\tAuthorized Use Only! Violators will be prosecuted; \n\tMon, 29 Aug 2016 23:07:51 +1000","from d23relay10.au.ibm.com (d23relay10.au.ibm.com [9.190.26.77])\n\tby d23dlp01.au.ibm.com (Postfix) with ESMTP id 64CA62CE8054\n\tfor <linuxppc-dev@lists.ozlabs.org>;\n\tMon, 29 Aug 2016 23:07:51 +1000 (EST)","from d23av01.au.ibm.com (d23av01.au.ibm.com [9.190.234.96])\n\tby d23relay10.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id\n\tu7TD7pcS63766778\n\tfor <linuxppc-dev@lists.ozlabs.org>; Mon, 29 Aug 2016 23:07:51 +1000","from d23av01.au.ibm.com (localhost [127.0.0.1])\n\tby d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id\n\tu7TD7ov1013120\n\tfor <linuxppc-dev@lists.ozlabs.org>; Mon, 29 Aug 2016 23:07:51 +1000","from srdronam.in.ibm.com (srdronam.in.ibm.com [9.124.31.34])\n\tby d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id\n\tu7TD7hkB012996; Mon, 29 Aug 2016 23:07:47 +1000"],"X-IBM-Helo":"d23dlp01.au.ibm.com","X-IBM-MailFrom":"srikar@linux.vnet.ibm.com","X-IBM-RcptTo":"linuxppc-dev@lists.ozlabs.org","From":"Srikar Dronamraju <srikar@linux.vnet.ibm.com>","To":"Andrew Morton <akpm@linux-foundation.org>","Subject":"[PATCH v3 1/3] mm: Introduce arch_reserved_kernel_pages()","Date":"Mon, 29 Aug 2016 18:36:48 +0530","X-Mailer":"git-send-email 2.1.4","In-Reply-To":"<1472476010-4709-1-git-send-email-srikar@linux.vnet.ibm.com>","References":"<1472476010-4709-1-git-send-email-srikar@linux.vnet.ibm.com>","X-TM-AS-MML":"disable","X-Content-Scanned":"Fidelis XPS MAILER","x-cbid":"16082913-0004-0000-0000-0000018CA631","X-IBM-AV-DETECTION":"SAVI=unused REMOTE=unused XFE=unused","x-cbparentid":"16082913-0005-0000-0000-000008909F7F","Message-Id":"<1472476010-4709-2-git-send-email-srikar@linux.vnet.ibm.com>","X-Proofpoint-Virus-Version":"vendor=fsecure engine=2.50.10432:, ,\n\tdefinitions=2016-08-29_05:, , signatures=0","X-Proofpoint-Spam-Details":"rule=outbound_notspam policy=outbound score=0\n\tspamscore=0 suspectscore=0\n\tmalwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam\n\tadjust=0 reason=mlx scancount=1 engine=8.0.1-1604210000\n\tdefinitions=main-1608290132","X-BeenThere":"linuxppc-dev@lists.ozlabs.org","X-Mailman-Version":"2.1.22","Precedence":"list","List-Id":"Linux on PowerPC Developers Mail List\n\t<linuxppc-dev.lists.ozlabs.org>","List-Unsubscribe":"<https://lists.ozlabs.org/options/linuxppc-dev>,\n\t<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=unsubscribe>","List-Archive":"<http://lists.ozlabs.org/pipermail/linuxppc-dev/>","List-Post":"<mailto:linuxppc-dev@lists.ozlabs.org>","List-Help":"<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=help>","List-Subscribe":"<https://lists.ozlabs.org/listinfo/linuxppc-dev>,\n\t<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=subscribe>","Cc":"Srikar Dronamraju <srikar@linux.vnet.ibm.com>,\n\tDave Hansen <dave.hansen@intel.com>, linuxppc-dev@lists.ozlabs.org,\n\tMichal Hocko <mhocko@kernel.org>, linux-mm@kvack.org,\n\tMahesh Salgaonkar <mahesh@linux.vnet.ibm.com>,\n\tHari Bathini <hbathini@linux.vnet.ibm.com>,\n\tMel Gorman <mgorman@techsingularity.net>,\n\tVlastimil Babka <vbabka@suse.cz>","Errors-To":"linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org","Sender":"\"Linuxppc-dev\"\n\t<linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org>"},"content":"Currently arch specific code can reserve memory blocks but\nalloc_large_system_hash() may not take it into consideration when sizing\nthe hashes. This can lead to bigger hash than required and lead to no\navailable memory for other purposes. This is specifically true for\nsystems with CONFIG_DEFERRED_STRUCT_PAGE_INIT enabled.\n\nOne approach to solve this problem would be to walk through the memblock\nregions and calculate the available memory and base the size of hash\nsystem on the available memory.\n\nThe other approach would be to depend on the architecture to provide the\nnumber of pages that are reserved. This change provides hooks to allow\nthe architecture to provide the required info.\n\nCc: linux-mm@kvack.org\nCc: Mel Gorman <mgorman@techsingularity.net>\nCc: Vlastimil Babka <vbabka@suse.cz>\nCc: Michal Hocko <mhocko@kernel.org>\nCc: Andrew Morton <akpm@linux-foundation.org>\nCc: Michael Ellerman <mpe@ellerman.id.au>\nCc: linuxppc-dev@lists.ozlabs.org\nCc: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>\nCc: Hari Bathini <hbathini@linux.vnet.ibm.com>\nCc: Dave Hansen <dave.hansen@intel.com>\nCc: Balbir Singh <bsingharora@gmail.com>\nSuggested-by: Mel Gorman <mgorman@techsingularity.net>\nSigned-off-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>\n---\n include/linux/mm.h |  3 +++\n mm/page_alloc.c    | 12 ++++++++++++\n 2 files changed, 15 insertions(+)","diff":"diff --git a/include/linux/mm.h b/include/linux/mm.h\nindex 08ed53e..7e91cd8 100644\n--- a/include/linux/mm.h\n+++ b/include/linux/mm.h\n@@ -1924,6 +1924,9 @@ extern void show_mem(unsigned int flags);\n extern long si_mem_available(void);\n extern void si_meminfo(struct sysinfo * val);\n extern void si_meminfo_node(struct sysinfo *val, int nid);\n+#ifdef __HAVE_ARCH_RESERVED_KERNEL_PAGES\n+extern unsigned long arch_reserved_kernel_pages(void);\n+#endif\n \n extern __printf(3, 4)\n void warn_alloc_failed(gfp_t gfp_mask, unsigned int order,\ndiff --git a/mm/page_alloc.c b/mm/page_alloc.c\nindex 3fbe73a..9d91706 100644\n--- a/mm/page_alloc.c\n+++ b/mm/page_alloc.c\n@@ -6976,6 +6976,17 @@ static int __init set_hashdist(char *str)\n __setup(\"hashdist=\", set_hashdist);\n #endif\n \n+#ifndef __HAVE_ARCH_RESERVED_KERNEL_PAGES\n+/*\n+ * Returns the number of pages that arch has reserved but\n+ * is not known to alloc_large_system_hash().\n+ */\n+static unsigned long __init arch_reserved_kernel_pages(void)\n+{\n+\treturn 0;\n+}\n+#endif\n+\n /*\n  * allocate a large system hash table from bootmem\n  * - it is assumed that the hash table must contain an exact power-of-2\n@@ -7000,6 +7011,7 @@ void *__init alloc_large_system_hash(const char *tablename,\n \tif (!numentries) {\n \t\t/* round applicable memory size up to nearest megabyte */\n \t\tnumentries = nr_kernel_pages;\n+\t\tnumentries -= arch_reserved_kernel_pages();\n \n \t\t/* It isn't necessary when PAGE_SIZE >= 1MB */\n \t\tif (PAGE_SHIFT < 20)\n","prefixes":["v3","1/3"]}