From patchwork Tue Dec 4 08:56:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 10711319 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 540EE1057 for ; Tue, 4 Dec 2018 08:57:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 436432A50D for ; Tue, 4 Dec 2018 08:57:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 32A0F2A861; Tue, 4 Dec 2018 08:57:17 +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,FREEMAIL_FROM,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 9E8D72A50D for ; Tue, 4 Dec 2018 08:57:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CF4B66B6DD8; Tue, 4 Dec 2018 03:57:15 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id CC8576B6DDB; Tue, 4 Dec 2018 03:57:15 -0500 (EST) 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 BBA276B6DDC; Tue, 4 Dec 2018 03:57:15 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by kanga.kvack.org (Postfix) with ESMTP id 76A716B6DD8 for ; Tue, 4 Dec 2018 03:57:15 -0500 (EST) Received: by mail-pg1-f197.google.com with SMTP id a18so8571959pga.16 for ; Tue, 04 Dec 2018 00:57:15 -0800 (PST) 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:cc:subject:date :message-id:in-reply-to:references; bh=4ZI9O2t5S5xhIpHTAjf+QRH1CAR9oLYK03wiuwh7AMk=; b=Pwl56cB7SL0Huc5a+U4Ou5T8h5Ur3IluxAhOMCzR5U9uMmzt0uTdmOehOyY5SOBDYP CGtD5GTqsKjYCuundqI7Fn79EOBFu2ywv/lc9G+yDdU3cYv+p2n6/O+rbnzWSuNfExm4 yUs/faKy2DwZRm/XRJVZi9NmeFeaDW7wbYjo0Esmt9PIDrvWWX5dU0jsFXG4RQWytYe6 arz/wWtwt0QOG2ry4MDi9RXN+0z8rVvsueonDhFOPXlxCHzk7Gb6FULCGT0OyWj8Wfza TDCHgG0E+dbBEX/1jDM+mFEGvrbwl0QfPbNttYg9hJWYKec7j6l6jIvn6cBQgaqnVoFf u9IQ== X-Gm-Message-State: AA+aEWbtDlVhLzuAqFO4y/hyzYfxrRdaVRazSENCTpkf5NsZX7F2oRtG YylUjBLKiIgy9bz3fdtVDAXQyXHW6ySEAyiVkY2wXUzjKPtUkEhbxJfGYre9+t0HSGC7qHgkIbN O2vKZSFU18xzllt0O+xEAQHPzyel89mu9fF9mMiq3lcn4WAyv2DPYXKQzZxd9XDeWXa77uUCjV/ UuWErRE1JAwDjZPZb7nMjwdNCnVs9rsriUyv0tQZRE9sfOkBZ5RIuyWgYrVy6XWJSpQIvPSHd90 pQgdPVTuiSwVB75f5WDrTFlp2pgcR8Lp/6UTEI2r0F0hik1di1JriqNIaNVR2GePdOrlvLsat8g 0S0YFSG6plJc3g18FdWbVgacBIkBCAc5rJ/b7+cJUVZ1pabTsPD3DDNXgFTUhqtauz9X5DiCaJ2 v X-Received: by 2002:a62:8f8c:: with SMTP id n134mr19562150pfd.137.1543913835063; Tue, 04 Dec 2018 00:57:15 -0800 (PST) X-Received: by 2002:a62:8f8c:: with SMTP id n134mr19562109pfd.137.1543913834009; Tue, 04 Dec 2018 00:57:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543913833; cv=none; d=google.com; s=arc-20160816; b=PaTJT8OGTGFZwTshubOZoBtSZK0g7PxUfXLmzyTcThIDQGdshusaJCcEBIvFbCw1tQ v3r/7pkM3WEd6R1dIV4ixl6gSibKBDt48S6NEPaQYEGLYLpuEn2W3wJXE/btrpGlA4yb zG3ljbGJ5igNMBdGqriZQ0idPVfguUUUfxRWoU3sK0ZAfrew2tg/7H4OkJXoaN6fE2RU QaxlQJuZxXBZiR1qC2TkppCGhg2B5uvORxenSDs4j71vwA34pVtemV7dwa8ICGltJJz7 2z0qkFoYl2tUc2Beu67HaOKEchJPO0tU0rzeE++KsZc4gJZv5HfLhgE1DYI8KSnjfy+v 56lw== 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 :dkim-signature; bh=4ZI9O2t5S5xhIpHTAjf+QRH1CAR9oLYK03wiuwh7AMk=; b=Ql1+uRr98YepE1LleVZewWZqMxnty679x+zFBWl0x9zYO8/Vaeoggj1Xv0o/ESDuSf 1Z5/njsB6LMpV+Ja/FCjk5Rnsp3Ase6RNWVX7sOs57RMRlLfKCc2oOuX/hW2mBm3pBl/ WNMh4tFjwo/QLWRHTl/zAzKjp1zwJ70Q2QcpSS/WKSvq43REyVkaN8eCbMb2HXcecsBK scJ66u+udmsYqj01gJyCMiHRhx26L05YCea8cqvX3NqSN4dG06/6vrcbVpuSBViLfT9x estAwILiqYFbOcvhZ1ImoFwJxXftOvEE8CNX7qmaeHnnav8FK2CF+xP40a1Y8vSMOisy HdnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=NeBANlqI; spf=pass (google.com: domain of richard.weiyang@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id n26sor17351188pfi.56.2018.12.04.00.57.13 for (Google Transport Security); Tue, 04 Dec 2018 00:57:13 -0800 (PST) Received-SPF: pass (google.com: domain of richard.weiyang@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=NeBANlqI; spf=pass (google.com: domain of richard.weiyang@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4ZI9O2t5S5xhIpHTAjf+QRH1CAR9oLYK03wiuwh7AMk=; b=NeBANlqIt/RLdMqN1wbwb2lZ2rsb0LdryE0gj2noSxvMfdWrtH9OiqkMABcKTDQcMk ff03TdVkDgdJnL0FBhwkN6hvYzIyldNsRQspNxR15QRq4Xzdh/5uwQ9Nbom+Z12bm71I 035Du+QT2YpxJRe91ZQxNcWMyDR83wLwNqyHsvQ1CijEYlI3z0tv9157KEJsGxiAApBG il+oC2VdjiRWRGyMlgDNgzKXOZr/+wICjaZImvGtP8mkPIECO8m7E2KyqAHxJGEHB3CM ck0OhoUEs8rrDRh5EwcH82r/BILAeaa5XXT/53Yw04t+LBnzsRAGtYZzkmE/OlKg/+7s 6FuA== X-Google-Smtp-Source: AFSGD/X9KzP9RMvHTYjxQqWfL01ZE1p0GCm0ZQwvH5iIQZk2MoxGTcrcouIibKq8ZzwNW+yxcIZc1Q== X-Received: by 2002:a62:3603:: with SMTP id d3mr20017028pfa.146.1543913833591; Tue, 04 Dec 2018 00:57:13 -0800 (PST) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id p24sm31612502pfk.155.2018.12.04.00.57.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Dec 2018 00:57:13 -0800 (PST) From: Wei Yang To: mhocko@suse.com, dave.hansen@intel.com, osalvador@suse.de, david@redhat.com Cc: akpm@linux-foundation.org, linux-mm@kvack.org, Wei Yang Subject: [PATCH v4 1/2] mm, sparse: drop pgdat_resize_lock in sparse_add/remove_one_section() Date: Tue, 4 Dec 2018 16:56:56 +0800 Message-Id: <20181204085657.20472-1-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20181129155316.8174-1-richard.weiyang@gmail.com> References: <20181129155316.8174-1-richard.weiyang@gmail.com> 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 pgdat_resize_lock is used to protect pgdat's memory region information like: node_start_pfn, node_present_pages, etc. While in function sparse_add/remove_one_section(), pgdat_resize_lock is used to protect initialization/release of one mem_section. This looks not proper. These code paths are currently protected by mem_hotplug_lock currently but should there ever be any reason for locking at the sparse layer a dedicated lock should be introduced. Following is the current call trace of sparse_add/remove_one_section() mem_hotplug_begin() arch_add_memory() add_pages() __add_pages() __add_section() sparse_add_one_section() mem_hotplug_done() mem_hotplug_begin() arch_remove_memory() __remove_pages() __remove_section() sparse_remove_one_section() mem_hotplug_done() The comment above the pgdat_resize_lock also mentions "Holding this will also guarantee that any pfn_valid() stays that way.", which is true with the current implementation and false after this patch. But current implementation doesn't meet this comment. There isn't any pfn walkers to take the lock so this looks like a relict from the past. This patch also removes this comment. [Michal: changelog suggestion] Signed-off-by: Wei Yang Acked-by: Michal Hocko Reviewed-by: David Hildenbrand --- v4: * fix typo in changelog * adjust second paragraph of changelog v3: * adjust the changelog with the reason for this change * remove a comment for pgdat_resize_lock * separate the prototype change of sparse_add_one_section() to another one v2: * adjust changelog to show this procedure is serialized by global mem_hotplug_lock --- include/linux/mmzone.h | 2 -- mm/sparse.c | 9 +-------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index d76177cb8436..be126113b499 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -639,8 +639,6 @@ typedef struct pglist_data { /* * Must be held any time you expect node_start_pfn, * node_present_pages, node_spanned_pages or nr_zones stay constant. - * Holding this will also guarantee that any pfn_valid() stays that - * way. * * pgdat_resize_lock() and pgdat_resize_unlock() are provided to * manipulate node_size_lock without checking for CONFIG_MEMORY_HOTPLUG diff --git a/mm/sparse.c b/mm/sparse.c index 33307fc05c4d..5825f276485f 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -669,7 +669,6 @@ int __meminit sparse_add_one_section(struct pglist_data *pgdat, struct mem_section *ms; struct page *memmap; unsigned long *usemap; - unsigned long flags; int ret; /* @@ -689,8 +688,6 @@ int __meminit sparse_add_one_section(struct pglist_data *pgdat, return -ENOMEM; } - pgdat_resize_lock(pgdat, &flags); - ms = __pfn_to_section(start_pfn); if (ms->section_mem_map & SECTION_MARKED_PRESENT) { ret = -EEXIST; @@ -707,7 +704,6 @@ int __meminit sparse_add_one_section(struct pglist_data *pgdat, sparse_init_one_section(ms, section_nr, memmap, usemap); out: - pgdat_resize_unlock(pgdat, &flags); if (ret < 0) { kfree(usemap); __kfree_section_memmap(memmap, altmap); @@ -769,10 +765,8 @@ void sparse_remove_one_section(struct zone *zone, struct mem_section *ms, unsigned long map_offset, struct vmem_altmap *altmap) { struct page *memmap = NULL; - unsigned long *usemap = NULL, flags; - struct pglist_data *pgdat = zone->zone_pgdat; + unsigned long *usemap = NULL; - pgdat_resize_lock(pgdat, &flags); if (ms->section_mem_map) { usemap = ms->pageblock_flags; memmap = sparse_decode_mem_map(ms->section_mem_map, @@ -780,7 +774,6 @@ void sparse_remove_one_section(struct zone *zone, struct mem_section *ms, ms->section_mem_map = 0; ms->pageblock_flags = NULL; } - pgdat_resize_unlock(pgdat, &flags); clear_hwpoisoned_pages(memmap + map_offset, PAGES_PER_SECTION - map_offset); From patchwork Tue Dec 4 08:56:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 10711321 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 B4BF21057 for ; Tue, 4 Dec 2018 08:57:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A6EE62A50D for ; Tue, 4 Dec 2018 08:57:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9A3E62A861; Tue, 4 Dec 2018 08:57:23 +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,FREEMAIL_FROM,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 2A8282A50D for ; Tue, 4 Dec 2018 08:57:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 52B556B6DDB; Tue, 4 Dec 2018 03:57:22 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 500476B6DDC; Tue, 4 Dec 2018 03:57:22 -0500 (EST) 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 3F1F26B6DDD; Tue, 4 Dec 2018 03:57:22 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by kanga.kvack.org (Postfix) with ESMTP id EF8C16B6DDB for ; Tue, 4 Dec 2018 03:57:21 -0500 (EST) Received: by mail-pf1-f197.google.com with SMTP id h11so13458797pfj.13 for ; Tue, 04 Dec 2018 00:57:21 -0800 (PST) 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:cc:subject:date :message-id:in-reply-to:references; bh=/BJUgbUYteirAsYokbZffEub6YPomN+G44tmfyiWZ5c=; b=a5sD/+7H52NLz9L5com0Bx+wgx14Kf0JCIbfqpnpRUTCCDK2w0LccThdQZnZmzo1vD kWEjlXh1v3gBy8ErvWVV7YzuFwNEzjI47NL/H8CIe/jCdO+C8tijCbaqvDuPfhwx+TCO uK0JXA5Cgnicfq4QcJ1IeKmKDRtT/ehxT4KSlEATmlP8BjSeJ/YbIItRJgQSzgKzB15R HBjoks7xa8xk3LAfBlqB50eU+sXphnlhkZNE5UF7qj0mU64g1tP5QMsfIuZ9Xq5GaNtR 5UzQ7XHcdPxwdJznirCj13os+r0eqvepoe5hP7hhs4KzidJj0KZcIrIqJhu9zbgjf1vW t8zQ== X-Gm-Message-State: AA+aEWbc9n+aaQvMEEFQaVsRrukiZTjwirj9gFFp5W27Jo9M0W5Xwrik nBG0Q8Ktd9qq0lSWBIpVL7AnQa4jBbAPrmy35WBbKkZMgeRKxScpDgbQ8OCk9GcT/421N7yqm+J x3LxRwXguVQ18nlj4BlPJ58162bOSs2hy0CLc63fdEdePV5SThB8+wTHD4paku4/KRlPxPBy3xp qGi9BLwPKKut9CergjeuQS4mf0jt+Qk7vmQRi+mOmgz8aBuioVIDJNE2IzsygvyaTBbm77nk+Aq 4JbiRKObsGPrfZFjZPmXs+jvOwg7AMwJO2lGHxHq5FpMLi/OM5RXL1sZjBu85IQeIEmjTBc6QI0 ANY+OCwDKw6PS/k/a0jZ9fbE4mtJqgEEy2NaMKC23k/J+Gd4hXBsgOBpFX3YYW3Y8gKkkncjioT r X-Received: by 2002:a65:65c9:: with SMTP id y9mr16468567pgv.438.1543913841649; Tue, 04 Dec 2018 00:57:21 -0800 (PST) X-Received: by 2002:a65:65c9:: with SMTP id y9mr16468540pgv.438.1543913840939; Tue, 04 Dec 2018 00:57:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543913840; cv=none; d=google.com; s=arc-20160816; b=Kff4oZClVebteogbeEEhErmh9habz0Xliu7qwKIjkm8PKrrbzT9/2OwrAlJbmb5ZSo sJ7dyiyQmFnIK4k4H6xCYzhmdrkyjqCaVBlOEIUhqh4652oaBuxr+4zxiK6NTDRbgLIy Y7J/cPvjDgwjaScvDyrL8Hofx5gKzQPcwFrM5S4Oy6pOomohWPFsngNdd1E7YHzs6vQL hdBPuUjdlWRzDq4gc2jJYTSr7cG+Jr55+zQjipB4ZpLyNyrB6PngL6v5K1PSyDIL60VX qx6R2Fc2zrgAtM9Q9rYjQwczydrCrwS6A2igrAhR2sNRzpxoLipNP1rFH8Ig5g3wfQS7 C1SQ== 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 :dkim-signature; bh=/BJUgbUYteirAsYokbZffEub6YPomN+G44tmfyiWZ5c=; b=xBXRCH2NJJ2q37v22RavEQh3BSUr8u6oO3YltUFdkIEMzjpo2WR5HTWRaixux+sG3d hFGBamlz/oQSrLqkddQrQdAbxV1Afsq6HCWsifx4ocBaxm5k4WbxD3DaGurkSobrGsQK bOHp+a5zdB/abu4WucN5rNqjkCfGAgVdWT4iK2rfUC0m6BKv7C7B7T4qteRHHTVSLcD9 E3AcOSut8M8fPE3F3sNgy8F5389SIi9OwYBslVNNs1ctOyKFswD5cqNr9sMefVwen0Rw El+pRz4SALsRG/TwpuZAZmHW5YaSoeittEJTkKIOV6yLvRuR1a8N5Dc8DaiebzYlkc51 oXXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=R6HYZril; spf=pass (google.com: domain of richard.weiyang@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id y23sor20572187pga.35.2018.12.04.00.57.20 for (Google Transport Security); Tue, 04 Dec 2018 00:57:20 -0800 (PST) Received-SPF: pass (google.com: domain of richard.weiyang@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=R6HYZril; spf=pass (google.com: domain of richard.weiyang@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/BJUgbUYteirAsYokbZffEub6YPomN+G44tmfyiWZ5c=; b=R6HYZrilphgqBPR1Dv8AToqxDFW81UdauCyVYERWcceJAaz78+UOsXw4fV9IYgorV6 WufHq3dt8HjFQTTs/CSuDXLkECGDnELj6g5EcIPl7nUsP/8kB5U7/KZPVYTmksQqs1Xc MiJa/d/ad2h/ub1kV1KkzPQle3a/1iEJf2BsmvYD0stUggt3N0bzkpSQ/TU8Lir5VDwC RRhx5e6YlDD89nbFJaJHea+ndalYlu7kCyp7DjoddTPe/AMm8g/v+yANcCkJRR3rku2F vlPAsQWeOXRUhe30wsAItLE9o8VDNNBBAJPhAcT8orMLikaChjDibBw9Iec94Lp1vvtC POYA== X-Google-Smtp-Source: AFSGD/VgSSirdPpHse5RXl5NF+w8H3f34dKdUEzWengBminWrgRixtD86pAAczgoahsXWHvo0v3bxA== X-Received: by 2002:a63:df13:: with SMTP id u19mr16231556pgg.294.1543913840565; Tue, 04 Dec 2018 00:57:20 -0800 (PST) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id y6sm45391424pfd.104.2018.12.04.00.57.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Dec 2018 00:57:19 -0800 (PST) From: Wei Yang To: mhocko@suse.com, dave.hansen@intel.com, osalvador@suse.de, david@redhat.com Cc: akpm@linux-foundation.org, linux-mm@kvack.org, Wei Yang Subject: [PATCH v4 2/2] mm, sparse: pass nid instead of pgdat to sparse_add_one_section() Date: Tue, 4 Dec 2018 16:56:57 +0800 Message-Id: <20181204085657.20472-2-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20181204085657.20472-1-richard.weiyang@gmail.com> References: <20181129155316.8174-1-richard.weiyang@gmail.com> <20181204085657.20472-1-richard.weiyang@gmail.com> 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 Since the information needed in sparse_add_one_section() is node id to allocate proper memory, it is not necessary to pass its pgdat. This patch changes the prototype of sparse_add_one_section() to pass node id directly. This is intended to reduce misleading that sparse_add_one_section() would touch pgdat. Signed-off-by: Wei Yang Reviewed-by: David Hildenbrand Acked-by: Michal Hocko --- * adjust parameter alignment --- include/linux/memory_hotplug.h | 4 ++-- mm/memory_hotplug.c | 2 +- mm/sparse.c | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h index 45a5affcab8a..b81cc29482d8 100644 --- a/include/linux/memory_hotplug.h +++ b/include/linux/memory_hotplug.h @@ -333,8 +333,8 @@ extern void move_pfn_range_to_zone(struct zone *zone, unsigned long start_pfn, unsigned long nr_pages, struct vmem_altmap *altmap); extern int offline_pages(unsigned long start_pfn, unsigned long nr_pages); extern bool is_memblock_offlined(struct memory_block *mem); -extern int sparse_add_one_section(struct pglist_data *pgdat, - unsigned long start_pfn, struct vmem_altmap *altmap); +extern int sparse_add_one_section(int nid, unsigned long start_pfn, + struct vmem_altmap *altmap); extern void sparse_remove_one_section(struct zone *zone, struct mem_section *ms, unsigned long map_offset, struct vmem_altmap *altmap); extern struct page *sparse_decode_mem_map(unsigned long coded_mem_map, diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index f626e7e5f57b..5b3a3d7b4466 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -253,7 +253,7 @@ static int __meminit __add_section(int nid, unsigned long phys_start_pfn, if (pfn_valid(phys_start_pfn)) return -EEXIST; - ret = sparse_add_one_section(NODE_DATA(nid), phys_start_pfn, altmap); + ret = sparse_add_one_section(nid, phys_start_pfn, altmap); if (ret < 0) return ret; diff --git a/mm/sparse.c b/mm/sparse.c index 5825f276485f..a4fdbcb21514 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -662,8 +662,8 @@ static void free_map_bootmem(struct page *memmap) * set. If this is <=0, then that means that the passed-in * map was not consumed and must be freed. */ -int __meminit sparse_add_one_section(struct pglist_data *pgdat, - unsigned long start_pfn, struct vmem_altmap *altmap) +int __meminit sparse_add_one_section(int nid, unsigned long start_pfn, + struct vmem_altmap *altmap) { unsigned long section_nr = pfn_to_section_nr(start_pfn); struct mem_section *ms; @@ -675,11 +675,11 @@ int __meminit sparse_add_one_section(struct pglist_data *pgdat, * no locking for this, because it does its own * plus, it does a kmalloc */ - ret = sparse_index_init(section_nr, pgdat->node_id); + ret = sparse_index_init(section_nr, nid); if (ret < 0 && ret != -EEXIST) return ret; ret = 0; - memmap = kmalloc_section_memmap(section_nr, pgdat->node_id, altmap); + memmap = kmalloc_section_memmap(section_nr, nid, altmap); if (!memmap) return -ENOMEM; usemap = __kmalloc_section_usemap();