From patchwork Tue Mar 26 09:02:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 10870641 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2C414922 for ; Tue, 26 Mar 2019 09:02:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 13D4728B75 for ; Tue, 26 Mar 2019 09:02:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 035F628F68; Tue, 26 Mar 2019 09:02:43 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE 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 DC4AC28B75 for ; Tue, 26 Mar 2019 09:02:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 50C276B0007; Tue, 26 Mar 2019 05:02:40 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 493F66B0008; Tue, 26 Mar 2019 05:02:40 -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 30F216B000A; Tue, 26 Mar 2019 05:02:40 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by kanga.kvack.org (Postfix) with ESMTP id 1421D6B0007 for ; Tue, 26 Mar 2019 05:02:40 -0400 (EDT) Received: by mail-qk1-f199.google.com with SMTP id x18so10980733qkf.8 for ; Tue, 26 Mar 2019 02:02:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=Rfq/KbollvLqK27V6rSdLsQNZwc1B0hDiuqQQN782C0=; b=h6s4BQNiHEHAO4ecTbDPRocZ0WVYv3BwXLCjosbbWCoVnPU4XdNTIht7Kvyf3V7xmG XaPFpn84z8929oXDGooYzqUpf+4ZmvOSck4pe7GSr/kEXlw3ed3QGQyLQVbdW+m7H4ka zFUSzKc4zfw5m0NlKLrPy5kK3MUEcu9P0o/uoYIy9uE+jWU6ay/Qo+qhIxF9rlmITH3e bY+iuSyJS0kd6nsAgDt9bofR179V5cnZUJtoHMKyEoS7cx2rGQmQgE4Uy2wib2c+Kk2U Uy+OZ1fBtQnKwQsv6V0QqUBbsru/YivgDaQPi+hJckL/mzzCXAXWxnzUJT4WgivdQn3J ZCqA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of bhe@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: APjAAAWE4pH0YWqpGpVT0n/O9X3liR0NpaNGIxvGKnq9oNdCLRwJZlIY kM3RrpMB3FVVWLi6t69sUwc/AufU7Tf+egeCdwqUdq8HYU+TV+b9k+Oi2NZpWMDtUcJHVm/EVuL jzWP/jylWWcx8FcUxpiIxSS+3XlrBdIMLLNaxiMrX/YF4MAM66raWLdKaeFjI6kGmeQ== X-Received: by 2002:aed:2497:: with SMTP id t23mr24005593qtc.359.1553590959858; Tue, 26 Mar 2019 02:02:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqztpDwPzS70socAOVAlkQOWCKY59qNBn/etmf82LVeiixjZd0IwPA+ghTk2w3loV6DvYueO X-Received: by 2002:aed:2497:: with SMTP id t23mr24005561qtc.359.1553590959237; Tue, 26 Mar 2019 02:02:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553590959; cv=none; d=google.com; s=arc-20160816; b=C9A1ai8nJq8p+rWs0Ns1niq1yA7umxXAjjY6zBmxUbTML11PRfWmavSw5tMpCvQjrm 6py4yRYFTllK7NYMwGYKS4hci6406xDTbHfznOU4qDbaW0jSzUKXrtq8hH55b1z4LXu1 PSycB/TvFwPe21WL2YT03LQI8xF93+AENz7EEiVB6DmRkhWm2xSGAz94ANjA3P+JufxQ wMEkrnHkd05NbHVO8QEaabiVfZhmZcd8OzqWrp97/KaeQNDVIiDSOdGGE6cKi9MSL78p AizrUQ5xmEo3s559KSa7dxMUAFDqO94W3Z9O1+oiaagi1y/71cOUTr7HkrFZ3WNxBt7S jlGw== 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:cc:to:from; bh=Rfq/KbollvLqK27V6rSdLsQNZwc1B0hDiuqQQN782C0=; b=oMLNuZUKlSCiO8GWSc0IguUiHpvtohcgMCinHN11cVtYChKIn+9pr9RibhCB3zL7xa VTyO1QOG6GLwbVKUy3oU+4YMWfBXVxz94tqVF/Q6t3jsublm2xQu4tGEa+Ld2WDdnobP CAou5O1Z0VxPc3XAdjtwZUtc2I9HfyG7WsVv34UIpXpb9IEhxqUbeJ9j5vatrnJBo/fS /ktWxsKz55E9PlNHBsXvYhodd6/pvOx8UViwATGxsjZoGnBRCRNC1aPIThJf1/vQo2e9 AEtVs/yNX3MxcYqeuZBjHmlsU8tSCDKt39EDJOuiuXpUx/64PUz7CfAJXusaugdn7AGL Ehag== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of bhe@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id h3si3139738qth.218.2019.03.26.02.02.39 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Mar 2019 02:02:39 -0700 (PDT) Received-SPF: pass (google.com: domain of bhe@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of bhe@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5D80230C1C07; Tue, 26 Mar 2019 09:02:38 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-21.pek2.redhat.com [10.72.12.21]) by smtp.corp.redhat.com (Postfix) with ESMTP id 42B0C8387B; Tue, 26 Mar 2019 09:02:34 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, mhocko@suse.com, rppt@linux.ibm.com, osalvador@suse.de, willy@infradead.org, william.kucharski@oracle.com, Baoquan He Subject: [PATCH v2 1/4] mm/sparse: Clean up the obsolete code comment Date: Tue, 26 Mar 2019 17:02:24 +0800 Message-Id: <20190326090227.3059-2-bhe@redhat.com> In-Reply-To: <20190326090227.3059-1-bhe@redhat.com> References: <20190326090227.3059-1-bhe@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Tue, 26 Mar 2019 09:02:38 +0000 (UTC) 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 The code comment above sparse_add_one_section() is obsolete and incorrect, clean it up and write new one. Signed-off-by: Baoquan He Reviewed-by: Mike Rapoport Acked-by: Michal Hocko --- v1-v2: Add comments to explain what the returned value means for each error code. mm/sparse.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/mm/sparse.c b/mm/sparse.c index 69904aa6165b..b2111f996aa6 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -685,9 +685,18 @@ static void free_map_bootmem(struct page *memmap) #endif /* CONFIG_SPARSEMEM_VMEMMAP */ /* - * returns the number of sections whose mem_maps were properly - * set. If this is <=0, then that means that the passed-in - * map was not consumed and must be freed. + * sparse_add_one_section - add a memory section + * @nid: The node to add section on + * @start_pfn: start pfn of the memory range + * @altmap: device page map + * + * This is only intended for hotplug. + * + * Returns: + * 0 on success. + * Other error code on failure: + * - -EEXIST - section has been present. + * - -ENOMEM - out of memory. */ int __meminit sparse_add_one_section(int nid, unsigned long start_pfn, struct vmem_altmap *altmap) From patchwork Tue Mar 26 09:02:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 10870643 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6990B922 for ; Tue, 26 Mar 2019 09:02:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 56A8628B75 for ; Tue, 26 Mar 2019 09:02:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4AB1A28F68; Tue, 26 Mar 2019 09:02:46 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE 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 D843528B75 for ; Tue, 26 Mar 2019 09:02:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B4D946B0008; Tue, 26 Mar 2019 05:02:44 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id AD4DE6B000A; Tue, 26 Mar 2019 05:02:44 -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 9ECE76B000C; Tue, 26 Mar 2019 05:02:44 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by kanga.kvack.org (Postfix) with ESMTP id 743AD6B0008 for ; Tue, 26 Mar 2019 05:02:44 -0400 (EDT) Received: by mail-qt1-f198.google.com with SMTP id 35so12853831qty.12 for ; Tue, 26 Mar 2019 02:02:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=7yUWtnQBiOqibJD3lCqD4KEusMHS1CkdLBfN5ckvauo=; b=frDdUQAXE6UMJ210oq+eRemneOhpn67hQ+K0pxwLtOgIn9zaI2rwyzqK8NnekNqA9N RjDTOy/2r8J/HaWRwDP28wO9azC2ZCfgyTGLAScuqoXgjKGPGVh8FHU0euE98v6F7JhE TrBP/MU0jkvIK/U4IgcUhZuc6MY/k5uOJIVM7ALOPSQDV6rSGHfe31DFpwdkdTt03haw qvCIlmS40YDQUZzst1MZGLEN4rAZ0N8MF3k1tDpB6ik3L8Dv1A+QiuQexOAh3lNafbbN lyrgxDhIETLBHXej4jJDBW+G/dkw7tVNiEeYZeNvoBfOmTniSIixNsiuTPT9mRZh+uPf RkSg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of bhe@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: APjAAAWGNI0xfU+cuNKM6pDSvkw4tC1ItJ+bedwuHzi+1u34RvcyAfuT yfZkjWq4iFI9aShU0zp4gQpKsalLmcFtdjGQVwf06IthZ73styikoqMMtjTxlpjkYsnmMDjQeCo IF81ZfPXuSot3e+q3q3h8eNo4d25Wy/pQTlu9ppt7UkgEvqC7/c7uQLogsTPGBZHnSw== X-Received: by 2002:ae9:dec2:: with SMTP id s185mr22321286qkf.107.1553590964273; Tue, 26 Mar 2019 02:02:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqxaqCGg86U0v8D4y4bjCSehWz2tCNvi30aT2Ql9ixduCRBnjmP0i/epFj9wG4pk6blodZ6n X-Received: by 2002:ae9:dec2:: with SMTP id s185mr22321236qkf.107.1553590963569; Tue, 26 Mar 2019 02:02:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553590963; cv=none; d=google.com; s=arc-20160816; b=zjGj+xWZN2VsOPmpRWZW91+0UkIFjfxKtKA00RSWtAk+kbj8ZJXPOCFnu1K9/Up488 zr059U+um7uQG/SgMF9LwGYj+pNnGxG29634an103dUX8WjhS4GHLhp+7QKSzZoH/rAf HJ4M41tpfRoUVqnyALJfDEDeIBS5eo+bz2DfqYdzKiNDbL+elbn3F0UijTWhe9EL9HJW kq8kiHZYt0FNczNgoSW7E7vT26koim9/ep+mvI4hy5t7ScmYgGqbMGpqsVvcju5wzkUh dHNJb4Rn2aRO6BSVvi9rytVvasiIJk2zybGp5cWIKARrKyO/Ss8TjbTjE4AdhkReAvik 9Slg== 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:cc:to:from; bh=7yUWtnQBiOqibJD3lCqD4KEusMHS1CkdLBfN5ckvauo=; b=Fo4McRit/u+0YSZt9H6PRCbq1JWYyfL72HtmV5nE05ONEZxKRkZ4GsXWJ5sRf/15FC Vs9I7C2aTsB6lj1ffopxuJUMUqKykUJQnyiGfDx5fDFn66YpSWTMBCwaHK43hmo6rHHO s+5o5ld8dcuO7U0ae/SdZuJooASt/kLoo6AFSotNVtBronRjuhPiZ0rz8iD8mPB4977a wsZwN7csgO5TYwaZUcKEj/0IyXxMD+b1tI1jf9KtDJhlKzgFVrEyKOHPwthR9rp0ndgs rVJdkJjFGNBhPsrS1pVg96R5oIYPx1FjqApxOHypD14p+r+w0nTw1sMRMYOkR56sUS50 cWFQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of bhe@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id h50si448638qvd.87.2019.03.26.02.02.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Mar 2019 02:02:43 -0700 (PDT) Received-SPF: pass (google.com: domain of bhe@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of bhe@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C1AF28762B; Tue, 26 Mar 2019 09:02:42 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-21.pek2.redhat.com [10.72.12.21]) by smtp.corp.redhat.com (Postfix) with ESMTP id D91EE80A3F; Tue, 26 Mar 2019 09:02:38 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, mhocko@suse.com, rppt@linux.ibm.com, osalvador@suse.de, willy@infradead.org, william.kucharski@oracle.com, Baoquan He Subject: [PATCH v2 2/4] mm/sparse: Optimize sparse_add_one_section() Date: Tue, 26 Mar 2019 17:02:25 +0800 Message-Id: <20190326090227.3059-3-bhe@redhat.com> In-Reply-To: <20190326090227.3059-1-bhe@redhat.com> References: <20190326090227.3059-1-bhe@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 26 Mar 2019 09:02:42 +0000 (UTC) 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 Reorder the allocation of usemap and memmap since usemap allocation is much simpler and easier. Otherwise hard work is done to make memmap ready, then have to rollback just because of usemap allocation failure. And also check if section is present earlier. Then don't bother to allocate usemap and memmap if yes. Signed-off-by: Baoquan He Reviewed-by: Mike Rapoport Signed-off-by: Baoquan He --- v1->v2: Do section existence checking earlier to further optimize code. mm/sparse.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/mm/sparse.c b/mm/sparse.c index b2111f996aa6..f4f34d69131e 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -714,20 +714,18 @@ int __meminit sparse_add_one_section(int nid, unsigned long start_pfn, ret = sparse_index_init(section_nr, nid); if (ret < 0 && ret != -EEXIST) return ret; - ret = 0; - memmap = kmalloc_section_memmap(section_nr, nid, altmap); - if (!memmap) - return -ENOMEM; - usemap = __kmalloc_section_usemap(); - if (!usemap) { - __kfree_section_memmap(memmap, altmap); - return -ENOMEM; - } ms = __pfn_to_section(start_pfn); - if (ms->section_mem_map & SECTION_MARKED_PRESENT) { - ret = -EEXIST; - goto out; + if (ms->section_mem_map & SECTION_MARKED_PRESENT) + return -EEXIST; + + usemap = __kmalloc_section_usemap(); + if (!usemap) + return -ENOMEM; + memmap = kmalloc_section_memmap(section_nr, nid, altmap); + if (!memmap) { + kfree(usemap); + return -ENOMEM; } /* @@ -739,12 +737,7 @@ int __meminit sparse_add_one_section(int nid, unsigned long start_pfn, section_mark_present(ms); sparse_init_one_section(ms, section_nr, memmap, usemap); -out: - if (ret < 0) { - kfree(usemap); - __kfree_section_memmap(memmap, altmap); - } - return ret; + return 0; } #ifdef CONFIG_MEMORY_HOTREMOVE From patchwork Tue Mar 26 09:02:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 10870645 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 56D1B17E6 for ; Tue, 26 Mar 2019 09:02:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 430BF28B75 for ; Tue, 26 Mar 2019 09:02:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 379F928F68; Tue, 26 Mar 2019 09:02:52 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE 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 B6F2628B75 for ; Tue, 26 Mar 2019 09:02:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CAB106B0005; Tue, 26 Mar 2019 05:02:50 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C5A426B000A; Tue, 26 Mar 2019 05:02:50 -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 B4AE16B000C; Tue, 26 Mar 2019 05:02:50 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by kanga.kvack.org (Postfix) with ESMTP id 927586B0005 for ; Tue, 26 Mar 2019 05:02:50 -0400 (EDT) Received: by mail-qk1-f199.google.com with SMTP id y64so11044261qka.3 for ; Tue, 26 Mar 2019 02:02:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=UgSKYmd1Jzx4h5TGK0shnAQGDXzcbCAb2UOZJVJE79I=; b=dCWWxQEf1cGa0oO6Kk7UEKECYPqD2f9VZS0YDY/uM1Wk9dc66MRUlJSNrMBHNAg2AX +BI6q8gkb0ZH7hYR5IEtFCirN8LXTcG+QwXDJZ4RvGPDnzqDAk5MpaY6iFlNO+GfIkFv 7WCaGKQ0mfd1qA2ZbapAEdfEXvnOJT0VXVAuVzRW+B6JtfhupwWnXU74fvwY21xKwScm V5xU6Yr7jFK57EUkD01Yhnylpy2WJvabXSZVPxprEpC0jTjll32B9qUWyqK4xkPgLA6F +NTAs8rn2n+JGI1yHDmip/S2kDtRc7XBfvwwZPTyamM1wfPIO1Y5vAJFAlPC45QvY6uz N10g== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of bhe@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: APjAAAWsT/cIUESDOjXQGEjkPNfapufV6Ritwq8aEL5sCZkmyGThwa4L Fl/ECtE88LfF5cd0wh1yN40egx3PbaI0l781uhS7ACSnDCFHSKVR6uPc6Rayfmlw3j4jAhVfvTU bHoVFO23dQ2pzBYU930nFC39OLjX2w5Klr7h+OFDQriwjypfIbvoie2U375lHuCz2Tg== X-Received: by 2002:a0c:d196:: with SMTP id e22mr23295155qvh.181.1553590970401; Tue, 26 Mar 2019 02:02:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqyo1qWuKDFC+OblLoCOLv2050lV1WCzD0XrrlBLDFHk9aQg+Gp9FNiIMNSeWNoZHEF5NIyB X-Received: by 2002:a0c:d196:: with SMTP id e22mr23295115qvh.181.1553590969843; Tue, 26 Mar 2019 02:02:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553590969; cv=none; d=google.com; s=arc-20160816; b=M2FJc15ffWa/MPyCL/3CIP2XoERygeuI5CiTJYxCxgPu5rC7/Pjed782DVIjkcJhnd goNeCYbehcweFe8utZIj/ihFehIKq7ckG/Ed7O+60JBddXEVyqOK8FHLleV35QqpWyKJ Nrs/xIOo/0+oCsLO/mnCq4XIjfLyQdLS1jL6lFkIIJp4Rp6+ZQzsTWh8CaMOdOZUi1LG BcjF2h8jlvGXENciWxbGHN1GdgNIMhLlg0/PAjo4XQpiogdqT6SgvazPkW8rrUGiJnMS WpKiZlGirX9QBWL1vZnADkGnnYfPPP5zQ4XlnqJcs/Vw64/SCyiShb84sVw56fkJix0/ aNxA== 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:cc:to:from; bh=UgSKYmd1Jzx4h5TGK0shnAQGDXzcbCAb2UOZJVJE79I=; b=Ta6ODK9x7REVWvphanhTk4AgJIe7hXtSMM5Nir34Ccvs/jHEUMTsV/H/BaBwrZqCTK BRn4dXz8WetDZL4Br3sFp4rxwbvLHr/KXqn47UD3ecsEpwXpt2Es+zNCPLnekSBPJ0Mc mNTt0MQT1W+w+EEG3niMqtMAilUapafYj91609cwaDSUvgks0auGq0l2FMlc9XGeB5IX 1V7tbUbAnN1NcO3XUUN2e8q4SvthqUvve/uWy89AcGsOKu+BdvW+T7nb/1Apym2i1+jw 77zzV5dXveGfYtdKdqMDVYhJXBToEQEonE4BYEUgmTsj7hau4Ed7+NMWMTek75nSmUCU 5nNQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of bhe@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id i12si2541845qtr.73.2019.03.26.02.02.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Mar 2019 02:02:49 -0700 (PDT) Received-SPF: pass (google.com: domain of bhe@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of bhe@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C0B9C89C31; Tue, 26 Mar 2019 09:02:48 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-21.pek2.redhat.com [10.72.12.21]) by smtp.corp.redhat.com (Postfix) with ESMTP id 46BBC8387A; Tue, 26 Mar 2019 09:02:43 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, mhocko@suse.com, rppt@linux.ibm.com, osalvador@suse.de, willy@infradead.org, william.kucharski@oracle.com, Baoquan He Subject: [PATCH v2 3/4] mm/sparse: Rename function related to section memmap allocation/free Date: Tue, 26 Mar 2019 17:02:26 +0800 Message-Id: <20190326090227.3059-4-bhe@redhat.com> In-Reply-To: <20190326090227.3059-1-bhe@redhat.com> References: <20190326090227.3059-1-bhe@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 26 Mar 2019 09:02:49 +0000 (UTC) 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 These functions are used to allocate/free section memmap, have nothing to do with kmalloc/free during the handling. Rename them to remove the confusion. Signed-off-by: Baoquan He Acked-by: Mike Rapoport --- mm/sparse.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/mm/sparse.c b/mm/sparse.c index f4f34d69131e..68a89d133fa7 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -590,13 +590,13 @@ void offline_mem_sections(unsigned long start_pfn, unsigned long end_pfn) #endif #ifdef CONFIG_SPARSEMEM_VMEMMAP -static inline struct page *kmalloc_section_memmap(unsigned long pnum, int nid, +static inline struct page *alloc_section_memmap(unsigned long pnum, int nid, struct vmem_altmap *altmap) { /* This will make the necessary allocations eventually. */ return sparse_mem_map_populate(pnum, nid, altmap); } -static void __kfree_section_memmap(struct page *memmap, +static void __free_section_memmap(struct page *memmap, struct vmem_altmap *altmap) { unsigned long start = (unsigned long)memmap; @@ -614,7 +614,7 @@ static void free_map_bootmem(struct page *memmap) } #endif /* CONFIG_MEMORY_HOTREMOVE */ #else -static struct page *__kmalloc_section_memmap(void) +static struct page *__alloc_section_memmap(void) { struct page *page, *ret; unsigned long memmap_size = sizeof(struct page) * PAGES_PER_SECTION; @@ -635,13 +635,13 @@ static struct page *__kmalloc_section_memmap(void) return ret; } -static inline struct page *kmalloc_section_memmap(unsigned long pnum, int nid, +static inline struct page *alloc_section_memmap(unsigned long pnum, int nid, struct vmem_altmap *altmap) { - return __kmalloc_section_memmap(); + return __alloc_section_memmap(); } -static void __kfree_section_memmap(struct page *memmap, +static void __free_section_memmap(struct page *memmap, struct vmem_altmap *altmap) { if (is_vmalloc_addr(memmap)) @@ -722,7 +722,7 @@ int __meminit sparse_add_one_section(int nid, unsigned long start_pfn, usemap = __kmalloc_section_usemap(); if (!usemap) return -ENOMEM; - memmap = kmalloc_section_memmap(section_nr, nid, altmap); + memmap = alloc_section_memmap(section_nr, nid, altmap); if (!memmap) { kfree(usemap); return -ENOMEM; @@ -786,7 +786,7 @@ static void free_section_usemap(struct page *memmap, unsigned long *usemap, if (PageSlab(usemap_page) || PageCompound(usemap_page)) { kfree(usemap); if (memmap) - __kfree_section_memmap(memmap, altmap); + __free_section_memmap(memmap, altmap); return; } From patchwork Tue Mar 26 09:02:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 10870647 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AD06B1575 for ; Tue, 26 Mar 2019 09:02:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 98D5F28B75 for ; Tue, 26 Mar 2019 09:02:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8B19728F68; Tue, 26 Mar 2019 09:02:57 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE 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 1F85728B75 for ; Tue, 26 Mar 2019 09:02:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1B0466B000A; Tue, 26 Mar 2019 05:02:56 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 15F7F6B000C; Tue, 26 Mar 2019 05:02:56 -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 04E8E6B000D; Tue, 26 Mar 2019 05:02:55 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by kanga.kvack.org (Postfix) with ESMTP id D6D836B000A for ; Tue, 26 Mar 2019 05:02:55 -0400 (EDT) Received: by mail-qk1-f200.google.com with SMTP id a15so8241215qkl.23 for ; Tue, 26 Mar 2019 02:02:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=z5ci/X/lLiFuZNLGAa3MIXoyWsKM2relopxyFwJjuV4=; b=HGqXevR6pXgy4t+SQVrEJHWlJwJ11cL0mgUOSYITydIN1wbyKlP86Zh9qh1eDKC+37 VngFGshraBVdyGu9So3w7BSc4HsKPpq2gahj+DJ6EVFX5fUDpMv4W04/byHLrMxCJda2 6fqCkaq/wVjA/Ne1SWau8EgnoHipifTRttLne+ZKSw0OyzMbJyMUru3MZxWFIYTOyKyV OvI6rMgnXP0ikJ3uq05EnTAvomEoSz7ZmNYd4f/9htayDg1jb/7A+73+vdyXA+o0MPke /wcaJj6lFu4GdRb5pPumHArQNlcW7gRfrY6Z1p0xBi6ZCfhO0YD2DHwn8vKM8uZXEYDH vtnQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of bhe@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: APjAAAX7IuUiX9GAR4elX/lnvMj+vMYqRfirLbSdPBpl14wqni4YCrp2 W47v1yoM1xW8gLL6LMEdsEw4X2JYiVUb/FoNH0i/UQOgW0HaMAt9nbLqMHjEdZAJY+HAkB2TGR+ apDnIQRmx6gt2gEpdsm0o3JMSEFJerW9/0Ubq02zStj4GWROmG++4fiz2BTh/sO5ahA== X-Received: by 2002:ac8:1acf:: with SMTP id h15mr24387455qtk.85.1553590975635; Tue, 26 Mar 2019 02:02:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqz78T6T50j5LTXQBJcOh/TfNeOzXt13UBxg844k5EAYH0qwu4t6/plqjh5tA4NYv58v/NPZ X-Received: by 2002:ac8:1acf:: with SMTP id h15mr24387398qtk.85.1553590974776; Tue, 26 Mar 2019 02:02:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553590974; cv=none; d=google.com; s=arc-20160816; b=0jicNPzWlmvx3Mc3bHnzSMxN0k2fAHFifInidVSuumEDFzKmV6S9HjMmn1tKKTUK2s C2TLpte5rDhDKZ2idlRMIK51FLwGDoIxQIM+WnNM4E/mC0a8sg7FJwJTtKQ17TFby1BD YprzTjCgm+/+sUUH1xbkBa5z5ReLMzUPkcfykRWnx5trqsbvhijHzCJFK8fa1uPmnTsn 8WD920i1e7htrMNh8M15KWIO6MVU5idkoH6+Pcl12EHIsxgmrNC2zZC4quoyxIlWfzI7 vuvYJ1rKcQhEzrVGmKTm7+Zx7ElftF1MjROSrZSoAI7DK5+OoJ64XMVfrmHLmElNTHgs DVPg== 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:cc:to:from; bh=z5ci/X/lLiFuZNLGAa3MIXoyWsKM2relopxyFwJjuV4=; b=W1wU+yT5yPxy71CZyMrRJVVDK1COw7x6RnNEF3ilw9Ofns1YEH7X6t9R2xh9PO4oW0 qEf8hBIuOkIDy6DO7ntyx8ksUbxy9z/mBRq5JgnLI4aleSh5Iz7z/sqc7sXbcMu6qvU9 3ekq2/MH0oVsvEUhBkkBF6oB4iMbofOL532Z1K53ms5LjHpFEV353420z1zIKsd0FKvg k6XjQ83Ht2nnomScMBjwfQe7vC92AMlw0tVjczSDFhboQwnqRhanSZqhr4OVCBeJETBa T84kZVMOfOQteJeCb9pyfo35m0zgPXLG+wpokjhbueH9BIxxmO8kXKOE8k9ZdiSENiVL Wg8A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of bhe@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id q57si1779905qtf.374.2019.03.26.02.02.54 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Mar 2019 02:02:54 -0700 (PDT) Received-SPF: pass (google.com: domain of bhe@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of bhe@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2F58988318; Tue, 26 Mar 2019 09:02:53 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-21.pek2.redhat.com [10.72.12.21]) by smtp.corp.redhat.com (Postfix) with ESMTP id 49BFB8261C; Tue, 26 Mar 2019 09:02:49 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, mhocko@suse.com, rppt@linux.ibm.com, osalvador@suse.de, willy@infradead.org, william.kucharski@oracle.com, Baoquan He , Greg Kroah-Hartman , "Rafael J. Wysocki" Subject: [PATCH v2 4/4] drivers/base/memory.c: Rename the misleading parameter Date: Tue, 26 Mar 2019 17:02:27 +0800 Message-Id: <20190326090227.3059-5-bhe@redhat.com> In-Reply-To: <20190326090227.3059-1-bhe@redhat.com> References: <20190326090227.3059-1-bhe@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 26 Mar 2019 09:02:54 +0000 (UTC) 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 The input parameter 'phys_index' of memory_block_action() is actually the section number, but not the phys_index of memory_block. Fix it. Signed-off-by: Baoquan He Cc: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" Reviewed-by: Rafael J. Wysocki Acked-by: Michal Hocko --- drivers/base/memory.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/base/memory.c b/drivers/base/memory.c index cb8347500ce2..184f4f8d1b62 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -231,13 +231,13 @@ static bool pages_correctly_probed(unsigned long start_pfn) * OK to have direct references to sparsemem variables in here. */ static int -memory_block_action(unsigned long phys_index, unsigned long action, int online_type) +memory_block_action(unsigned long sec, unsigned long action, int online_type) { unsigned long start_pfn; unsigned long nr_pages = PAGES_PER_SECTION * sections_per_block; int ret; - start_pfn = section_nr_to_pfn(phys_index); + start_pfn = section_nr_to_pfn(sec); switch (action) { case MEM_ONLINE: @@ -251,7 +251,7 @@ memory_block_action(unsigned long phys_index, unsigned long action, int online_t break; default: WARN(1, KERN_WARNING "%s(%ld, %ld) unknown action: " - "%ld\n", __func__, phys_index, action, action); + "%ld\n", __func__, sec, action, action); ret = -EINVAL; }