From patchwork Thu Jul 12 20:37:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Tatashin X-Patchwork-Id: 10522273 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 B7EFF603D7 for ; Thu, 12 Jul 2018 20:38:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A8B9F298EC for ; Thu, 12 Jul 2018 20:38:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9D12529964; Thu, 12 Jul 2018 20:38:06 +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 176E8298EC for ; Thu, 12 Jul 2018 20:38:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8724B6B000A; Thu, 12 Jul 2018 16:38:00 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 7FDD26B000D; Thu, 12 Jul 2018 16:38:00 -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 6BB076B000E; Thu, 12 Jul 2018 16:38:00 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt0-f199.google.com (mail-qt0-f199.google.com [209.85.216.199]) by kanga.kvack.org (Postfix) with ESMTP id 404746B000A for ; Thu, 12 Jul 2018 16:38:00 -0400 (EDT) Received: by mail-qt0-f199.google.com with SMTP id e4-v6so15126727qtj.5 for ; Thu, 12 Jul 2018 13:38:00 -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=ycDi3B3bKX8sD3KezhQsUBf32RoDZ0Pt+YJGecx50XA=; b=r3d+Wb0n340nV6iMm5o0Id1+NbB44ssFFz5QpL35A8OhnsuctVNExSOMgfWGjHe4/e b0/+HDmRJddMdTZ0bdr7BGgbBah2kPkx+Q6xaXSetmi44C7PLygR3hHTL+qE7WBmIrON Cj6jhfCtk+e3BWbGe2myBgFVRKxsgbh+mMZ5xQMiUKYQKYspKuErXWMKZIMOnX6qmjzB wrOYKGr7xAXSbAkCCyi/+/HLmoHm6Xn8gUGZiFxjhmwnwo+M6oYJmWq7s9E3wygze4kr eTsN41aYOMt1WAutvM5V74wXFboiEt7y58jAdqWeJ9/hhnhhc9Gus4tPENgmMd5PbPWD lgfA== X-Gm-Message-State: AOUpUlEcjpPvU4a7hkh7izZYTf0PJoIbj8H5Bqx0UsI5DIFMyRznp/XH G+Ee01zOG8DBF6HixL/GKzXAxNvPWLoG5QPAQvFFB/X+7yiJ5D3DR02aJaCqqX1qnPWZpbwSVvV joFsvOsOFuuM5zlDTG2AgaMz5Bz0Cjh/8HCAsySyMBAaU6kstdpTxOvKNff0pab9gqw== X-Received: by 2002:ac8:709:: with SMTP id g9-v6mr3394856qth.110.1531427880054; Thu, 12 Jul 2018 13:38:00 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdGLGashsBKvc2mSOZrtXffwFQJFp+uE7BhNU7eol7yC+9iiWgIF+s4vJcCtlIU7jr9ELa4 X-Received: by 2002:ac8:709:: with SMTP id g9-v6mr3394830qth.110.1531427879599; Thu, 12 Jul 2018 13:37:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531427879; cv=none; d=google.com; s=arc-20160816; b=D1dn1rnFnZPs2zLNCKFOxaX+rsoohFECCzTJNTVlA7K8C9EW5LMVgtjccowAzGFPyD VdFu86SGaDUtL50FovfgwXGtQzalx3XxnmdhVMlZoKZgHP0kZcqbcEAYd91kMVk7HMm8 Sd304MnXLHqHLMX7avWd9Fp6o9KibYldziAiZ5KoFkCq2bkR4Iq5NIiFO8c/tPwKFo0v DnrtKIC+SpWcyUlPqSXmf7gAFbZMoAxSkY3lkNipUwGkmD1A3swcI1PhwTzCpIF7fsuG vn5MJ0/4TEjkz2hYLpUjJvLvukOpKaUb4oj+qs3y7GeKF3+lZcgNyI5UsOKdV9uH2h8V PESA== 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=ycDi3B3bKX8sD3KezhQsUBf32RoDZ0Pt+YJGecx50XA=; b=UDCUWJUZ8Fs09vWlx6fbMOSPfohqN3U7HoHN8G48XCVHu+KyyWoMQ881JlTFledwbf EOWYYFI8bjs+TJ0CPDELeEuwCAEHkXY7kr2q/x5e0cdb8f77fJddLppoMZnm8WJRvYbu DZZwt62vy1RE5wJiLb/YnU3H8IchmmGFZIHtLaXTULVJqNLEvSAGaFMHc245RI+FQT8A Sb7bL3/01VrRI8g2GL5SKbl3FHfxd97Z4jXrjPiQJwSpAzETFEeMYfTP4UdaRZyUG2uo kai+JJn/7BL/VRVlCaUVqRax9mAkx+E0fLOPYuGNZLXRCxow7LdO+enS9hSpcnY8UaBO VwhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=bCtvEn4t; spf=pass (google.com: domain of pasha.tatashin@oracle.com designates 141.146.126.79 as permitted sender) smtp.mailfrom=pasha.tatashin@oracle.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from aserp2130.oracle.com (aserp2130.oracle.com. [141.146.126.79]) by mx.google.com with ESMTPS id q54-v6si7274038qtq.97.2018.07.12.13.37.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Jul 2018 13:37:59 -0700 (PDT) Received-SPF: pass (google.com: domain of pasha.tatashin@oracle.com designates 141.146.126.79 as permitted sender) client-ip=141.146.126.79; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=bCtvEn4t; spf=pass (google.com: domain of pasha.tatashin@oracle.com designates 141.146.126.79 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 (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w6CKSrJu182576; Thu, 12 Jul 2018 20:37:50 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=ycDi3B3bKX8sD3KezhQsUBf32RoDZ0Pt+YJGecx50XA=; b=bCtvEn4t7qI6goMyYbPr/hztaPLAdjUNFyectNTx/Er4HL8xIfjGVQJ2FcRXgxLy7KOv w+UnWSccrekEbWINaUOkgDlXfqALxhLke0hHaZYxtMyo4rHfiCHaykt3XKXbrNVB+0H0 vCTLzx5tVf9PG6AtBbMs/qlGoe3Xzu0BmFtV9Au1dvQwyCzN/u6ZN+w4MFLw5ll8Bviw CHB6BvzKlJo81Rdvd9lRQbAYkufuO82Hd2QphNKMfSjkGLTZM4BhlD8M2jRQ+pPW0boc wFBu8bS/eZI0lepbIKc9jQc+n+AZqYADeH+fJaOE1aaKyJ5WhRg2VMig/7yZ1ey0w8pT yQ== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2130.oracle.com with ESMTP id 2k2p765bv9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Jul 2018 20:37:50 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w6CKbmW1030473 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Jul 2018 20:37:49 GMT Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w6CKblVU017045; Thu, 12 Jul 2018 20:37:47 GMT Received: from localhost.localdomain (/73.69.118.222) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 12 Jul 2018 13:37:47 -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 3/5] mm/sparse: move buffer init/fini to the common place Date: Thu, 12 Jul 2018 16:37:28 -0400 Message-Id: <20180712203730.8703-4-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 Now, that both variants of sparse memory use the same buffers to populate memory map, we can move sparse_buffer_init()/sparse_buffer_fini() to the common place. Signed-off-by: Pavel Tatashin --- include/linux/mm.h | 3 --- mm/sparse-vmemmap.c | 2 -- mm/sparse.c | 14 +++++++------- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index a83d3e0e66d4..99d8c50adef6 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2655,9 +2655,6 @@ void sparse_mem_maps_populate_node(struct page **map_map, unsigned long map_count, int nodeid); -unsigned long __init section_map_size(void); -void sparse_buffer_init(unsigned long size, int nid); -void sparse_buffer_fini(void); void *sparse_buffer_alloc(unsigned long size); struct page *sparse_mem_map_populate(unsigned long pnum, int nid, struct vmem_altmap *altmap); diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c index b05c7663c640..cd15f3d252c3 100644 --- a/mm/sparse-vmemmap.c +++ b/mm/sparse-vmemmap.c @@ -270,7 +270,6 @@ void __init sparse_mem_maps_populate_node(struct page **map_map, unsigned long pnum; int nr_consumed_maps = 0; - sparse_buffer_init(section_map_size() * map_count, nodeid); for (pnum = pnum_begin; pnum < pnum_end; pnum++) { if (!present_section_nr(pnum)) continue; @@ -282,5 +281,4 @@ void __init sparse_mem_maps_populate_node(struct page **map_map, pr_err("%s: sparsemem memory map backing failed some memory will not be available\n", __func__); } - sparse_buffer_fini(); } diff --git a/mm/sparse.c b/mm/sparse.c index 976854a3af8b..01c616342909 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -401,14 +401,14 @@ static void __init sparse_early_usemaps_alloc_node(void *data, } #ifdef CONFIG_SPARSEMEM_VMEMMAP -unsigned long __init section_map_size(void) +static unsigned long __init section_map_size(void) { return ALIGN(sizeof(struct page) * PAGES_PER_SECTION, PMD_SIZE); } #else -unsigned long __init section_map_size(void) +static unsigned long __init section_map_size(void) { return PAGE_ALIGN(sizeof(struct page) * PAGES_PER_SECTION); } @@ -433,10 +433,8 @@ void __init sparse_mem_maps_populate_node(struct page **map_map, unsigned long map_count, int nodeid) { unsigned long pnum; - unsigned long size = section_map_size(); int nr_consumed_maps = 0; - sparse_buffer_init(size * map_count, nodeid); for (pnum = pnum_begin; pnum < pnum_end; pnum++) { if (!present_section_nr(pnum)) continue; @@ -447,14 +445,13 @@ void __init sparse_mem_maps_populate_node(struct page **map_map, pr_err("%s: sparsemem memory map backing failed some memory will not be available\n", __func__); } - sparse_buffer_fini(); } #endif /* !CONFIG_SPARSEMEM_VMEMMAP */ static void *sparsemap_buf __meminitdata; static void *sparsemap_buf_end __meminitdata; -void __init sparse_buffer_init(unsigned long size, int nid) +static void __init sparse_buffer_init(unsigned long size, int nid) { BUG_ON(sparsemap_buf); sparsemap_buf = @@ -464,7 +461,7 @@ void __init sparse_buffer_init(unsigned long size, int nid) sparsemap_buf_end = sparsemap_buf + size; } -void __init sparse_buffer_fini(void) +static void __init sparse_buffer_fini(void) { unsigned long size = sparsemap_buf_end - sparsemap_buf; @@ -494,8 +491,11 @@ static void __init sparse_early_mem_maps_alloc_node(void *data, unsigned long map_count, int nodeid) { struct page **map_map = (struct page **)data; + + sparse_buffer_init(section_map_size() * map_count, nodeid); sparse_mem_maps_populate_node(map_map, pnum_begin, pnum_end, map_count, nodeid); + sparse_buffer_fini(); } #else static struct page __init *sparse_early_mem_map_alloc(unsigned long pnum)