From patchwork Mon May 27 11:11:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 10962549 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 DAB7E933 for ; Mon, 27 May 2019 11:12:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C9CBC28AD4 for ; Mon, 27 May 2019 11:12:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BE06428ADC; Mon, 27 May 2019 11:12:18 +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 8A23628AD4 for ; Mon, 27 May 2019 11:12:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CB47D6B0274; Mon, 27 May 2019 07:12:15 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C66866B0275; Mon, 27 May 2019 07:12:15 -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 AB82B6B0276; Mon, 27 May 2019 07:12:15 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ot1-f72.google.com (mail-ot1-f72.google.com [209.85.210.72]) by kanga.kvack.org (Postfix) with ESMTP id 8439D6B0274 for ; Mon, 27 May 2019 07:12:15 -0400 (EDT) Received: by mail-ot1-f72.google.com with SMTP id d62so6345252otb.4 for ; Mon, 27 May 2019 04:12:15 -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:mime-version :content-transfer-encoding; bh=ZzVHyKxsaFuN8jNqoGwUqAgqRnUraSka3HiY2u0A+MY=; b=aSnouf9RyDOvoQKFgLhLC+3AM5xHrHUGLDGuxFn7W6tPegk7OzKRuFlFkTEv9Y6pvQ QwVquFZdQcYKWwMxSUUK9fWJEAIITgBO1Vo+bw+9QULYtAJHb6wqlYgwGur38HSbng4o 61CVgvcJlIn0xHLggpLdFGTTiHBmCYRsXRPutA99xz3Vxg0Q4cCup74LS9XAXNAGa9Kd YR0HzXCuQpnCQC/iw6eoXvBrTt98EDiR+GsaB2hVriNtFKtviPgDYOg3c+oEzilzpLlg vE9a/6oMKn6d+nOJtTaqU7lYU9CUSsaX2n3JK2wvcZCgNA7LgbiWotUkFTOeqw+XglDB x8sQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of david@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: APjAAAXIUZQmR3yeIQmbRQRCaAVh/YbS4pQge7NCoGH+Qq29GrUnCSFx xgIPM1teODeJXPQl7aavBubbWui/xZ2V2lBcKUsjMbhBLkvkzTfRqbXPZZb+BcgsNpk9o7OwVYy Ip5wQN03ROxksNHOvcwbclyxWGzGk3kuIuXxbBHSqC6VNKT4uDSwhLHVvZudcWLY54w== X-Received: by 2002:aca:ed44:: with SMTP id l65mr15066258oih.107.1558955535193; Mon, 27 May 2019 04:12:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqxY4PmiM1ulv6fNQnT8Gx79t5npl5wsf9OZ+pEHu+vD5TfIuvm1+ARBjuz3fx1WsCFjfATc X-Received: by 2002:aca:ed44:: with SMTP id l65mr15066229oih.107.1558955534640; Mon, 27 May 2019 04:12:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558955534; cv=none; d=google.com; s=arc-20160816; b=yaW3FepraXXpF744nJVYUuVgicqKW6PcV+Zt2yE/tgkYK6D71wq7Tr7HgY5IGN+zjn gfGfx5aOcmIH5xzY/XfvL6bOykzr8b9bo/9PIiNlRgvmuGBp70QfNwOCq+ZaVl6za/sL dS8tmZhlwyonUup17yR7Je/SbBDCC+229lFm7WNqlY4WFDSLgQGWPoBsMLmnD4JI6xaB upgw/dTyNQzmYxPnq33IxoZpcAckBKCNt+gA8jhsGQz4hYs86M1LskEbzlSTpTvWiRNJ +bR10jSwK5SX3Fmp1o79g1XNpym1OVECEwpfS0w1FBkdQpVjKcJyRfmnh97PgU250oot aA5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=ZzVHyKxsaFuN8jNqoGwUqAgqRnUraSka3HiY2u0A+MY=; b=rbSWC7hEjfV/U30cbQbMnjKrfZo168PtrA0uw/awQaws9ba+y67lDfin7H3JlzUeHR tG//FgAR2/G9i+y/fHvuwaipYC19IH69dYRlggonEm0gzKuur7zHJAwylA6EkqHCK126 D73xhC+POB/RLj+h9VkWtcq1nLD8JEdRoZMvoLVfCbzNhnUJUfqCh5wOj7w/np6oCzHk v7su0CJaf1gXBJGfs9ZE6McCK6iwmZl8h6RtKO7+SekjpFS71mBE5nfqYSTnjoAOYQBV S2Aeeb5PtfgM4jLUhsfi2oybXMalslRWBMQFutvMzExHeuOklk8bFh9B9bZ6/Dz+WHre PU9Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of david@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=david@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 r3si7059719otg.222.2019.05.27.04.12.14 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 May 2019 04:12:14 -0700 (PDT) Received-SPF: pass (google.com: domain of david@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 david@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CD8CF330259; Mon, 27 May 2019 11:12:13 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-89.ams2.redhat.com [10.36.117.89]) by smtp.corp.redhat.com (Postfix) with ESMTP id 54D6E19C7F; Mon, 27 May 2019 11:12:10 +0000 (UTC) From: David Hildenbrand To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, linux-ia64@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linux-arm-kernel@lists.infradead.org, akpm@linux-foundation.org, Dan Williams , Wei Yang , Igor Mammedov , David Hildenbrand , Oscar Salvador , Michal Hocko , Pavel Tatashin , Qian Cai , Arun KS , Mathieu Malaterre , Wei Yang Subject: [PATCH v3 01/11] mm/memory_hotplug: Simplify and fix check_hotplug_memory_range() Date: Mon, 27 May 2019 13:11:42 +0200 Message-Id: <20190527111152.16324-2-david@redhat.com> In-Reply-To: <20190527111152.16324-1-david@redhat.com> References: <20190527111152.16324-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 27 May 2019 11:12:14 +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 By converting start and size to page granularity, we actually ignore unaligned parts within a page instead of properly bailing out with an error. Cc: Andrew Morton Cc: Oscar Salvador Cc: Michal Hocko Cc: David Hildenbrand Cc: Pavel Tatashin Cc: Qian Cai Cc: Wei Yang Cc: Arun KS Cc: Mathieu Malaterre Reviewed-by: Dan Williams Reviewed-by: Wei Yang Signed-off-by: David Hildenbrand Reviewed-by: Pavel Tatashin Reviewed-by: Oscar Salvador Acked-by: Michal Hocko --- mm/memory_hotplug.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index e096c987d261..762887b2358b 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1051,16 +1051,11 @@ int try_online_node(int nid) static int check_hotplug_memory_range(u64 start, u64 size) { - unsigned long block_sz = memory_block_size_bytes(); - u64 block_nr_pages = block_sz >> PAGE_SHIFT; - u64 nr_pages = size >> PAGE_SHIFT; - u64 start_pfn = PFN_DOWN(start); - /* memory range must be block size aligned */ - if (!nr_pages || !IS_ALIGNED(start_pfn, block_nr_pages) || - !IS_ALIGNED(nr_pages, block_nr_pages)) { + if (!size || !IS_ALIGNED(start, memory_block_size_bytes()) || + !IS_ALIGNED(size, memory_block_size_bytes())) { pr_err("Block size [%#lx] unaligned hotplug range: start %#llx, size %#llx", - block_sz, start, size); + memory_block_size_bytes(), start, size); return -EINVAL; } From patchwork Mon May 27 11:11:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 10962557 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 1620B933 for ; Mon, 27 May 2019 11:12:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 06DA428AD5 for ; Mon, 27 May 2019 11:12:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EEF4E28AD9; Mon, 27 May 2019 11:12:22 +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=unavailable 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 94B0428AD5 for ; Mon, 27 May 2019 11:12:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 97FC16B0275; Mon, 27 May 2019 07:12:21 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 908436B0276; Mon, 27 May 2019 07:12:21 -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 81ECF6B0277; Mon, 27 May 2019 07:12:21 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ot1-f71.google.com (mail-ot1-f71.google.com [209.85.210.71]) by kanga.kvack.org (Postfix) with ESMTP id 5B1076B0275 for ; Mon, 27 May 2019 07:12:21 -0400 (EDT) Received: by mail-ot1-f71.google.com with SMTP id e17so8667531otq.0 for ; Mon, 27 May 2019 04:12:21 -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:mime-version :content-transfer-encoding; bh=Swr+8nWtCkcUT0w+A5+pIbEH1netntQUXuvTN9iIMe8=; b=HKPRMChA80DXm0B0isCrUOaVf78eFG7vaZQoKYUwpatX4VWLYpO5wcfdO2amVz17oG emHNPaHZ4pm+nxqESmOqt0Nm+gBeplHM+TWSLoSvSk1iiCau6svx+UREkzNI557ovKjD k6Sy/QmaZMyJf+Y+Ne8kLK5xlalGNSviQEMltnupBJgbaV8B+2PbifuAoTpfB+hqEc5p VU0TLFis1atR7C5+489Q96A60HDbPNU+ZoCQy9bKuCUVwtqj2ztCTcH4IS1fQR/5TBlr iNWi6EDDHu2Qc3nS5ta5Xlmi/2CXNz8tMaFLrRy+J5TXehjUMHDU8RZF2gh1EnaBjnMG HH+Q== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of david@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: APjAAAWS1YSEaZkw/5FXkbR950hY2pF1LC+9iWs4wx68XxhGe3iCd151 NY8gwZLEEz2PUXJjvu4MWCulMYPIrbdajX50Eac6I0jnArJ/TdDmWGVHpxIrkJe/2h2jO5NU1dx bCV7W8rv+Y9iS1x/vVhBMyCrmlJ2wg98pMLrEHVkOpu31wipM8EEyFyV0c/E9DVThcA== X-Received: by 2002:a9d:5d10:: with SMTP id b16mr36601646oti.35.1558955541085; Mon, 27 May 2019 04:12:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqzqO8X62iXjCGrkE01KAA05fm4gdsJJgAVT2bS5v7A7xI+JpXQOq0i3r2DQMa5kF6/IL4Rx X-Received: by 2002:a9d:5d10:: with SMTP id b16mr36601621oti.35.1558955540587; Mon, 27 May 2019 04:12:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558955540; cv=none; d=google.com; s=arc-20160816; b=yLAYqBEMdgbgjqf2Fd2AeMfXVzpsuFbOKVq8rw2l17AyjUkHRZ6t9Psv6AwEhRmYby ezSX2m5jGNoLLITuYGVIiU0BemzZSf7vX0S0cTQ7lMMplTQcmp0LjivTw9R+7iJEgYol EIyqf+3Dl0LdDa6UssnlRgsk+zEAbS9BZaeZWIC/HBTOhK7ai2mOIQeMuUyJmmW8AJqt rRXDAINI4HCaSCH+Wz8rlIAROABKEi8S9fWfRR2rkU4LHU7+Nmip7c65RZ5E+83GDGZa HZbIbwCaVP7T+c9gsF5Ts1jVSASUmTPE+r5KPIBEQMSMkERxcSXc66m/29rOXmSt+ZtN R0DQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=Swr+8nWtCkcUT0w+A5+pIbEH1netntQUXuvTN9iIMe8=; b=abgpZ8b5QsICFhb5pRjZcjQxSTwc2Roo2EJ3uipdxWSQM81qJ0e9Wnd/ZNT2fNF3pL zKubT+Z+1F9KB2lY66M26CixkAGNqG2W4ZrCb2u41s77ATBoIZtgqIRsLEYKfhw99DKN TRkuosz7DquUpeNBQzlWNyX9MyuTS0zGHydWw5Il2SS6i55cBgd2YlT8jET2MEmDsYEI AZSCcQOxr+g4Pc/wx0O1XwPTRjjQiD8Md/N0TPWu776FrVoY0rXn7uUic0P0b9GE+Xu0 z3yySegsGgw/r7MjI+1PgfYPKPCtZl4P6kDDb+E1TxrmcBY0qtIevOLZrbNzvXG8RmZZ taEQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of david@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=david@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 c3si5775739otr.37.2019.05.27.04.12.20 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 May 2019 04:12:20 -0700 (PDT) Received-SPF: pass (google.com: domain of david@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 david@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BE4F43082B4D; Mon, 27 May 2019 11:12:19 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-89.ams2.redhat.com [10.36.117.89]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A88F19C7F; Mon, 27 May 2019 11:12:14 +0000 (UTC) From: David Hildenbrand To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, linux-ia64@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linux-arm-kernel@lists.infradead.org, akpm@linux-foundation.org, Dan Williams , Wei Yang , Igor Mammedov , David Hildenbrand , Martin Schwidefsky , Heiko Carstens , Michal Hocko , Mike Rapoport , Vasily Gorbik , Oscar Salvador Subject: [PATCH v3 02/11] s390x/mm: Fail when an altmap is used for arch_add_memory() Date: Mon, 27 May 2019 13:11:43 +0200 Message-Id: <20190527111152.16324-3-david@redhat.com> In-Reply-To: <20190527111152.16324-1-david@redhat.com> References: <20190527111152.16324-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Mon, 27 May 2019 11:12:20 +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 ZONE_DEVICE is not yet supported, fail if an altmap is passed, so we don't forget arch_add_memory()/arch_remove_memory() when unlocking support. Cc: Martin Schwidefsky Cc: Heiko Carstens Cc: Andrew Morton Cc: Michal Hocko Cc: Mike Rapoport Cc: David Hildenbrand Cc: Vasily Gorbik Cc: Oscar Salvador Suggested-by: Dan Williams Signed-off-by: David Hildenbrand Reviewed-by: Oscar Salvador --- arch/s390/mm/init.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c index 14d1eae9fe43..d552e330fbcc 100644 --- a/arch/s390/mm/init.c +++ b/arch/s390/mm/init.c @@ -226,6 +226,9 @@ int arch_add_memory(int nid, u64 start, u64 size, unsigned long size_pages = PFN_DOWN(size); int rc; + if (WARN_ON_ONCE(restrictions->altmap)) + return -EINVAL; + rc = vmem_add_mapping(start, size); if (rc) return rc; From patchwork Mon May 27 11:11:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 10962559 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 CC98B112C for ; Mon, 27 May 2019 11:12:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BC27428AD4 for ; Mon, 27 May 2019 11:12:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B055828AD9; Mon, 27 May 2019 11:12:26 +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 4F86D28AD4 for ; Mon, 27 May 2019 11:12:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 317286B0276; Mon, 27 May 2019 07:12:25 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2C6736B0277; Mon, 27 May 2019 07:12:25 -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 1B6686B0278; Mon, 27 May 2019 07:12:25 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ot1-f71.google.com (mail-ot1-f71.google.com [209.85.210.71]) by kanga.kvack.org (Postfix) with ESMTP id E62B96B0276 for ; Mon, 27 May 2019 07:12:24 -0400 (EDT) Received: by mail-ot1-f71.google.com with SMTP id z1so8654256oth.8 for ; Mon, 27 May 2019 04:12:24 -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:mime-version :content-transfer-encoding; bh=FWepBTVtBSrXDhoobt+I+QFd6CdFMlIwO5u9/uFDPcc=; b=Ub9nYLysuLO0GMHm0jY4pYb6OQJrviNvoI8nRm+1HYACQMX9pWWIo8zu/1VoK2XHbO shjikMrwe+U+3KMfwmD8rkwuI2kHQF6GYk9w46vBjgWLyI1+Xbv4WYdCZNy4ZqNRl4Sz C9LXc06Onul88mOP/qYLI+BZipaQ0gmk1iela56augqtTxIF8Adx0FCzeeVk5T/yR9Tj wY4Cyje4Rc+g1lILVPQq1XZCKA9rB1Kl8dmPRgNk1802T4zIkTt7Yu+T7kIvZZNpAKUX T0CCnXSLw70t+AmtU5zTC2j8uzl0Kc+UVub0Ejq8Yc6W4ruIvOmJlABwgxY8CzAj0WBD +FIA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of david@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: APjAAAXNAToYhNgK7VkxfaFQxxp1hicXeaZPOlQBPDh3+c6dxnKS/yFC uNSHxCYiBhU9Ef0TwSIOZIRKvfx7wr2T8He8505nnQe005fclK5phc4y3huEoOGKWW1xbp5weiY TAE7V9X5pg9RrlQy+841mS0SSPRio/7xckAUeB7Soz8C+n7dC/XDOk6L94GLXQvcYrQ== X-Received: by 2002:aca:844:: with SMTP id 65mr14123925oii.109.1558955544602; Mon, 27 May 2019 04:12:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqy1sz8iymntK/+3yy0yUP854o7C5KZefWwgz2i5unxCYaPvQl0G+rUMM8cs3dpudlfaDE2r X-Received: by 2002:aca:844:: with SMTP id 65mr14123904oii.109.1558955544099; Mon, 27 May 2019 04:12:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558955544; cv=none; d=google.com; s=arc-20160816; b=t8ig3PUqYgNabmx7ehKNCe1ncdqLtZDjDoMR2kKfP211hfFoPm8Jkri02KdO8W64U6 V9CMWfhfHgiAscn4cwUL0gh+JdE6MO5nAZ/eX/P+f/6Te0ised/ZCwEQimLhHWi2k9Jh BQH4mzcQoYhWwbgflLHYciMYCljyXYp225Ltp872z38h/qvnyVzvSiEjIniV9ESdyy7i 6NC1eY2miTOJMCzhvJ9h96Jqi78rjt13pFIA65LopX6N02x5TqrM/+qUjWMmXvTFtveA I15A4d2Jk2jx/6JmFBvCutmucOT2YXlH8pH4vnDC4Me2xmrlidGHL80vkdd0XVgxWUwk HesQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=FWepBTVtBSrXDhoobt+I+QFd6CdFMlIwO5u9/uFDPcc=; b=mhyT5Mmi2LyRdXEwU1Ap0hQfF3vF1+uVlW5jMn2z9/IbvB720kM8Nf/fAO+V/tTA81 28KiIgcYrjAByhAGxLd/B2Eu5/52YWDpvLR3+uNEQz2HPMcKkuHQON+fNr68zOVp2Ix9 ogo4uF7Klo2smSXG/CyeKSgd1kco3NvVJzw/4niPGRuwVR13CtN9Q3CKeJ4zTCRNZiDZ DMHk1+ypLmFfOY9iG+Zp5OuV53ayoNj1XOeW9iY2CYMRsv80QkXsU4t3OhENc48wGQuU n3aQeHDcdAino65rv4UwJkEhdbRaQ+hyb6+Hvcvd2zWfuDpEKnl+UcxG0m5g6kZi4rBv r9ww== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of david@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=david@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 i8si6134783oih.11.2019.05.27.04.12.23 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 May 2019 04:12:24 -0700 (PDT) Received-SPF: pass (google.com: domain of david@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 david@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 61EDA5D60F; Mon, 27 May 2019 11:12:23 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-89.ams2.redhat.com [10.36.117.89]) by smtp.corp.redhat.com (Postfix) with ESMTP id 200CD19C7F; Mon, 27 May 2019 11:12:19 +0000 (UTC) From: David Hildenbrand To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, linux-ia64@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linux-arm-kernel@lists.infradead.org, akpm@linux-foundation.org, Dan Williams , Wei Yang , Igor Mammedov , David Hildenbrand , Martin Schwidefsky , Heiko Carstens , Michal Hocko , Mike Rapoport , Vasily Gorbik , Oscar Salvador Subject: [PATCH v3 03/11] s390x/mm: Implement arch_remove_memory() Date: Mon, 27 May 2019 13:11:44 +0200 Message-Id: <20190527111152.16324-4-david@redhat.com> In-Reply-To: <20190527111152.16324-1-david@redhat.com> References: <20190527111152.16324-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 27 May 2019 11:12:23 +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 Will come in handy when wanting to handle errors after arch_add_memory(). Cc: Martin Schwidefsky Cc: Heiko Carstens Cc: Andrew Morton Cc: Michal Hocko Cc: Mike Rapoport Cc: David Hildenbrand Cc: Vasily Gorbik Cc: Oscar Salvador Signed-off-by: David Hildenbrand --- arch/s390/mm/init.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c index d552e330fbcc..14955e0a9fcf 100644 --- a/arch/s390/mm/init.c +++ b/arch/s390/mm/init.c @@ -243,12 +243,13 @@ int arch_add_memory(int nid, u64 start, u64 size, void arch_remove_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap) { - /* - * There is no hardware or firmware interface which could trigger a - * hot memory remove on s390. So there is nothing that needs to be - * implemented. - */ - BUG(); + unsigned long start_pfn = start >> PAGE_SHIFT; + unsigned long nr_pages = size >> PAGE_SHIFT; + struct zone *zone; + + zone = page_zone(pfn_to_page(start_pfn)); + __remove_pages(zone, start_pfn, nr_pages, altmap); + vmem_remove_mapping(start, size); } #endif #endif /* CONFIG_MEMORY_HOTPLUG */ From patchwork Mon May 27 11:11:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 10962565 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 32909112C for ; Mon, 27 May 2019 11:12:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 23AA928AD5 for ; Mon, 27 May 2019 11:12:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1754F28AD9; Mon, 27 May 2019 11:12:31 +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=unavailable 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 8524C28AD5 for ; Mon, 27 May 2019 11:12:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8E48F6B0277; Mon, 27 May 2019 07:12:29 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8BA8E6B0278; Mon, 27 May 2019 07:12:29 -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 7D2106B0279; Mon, 27 May 2019 07:12:29 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-oi1-f200.google.com (mail-oi1-f200.google.com [209.85.167.200]) by kanga.kvack.org (Postfix) with ESMTP id 5499A6B0277 for ; Mon, 27 May 2019 07:12:29 -0400 (EDT) Received: by mail-oi1-f200.google.com with SMTP id r78so5294096oie.8 for ; Mon, 27 May 2019 04:12:29 -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:mime-version :content-transfer-encoding; bh=rSz3Zt/+BgR8xImgIVcrGb75Z6CG2oL9X/qCww6Ms78=; b=LWFvAHGIEFqO+eQj5kQegO7/aUtypqZkhDFQEAIPq4jTvaQMjoghD4vwRAfpAePK0N dVnTSdFxtFqwouOdw288swo+bICsYDGoOQbmuT1RWxfGubT4y5NoS3xcEFNK8QbSGX5d RbqkI2bpAd6xIlqzqIcinnOm6g4OAnyMkl39x7q0RCXTrRr3W+MQPLTI3PMGC0vXTtPS xVueelxZ0NcjhrVQ2s33SSyg9Bwtxqg46xG+E2Rzjn0eMqAoB2l5luvwIOIUT2UdRnon An1J4SNwnwAFd+Q3Y1iez1/lsnOnDMu3sIG5pwjq9n2juMsbFby/b9f8xVM1nM4ItV1x 3Zaw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of david@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: APjAAAVvkMG9OI8mHDYton55D0GsBKkVaYe1rcHWfzPREjRkFviUVVtp UUWdbvu4qkb0mYYonQpSIGcgiohAUT0xfsCaKNdCpH72WZ+JRrzd6N9XZduTiNBcxX4TF7cT9I+ lDHixkoFRBkcw6GggqNJFu4mMrHf7H94nUfFSlf686Ygbz4VRmyE4mfQtmif2KojyRw== X-Received: by 2002:a9d:4a84:: with SMTP id i4mr63084695otf.148.1558955549026; Mon, 27 May 2019 04:12:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqxd0VggAnr1sNOn5GivhFAOLL36tU0v2/losBta6ePJXwevt9S9/JdR3qA3mH0e+bjiYNfB X-Received: by 2002:a9d:4a84:: with SMTP id i4mr63084660otf.148.1558955548452; Mon, 27 May 2019 04:12:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558955548; cv=none; d=google.com; s=arc-20160816; b=d1T4rZBHxHJVNWyckUG7z3cU7HXP9YNukY3aeNWunhhFaZ8/j+ZShQ6zOKjGAd3SKs DBE63DQoTHrEOqm7yHCqF/4xVq424tP/WnaMEtgxYe38Jp+nXllbZauyXaHgICESLJHR Hva7dMjJYaoj1VTGfPsAzz/QzEpZQrrM7JTdLQ0ZP6CUPgNqKyHPVl2yW4Q3wXmAJ1Cc boJjO7PE98I1FnoecoILvWnexVXDV3pdTf2zq0bzMJ69ZHBgb0V6nCpOYF1x6vr+lwI0 phwQTTeOwY4W/GvC6vo0xm9FANhXAbKeDF9Fwxx/pFsd86eMEYHY6IcvLX+jyq2/dSwj 8nmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=rSz3Zt/+BgR8xImgIVcrGb75Z6CG2oL9X/qCww6Ms78=; b=wq/pjT0CS1GHUIOYWazBOLzrjEgpr3+N11trFEu6LE23UdlLokElxA1hd6Y8Xvrn3X MobBmqdXIwojf8fI+6MjTJCOzmJh8jHxdXqKcjvQ8GfPhHzvNibCVSqlM9W/g9IAYRCs 5jpkhSOOZqIeVgJlFh/U3Vwb1zI7RwR1pFg2IZc+5tFSrNQng+6aYOX5gQGqyX96H3z3 KyQysqSGRj5BQUYOJJz3mYs4KGqRARzP+cezG87A0rgpGTeg5Hr9MvdcD2H3bgCjr1/k mi/YEUHXGC/lvhPhcMt6oQ2hfmWUjJE7HXZEFm0x9h0jT7YBSlGSG7J7lJuHTvzp76d/ A5rA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of david@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=david@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 g3si5894480otn.127.2019.05.27.04.12.28 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 May 2019 04:12:28 -0700 (PDT) Received-SPF: pass (google.com: domain of david@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 david@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AADC387621; Mon, 27 May 2019 11:12:27 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-89.ams2.redhat.com [10.36.117.89]) by smtp.corp.redhat.com (Postfix) with ESMTP id B59CC2AA83; Mon, 27 May 2019 11:12:23 +0000 (UTC) From: David Hildenbrand To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, linux-ia64@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linux-arm-kernel@lists.infradead.org, akpm@linux-foundation.org, Dan Williams , Wei Yang , Igor Mammedov , David Hildenbrand , Catalin Marinas , Will Deacon , Mark Rutland , Ard Biesheuvel , Chintan Pandya , Mike Rapoport , Jun Yao , Yu Zhao , Robin Murphy , Anshuman Khandual Subject: [PATCH v3 04/11] arm64/mm: Add temporary arch_remove_memory() implementation Date: Mon, 27 May 2019 13:11:45 +0200 Message-Id: <20190527111152.16324-5-david@redhat.com> In-Reply-To: <20190527111152.16324-1-david@redhat.com> References: <20190527111152.16324-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 27 May 2019 11:12:27 +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 A proper arch_remove_memory() implementation is on its way, which also cleanly removes page tables in arch_add_memory() in case something goes wrong. As we want to use arch_remove_memory() in case something goes wrong during memory hotplug after arch_add_memory() finished, let's add a temporary hack that is sufficient enough until we get a proper implementation that cleans up page table entries. We will remove CONFIG_MEMORY_HOTREMOVE around this code in follow up patches. Cc: Catalin Marinas Cc: Will Deacon Cc: Mark Rutland Cc: Andrew Morton Cc: Ard Biesheuvel Cc: Chintan Pandya Cc: Mike Rapoport Cc: Jun Yao Cc: Yu Zhao Cc: Robin Murphy Cc: Anshuman Khandual Signed-off-by: David Hildenbrand --- arch/arm64/mm/mmu.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index a1bfc4413982..e569a543c384 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -1084,4 +1084,23 @@ int arch_add_memory(int nid, u64 start, u64 size, return __add_pages(nid, start >> PAGE_SHIFT, size >> PAGE_SHIFT, restrictions); } +#ifdef CONFIG_MEMORY_HOTREMOVE +void arch_remove_memory(int nid, u64 start, u64 size, + struct vmem_altmap *altmap) +{ + unsigned long start_pfn = start >> PAGE_SHIFT; + unsigned long nr_pages = size >> PAGE_SHIFT; + struct zone *zone; + + /* + * FIXME: Cleanup page tables (also in arch_add_memory() in case + * adding fails). Until then, this function should only be used + * during memory hotplug (adding memory), not for memory + * unplug. ARCH_ENABLE_MEMORY_HOTREMOVE must not be + * unlocked yet. + */ + zone = page_zone(pfn_to_page(start_pfn)); + __remove_pages(zone, start_pfn, nr_pages, altmap); +} +#endif #endif From patchwork Mon May 27 11:11:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 10962569 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 9E613933 for ; Mon, 27 May 2019 11:12:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8DDBF28AD4 for ; Mon, 27 May 2019 11:12:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 81F9E28AD7; Mon, 27 May 2019 11:12:35 +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 A73A728AD5 for ; Mon, 27 May 2019 11:12:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 784346B0278; Mon, 27 May 2019 07:12:32 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 75AF36B0279; Mon, 27 May 2019 07:12:32 -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 5D4A46B027A; Mon, 27 May 2019 07:12:32 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-oi1-f200.google.com (mail-oi1-f200.google.com [209.85.167.200]) by kanga.kvack.org (Postfix) with ESMTP id 3567E6B0278 for ; Mon, 27 May 2019 07:12:32 -0400 (EDT) Received: by mail-oi1-f200.google.com with SMTP id r78so5294136oie.8 for ; Mon, 27 May 2019 04:12:32 -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:mime-version :content-transfer-encoding; bh=FNTktvj0kV+SOdLAQ71+yr15WutmVjJpnyIy6jk9OZM=; b=T70ZJfUlRpS3gc1fpb7E57bu3dfGlN6gZym3N7P3dkaUV/AApz0rnzrJpiS4rkTXXT t6ftgwy49R9v2O3ciGTJPc651aJq48uW+kX8DVxHR1gcwVbnSiuqfawicpT965DZVBNj j1dmYC1vlozZY+AdQglCGMYQrTsqlso9ftnEBzagLnBU6AWB3fd2kJKzR1hU4RMakexi Hs2/lgYHVD5DsBj1TL2ICBw731IesZyYbRZ0oin1dsvW/hNB/sqM7EE8i/X3Xyj+q9LE lAVGWPYQacGtFGchJRy2cKTGRNZD0d7kAltqLzTwUEDLJEJFxRxgQav6Q1voK6erZ7j5 mUtw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of david@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: APjAAAWhEPI1sbGKD8e7qXVJomrazS9vTeAl7/oLIWg3xvaDFDCQmO33 0MJ3xKm31E1XTIL1gwhpiSKW1anG+QA1ShdkI6PD/4XJeH+6l4Y7z9YCbd92q/6isrcLqlO3eNo 3y+RfSXzLbXRytOW/gCPi702A+WrX5rMMF3xyhBvN3gh0QTjuE04bl6HZ3Hjhmch1aA== X-Received: by 2002:a9d:6287:: with SMTP id x7mr22722402otk.287.1558955551913; Mon, 27 May 2019 04:12:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqyZ8sQfhP38lV3aOH75A7pSjctcddeZX6MqBND8EnimWoK0gR469rsfPR2v4mMWZ5u1jiS6 X-Received: by 2002:a9d:6287:: with SMTP id x7mr22722368otk.287.1558955551350; Mon, 27 May 2019 04:12:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558955551; cv=none; d=google.com; s=arc-20160816; b=MDmPBaBQdPvSTgoIPAV0MN+Bz7znOXcBzQiF0TN6JjdV6cUMFblDp72H3zUxRvtw8p 9IBnhkn4EtLfZBVs0paD9VAyZvBpavv+ae+5GSlIe6haq5joRZ+Ydlva4tTJ/dlhDSQu VSlfXA4wNUPvXCSpug9rLjTIqFkPYfL7S2MfQfOXUu9oWYNoZ5PLpmlxjOLHBXE+fJGm 4pCClf1XXaS9hLUL3G77yTA/psV8OHdusG9oJUEQ63IpRtmCf6ys/6z3xSfnF8wKVesK UYZuWiUnviYPmJo1xATFj+33Wd9/oZeIR4eTvm2Zs6+6JSq1aSulTgXQm128SNwvg1fn xT4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=FNTktvj0kV+SOdLAQ71+yr15WutmVjJpnyIy6jk9OZM=; b=AKcdprAYQD+MtiakdtxOBf3Hhfe7kY/rf0sJs+ewv4kt9S1h5Djqthg4vEwjHYJD96 JgU/O2qX1VlrnbR8ToEPYAUD7+2jQhfYs8vyVOpso/Ouqp6nZQGKH3J6uV27ghUtORuq diOWsdbQ63yVhPFONP/ihr0Ib9X3+64lg0MdsXBABK68GZYug/LM00pEnnSn5TtKn8YB 8iIZESQu52G3ary/REh/YyWf5Ba4LpwcwKinZrCPgASEgP9F+XYX35vqWLZZvAqQ9HJs my9JnbJvxBaH6i0W/MZiSK/xoE0lzbJ1a8ix2flqz5Ct+sLy0Nl6AyoTleOvdJmyZ3nA Rx1g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of david@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=david@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 r84si4664079oig.180.2019.05.27.04.12.31 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 May 2019 04:12:31 -0700 (PDT) Received-SPF: pass (google.com: domain of david@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 david@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B17DE88319; Mon, 27 May 2019 11:12:30 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-89.ams2.redhat.com [10.36.117.89]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0FD3919C7F; Mon, 27 May 2019 11:12:27 +0000 (UTC) From: David Hildenbrand To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, linux-ia64@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linux-arm-kernel@lists.infradead.org, akpm@linux-foundation.org, Dan Williams , Wei Yang , Igor Mammedov , David Hildenbrand , Greg Kroah-Hartman , "Rafael J. Wysocki" Subject: [PATCH v3 05/11] drivers/base/memory: Pass a block_id to init_memory_block() Date: Mon, 27 May 2019 13:11:46 +0200 Message-Id: <20190527111152.16324-6-david@redhat.com> In-Reply-To: <20190527111152.16324-1-david@redhat.com> References: <20190527111152.16324-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 27 May 2019 11:12:30 +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 We'll rework hotplug_memory_register() shortly, so it no longer consumes pass a section. Cc: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" Signed-off-by: David Hildenbrand Acked-by: Michal Hocko --- drivers/base/memory.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/base/memory.c b/drivers/base/memory.c index f180427e48f4..f914fa6fe350 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -651,21 +651,18 @@ int register_memory(struct memory_block *memory) return ret; } -static int init_memory_block(struct memory_block **memory, - struct mem_section *section, unsigned long state) +static int init_memory_block(struct memory_block **memory, int block_id, + unsigned long state) { struct memory_block *mem; unsigned long start_pfn; - int scn_nr; int ret = 0; mem = kzalloc(sizeof(*mem), GFP_KERNEL); if (!mem) return -ENOMEM; - scn_nr = __section_nr(section); - mem->start_section_nr = - base_memory_block_id(scn_nr) * sections_per_block; + mem->start_section_nr = block_id * sections_per_block; mem->end_section_nr = mem->start_section_nr + sections_per_block - 1; mem->state = state; start_pfn = section_nr_to_pfn(mem->start_section_nr); @@ -694,7 +691,8 @@ static int add_memory_block(int base_section_nr) if (section_count == 0) return 0; - ret = init_memory_block(&mem, __nr_to_section(section_nr), MEM_ONLINE); + ret = init_memory_block(&mem, base_memory_block_id(base_section_nr), + MEM_ONLINE); if (ret) return ret; mem->section_count = section_count; @@ -707,6 +705,7 @@ static int add_memory_block(int base_section_nr) */ int hotplug_memory_register(int nid, struct mem_section *section) { + int block_id = base_memory_block_id(__section_nr(section)); int ret = 0; struct memory_block *mem; @@ -717,7 +716,7 @@ int hotplug_memory_register(int nid, struct mem_section *section) mem->section_count++; put_device(&mem->dev); } else { - ret = init_memory_block(&mem, section, MEM_OFFLINE); + ret = init_memory_block(&mem, block_id, MEM_OFFLINE); if (ret) goto out; mem->section_count++; From patchwork Mon May 27 11:11:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 10962575 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 423A3933 for ; Mon, 27 May 2019 11:12:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2EA8028AD4 for ; Mon, 27 May 2019 11:12:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 21ED928AD7; Mon, 27 May 2019 11:12:48 +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 9DDCE28AD4 for ; Mon, 27 May 2019 11:12:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9A5CE6B0279; Mon, 27 May 2019 07:12:45 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 97DBB6B027A; Mon, 27 May 2019 07:12:45 -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 86E966B027B; Mon, 27 May 2019 07:12:45 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-oi1-f200.google.com (mail-oi1-f200.google.com [209.85.167.200]) by kanga.kvack.org (Postfix) with ESMTP id 5D3DF6B0279 for ; Mon, 27 May 2019 07:12:45 -0400 (EDT) Received: by mail-oi1-f200.google.com with SMTP id w5so5283530oig.18 for ; Mon, 27 May 2019 04:12:45 -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:mime-version :content-transfer-encoding; bh=YRiQ/Ft+/J+a7B/8egatgJP8Bg39rSfzFQA6NK4ANOk=; b=FF7QbpeDNjQPL9Vo9Mvr5NQBsNd0edcUmHDcts87jSW7QEQgGcwKSjook9YjvaZ26/ LmS9qKz51WKE8QdtvA2FlU7CNFmzD2d6FuwRkEx/GuW3G8pHfVBv+l70aYhCseeNZDMJ h/TKGgwUyZtoBfj4RPPUKjpS0G82fgp2nBeOrrD2bLpZxzVZNf75+s4tpn5oQpz8MEdH RiiUVqw30bJ/83kcT9j5FSZfv86gWNzsoCO1fvCsPSZjDlYk1lN0WEEXogdfMpmmXC8J jpjwPmkhXTmc4s7C2AtpUW7B5NEF7U2TCj0uMhKy6Yun+yXRcPNls7nd7yXXrTUwQ+wa 2mCA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of david@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: APjAAAVaHKwzO4Wnq9RbMPSSVLfPzT2u457acr0TrOthKkJuzbwIMOkp nfIUy2C7rVUssKxzZx17zlS2QWs11eaLtZCh7bZcud4l9RM0vtGX5qBIJx9H6UPGNE56Q3EA8dS eB6cDSTbONraI4Bp/vuSPj+FRFW3/6gYbh2jlsn5YCZz8gJlWxqfiRMBy3WIYS3SLtQ== X-Received: by 2002:a9d:2f68:: with SMTP id h95mr57217475otb.152.1558955565078; Mon, 27 May 2019 04:12:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqxah7q+n/IGj34R3n5hXguVAJ/GZe0RdgZGMHejtj92VnW+nl+a57KixATAYiGLvjPTrNE2 X-Received: by 2002:a9d:2f68:: with SMTP id h95mr57217430otb.152.1558955564355; Mon, 27 May 2019 04:12:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558955564; cv=none; d=google.com; s=arc-20160816; b=d4RJMGHaE6f8eIBulFdiyFcfrRO1dnwDsupj79ycwLL/rAKMLxB+NB+KB0eCfm3/Oq TT2joNJA/pXlR9TLq/lZsMZ5dtdWwPEEvGyNcI8hcUma10I+P5Uq/dE1Akt3/z/ASY7g GTV00TV1UbDT/o7FfFQ2Fa2MLpAqVjkOXRYblQoA1vvZmxQt9t8EwJSPuP6sZrEp7AL+ lCVNLWb+TTR+tlZoBZv6HKXsOP5ydBSH7AiO59M6Cuw9QDPoZGZltlrB52n371ovFvOz iasDNKtvgJwD8p1Zt/PpLdm1VHyZgdUNqcF6ZqNkXhD2D1ZLJQG+tsNhVjoJfS92V+uP tIBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=YRiQ/Ft+/J+a7B/8egatgJP8Bg39rSfzFQA6NK4ANOk=; b=DkG6DlWro5SOWNb8glg7ZsakuLBN7ZN0TwQ8rUR6UzwtCDHUTNKztvchi3sEAZ2sjn Wrbre8qBIBOaox23gpSi9YCjWQxxzO5hD8D+GQ8yZjZwnDLiecrG9tB+qMKypMikckRc ++us4aL6q/1l997SqCzAu8l90fOZxduSArT1e47iJ32WXzydh32nvH6wtAuGNvEGqcr5 6PW7umWEDwFkH3ujAJ+hpE7GlZZf0l8qXXUMkspZBzFYMgEfv9iH+vzUN0JqJGfnX7T5 Q769xi1SInLVKwK1IK7TSdgxbF1MEgfrSr90QE4PD+2BbdB6nDXNjsYh3xB8JKWS5Jd9 DWlw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of david@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=david@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 h3si6043514oia.212.2019.05.27.04.12.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 May 2019 04:12:44 -0700 (PDT) Received-SPF: pass (google.com: domain of david@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 david@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DFAD930832EA; Mon, 27 May 2019 11:12:42 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-89.ams2.redhat.com [10.36.117.89]) by smtp.corp.redhat.com (Postfix) with ESMTP id 094702AA81; Mon, 27 May 2019 11:12:30 +0000 (UTC) From: David Hildenbrand To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, linux-ia64@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linux-arm-kernel@lists.infradead.org, akpm@linux-foundation.org, Dan Williams , Wei Yang , Igor Mammedov , David Hildenbrand , Tony Luck , Fenghua Yu , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Martin Schwidefsky , Heiko Carstens , Yoshinori Sato , Rich Felker , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Greg Kroah-Hartman , "Rafael J. Wysocki" , Michal Hocko , Mike Rapoport , Oscar Salvador , "Kirill A. Shutemov" , Alex Deucher , "David S. Miller" , Mark Brown , Chris Wilson , Christophe Leroy , Nicholas Piggin , Vasily Gorbik , Rob Herring , Masahiro Yamada , "mike.travis@hpe.com" , Andrew Banman , Pavel Tatashin , Wei Yang , Arun KS , Qian Cai , Mathieu Malaterre , Baoquan He , Logan Gunthorpe , Anshuman Khandual Subject: [PATCH v3 06/11] mm/memory_hotplug: Allow arch_remove_pages() without CONFIG_MEMORY_HOTREMOVE Date: Mon, 27 May 2019 13:11:47 +0200 Message-Id: <20190527111152.16324-7-david@redhat.com> In-Reply-To: <20190527111152.16324-1-david@redhat.com> References: <20190527111152.16324-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Mon, 27 May 2019 11:12:43 +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 We want to improve error handling while adding memory by allowing to use arch_remove_memory() and __remove_pages() even if CONFIG_MEMORY_HOTREMOVE is not set to e.g., implement something like: arch_add_memory() rc = do_something(); if (rc) { arch_remove_memory(); } We won't get rid of CONFIG_MEMORY_HOTREMOVE for now, as it will require quite some dependencies for memory offlining. Cc: Tony Luck Cc: Fenghua Yu Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: Michael Ellerman Cc: Martin Schwidefsky Cc: Heiko Carstens Cc: Yoshinori Sato Cc: Rich Felker Cc: Dave Hansen Cc: Andy Lutomirski Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: "H. Peter Anvin" Cc: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" Cc: Andrew Morton Cc: Michal Hocko Cc: Mike Rapoport Cc: David Hildenbrand Cc: Oscar Salvador Cc: "Kirill A. Shutemov" Cc: Alex Deucher Cc: "David S. Miller" Cc: Mark Brown Cc: Chris Wilson Cc: Christophe Leroy Cc: Nicholas Piggin Cc: Vasily Gorbik Cc: Rob Herring Cc: Masahiro Yamada Cc: "mike.travis@hpe.com" Cc: Andrew Banman Cc: Pavel Tatashin Cc: Wei Yang Cc: Arun KS Cc: Qian Cai Cc: Mathieu Malaterre Cc: Baoquan He Cc: Logan Gunthorpe Cc: Anshuman Khandual Signed-off-by: David Hildenbrand Reviewed-by: Pavel Tatashin --- arch/arm64/mm/mmu.c | 2 -- arch/ia64/mm/init.c | 2 -- arch/powerpc/mm/mem.c | 2 -- arch/s390/mm/init.c | 2 -- arch/sh/mm/init.c | 2 -- arch/x86/mm/init_32.c | 2 -- arch/x86/mm/init_64.c | 2 -- drivers/base/memory.c | 2 -- include/linux/memory.h | 2 -- include/linux/memory_hotplug.h | 2 -- mm/memory_hotplug.c | 2 -- mm/sparse.c | 6 ------ 12 files changed, 28 deletions(-) diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index e569a543c384..9ccd7539f2d4 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -1084,7 +1084,6 @@ int arch_add_memory(int nid, u64 start, u64 size, return __add_pages(nid, start >> PAGE_SHIFT, size >> PAGE_SHIFT, restrictions); } -#ifdef CONFIG_MEMORY_HOTREMOVE void arch_remove_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap) { @@ -1103,4 +1102,3 @@ void arch_remove_memory(int nid, u64 start, u64 size, __remove_pages(zone, start_pfn, nr_pages, altmap); } #endif -#endif diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c index d28e29103bdb..aae75fd7b810 100644 --- a/arch/ia64/mm/init.c +++ b/arch/ia64/mm/init.c @@ -681,7 +681,6 @@ int arch_add_memory(int nid, u64 start, u64 size, return ret; } -#ifdef CONFIG_MEMORY_HOTREMOVE void arch_remove_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap) { @@ -693,4 +692,3 @@ void arch_remove_memory(int nid, u64 start, u64 size, __remove_pages(zone, start_pfn, nr_pages, altmap); } #endif -#endif diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c index e885fe2aafcc..e4bc2dc3f593 100644 --- a/arch/powerpc/mm/mem.c +++ b/arch/powerpc/mm/mem.c @@ -130,7 +130,6 @@ int __ref arch_add_memory(int nid, u64 start, u64 size, return __add_pages(nid, start_pfn, nr_pages, restrictions); } -#ifdef CONFIG_MEMORY_HOTREMOVE void __ref arch_remove_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap) { @@ -164,7 +163,6 @@ void __ref arch_remove_memory(int nid, u64 start, u64 size, pr_warn("Hash collision while resizing HPT\n"); } #endif -#endif /* CONFIG_MEMORY_HOTPLUG */ #ifndef CONFIG_NEED_MULTIPLE_NODES void __init mem_topology_setup(void) diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c index 14955e0a9fcf..ffb81fe95c77 100644 --- a/arch/s390/mm/init.c +++ b/arch/s390/mm/init.c @@ -239,7 +239,6 @@ int arch_add_memory(int nid, u64 start, u64 size, return rc; } -#ifdef CONFIG_MEMORY_HOTREMOVE void arch_remove_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap) { @@ -251,5 +250,4 @@ void arch_remove_memory(int nid, u64 start, u64 size, __remove_pages(zone, start_pfn, nr_pages, altmap); vmem_remove_mapping(start, size); } -#endif #endif /* CONFIG_MEMORY_HOTPLUG */ diff --git a/arch/sh/mm/init.c b/arch/sh/mm/init.c index 13c6a6bb5fd9..dfdbaa50946e 100644 --- a/arch/sh/mm/init.c +++ b/arch/sh/mm/init.c @@ -429,7 +429,6 @@ int memory_add_physaddr_to_nid(u64 addr) EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid); #endif -#ifdef CONFIG_MEMORY_HOTREMOVE void arch_remove_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap) { @@ -440,5 +439,4 @@ void arch_remove_memory(int nid, u64 start, u64 size, zone = page_zone(pfn_to_page(start_pfn)); __remove_pages(zone, start_pfn, nr_pages, altmap); } -#endif #endif /* CONFIG_MEMORY_HOTPLUG */ diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c index f265a4316179..4068abb9427f 100644 --- a/arch/x86/mm/init_32.c +++ b/arch/x86/mm/init_32.c @@ -860,7 +860,6 @@ int arch_add_memory(int nid, u64 start, u64 size, return __add_pages(nid, start_pfn, nr_pages, restrictions); } -#ifdef CONFIG_MEMORY_HOTREMOVE void arch_remove_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap) { @@ -872,7 +871,6 @@ void arch_remove_memory(int nid, u64 start, u64 size, __remove_pages(zone, start_pfn, nr_pages, altmap); } #endif -#endif int kernel_set_to_readonly __read_mostly; diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c index 693aaf28d5fe..8335ac6e1112 100644 --- a/arch/x86/mm/init_64.c +++ b/arch/x86/mm/init_64.c @@ -1196,7 +1196,6 @@ void __ref vmemmap_free(unsigned long start, unsigned long end, remove_pagetable(start, end, false, altmap); } -#ifdef CONFIG_MEMORY_HOTREMOVE static void __meminit kernel_physical_mapping_remove(unsigned long start, unsigned long end) { @@ -1221,7 +1220,6 @@ void __ref arch_remove_memory(int nid, u64 start, u64 size, __remove_pages(zone, start_pfn, nr_pages, altmap); kernel_physical_mapping_remove(start, start + size); } -#endif #endif /* CONFIG_MEMORY_HOTPLUG */ static struct kcore_list kcore_vsyscall; diff --git a/drivers/base/memory.c b/drivers/base/memory.c index f914fa6fe350..ac17c95a5f28 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -727,7 +727,6 @@ int hotplug_memory_register(int nid, struct mem_section *section) return ret; } -#ifdef CONFIG_MEMORY_HOTREMOVE static void unregister_memory(struct memory_block *memory) { @@ -766,7 +765,6 @@ void unregister_memory_section(struct mem_section *section) out_unlock: mutex_unlock(&mem_sysfs_mutex); } -#endif /* CONFIG_MEMORY_HOTREMOVE */ /* return true if the memory block is offlined, otherwise, return false */ bool is_memblock_offlined(struct memory_block *mem) diff --git a/include/linux/memory.h b/include/linux/memory.h index e1dc1bb2b787..474c7c60c8f2 100644 --- a/include/linux/memory.h +++ b/include/linux/memory.h @@ -112,9 +112,7 @@ extern void unregister_memory_notifier(struct notifier_block *nb); extern int register_memory_isolate_notifier(struct notifier_block *nb); extern void unregister_memory_isolate_notifier(struct notifier_block *nb); int hotplug_memory_register(int nid, struct mem_section *section); -#ifdef CONFIG_MEMORY_HOTREMOVE extern void unregister_memory_section(struct mem_section *); -#endif extern int memory_dev_init(void); extern int memory_notify(unsigned long val, void *v); extern int memory_isolate_notify(unsigned long val, void *v); diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h index ae892eef8b82..2d4de313926d 100644 --- a/include/linux/memory_hotplug.h +++ b/include/linux/memory_hotplug.h @@ -123,12 +123,10 @@ static inline bool movable_node_is_enabled(void) return movable_node_enabled; } -#ifdef CONFIG_MEMORY_HOTREMOVE extern void arch_remove_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap); extern void __remove_pages(struct zone *zone, unsigned long start_pfn, unsigned long nr_pages, struct vmem_altmap *altmap); -#endif /* CONFIG_MEMORY_HOTREMOVE */ /* * Do we want sysfs memblock files created. This will allow userspace to online diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 762887b2358b..4b9d2974f86c 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -318,7 +318,6 @@ int __ref __add_pages(int nid, unsigned long phys_start_pfn, return err; } -#ifdef CONFIG_MEMORY_HOTREMOVE /* find the smallest valid pfn in the range [start_pfn, end_pfn) */ static unsigned long find_smallest_section_pfn(int nid, struct zone *zone, unsigned long start_pfn, @@ -582,7 +581,6 @@ void __remove_pages(struct zone *zone, unsigned long phys_start_pfn, set_zone_contiguous(zone); } -#endif /* CONFIG_MEMORY_HOTREMOVE */ int set_online_page_callback(online_page_callback_t callback) { diff --git a/mm/sparse.c b/mm/sparse.c index fd13166949b5..d1d5e05f5b8d 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -604,7 +604,6 @@ static void __kfree_section_memmap(struct page *memmap, vmemmap_free(start, end, altmap); } -#ifdef CONFIG_MEMORY_HOTREMOVE static void free_map_bootmem(struct page *memmap) { unsigned long start = (unsigned long)memmap; @@ -612,7 +611,6 @@ static void free_map_bootmem(struct page *memmap) vmemmap_free(start, end, NULL); } -#endif /* CONFIG_MEMORY_HOTREMOVE */ #else static struct page *__kmalloc_section_memmap(void) { @@ -651,7 +649,6 @@ static void __kfree_section_memmap(struct page *memmap, get_order(sizeof(struct page) * PAGES_PER_SECTION)); } -#ifdef CONFIG_MEMORY_HOTREMOVE static void free_map_bootmem(struct page *memmap) { unsigned long maps_section_nr, removing_section_nr, i; @@ -681,7 +678,6 @@ static void free_map_bootmem(struct page *memmap) put_page_bootmem(page); } } -#endif /* CONFIG_MEMORY_HOTREMOVE */ #endif /* CONFIG_SPARSEMEM_VMEMMAP */ /** @@ -746,7 +742,6 @@ int __meminit sparse_add_one_section(int nid, unsigned long start_pfn, return ret; } -#ifdef CONFIG_MEMORY_HOTREMOVE #ifdef CONFIG_MEMORY_FAILURE static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages) { @@ -823,5 +818,4 @@ void sparse_remove_one_section(struct zone *zone, struct mem_section *ms, PAGES_PER_SECTION - map_offset); free_section_usemap(memmap, usemap, altmap); } -#endif /* CONFIG_MEMORY_HOTREMOVE */ #endif /* CONFIG_MEMORY_HOTPLUG */ From patchwork Mon May 27 11:11:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 10962579 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 BBA21112C for ; Mon, 27 May 2019 11:12:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC9E828AD4 for ; Mon, 27 May 2019 11:12:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A0FDE28AD7; Mon, 27 May 2019 11:12:55 +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=unavailable 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 DD82628AD4 for ; Mon, 27 May 2019 11:12:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D292D6B027A; Mon, 27 May 2019 07:12:53 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D00666B027B; Mon, 27 May 2019 07:12:53 -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 C15C86B027C; Mon, 27 May 2019 07:12:53 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-oi1-f200.google.com (mail-oi1-f200.google.com [209.85.167.200]) by kanga.kvack.org (Postfix) with ESMTP id 985B16B027A for ; Mon, 27 May 2019 07:12:53 -0400 (EDT) Received: by mail-oi1-f200.google.com with SMTP id x7so3543470oic.16 for ; Mon, 27 May 2019 04:12:53 -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:mime-version :content-transfer-encoding; bh=+dZlDd1tAev3dLme2rjfCh5W1xubYN61UESP9inHmTk=; b=kghC06VAAGfDXOC7FQtwj/VM27cOI+5A2BJkB4kcbzPFvrBnPVloYC1mxVMMg6HgJ0 ilmxDxtG+7v2j+MXTpNP5OybpPnJjhtSiGQ6pF1Sgmkq4l7mFJA2WoBdLsNFWEzIeaJ0 Sxqtcq2/ykXU+3vrSO9VYuv7PTH+CLkzrlwAmQnbgFdBnE1nGDDEFl3h930oCMTjALzD 4DwgV0Z1EBnxsFNsAHu3u+Tea8grY7Ka5NlMgPJP0q9x8MbINPG7eunun67HK81D4LIv 7U8pjwN9d919CJaJkwZT9cvvYEKjjyRR920cxAOjlLkLhlhM4UOP2Zud9pD60kqbKByd WnvA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of david@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: APjAAAXzuDQvgo3PDyhXulE1ue4VjsNec3SoRTePtvs1nSjjx/Lh2v+F t4w7K8fgwpi/zXZlDifbwMXrVu4dADO7wBtIgzy8lk6THZf/KxmcIyZMJGZapJDw10/iTXneT8l EEBXnwHv+rZmsUXZDsXg7kEt9xBo0XWJTcL4nhcSGec029/d72NWR2mk4EtQXS3QFig== X-Received: by 2002:a9d:7cc3:: with SMTP id r3mr28319181otn.256.1558955573320; Mon, 27 May 2019 04:12:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqyx+YFyIJ6WSPKRdkF4xYWkAG4t+MguDeTDmIU6yWy/x3DWsWA7xR8xYm56wqdG6HpE0hyp X-Received: by 2002:a9d:7cc3:: with SMTP id r3mr28319114otn.256.1558955572081; Mon, 27 May 2019 04:12:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558955572; cv=none; d=google.com; s=arc-20160816; b=IHGY1ZbwbvDNeO3NH6innUiS8up7O2xQZYQjn8xD8Ph/oTBPNGrcc7EqsmkS/SzlAr DZcbbwlVVR40BkbCjtFd31KNbId/RVGWoAqtAPI5nb8X2mPh9C2oHFYl9F9ZLcN4EjpU NuHXhuZ47okBzsLsKfuHTqhN+av7uZs8QeYAkbUlP3pQJecHxb5V0QIt6ri5nZLgI0Rk zZeO+Fl2OLt+6rjLiLfn6sMw62UHQUUUNEl/7qaBlFDmxFcvt5brVFzguun6bYu9+j0i qmNxj92gkqGUAVPzHWEifCwpL7SwCLz6carDRNWFL26YNEp4p3prF2S+GHjuKgDPfZGS F2Vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=+dZlDd1tAev3dLme2rjfCh5W1xubYN61UESP9inHmTk=; b=IDP+AP3qUWpbNlI0lGvkVj0bHA6KOIGjD8MQr/55cU+urqrzH6fEfEN12yCXohuoYh u5vStwu8GCc1XLd+11B7m9HIa0Us95pugKB4PzkoYv2PrL5BtmP26D0od5A0BMMr3ttR 7zLQdb8M1UHpzF4b4f43MtDqGFd+khZ5OMDzEV0xQCB+OlAct+Vrpot+4OeH35B0GxnN kebbO7TED7TblrzbFmoVB6FwU/TqC8yO/tMzUA1l1W0VGVrRWGeTgi/wdmpvFjj4+eYV YSHSEUB9w/rpocAopP+FXQIKLIk9Tjzl7nVAoqZhZ90IGA/bEZulxvzeGKix4JbQ4CeN lxcw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of david@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=david@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 c127si5767572oib.127.2019.05.27.04.12.51 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 May 2019 04:12:52 -0700 (PDT) Received-SPF: pass (google.com: domain of david@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 david@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 48FDA3086214; Mon, 27 May 2019 11:12:51 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-89.ams2.redhat.com [10.36.117.89]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3CE8B19C7F; Mon, 27 May 2019 11:12:43 +0000 (UTC) From: David Hildenbrand To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, linux-ia64@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linux-arm-kernel@lists.infradead.org, akpm@linux-foundation.org, Dan Williams , Wei Yang , Igor Mammedov , David Hildenbrand , Greg Kroah-Hartman , "Rafael J. Wysocki" , "mike.travis@hpe.com" , Ingo Molnar , Andrew Banman , Oscar Salvador , Michal Hocko , Pavel Tatashin , Qian Cai , Arun KS , Mathieu Malaterre Subject: [PATCH v3 07/11] mm/memory_hotplug: Create memory block devices after arch_add_memory() Date: Mon, 27 May 2019 13:11:48 +0200 Message-Id: <20190527111152.16324-8-david@redhat.com> In-Reply-To: <20190527111152.16324-1-david@redhat.com> References: <20190527111152.16324-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Mon, 27 May 2019 11:12:51 +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 Only memory to be added to the buddy and to be onlined/offlined by user space using /sys/devices/system/memory/... needs (and should have!) memory block devices. Factor out creation of memory block devices. Create all devices after arch_add_memory() succeeded. We can later drop the want_memblock parameter, because it is now effectively stale. Only after memory block devices have been added, memory can be onlined by user space. This implies, that memory is not visible to user space at all before arch_add_memory() succeeded. While at it - use WARN_ON_ONCE instead of BUG_ON in moved unregister_memory() - introduce find_memory_block_by_id() to search via block id - Use find_memory_block_by_id() in init_memory_block() to catch duplicates Cc: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" Cc: David Hildenbrand Cc: "mike.travis@hpe.com" Cc: Andrew Morton Cc: Ingo Molnar Cc: Andrew Banman Cc: Oscar Salvador Cc: Michal Hocko Cc: Pavel Tatashin Cc: Qian Cai Cc: Wei Yang Cc: Arun KS Cc: Mathieu Malaterre Signed-off-by: David Hildenbrand Reviewed-by: Pavel Tatashin Acked-by: Michal Hocko --- drivers/base/memory.c | 82 +++++++++++++++++++++++++++--------------- include/linux/memory.h | 2 +- mm/memory_hotplug.c | 15 ++++---- 3 files changed, 63 insertions(+), 36 deletions(-) diff --git a/drivers/base/memory.c b/drivers/base/memory.c index ac17c95a5f28..5a0370f0c506 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -39,6 +39,11 @@ static inline int base_memory_block_id(int section_nr) return section_nr / sections_per_block; } +static inline int pfn_to_block_id(unsigned long pfn) +{ + return base_memory_block_id(pfn_to_section_nr(pfn)); +} + static int memory_subsys_online(struct device *dev); static int memory_subsys_offline(struct device *dev); @@ -582,10 +587,9 @@ int __weak arch_get_memory_phys_device(unsigned long start_pfn) * A reference for the returned object is held and the reference for the * hinted object is released. */ -struct memory_block *find_memory_block_hinted(struct mem_section *section, - struct memory_block *hint) +static struct memory_block *find_memory_block_by_id(int block_id, + struct memory_block *hint) { - int block_id = base_memory_block_id(__section_nr(section)); struct device *hintdev = hint ? &hint->dev : NULL; struct device *dev; @@ -597,6 +601,14 @@ struct memory_block *find_memory_block_hinted(struct mem_section *section, return to_memory_block(dev); } +struct memory_block *find_memory_block_hinted(struct mem_section *section, + struct memory_block *hint) +{ + int block_id = base_memory_block_id(__section_nr(section)); + + return find_memory_block_by_id(block_id, hint); +} + /* * For now, we have a linear search to go find the appropriate * memory_block corresponding to a particular phys_index. If @@ -658,6 +670,11 @@ static int init_memory_block(struct memory_block **memory, int block_id, unsigned long start_pfn; int ret = 0; + mem = find_memory_block_by_id(block_id, NULL); + if (mem) { + put_device(&mem->dev); + return -EEXIST; + } mem = kzalloc(sizeof(*mem), GFP_KERNEL); if (!mem) return -ENOMEM; @@ -699,44 +716,53 @@ static int add_memory_block(int base_section_nr) return 0; } +static void unregister_memory(struct memory_block *memory) +{ + if (WARN_ON_ONCE(memory->dev.bus != &memory_subsys)) + return; + + /* drop the ref. we got via find_memory_block() */ + put_device(&memory->dev); + device_unregister(&memory->dev); +} + /* - * need an interface for the VM to add new memory regions, - * but without onlining it. + * Create memory block devices for the given memory area. Start and size + * have to be aligned to memory block granularity. Memory block devices + * will be initialized as offline. */ -int hotplug_memory_register(int nid, struct mem_section *section) +int create_memory_block_devices(unsigned long start, unsigned long size) { - int block_id = base_memory_block_id(__section_nr(section)); - int ret = 0; + const int start_block_id = pfn_to_block_id(PFN_DOWN(start)); + int end_block_id = pfn_to_block_id(PFN_DOWN(start + size)); struct memory_block *mem; + unsigned long block_id; + int ret = 0; - mutex_lock(&mem_sysfs_mutex); + if (WARN_ON_ONCE(!IS_ALIGNED(start, memory_block_size_bytes()) || + !IS_ALIGNED(size, memory_block_size_bytes()))) + return -EINVAL; - mem = find_memory_block(section); - if (mem) { - mem->section_count++; - put_device(&mem->dev); - } else { + mutex_lock(&mem_sysfs_mutex); + for (block_id = start_block_id; block_id != end_block_id; block_id++) { ret = init_memory_block(&mem, block_id, MEM_OFFLINE); if (ret) - goto out; - mem->section_count++; + break; + mem->section_count = sections_per_block; + } + if (ret) { + end_block_id = block_id; + for (block_id = start_block_id; block_id != end_block_id; + block_id++) { + mem = find_memory_block_by_id(block_id, NULL); + mem->section_count = 0; + unregister_memory(mem); + } } - -out: mutex_unlock(&mem_sysfs_mutex); return ret; } -static void -unregister_memory(struct memory_block *memory) -{ - BUG_ON(memory->dev.bus != &memory_subsys); - - /* drop the ref. we got via find_memory_block() */ - put_device(&memory->dev); - device_unregister(&memory->dev); -} - void unregister_memory_section(struct mem_section *section) { struct memory_block *mem; diff --git a/include/linux/memory.h b/include/linux/memory.h index 474c7c60c8f2..db3e8567f900 100644 --- a/include/linux/memory.h +++ b/include/linux/memory.h @@ -111,7 +111,7 @@ extern int register_memory_notifier(struct notifier_block *nb); extern void unregister_memory_notifier(struct notifier_block *nb); extern int register_memory_isolate_notifier(struct notifier_block *nb); extern void unregister_memory_isolate_notifier(struct notifier_block *nb); -int hotplug_memory_register(int nid, struct mem_section *section); +int create_memory_block_devices(unsigned long start, unsigned long size); extern void unregister_memory_section(struct mem_section *); extern int memory_dev_init(void); extern int memory_notify(unsigned long val, void *v); diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 4b9d2974f86c..b1fde90bbf19 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -259,13 +259,7 @@ static int __meminit __add_section(int nid, unsigned long phys_start_pfn, return -EEXIST; ret = sparse_add_one_section(nid, phys_start_pfn, altmap); - if (ret < 0) - return ret; - - if (!want_memblock) - return 0; - - return hotplug_memory_register(nid, __pfn_to_section(phys_start_pfn)); + return ret < 0 ? ret : 0; } /* @@ -1107,6 +1101,13 @@ int __ref add_memory_resource(int nid, struct resource *res) if (ret < 0) goto error; + /* create memory block devices after memory was added */ + ret = create_memory_block_devices(start, size); + if (ret) { + arch_remove_memory(nid, start, size, NULL); + goto error; + } + if (new_node) { /* If sysfs file of new node can't be created, cpu on the node * can't be hot-added. There is no rollback way now. From patchwork Mon May 27 11:11:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 10962583 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 D578E933 for ; Mon, 27 May 2019 11:12:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C680C28AD4 for ; Mon, 27 May 2019 11:12:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BAD9228AD7; Mon, 27 May 2019 11:12:58 +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=unavailable 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 4AB5428AD4 for ; Mon, 27 May 2019 11:12:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 058236B027B; Mon, 27 May 2019 07:12:57 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 02E4A6B027C; Mon, 27 May 2019 07:12: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 E87C66B027D; Mon, 27 May 2019 07:12:56 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-oi1-f198.google.com (mail-oi1-f198.google.com [209.85.167.198]) by kanga.kvack.org (Postfix) with ESMTP id C12416B027B for ; Mon, 27 May 2019 07:12:56 -0400 (EDT) Received: by mail-oi1-f198.google.com with SMTP id r78so5294456oie.8 for ; Mon, 27 May 2019 04:12:56 -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:mime-version :content-transfer-encoding; bh=81dv9FTnNj/7LyZAowjAA1AFW7W3zsQkqaihczv2Mls=; b=NyDgsQfJOs/nunWdg/FgnpAl9yMjvQ7tsUqOIYFchgtJ+veJfl6DojOK6BWkaXaJMg vxodkWdqTJ2ezvQc5aKKJRtbM3i8+Pig/babnwAqjFQTGy8jfPGgpC/gs4nooy2C2VFb UT4WvovNZmlPSmaO24B2AaNlLNrqNIgWkJlRKA2CszW6PCB6bROLqixt+yNndyPNkVXz Cm9jKUqI5vCXJlyLc2ZOTGbeOIxbNcOc205UY6VLi55gmq2204sPD5FW039CzlKK3TQ/ FSl4y4DPfp9u5pdibKWxc0N0dAn33dt3d88hpXhzemmsWcTMuAzESmifWNrxNQwkGFVK uBGQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of david@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: APjAAAW4OEcYoxTlxpLPfRcDdUB6XfMVmBP3XLQjyGLo1NgqUTz5r/d8 feF9wzooCgQZ6OT+9bA7ZOLH098XydF9pWTFY1L34zQZ8M473dZ2HpGDirs4P4oP3lT/0YipWYL WT++31sQkWUzBWN6MR9KDyXjuGG+QTvt0LaxWcleXD1zAFJOHeH/R7+PMwAE7uKjQaA== X-Received: by 2002:a9d:6848:: with SMTP id c8mr13823597oto.200.1558955576492; Mon, 27 May 2019 04:12:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqzTSPBumoyEsoXtZziU5oHnr3auxY7q5CLU8DiZyFOGvhu4xqR3C5LpNCst69B3NM7PfgtT X-Received: by 2002:a9d:6848:: with SMTP id c8mr13823573oto.200.1558955575986; Mon, 27 May 2019 04:12:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558955575; cv=none; d=google.com; s=arc-20160816; b=ixV6IXkseNy3vf6b2A2sknRzRmp0GNA8rCErlvhGUN2p+GSxKoK3i6CHrxa+wAStK7 xG7N8cHB8m3EApuItXWafuB5zb3KMcgBPYk80WBu9hHC5nmL/8UJhXl6M5VWi+W//p/c cCfw2eOGVNzjmSXEPEUmJ7lmd8/nDYw0//SzfPW0vhwVkbhcKaFZ9Tg9dDnmiyLemitW G6/kXupfES51OPGNbg2CWN/oHBmpCiqNVbaoOubxCSZxP0V82YLtcT+4p/G8scNvBsBf Chy/HQwhX9ynmvY8RUVMADhRtg6dicYgOWYxYw53RqYt2t5rvv2CjzHFHPP09rcBlRGO m6yA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=81dv9FTnNj/7LyZAowjAA1AFW7W3zsQkqaihczv2Mls=; b=MGhk233lzyJeLOV6neZNGN0KWE+VODghNqEAJw4LBpbIO6qPQ0m3d/1XwB9DrS8mN2 jrXU8Ji9AmaMZaOl/UwPL3qclAg3SwW+1ZtmYQ6YXXhqdj+l3L7HZ97r+f5lDH5SZmEN nl+NWgT+yw6hNETpAEH6p+AdpzuqjVybmwJfZO5BYXpGZibxqYwvrtdZGplCXxOevovs 2wSeDjNh78tgtQtgWWMEFOgHsy7jjga1IAqRAdDs80NPDqolSHrqFuUsosGPL5jVFATb fbDHq8hxL4O080GW9JZMR2NC0aYu2Y7aQXxtor+bTBwuDwDTya/vRnUkqidz+kyFu+Ju 9PPA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of david@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=david@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 c3si5628089otm.117.2019.05.27.04.12.55 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 May 2019 04:12:55 -0700 (PDT) Received-SPF: pass (google.com: domain of david@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 david@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 19FE3307D855; Mon, 27 May 2019 11:12:55 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-89.ams2.redhat.com [10.36.117.89]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9F3D72AA82; Mon, 27 May 2019 11:12:51 +0000 (UTC) From: David Hildenbrand To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, linux-ia64@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linux-arm-kernel@lists.infradead.org, akpm@linux-foundation.org, Dan Williams , Wei Yang , Igor Mammedov , David Hildenbrand , Michal Hocko , Oscar Salvador , Pavel Tatashin , Joonsoo Kim , Qian Cai , Arun KS , Mathieu Malaterre Subject: [PATCH v3 08/11] mm/memory_hotplug: Drop MHP_MEMBLOCK_API Date: Mon, 27 May 2019 13:11:49 +0200 Message-Id: <20190527111152.16324-9-david@redhat.com> In-Reply-To: <20190527111152.16324-1-david@redhat.com> References: <20190527111152.16324-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Mon, 27 May 2019 11:12:55 +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 No longer needed, the callers of arch_add_memory() can handle this manually. Cc: Andrew Morton Cc: David Hildenbrand Cc: Michal Hocko Cc: Oscar Salvador Cc: Pavel Tatashin Cc: Wei Yang Cc: Joonsoo Kim Cc: Qian Cai Cc: Arun KS Cc: Mathieu Malaterre Signed-off-by: David Hildenbrand Reviewed-by: Wei Yang Acked-by: Michal Hocko --- include/linux/memory_hotplug.h | 8 -------- mm/memory_hotplug.c | 9 +++------ 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h index 2d4de313926d..2f1f87e13baa 100644 --- a/include/linux/memory_hotplug.h +++ b/include/linux/memory_hotplug.h @@ -128,14 +128,6 @@ extern void arch_remove_memory(int nid, u64 start, u64 size, extern void __remove_pages(struct zone *zone, unsigned long start_pfn, unsigned long nr_pages, struct vmem_altmap *altmap); -/* - * Do we want sysfs memblock files created. This will allow userspace to online - * and offline memory explicitly. Lack of this bit means that the caller has to - * call move_pfn_range_to_zone to finish the initialization. - */ - -#define MHP_MEMBLOCK_API (1<<0) - /* reasonably generic interface to expand the physical pages */ extern int __add_pages(int nid, unsigned long start_pfn, unsigned long nr_pages, struct mhp_restrictions *restrictions); diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index b1fde90bbf19..9a92549ef23b 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -251,7 +251,7 @@ void __init register_page_bootmem_info_node(struct pglist_data *pgdat) #endif /* CONFIG_HAVE_BOOTMEM_INFO_NODE */ static int __meminit __add_section(int nid, unsigned long phys_start_pfn, - struct vmem_altmap *altmap, bool want_memblock) + struct vmem_altmap *altmap) { int ret; @@ -294,8 +294,7 @@ int __ref __add_pages(int nid, unsigned long phys_start_pfn, } for (i = start_sec; i <= end_sec; i++) { - err = __add_section(nid, section_nr_to_pfn(i), altmap, - restrictions->flags & MHP_MEMBLOCK_API); + err = __add_section(nid, section_nr_to_pfn(i), altmap); /* * EEXIST is finally dealt with by ioresource collision @@ -1067,9 +1066,7 @@ static int online_memory_block(struct memory_block *mem, void *arg) */ int __ref add_memory_resource(int nid, struct resource *res) { - struct mhp_restrictions restrictions = { - .flags = MHP_MEMBLOCK_API, - }; + struct mhp_restrictions restrictions = {}; u64 start, size; bool new_node = false; int ret; From patchwork Mon May 27 11:11:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 10962589 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 C0A4F933 for ; Mon, 27 May 2019 11:13:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B14E428AD4 for ; Mon, 27 May 2019 11:13:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A573D28AD7; Mon, 27 May 2019 11:13:04 +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=unavailable 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 E276E28AD4 for ; Mon, 27 May 2019 11:13:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 734C96B027C; Mon, 27 May 2019 07:13:02 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 70D446B027D; Mon, 27 May 2019 07:13:02 -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 5FC9D6B027E; Mon, 27 May 2019 07:13:02 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-oi1-f199.google.com (mail-oi1-f199.google.com [209.85.167.199]) by kanga.kvack.org (Postfix) with ESMTP id 34BA46B027C for ; Mon, 27 May 2019 07:13:02 -0400 (EDT) Received: by mail-oi1-f199.google.com with SMTP id f30so5307125oij.3 for ; Mon, 27 May 2019 04:13:02 -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:mime-version :content-transfer-encoding; bh=e5EF8dpMsbDDNCAATVA9f1rm/c9fnhfqkSCcpFKc4do=; b=Y+gCV0klbNF/hB4Y6zbud5SBWTK4dY0w8HHaAYQ1F2yJWOtH+g0Oyq2IZwL4rXPMmD h8fbrE9jZTSkMEprIdsIpuvg/57C+9sD7z+UV3oJOi2u4d+lo7wO2dWU5Ap4gtH6zgNc kIJuPh+AYaL6H20S0nDpKwgqmACxeL+KbIYCAUj6NU9k19TNxh8cEqjijqsr9QuBILRX As7EbGGb5Y98nHFRolhOBlU1AcPNU9b6bx3OHEtCedhYPaaAfXK4wDXogfk6ndeQrfwF v5Lxqg4Um4oX86pAyZgklJVIItejGTGZm+KBuxUSMswDdIyj/n6rvTOp5Dt4N3GhyO7k rgag== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of david@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: APjAAAXZBPwsNNPsF7MQd1AbtZ97Ns2LS7LUJT3tk1UHIbavwxl2INGY ST4HD9DXRu+1yTNyVq4vk2FKkHG3ef3cLtECDkYCUe6xT024lEwoIoFtm7Fl6TWOaIIVLeWcflR jLY3ypbFE5GH5DrHlLJzyXbwkxZvXIgUxYF2QRBSO0Jowx7tpaiScXtWewhZJ0tW56A== X-Received: by 2002:a05:6830:153:: with SMTP id j19mr802375otp.368.1558955581881; Mon, 27 May 2019 04:13:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqzSvKPtq+ry79Po3MRGB/8D3rw83sZtqyMOMMnUQEnAZe5TGD1MJ5cnsR+s4cFK2A4UxubM X-Received: by 2002:a05:6830:153:: with SMTP id j19mr802347otp.368.1558955581247; Mon, 27 May 2019 04:13:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558955581; cv=none; d=google.com; s=arc-20160816; b=XDfJIn9fFAXxX5GkBWJTOVz+Xeb5150VNr1fyxrUby6b5gQZB7/L9v9Hwu7k9VkHcZ he5a0+YrD1TWuHoTVNbuw024z6ApJgL/TDCvNoyPBGTSHrt6pxt+DnKBRTwaDJ/dMOPm aq4Q/6njTMKWw0nSZnLuUUwXobJPthTqhWlEHD407qSeMXNRO7Yn37mhz6sZHpehQ3XB WgaQDPLTTcVHiC/Sx9jQwFduB+ok3em6f26biVIrjDf5UTEvfgV3lognzXszzo7LzoFq KPVER8/2V56y5jA3er+HmgjJVBeJ3pFLxeEICgZPWgmpwcZFrO451GxB91mniPcakUJC Hefw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=e5EF8dpMsbDDNCAATVA9f1rm/c9fnhfqkSCcpFKc4do=; b=eTZcjHW+JBCHnvaY0de5pOud0TnbxTco5ljQagblpEuWQaxl4/KRgcA0Z/1F7yZMQk J33CNnaDV8yG2OHztB5p/n4pnY1FIu5I5xdB1kjIbbvET8V/VQ3YEFxWqSorYGjTAFGo lzjLqMPO9R3CDQqdNDflDvaPseifT0wM3lofNtB1lpX4/PRY66HHWlaFxzNx1Ru6QfsL ztGR1cn43EbJJseIo0xDy/fJ45RNqTQ12+JHq6GNzNtZUAeCwaubvLNEVug5Y1TLKZUs UJeBE5bgSAENMD5d2MOKv4kG4MOnLy+Q3fWk/F3yyEEGZc8xc88njafScHHubJVQXUlC XkpQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of david@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=david@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 r5si6029933ota.107.2019.05.27.04.13.01 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 May 2019 04:13:01 -0700 (PDT) Received-SPF: pass (google.com: domain of david@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 david@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 61501C002966; Mon, 27 May 2019 11:13:00 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-89.ams2.redhat.com [10.36.117.89]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7440F19C7F; Mon, 27 May 2019 11:12:55 +0000 (UTC) From: David Hildenbrand To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, linux-ia64@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linux-arm-kernel@lists.infradead.org, akpm@linux-foundation.org, Dan Williams , Wei Yang , Igor Mammedov , David Hildenbrand , Greg Kroah-Hartman , "Rafael J. Wysocki" , "mike.travis@hpe.com" , Andrew Banman , Ingo Molnar , Alex Deucher , "David S. Miller" , Mark Brown , Chris Wilson , Oscar Salvador , Jonathan Cameron , Michal Hocko , Pavel Tatashin , Arun KS , Mathieu Malaterre Subject: [PATCH v3 09/11] mm/memory_hotplug: Remove memory block devices before arch_remove_memory() Date: Mon, 27 May 2019 13:11:50 +0200 Message-Id: <20190527111152.16324-10-david@redhat.com> In-Reply-To: <20190527111152.16324-1-david@redhat.com> References: <20190527111152.16324-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 27 May 2019 11:13:00 +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 Let's factor out removing of memory block devices, which is only necessary for memory added via add_memory() and friends that created memory block devices. Remove the devices before calling arch_remove_memory(). This finishes factoring out memory block device handling from arch_add_memory() and arch_remove_memory(). Cc: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" Cc: David Hildenbrand Cc: "mike.travis@hpe.com" Cc: Andrew Morton Cc: Andrew Banman Cc: Ingo Molnar Cc: Alex Deucher Cc: "David S. Miller" Cc: Mark Brown Cc: Chris Wilson Cc: Oscar Salvador Cc: Jonathan Cameron Cc: Michal Hocko Cc: Pavel Tatashin Cc: Arun KS Cc: Mathieu Malaterre Reviewed-by: Dan Williams Signed-off-by: David Hildenbrand Acked-by: Michal Hocko --- drivers/base/memory.c | 37 ++++++++++++++++++------------------- drivers/base/node.c | 11 ++++++----- include/linux/memory.h | 2 +- include/linux/node.h | 6 ++---- mm/memory_hotplug.c | 5 +++-- 5 files changed, 30 insertions(+), 31 deletions(-) diff --git a/drivers/base/memory.c b/drivers/base/memory.c index 5a0370f0c506..f28efb0bf5c7 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -763,32 +763,31 @@ int create_memory_block_devices(unsigned long start, unsigned long size) return ret; } -void unregister_memory_section(struct mem_section *section) +/* + * Remove memory block devices for the given memory area. Start and size + * have to be aligned to memory block granularity. Memory block devices + * have to be offline. + */ +void remove_memory_block_devices(unsigned long start, unsigned long size) { + const int start_block_id = pfn_to_block_id(PFN_DOWN(start)); + const int end_block_id = pfn_to_block_id(PFN_DOWN(start + size)); struct memory_block *mem; + int block_id; - if (WARN_ON_ONCE(!present_section(section))) + if (WARN_ON_ONCE(!IS_ALIGNED(start, memory_block_size_bytes()) || + !IS_ALIGNED(size, memory_block_size_bytes()))) return; mutex_lock(&mem_sysfs_mutex); - - /* - * Some users of the memory hotplug do not want/need memblock to - * track all sections. Skip over those. - */ - mem = find_memory_block(section); - if (!mem) - goto out_unlock; - - unregister_mem_sect_under_nodes(mem, __section_nr(section)); - - mem->section_count--; - if (mem->section_count == 0) + for (block_id = start_block_id; block_id != end_block_id; block_id++) { + mem = find_memory_block_by_id(block_id, NULL); + if (WARN_ON_ONCE(!mem)) + continue; + mem->section_count = 0; + unregister_memory_block_under_nodes(mem); unregister_memory(mem); - else - put_device(&mem->dev); - -out_unlock: + } mutex_unlock(&mem_sysfs_mutex); } diff --git a/drivers/base/node.c b/drivers/base/node.c index 8598fcbd2a17..04fdfa99b8bc 100644 --- a/drivers/base/node.c +++ b/drivers/base/node.c @@ -801,9 +801,10 @@ int register_mem_sect_under_node(struct memory_block *mem_blk, void *arg) return 0; } -/* unregister memory section under all nodes that it spans */ -int unregister_mem_sect_under_nodes(struct memory_block *mem_blk, - unsigned long phys_index) +/* + * Unregister memory block device under all nodes that it spans. + */ +int unregister_memory_block_under_nodes(struct memory_block *mem_blk) { NODEMASK_ALLOC(nodemask_t, unlinked_nodes, GFP_KERNEL); unsigned long pfn, sect_start_pfn, sect_end_pfn; @@ -816,8 +817,8 @@ int unregister_mem_sect_under_nodes(struct memory_block *mem_blk, return -ENOMEM; nodes_clear(*unlinked_nodes); - sect_start_pfn = section_nr_to_pfn(phys_index); - sect_end_pfn = sect_start_pfn + PAGES_PER_SECTION - 1; + sect_start_pfn = section_nr_to_pfn(mem_blk->start_section_nr); + sect_end_pfn = section_nr_to_pfn(mem_blk->end_section_nr); for (pfn = sect_start_pfn; pfn <= sect_end_pfn; pfn++) { int nid; diff --git a/include/linux/memory.h b/include/linux/memory.h index db3e8567f900..f26a5417ec5d 100644 --- a/include/linux/memory.h +++ b/include/linux/memory.h @@ -112,7 +112,7 @@ extern void unregister_memory_notifier(struct notifier_block *nb); extern int register_memory_isolate_notifier(struct notifier_block *nb); extern void unregister_memory_isolate_notifier(struct notifier_block *nb); int create_memory_block_devices(unsigned long start, unsigned long size); -extern void unregister_memory_section(struct mem_section *); +void remove_memory_block_devices(unsigned long start, unsigned long size); extern int memory_dev_init(void); extern int memory_notify(unsigned long val, void *v); extern int memory_isolate_notify(unsigned long val, void *v); diff --git a/include/linux/node.h b/include/linux/node.h index 1a557c589ecb..02a29e71b175 100644 --- a/include/linux/node.h +++ b/include/linux/node.h @@ -139,8 +139,7 @@ extern int register_cpu_under_node(unsigned int cpu, unsigned int nid); extern int unregister_cpu_under_node(unsigned int cpu, unsigned int nid); extern int register_mem_sect_under_node(struct memory_block *mem_blk, void *arg); -extern int unregister_mem_sect_under_nodes(struct memory_block *mem_blk, - unsigned long phys_index); +extern int unregister_memory_block_under_nodes(struct memory_block *mem_blk); extern int register_memory_node_under_compute_node(unsigned int mem_nid, unsigned int cpu_nid, @@ -176,8 +175,7 @@ static inline int register_mem_sect_under_node(struct memory_block *mem_blk, { return 0; } -static inline int unregister_mem_sect_under_nodes(struct memory_block *mem_blk, - unsigned long phys_index) +static inline int unregister_memory_block_under_nodes(struct memory_block *mem_blk) { return 0; } diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 9a92549ef23b..82136c5b4c5f 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -520,8 +520,6 @@ static void __remove_section(struct zone *zone, struct mem_section *ms, if (WARN_ON_ONCE(!valid_section(ms))) return; - unregister_memory_section(ms); - scn_nr = __section_nr(ms); start_pfn = section_nr_to_pfn((unsigned long)scn_nr); __remove_zone(zone, start_pfn); @@ -1845,6 +1843,9 @@ void __ref __remove_memory(int nid, u64 start, u64 size) memblock_free(start, size); memblock_remove(start, size); + /* remove memory block devices before removing memory */ + remove_memory_block_devices(start, size); + arch_remove_memory(nid, start, size, NULL); __release_memory_resource(start, size); From patchwork Mon May 27 11:11:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 10962591 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 72DDD112C for ; Mon, 27 May 2019 11:13:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 626DB28AD4 for ; Mon, 27 May 2019 11:13:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 565BF28AD7; Mon, 27 May 2019 11:13:08 +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 B751028AD4 for ; Mon, 27 May 2019 11:13:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 49E0A6B027F; Mon, 27 May 2019 07:13:06 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 474776B0280; Mon, 27 May 2019 07:13:06 -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 389EC6B0281; Mon, 27 May 2019 07:13:06 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ot1-f69.google.com (mail-ot1-f69.google.com [209.85.210.69]) by kanga.kvack.org (Postfix) with ESMTP id 1064F6B027F for ; Mon, 27 May 2019 07:13:06 -0400 (EDT) Received: by mail-ot1-f69.google.com with SMTP id g80so8650100otg.12 for ; Mon, 27 May 2019 04:13:06 -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:mime-version :content-transfer-encoding; bh=jwqamueXeySfeFxINzjppTw9mQ9ehliTYQXoU7pLAas=; b=G/fBbfbopM1Gor1W1sb1Ow59tgBcupaqQNpkxNMObH0R+A6AM89GqHuLfq7TLGAPQI OZQYhn3z58FpbREoRnNy4To+N/6/ZM4YvoCmdq44w6vLoyGERg9XAWBmBlW4vmfN2EXz RJBUUYifbBQD/cq772nEM0Y3tPy5QI6bEoK9Cfg3mC6rlABJHJQ9285vy/hutqj9cXFW S7BN1OrUDphkXcQANE/KCGadiZpfIdbutdBRUTiCqcMDr4txsZK/Y2hWbY7/NcVNBANI 6rbMbXwR4Tkor3ybej4xs5WPU/JMnUfL0GfQ5TQI+XYLKkUjaBYwA6oe080b70h4T68l ofng== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of david@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: APjAAAWY8ygfR0ODn5IEXszs1AsW9tm021a5ZIMpcNpcOT+7wSdfrplp F37ooJUIiQhUoy79t5jDZQlBk9xvyjZNfNsTUzhv4B5r4AaZ38JtOX20xe3GogtIpK+vx4A/5Vl pc11XWsnbn+nx7wdDGjwoGN5aWcQw3vtTWyKCH5D4nu0r7105/tNU4fFvdzq508CjfA== X-Received: by 2002:aca:48c2:: with SMTP id v185mr13977051oia.171.1558955585727; Mon, 27 May 2019 04:13:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqz7SZpMpzvAdNzb54JIBqXBtz9dM+G3sVterAaauUxaoq7dKSlMWkbQEg/C7xdUyfPrqHiV X-Received: by 2002:aca:48c2:: with SMTP id v185mr13977021oia.171.1558955585134; Mon, 27 May 2019 04:13:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558955585; cv=none; d=google.com; s=arc-20160816; b=LvAmQqrjO6um92HamE2Q8ayi9riAZZc/AYwuLSf8/xcZDc9kjPRk3oFGfI2V/uMDCB kRXIG2hom9MzmBRF4/mqXo+hI/Hx9fhvOI1G1LHNX89NmDQlc++F45HKqao1GKgLCQ5P iiyzJEld/kdPwbOCHNpVEtmeGNNElo5KRQwuH+SArnfFmXU1htTiHbXG6Coxn+hsuiY/ q5a//utdLrIiNRnFfM6dGFeeC8z1EB0ZqYlUx3IZrxx/sEoK4ZCbDgqsYigo7QTmxe10 AIdqJWGBc56Jo3b9M9epEIaifNcmZQzIyx/BPTk1HOeqlZpU8lqo6TCOt39tNl3ht/BB W2TA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=jwqamueXeySfeFxINzjppTw9mQ9ehliTYQXoU7pLAas=; b=LrJ2EvIohfyN6ame98kAHon5BvVa5geDsMIsvh9Gv4iF3+tErNYbpgEZ+Vsrxw+ATZ DmqO0gyQDozd7wyfcKuNUCHPtct2xpoPjV5QL46aPPdYFnbuodRhqkJy1fTpT3ebmy6h CpF7OnRaWXN3LCmEduGok9u6h+VhXUwsn7UCILkt50KztCgMcLelSTRRH7S9mB9Ovw1y kB6Bn5YqHTxQUU07IwJmsmPdddfsHmpjzAagk+9NrTGjBUUxWO24VqF0cebED4NPnGxE E/SZBAA2hdoaK0+4QXOkKqmhBbstfhhGSuGbRYd1OFbvtKEMjQXETCzyKPXzvoUMcu5k d+7w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of david@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=david@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 m88si5804831otc.103.2019.05.27.04.13.04 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 May 2019 04:13:05 -0700 (PDT) Received-SPF: pass (google.com: domain of david@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 david@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 551563082B5F; Mon, 27 May 2019 11:13:04 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-89.ams2.redhat.com [10.36.117.89]) by smtp.corp.redhat.com (Postfix) with ESMTP id B086919C7F; Mon, 27 May 2019 11:13:00 +0000 (UTC) From: David Hildenbrand To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, linux-ia64@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linux-arm-kernel@lists.infradead.org, akpm@linux-foundation.org, Dan Williams , Wei Yang , Igor Mammedov , David Hildenbrand , Greg Kroah-Hartman , "Rafael J. Wysocki" , Alex Deucher , "David S. Miller" , Mark Brown , Chris Wilson , Oscar Salvador , Jonathan Cameron Subject: [PATCH v3 10/11] mm/memory_hotplug: Make unregister_memory_block_under_nodes() never fail Date: Mon, 27 May 2019 13:11:51 +0200 Message-Id: <20190527111152.16324-11-david@redhat.com> In-Reply-To: <20190527111152.16324-1-david@redhat.com> References: <20190527111152.16324-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Mon, 27 May 2019 11:13:04 +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 We really don't want anything during memory hotunplug to fail. We always pass a valid memory block device, that check can go. Avoid allocating memory and eventually failing. As we are always called under lock, we can use a static piece of memory. This avoids having to put the structure onto the stack, having to guess about the stack size of callers. Patch inspired by a patch from Oscar Salvador. In the future, there might be no need to iterate over nodes at all. mem->nid should tell us exactly what to remove. Memory block devices with mixed nodes (added during boot) should properly fenced off and never removed. Cc: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" Cc: Alex Deucher Cc: "David S. Miller" Cc: Mark Brown Cc: Chris Wilson Cc: David Hildenbrand Cc: Oscar Salvador Cc: Andrew Morton Cc: Jonathan Cameron Signed-off-by: David Hildenbrand Reviewed-by: Wei Yang Reviewed-by: Oscar Salvador Acked-by: Michal Hocko --- drivers/base/node.c | 18 +++++------------- include/linux/node.h | 5 ++--- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/drivers/base/node.c b/drivers/base/node.c index 04fdfa99b8bc..9be88fd05147 100644 --- a/drivers/base/node.c +++ b/drivers/base/node.c @@ -803,20 +803,14 @@ int register_mem_sect_under_node(struct memory_block *mem_blk, void *arg) /* * Unregister memory block device under all nodes that it spans. + * Has to be called with mem_sysfs_mutex held (due to unlinked_nodes). */ -int unregister_memory_block_under_nodes(struct memory_block *mem_blk) +void unregister_memory_block_under_nodes(struct memory_block *mem_blk) { - NODEMASK_ALLOC(nodemask_t, unlinked_nodes, GFP_KERNEL); unsigned long pfn, sect_start_pfn, sect_end_pfn; + static nodemask_t unlinked_nodes; - if (!mem_blk) { - NODEMASK_FREE(unlinked_nodes); - return -EFAULT; - } - if (!unlinked_nodes) - return -ENOMEM; - nodes_clear(*unlinked_nodes); - + nodes_clear(unlinked_nodes); sect_start_pfn = section_nr_to_pfn(mem_blk->start_section_nr); sect_end_pfn = section_nr_to_pfn(mem_blk->end_section_nr); for (pfn = sect_start_pfn; pfn <= sect_end_pfn; pfn++) { @@ -827,15 +821,13 @@ int unregister_memory_block_under_nodes(struct memory_block *mem_blk) continue; if (!node_online(nid)) continue; - if (node_test_and_set(nid, *unlinked_nodes)) + if (node_test_and_set(nid, unlinked_nodes)) continue; sysfs_remove_link(&node_devices[nid]->dev.kobj, kobject_name(&mem_blk->dev.kobj)); sysfs_remove_link(&mem_blk->dev.kobj, kobject_name(&node_devices[nid]->dev.kobj)); } - NODEMASK_FREE(unlinked_nodes); - return 0; } int link_mem_sections(int nid, unsigned long start_pfn, unsigned long end_pfn) diff --git a/include/linux/node.h b/include/linux/node.h index 02a29e71b175..548c226966a2 100644 --- a/include/linux/node.h +++ b/include/linux/node.h @@ -139,7 +139,7 @@ extern int register_cpu_under_node(unsigned int cpu, unsigned int nid); extern int unregister_cpu_under_node(unsigned int cpu, unsigned int nid); extern int register_mem_sect_under_node(struct memory_block *mem_blk, void *arg); -extern int unregister_memory_block_under_nodes(struct memory_block *mem_blk); +extern void unregister_memory_block_under_nodes(struct memory_block *mem_blk); extern int register_memory_node_under_compute_node(unsigned int mem_nid, unsigned int cpu_nid, @@ -175,9 +175,8 @@ static inline int register_mem_sect_under_node(struct memory_block *mem_blk, { return 0; } -static inline int unregister_memory_block_under_nodes(struct memory_block *mem_blk) +static inline void unregister_memory_block_under_nodes(struct memory_block *mem_blk) { - return 0; } static inline void register_hugetlbfs_with_node(node_registration_func_t reg, From patchwork Mon May 27 11:11:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 10962595 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 D78DB933 for ; Mon, 27 May 2019 11:13:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C7CC928AD4 for ; Mon, 27 May 2019 11:13:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B95E528AD7; Mon, 27 May 2019 11:13:12 +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 41E7828AD4 for ; Mon, 27 May 2019 11:13:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E39636B0280; Mon, 27 May 2019 07:13:10 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DE9B46B0281; Mon, 27 May 2019 07:13:10 -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 CB15B6B0282; Mon, 27 May 2019 07:13:10 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ot1-f72.google.com (mail-ot1-f72.google.com [209.85.210.72]) by kanga.kvack.org (Postfix) with ESMTP id A3EB36B0280 for ; Mon, 27 May 2019 07:13:10 -0400 (EDT) Received: by mail-ot1-f72.google.com with SMTP id o16so2987556otp.17 for ; Mon, 27 May 2019 04:13:10 -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:mime-version :content-transfer-encoding; bh=FcpQtkM7mXzSuK2MeOX2MTV1RrfG5BMJDhikRUdEp1k=; b=P56zM598yJe6nCsTjetcudAJSY5P2aOTfs35St5UOBpef6jDKRpyQAJscS0cLgEEK3 o5C8hjQModPz64GFjUvaov66ivbc/Z5MPAqU6USfDjrtwJOid2oAaAo4VkP+pw+/bO0Q 98jFRTuJtsYqTvUllvBJZf/YAiaHDxAqNEZ92YhIXw38V7PRIKV5ZmeT+kLhmzze0LwW yAgXZqHzZBpJpxA+iCXIxVMdXTNlxZIr8RGDyemsMRFBHIqyL9l9rM9IHyck1YPcwZLm DhjvmKYGxbWgKTaMin/SkHcuC62hPMLLDNt5u3bqmPhiLtth3moQmwYKpIUuSG2aIL30 bXVg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of david@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: APjAAAWrShZWUhw33Mka7kKEvjOhAZNaojybRI/JvuhKT3uTjrRlNPF4 Qb2+3o10+7V3KeVlVkoS3zQCTSsaj+06jStjECuwUNH7wDrW4nduG+7aEKxTHdwJFdFeRA9jLTz B+Adi3WBL5ReruYW2+sG5przYhxBlh+IeFQ8wdl55IOLLjMP+tHG5XqG3KFjZ1x53bg== X-Received: by 2002:a9d:7457:: with SMTP id p23mr349883otk.5.1558955590398; Mon, 27 May 2019 04:13:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqyIppsBxQFyEzbURdUtPa8v9VxzKvhChV0/yEkxkeYaoJqjcNN8BQfrC1gasLvsle+PCUok X-Received: by 2002:a9d:7457:: with SMTP id p23mr349852otk.5.1558955589876; Mon, 27 May 2019 04:13:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558955589; cv=none; d=google.com; s=arc-20160816; b=ahd4NkVTYefSWQnR5yok43WixF5ZcAL9iKqHC09XbSXPsLof7XqXaerQrjPJNc57ub M/9N7PTx4t7ir+iDe6eYIEc42lJJ2T0Hw91giBZbf6nz71BrQajUfNLLF7mTM7MiSYGA 1j15SqoETFSfYq6EexzYP5BsjzMKA8dvK3AbT1UVCZosPr3FQnHwZhNqYexF+RQKBjug adOthz+luD6o5q/5Xfu27w1/yquuKRugFIUBEkdB0GeehJMTp/eM2Vt+72TxcrUFjcRc 5ZmaaXjztupnCiRGth5VQu/g/KihlkroLWR3sT7eabILbqntALrnRtE4wf93FL1cAnlP TrJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=FcpQtkM7mXzSuK2MeOX2MTV1RrfG5BMJDhikRUdEp1k=; b=uSP9L38Zfm1NdET8qx06nbnMyUAt4kbfm1xjVWFh7yeZXzKN37ruhbSLCam2Tdeva1 gemciI4HvME6XiCGeXQJNfiH71FP8DvpQQHVn3GEGVm0yC9coIIZZ2bjQKaajnw+yy3a pEdJsDRYcBB7BdhgtHRDsOwpdz/RwIGzebjyT+fvH4tesNjMve8PlD8/ozfbZd2ku3Z4 5qDBePBIzUAGRPHNmOgxZcsXf8DsFuEh0Gd4lVpJTdjmaD3gqFMFVMsxAVxHwxasMN/z NOHqX3ijl3qIwK015LPOtprVaRSFtTQAwbO9wR++j5RGBlYoxnfPNtpRGJTEABnPXfOB TZgw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of david@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=david@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 u51si5903612otb.63.2019.05.27.04.13.09 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 May 2019 04:13:09 -0700 (PDT) Received-SPF: pass (google.com: domain of david@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 david@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 32F0F30833BF; Mon, 27 May 2019 11:13:09 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-89.ams2.redhat.com [10.36.117.89]) by smtp.corp.redhat.com (Postfix) with ESMTP id A50CC19C7F; Mon, 27 May 2019 11:13:04 +0000 (UTC) From: David Hildenbrand To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, linux-ia64@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linux-arm-kernel@lists.infradead.org, akpm@linux-foundation.org, Dan Williams , Wei Yang , Igor Mammedov , David Hildenbrand Subject: [PATCH v3 11/11] mm/memory_hotplug: Remove "zone" parameter from sparse_remove_one_section Date: Mon, 27 May 2019 13:11:52 +0200 Message-Id: <20190527111152.16324-12-david@redhat.com> In-Reply-To: <20190527111152.16324-1-david@redhat.com> References: <20190527111152.16324-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Mon, 27 May 2019 11:13:09 +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 parameter is unused, so let's drop it. Memory removal paths should never care about zones. This is the job of memory offlining and will require more refactorings. Reviewed-by: Dan Williams Signed-off-by: David Hildenbrand Reviewed-by: Wei Yang Reviewed-by: Oscar Salvador Acked-by: Michal Hocko --- include/linux/memory_hotplug.h | 2 +- mm/memory_hotplug.c | 2 +- mm/sparse.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h index 2f1f87e13baa..1a4257c5f74c 100644 --- a/include/linux/memory_hotplug.h +++ b/include/linux/memory_hotplug.h @@ -346,7 +346,7 @@ extern void move_pfn_range_to_zone(struct zone *zone, unsigned long start_pfn, extern bool is_memblock_offlined(struct memory_block *mem); 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, +extern void sparse_remove_one_section(struct mem_section *ms, unsigned long map_offset, struct vmem_altmap *altmap); extern struct page *sparse_decode_mem_map(unsigned long coded_mem_map, unsigned long pnum); diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 82136c5b4c5f..e48ec7b9dee2 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -524,7 +524,7 @@ static void __remove_section(struct zone *zone, struct mem_section *ms, start_pfn = section_nr_to_pfn((unsigned long)scn_nr); __remove_zone(zone, start_pfn); - sparse_remove_one_section(zone, ms, map_offset, altmap); + sparse_remove_one_section(ms, map_offset, altmap); } /** diff --git a/mm/sparse.c b/mm/sparse.c index d1d5e05f5b8d..1552c855d62a 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -800,8 +800,8 @@ static void free_section_usemap(struct page *memmap, unsigned long *usemap, free_map_bootmem(memmap); } -void sparse_remove_one_section(struct zone *zone, struct mem_section *ms, - unsigned long map_offset, struct vmem_altmap *altmap) +void sparse_remove_one_section(struct mem_section *ms, unsigned long map_offset, + struct vmem_altmap *altmap) { struct page *memmap = NULL; unsigned long *usemap = NULL;