From patchwork Thu Jul 12 20:37:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Tatashin X-Patchwork-Id: 10522271 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D4DFD6032C for ; Thu, 12 Jul 2018 20:38:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C50BD298EC for ; Thu, 12 Jul 2018 20:38:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B963D29964; Thu, 12 Jul 2018 20:38:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4D9E729938 for ; Thu, 12 Jul 2018 20:38:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 380166B0007; Thu, 12 Jul 2018 16:37:58 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 315C86B000A; Thu, 12 Jul 2018 16:37:58 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 11C1D6B0006; Thu, 12 Jul 2018 16:37:58 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ua0-f200.google.com (mail-ua0-f200.google.com [209.85.217.200]) by kanga.kvack.org (Postfix) with ESMTP id CC7786B0007 for ; Thu, 12 Jul 2018 16:37:57 -0400 (EDT) Received: by mail-ua0-f200.google.com with SMTP id z26-v6so9172503uao.20 for ; Thu, 12 Jul 2018 13:37:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:subject:date:message-id :in-reply-to:references; bh=Q2cZNYC745nuFn5fyPmxQMIBBemPYgtVKqIT1J+lGs4=; b=lnNLLCQfnXZ21zOoKLcpePdkMZcyn+Q9B9vJ6GZMpX910gEIGSNomsDLPH+BSwLXwt Y8v/uUmpvV315bvYOn9EL4AkXqLBzaVaGXt1Zy/UcZb+6OX+Hrzm28v74Dn2hR0ZTAKF H9cEuAXsPbYmTs0e/0N8fhpiWrBhc383X9ImkUV9liR37kaGaSYyhJbknQ3e+CFLbSTa 7Cj2FIZO4E1Lb9B7JL8aFLbxvJ486RmdVVAWm4jG/4nhRqKwOZ+1HSNvqcVQqMmIfSkk PvveRauGloJamPDa6F7MeH1AlSUDPMINSDREFq+WB+niJEfJaPHtw5CQXUZLwL59WYOz RYgQ== X-Gm-Message-State: AOUpUlEA9kNugHZT1Tts+C7pYYzPJI4ZSYFEGb7PbIPt6dqNb8RQDLit 5ehxoxL6nIOe8O5LM4PTvys12hHSPohRsRyyu9gPBXGQVM3HKV8g+ScJ0/iuW+HfqDBFrty6OPA 48laCQOgN5Q5/m4l1WohDmdY6XrGnHKewB9qO6B+Q3H0pvyb+fo6WkrJb95hqJqb7wg== X-Received: by 2002:a1f:154b:: with SMTP id 72-v6mr2060407vkv.70.1531427877546; Thu, 12 Jul 2018 13:37:57 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdkOxshLeQz1Se+ERbuJCvFTlRS2i/R+inU3aliwXG1EsAK52APKxHRsMiysHYhsIEDRuJL X-Received: by 2002:a1f:154b:: with SMTP id 72-v6mr2060385vkv.70.1531427876791; Thu, 12 Jul 2018 13:37:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531427876; cv=none; d=google.com; s=arc-20160816; b=e0Q/2rxc0LfURJRZCwZcm+1w6QMGKDvj6Wt3YV0bGjxRtmZpnl6/OQsRXyEflFz72u Xf08pD/gEt1pKTz7Ok1nlLRPemSl3RZN8Oo/sgji/QGNGwNs8VSdBVUjamK+KAAkJw41 M9XuBSOaskL8v1Y16KFQbYYgAmKoOQy1D5o78d2wH7JEiAxxgggh62LPuE9pPnEhnhdS iZCNacUhG/66in+0RtnscG3UUv47+8DhQkYlcFKQT/xne2idpg1T2fKJwx+VlC1BdUL1 l17+kvMZVDW2wdFB0zDFdBht0MUpYT71AmD9N8bK6k+XVEJjG7hN7d8AtMvMg7rCKLNk pmvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from :dkim-signature:arc-authentication-results; bh=Q2cZNYC745nuFn5fyPmxQMIBBemPYgtVKqIT1J+lGs4=; b=G5vit135CMQvkJh8EZtHk+x+61O52WgkwB7UysYCat+UZL3ZfEYQIbIqLHWwdtPk8J Z08djcs4YVD7vGdhcspm0TCQq53gFYg6FDOprwj4gF+7sIjMHv8liGDjxqbTMzKRtv6T 9gmaO4cODo76ormpoh59HzovtIKX3Xh7mbrB/MP2gxcgNNltvB2XV4rDUD/KZe6vXIdU jH66ww95JnT2A2f7qnNE8GbXCykwNoU3f0hUV0zUlN2fIFOYvJEerBNgqflNEgX+15ij NY21OVt3yZDjeFqq5jPbHc5FIAXp3WoHW6pUUUOLV1qV5kTFVOzvcjykznaVaMb03IOR bM1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b="ZH6Xoi/H"; spf=pass (google.com: domain of pasha.tatashin@oracle.com designates 156.151.31.85 as permitted sender) smtp.mailfrom=pasha.tatashin@oracle.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from userp2120.oracle.com (userp2120.oracle.com. [156.151.31.85]) by mx.google.com with ESMTPS id b82-v6si1318471vkb.51.2018.07.12.13.37.56 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Jul 2018 13:37:56 -0700 (PDT) Received-SPF: pass (google.com: domain of pasha.tatashin@oracle.com designates 156.151.31.85 as permitted sender) client-ip=156.151.31.85; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b="ZH6Xoi/H"; spf=pass (google.com: domain of pasha.tatashin@oracle.com designates 156.151.31.85 as permitted sender) smtp.mailfrom=pasha.tatashin@oracle.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w6CKSudA152046; Thu, 12 Jul 2018 20:37:46 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2018-07-02; bh=Q2cZNYC745nuFn5fyPmxQMIBBemPYgtVKqIT1J+lGs4=; b=ZH6Xoi/HnGijYlL6UAsW3jlnYitZcXQZjm42LdPxHc+Re2Z0BJR7vOPakOLaAFLyASdC NqZaYQvOe6NUBHItmSMGr/7LgC+1MKDzZUVxTvDrgpozTjx2RehvrFQBtS+X7eB9LK4f QNt5yl9ATrfE4Lly9FEiejx8OYDLv4vGBY5OLuhVu2WOycm9IqCUpekqWX5oxyZ1ieOW QrmuL/iW6vph4exf1GpAgmsQuiLZPRvZH44W183TOkEbK0ZTg1n/MdEDhQuKRszUdCee /rS1xoS6uXalTmRIaoCgiWiGj+nXNJ7zOn+DerBDRIVjdVU3zkrK+VHq0bqyHqvTeAG+ 0g== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2120.oracle.com with ESMTP id 2k2p7vnaf7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Jul 2018 20:37:46 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w6CKbkZJ030392 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Jul 2018 20:37:46 GMT Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w6CKbjQb030770; Thu, 12 Jul 2018 20:37:45 GMT Received: from localhost.localdomain (/73.69.118.222) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 12 Jul 2018 13:37:45 -0700 From: Pavel Tatashin To: steven.sistare@oracle.com, daniel.m.jordan@oracle.com, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, kirill.shutemov@linux.intel.com, mhocko@suse.com, linux-mm@kvack.org, dan.j.williams@intel.com, jack@suse.cz, jglisse@redhat.com, jrdr.linux@gmail.com, bhe@redhat.com, gregkh@linuxfoundation.org, vbabka@suse.cz, richard.weiyang@gmail.com, dave.hansen@intel.com, rientjes@google.com, mingo@kernel.org, osalvador@techadventures.net, pasha.tatashin@oracle.com, abdhalee@linux.vnet.ibm.com, mpe@ellerman.id.au Subject: [PATCH v5 2/5] mm/sparse: use the new sparse buffer functions in non-vmemmap Date: Thu, 12 Jul 2018 16:37:27 -0400 Message-Id: <20180712203730.8703-3-pasha.tatashin@oracle.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180712203730.8703-1-pasha.tatashin@oracle.com> References: <20180712203730.8703-1-pasha.tatashin@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8952 signatures=668706 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1807120216 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP non-vmemmap sparse also allocated large contiguous chunk of memory, and if fails falls back to smaller allocations. Use the same functions to allocate buffer as the vmemmap-sparse Signed-off-by: Pavel Tatashin --- mm/sparse.c | 41 ++++++++++++++--------------------------- 1 file changed, 14 insertions(+), 27 deletions(-) diff --git a/mm/sparse.c b/mm/sparse.c index ac57bae476f4..976854a3af8b 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -408,13 +408,20 @@ unsigned long __init section_map_size(void) } #else +unsigned long __init section_map_size(void) +{ + return PAGE_ALIGN(sizeof(struct page) * PAGES_PER_SECTION); +} + struct page __init *sparse_mem_map_populate(unsigned long pnum, int nid, struct vmem_altmap *altmap) { - struct page *map; - unsigned long size; + unsigned long size = section_map_size(); + struct page *map = sparse_buffer_alloc(size); + + if (map) + return map; - size = PAGE_ALIGN(sizeof(struct page) * PAGES_PER_SECTION); map = memblock_virt_alloc_try_nid(size, PAGE_SIZE, __pa(MAX_DMA_ADDRESS), BOOTMEM_ALLOC_ACCESSIBLE, nid); @@ -425,42 +432,22 @@ void __init sparse_mem_maps_populate_node(struct page **map_map, unsigned long pnum_end, unsigned long map_count, int nodeid) { - void *map; unsigned long pnum; - unsigned long size = sizeof(struct page) * PAGES_PER_SECTION; - int nr_consumed_maps; - - size = PAGE_ALIGN(size); - map = memblock_virt_alloc_try_nid_raw(size * map_count, - PAGE_SIZE, __pa(MAX_DMA_ADDRESS), - BOOTMEM_ALLOC_ACCESSIBLE, nodeid); - if (map) { - nr_consumed_maps = 0; - for (pnum = pnum_begin; pnum < pnum_end; pnum++) { - if (!present_section_nr(pnum)) - continue; - map_map[nr_consumed_maps] = map; - map += size; - nr_consumed_maps++; - } - return; - } + unsigned long size = section_map_size(); + int nr_consumed_maps = 0; - /* fallback */ - nr_consumed_maps = 0; + sparse_buffer_init(size * map_count, nodeid); for (pnum = pnum_begin; pnum < pnum_end; pnum++) { - struct mem_section *ms; - if (!present_section_nr(pnum)) continue; map_map[nr_consumed_maps] = sparse_mem_map_populate(pnum, nodeid, NULL); if (map_map[nr_consumed_maps++]) continue; - ms = __nr_to_section(pnum); pr_err("%s: sparsemem memory map backing failed some memory will not be available\n", __func__); } + sparse_buffer_fini(); } #endif /* !CONFIG_SPARSEMEM_VMEMMAP */