From patchwork Tue Apr 9 10:01: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: 10890847 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 637251390 for ; Tue, 9 Apr 2019 10:02:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4CEE628895 for ; Tue, 9 Apr 2019 10:02:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3F74B2889B; Tue, 9 Apr 2019 10:02: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 9CC2428899 for ; Tue, 9 Apr 2019 10:02:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 268B06B0007; Tue, 9 Apr 2019 06:02:06 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 211146B000D; Tue, 9 Apr 2019 06:02: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 091E56B0010; Tue, 9 Apr 2019 06:02:06 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by kanga.kvack.org (Postfix) with ESMTP id DCF976B0007 for ; Tue, 9 Apr 2019 06:02:05 -0400 (EDT) Received: by mail-qk1-f198.google.com with SMTP id s70so14081076qka.1 for ; Tue, 09 Apr 2019 03:02:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=74ERUBoHJPrSHJLqNHZrJXdfWEaat/pYAfyl8SvmS20=; b=KVHWxYIpUFEQYjqISyy6wdkYh8lALbYlghxhV6038VEzLKlB13HhD3NR+/0I3MmqS5 bXO5PPkQantmy/twkL2koRUu+kZ8RQbKET84+ealK3nImoEokXvvRsmP4AVdMfxPVdnl +HtMXq29dMDzuvgKCcjU9EqrSz68mPWZz4YktM8dUKS8h6f3X9utKCf3xbOhEDK3nRrN Xbry/crCSfKLymEmwRCnIo03cngaHSCsjRjblId5PbYXC7mYlhxGJvFfthZN7kmQuhmn uMJm9Q26rLDLKNu6858K/E+Y0dQ81583cEJKGiBQF779VnCQ7yXGoLsa9qDlqyMaLgwb VKBg== 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: APjAAAUaxTerhhyoTet1vzvmR5qnnPhERHxpJRSjqhYS8Lj7P7n3KM14 LdWJx1r984x6TzORjO0MimrJl3cMcd1GKZ1h/9UkqLf2wq6fzZ6bqnil7hy7OCGakGULF8acCJ4 tDa+3ILkv6TS/cYQwzW33o5ElWqacWnWLZ/tt73OtjV1NbGXJFmHImGcvIJOszl2rgA== X-Received: by 2002:a37:7381:: with SMTP id o123mr26048453qkc.96.1554804125658; Tue, 09 Apr 2019 03:02:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqxSgt8T2z3qmK8qXWjxc0JSp4NEOKNJdynYL1jO/FfzAz/J4/+6nAt5ZZoibivFe4C/TaHy X-Received: by 2002:a37:7381:: with SMTP id o123mr26048374qkc.96.1554804124488; Tue, 09 Apr 2019 03:02:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554804124; cv=none; d=google.com; s=arc-20160816; b=eHo3eWOawb0lp/mcyGw+apcGp9FWBfkqcvO9/ertx1Qokb/ea46t+V4b6Hf7ATB4Nt HCTxWcdLGy6Dxc8txPJfD751i+dsz7bRsOGuubBa002Adeitm7ll5ZKXwFYGaqLSBpad igsc4ucvYbQ6wMXC0On3hQJRNhzrda6U54m6dppoANNBLKkG3Rd2o+n2vzxEPNPhKJFC mJH6JUoZLzkR1z/oBBS4m/sEfDQzxpn7UMmR0cQz9hqleSTRKE32B7Xzo8u4Wso4ytOE qZUW6yuGjF9uj7np/7kCxiX3vemKW8JdN6iceaoT+aMZCMd+8+a40e6eTrG0IdhpdOT7 X5TQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=74ERUBoHJPrSHJLqNHZrJXdfWEaat/pYAfyl8SvmS20=; b=Bokh8C8/8svrmhp/2bnbJrrpvZ+s3phZmYNoTaz6yPlbpv/ixMa4idSnXmAoMofwAq yTTuZkeOOXKjcjyPgwBMTsIEswy5s3BkNCSsqbnBZ6Q4zk8k3zUBSe30GEvHjXXHIc/r HmmoaLKm4zO+Mu7oGP+lHs6Gwsh4FQ8o74KT3S8cI3Vvhkx4YsweSeCr9QuRBCnXljC2 uXw3yI9JxpbIHJO72qjX/BsURrD1zQvnfpfKEuaoOeHvpA0GLQoHcr2CpTeauIUELkB8 /NrepMlNcPenbF2ZE+XdLBvn0kFjNcmB1qx+KjWU9zUEQ1xeIpQAA7+yGl2rWSmbTOia pneg== 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 u17si624711qka.140.2019.04.09.03.02.04 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Apr 2019 03:02:04 -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-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 98722307D860; Tue, 9 Apr 2019 10:02:03 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-49.ams2.redhat.com [10.36.117.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5767F5D721; Tue, 9 Apr 2019 10:02:00 +0000 (UTC) From: David Hildenbrand To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, David Hildenbrand , Andrew Morton , Oscar Salvador , Michal Hocko , Pavel Tatashin , Wei Yang , Qian Cai , Arun KS , Mathieu Malaterre Subject: [PATCH v1 1/4] mm/memory_hotplug: Release memory resource after arch_remove_memory() Date: Tue, 9 Apr 2019 12:01:45 +0200 Message-Id: <20190409100148.24703-2-david@redhat.com> In-Reply-To: <20190409100148.24703-1-david@redhat.com> References: <20190409100148.24703-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Tue, 09 Apr 2019 10:02:03 +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 __add_pages() doesn't add the memory resource, so __remove_pages() shouldn't remove it. Let's factor it out. Especially as it is a special case for memory used as system memory, added via add_memory() and friends. We now remove the resource after removing the sections instead of doing it the other way around. I don't think this change is problematic. add_memory() register memory resource arch_add_memory() remove_memory arch_remove_memory() release memory resource While at it, explain why we ignore errors and that it only happeny if we remove memory in a different granularity as we added it. Cc: Andrew Morton Cc: Oscar Salvador Cc: Michal Hocko Cc: David Hildenbrand Cc: Pavel Tatashin Cc: Wei Yang Cc: Qian Cai Cc: Arun KS Cc: Mathieu Malaterre Signed-off-by: David Hildenbrand Reviewed-by: Oscar Salvador --- mm/memory_hotplug.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 4970ff658055..696ed7ee5e28 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -562,20 +562,6 @@ int __remove_pages(struct zone *zone, unsigned long phys_start_pfn, if (is_dev_zone(zone)) { if (altmap) map_offset = vmem_altmap_offset(altmap); - } else { - resource_size_t start, size; - - start = phys_start_pfn << PAGE_SHIFT; - size = nr_pages * PAGE_SIZE; - - ret = release_mem_region_adjustable(&iomem_resource, start, - size); - if (ret) { - resource_size_t endres = start + size - 1; - - pr_warn("Unable to release resource <%pa-%pa> (%d)\n", - &start, &endres, ret); - } } clear_zone_contiguous(zone); @@ -1820,6 +1806,25 @@ void try_offline_node(int nid) } EXPORT_SYMBOL(try_offline_node); +static void __release_memory_resource(u64 start, u64 size) +{ + int ret; + + /* + * When removing memory in the same granularity as it was added, + * this function never fails. It might only fail if resources + * have to be adjusted or split. We'll ignore the error, as + * removing of memory cannot fail. + */ + ret = release_mem_region_adjustable(&iomem_resource, start, size); + if (ret) { + resource_size_t endres = start + size - 1; + + pr_warn("Unable to release resource <%pa-%pa> (%d)\n", + &start, &endres, ret); + } +} + /** * remove_memory * @nid: the node ID @@ -1854,6 +1859,7 @@ void __ref __remove_memory(int nid, u64 start, u64 size) memblock_remove(start, size); arch_remove_memory(nid, start, size, NULL); + __release_memory_resource(start, size); try_offline_node(nid); From patchwork Tue Apr 9 10:01: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: 10890851 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 30BDA1669 for ; Tue, 9 Apr 2019 10:02:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1CD2A28895 for ; Tue, 9 Apr 2019 10:02:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 10F302889B; Tue, 9 Apr 2019 10:02:20 +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 833F728895 for ; Tue, 9 Apr 2019 10:02:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 12DF16B000D; Tue, 9 Apr 2019 06:02:10 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 0DE416B0010; Tue, 9 Apr 2019 06:02: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 F12966B0266; Tue, 9 Apr 2019 06:02:09 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by kanga.kvack.org (Postfix) with ESMTP id D28176B000D for ; Tue, 9 Apr 2019 06:02:09 -0400 (EDT) Received: by mail-qt1-f197.google.com with SMTP id q12so15398065qtr.3 for ; Tue, 09 Apr 2019 03:02:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=WZXpfD7EsjnN1SQ5fEAHTKPSxNkAK91+tRvlhxLuxp4=; b=OrLO0RD7lP38aBYK0L7e11lbFguMw+tkE4dYKKTnM1Fn/IZWZ7jmTmUjNHtIssW77g GT0MLTMCtbtHKu9XzDKC0zydM4J33YpAR1g120LmXQKIt7hwFfxeIvNvxYE2JjYolw+g e1mKR/SP8WH+2nFTt8OEk4qlQwvpUvWtIHONNJwewF92p4uWuXJDD5tmuVfzzXgH/LU0 K3uRLYOqYjLrJgQyZYrPU8Vw1FRJ0fBDcvUrRq43XZGSPx53kGzwwR4fNJqgGKMryM+8 HWikoNmJslfbvJrSc1i6uHVt10pVJIgzqK4IbOSQPnSwg7fIqIRUSrzTNMIVVS2b23Qg llxw== 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: APjAAAWWq30reG8OZIeGfbCahg5V6rDnTp0o+7nG6DCNmDrBCzBtDayX 8eYWnk19g0b/Xl4Qy5OT+AGeuDIE4APh9B7oQZ88T3/09pMzKAnth2lvV/TwhKmSaJzgf+2mXBz H6YVyplZwLE99aMjHW1Qxe25sJVAEo7pEfXd0Bhfu4tx+zT8/X8URhuq4l7Nd8qIhyg== X-Received: by 2002:ac8:33dd:: with SMTP id d29mr28897957qtb.320.1554804129343; Tue, 09 Apr 2019 03:02:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqySvfIWMatmY9RsXJHCKM4kKpRTAgWF3ZPgkD+opWIVZj+zeDilJGnTP+btgh+JuTlEjBbF X-Received: by 2002:ac8:33dd:: with SMTP id d29mr28897841qtb.320.1554804127943; Tue, 09 Apr 2019 03:02:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554804127; cv=none; d=google.com; s=arc-20160816; b=sNT2mYZ+V1WhsOXwjDKAdmozSF1SWre8g31QqXADzfNO9XVPTz59zbmchel2wRKBi1 mlgZQ82eodCnF4xrYv9X/jJr1JVNqNngsNmYXqR/UKQ0JiKAUHPh+ZZ7z7tS+n0BOv8I /RpvrOzPo7vR+/ipzsSii1sLNrPqlWN7U2KBXED8+HC0/EwJfps3W0XTXj70n6CMRE5N qEXqq8EqCtzvs6zJDbLJGfioK2DR/XgngSzWUN3ZwgAtILRkbTIs/S+fXTDiEJy29ijA Lg+hIIc3lutQ1VZ+uLzIE8fdlMEqypkFTCvA9Fbw47qugvw7vnDjAmv3XgGgPrMUuQ7I 8OCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=WZXpfD7EsjnN1SQ5fEAHTKPSxNkAK91+tRvlhxLuxp4=; b=y5BsLKuA3H40Ggr7qzXboQWDUzFJhOEfFFOcxcXAe46k5RbvcOBYh3RV9AEkGzRrja DXDk+09iLEc5RFYfH4uE5GCj8hgnBTYarggf/f6QnSHacYlzGMB1kLTypWvXpNlK6QV5 aG3l2fo/GoRkcsUG9eTWgvaV95hgZLSyXLZKKqo4OO1wZFPZoD0JLAZNdRnK7B8voYV9 f4YaUvTfIMIT70htBWlyxd+8Rdo2d3CHY5P+fcc7fxBsscFHia2WRYwrz3efTn6GL5lh 75GQ/GnKgxgFr6eZpeQtf6akZRj1KlE7REylvzgC2SffYFGoULF4vGYA0NrPBVHnZrGK 5iUQ== 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 i16si1401059qkk.141.2019.04.09.03.02.07 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Apr 2019 03:02:07 -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-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E0441308794C; Tue, 9 Apr 2019 10:02:06 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-49.ams2.redhat.com [10.36.117.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id ED59E5D71E; Tue, 9 Apr 2019 10:02:03 +0000 (UTC) From: David Hildenbrand To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, David Hildenbrand , Greg Kroah-Hartman , "Rafael J. Wysocki" , Ingo Molnar , Andrew Banman , "mike.travis@hpe.com" , Andrew Morton , Oscar Salvador , Michal Hocko , Pavel Tatashin , Qian Cai , Wei Yang , Arun KS , Mathieu Malaterre Subject: [PATCH v1 2/4] mm/memory_hotplug: Make unregister_memory_section() never fail Date: Tue, 9 Apr 2019 12:01:46 +0200 Message-Id: <20190409100148.24703-3-david@redhat.com> In-Reply-To: <20190409100148.24703-1-david@redhat.com> References: <20190409100148.24703-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Tue, 09 Apr 2019 10:02:07 +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 Failing while removing memory is mostly ignored and cannot really be handled. Let's treat errors in unregister_memory_section() in a nice way, warning, but continuing. Cc: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" Cc: Ingo Molnar Cc: Andrew Banman Cc: "mike.travis@hpe.com" Cc: David Hildenbrand Cc: Andrew Morton 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 Signed-off-by: Oscar Salvador --- drivers/base/memory.c | 16 +++++----------- include/linux/memory.h | 2 +- mm/memory_hotplug.c | 4 +--- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/drivers/base/memory.c b/drivers/base/memory.c index 0c9e22ffa47a..f180427e48f4 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -734,15 +734,18 @@ unregister_memory(struct memory_block *memory) { BUG_ON(memory->dev.bus != &memory_subsys); - /* drop the ref. we got in remove_memory_section() */ + /* drop the ref. we got via find_memory_block() */ put_device(&memory->dev); device_unregister(&memory->dev); } -static int remove_memory_section(struct mem_section *section) +void unregister_memory_section(struct mem_section *section) { struct memory_block *mem; + if (WARN_ON_ONCE(!present_section(section))) + return; + mutex_lock(&mem_sysfs_mutex); /* @@ -763,15 +766,6 @@ static int remove_memory_section(struct mem_section *section) out_unlock: mutex_unlock(&mem_sysfs_mutex); - return 0; -} - -int unregister_memory_section(struct mem_section *section) -{ - if (!present_section(section)) - return -EINVAL; - - return remove_memory_section(section); } #endif /* CONFIG_MEMORY_HOTREMOVE */ diff --git a/include/linux/memory.h b/include/linux/memory.h index a6ddefc60517..e1dc1bb2b787 100644 --- a/include/linux/memory.h +++ b/include/linux/memory.h @@ -113,7 +113,7 @@ 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 int unregister_memory_section(struct mem_section *); +extern void unregister_memory_section(struct mem_section *); #endif 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 696ed7ee5e28..b0cb05748f99 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -527,9 +527,7 @@ static int __remove_section(struct zone *zone, struct mem_section *ms, if (!valid_section(ms)) return ret; - ret = unregister_memory_section(ms); - if (ret) - return ret; + unregister_memory_section(ms); scn_nr = __section_nr(ms); start_pfn = section_nr_to_pfn((unsigned long)scn_nr); From patchwork Tue Apr 9 10:01: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: 10890849 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 289F61669 for ; Tue, 9 Apr 2019 10:02:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1503128899 for ; Tue, 9 Apr 2019 10:02:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 06A61288A0; Tue, 9 Apr 2019 10:02:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-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 601EC28899 for ; Tue, 9 Apr 2019 10:02:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4635F6B0010; Tue, 9 Apr 2019 06:02:15 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 412E66B0266; Tue, 9 Apr 2019 06:02: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 32A986B0269; Tue, 9 Apr 2019 06:02:15 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by kanga.kvack.org (Postfix) with ESMTP id 1565C6B0010 for ; Tue, 9 Apr 2019 06:02:15 -0400 (EDT) Received: by mail-qk1-f197.google.com with SMTP id 77so14095804qkd.9 for ; Tue, 09 Apr 2019 03:02: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; bh=bupoFsCuB4wIEE6yTajOpUXs8f4zPHEQe9ygmCk08zM=; b=Pvmre8Q5ZU/v9xeu5c9oBqhVst3canonx8Fj+DgBe2ia2KP3y9quwBLzyr8N9txmjI rcFu61QbJBm52ujfCg16VSctQm4adMOTuIgrorIgQh2STxO2wOvikn5qD7RxrXvO1LKw yS+fo0vCuRCiuMVAQMTpsXKUhkjyNQIIBqxpa42gne/jjX5Cr1eBtJVraG99VuYW3ave IUkaTnEvq1qClcIxb1dzrymxrEkobil1zRN/Y/jK38TBT2si2ZMKRndJjzu4KrCjF5RT U3NZEW8Z6eY+OLQmFh8t9uhlMEqsLUvvAyd7Pj7Od0pm+gG/N+oqdavxSL96ttcQQ4Dd Xm3A== 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: APjAAAVjtQxb27VSOSgPLOaaAR/0tTA8e0YFB7BFj+K5JJSJE+1N59xi 1sCU7g/x8GI87Ed2cUCVnpKjK1kCdCqgdSu7CFuKBYIji/V0/Ldcn262Z+wTHgDzuZhqA8ZCl53 ra6SnAEhcPowiz6PQJqPqJ/qTSrrub+YXZu3EVKSSVfZ+ry7s7ySqiWO9uYLo5cfXhg== X-Received: by 2002:a05:620a:138a:: with SMTP id k10mr28236813qki.188.1554804134814; Tue, 09 Apr 2019 03:02:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqxR1AnCIFKshCN+G3YM0Yw6TgWh3IM5LEllVHRe9+C8RTRvorEmFA/9/IbdAjy7bseoFMCi X-Received: by 2002:a05:620a:138a:: with SMTP id k10mr28236725qki.188.1554804133860; Tue, 09 Apr 2019 03:02:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554804133; cv=none; d=google.com; s=arc-20160816; b=dE/zxZ5BWk1ZOjcPXe8fBpg3HibHpchG04usrUO3kmZ3fNGX6nS1DjOY53QmwzgElm DmEJJUpaTjeLqinDBQvrRxlQ86Fh7M8UvmESty44JLXRGXUYRith01m0fHN/ae3/nI9g CkBiWfFQb0d6ZHWcTwQCKhH/YfgIEAvYuIpRnz8Q7R6YxRwoL4XfsbeUZtlaNQsFJJ1p TAFoWXtTpYXIm7PnLwAnJJESAWBYrPn/Rafq14SoLAjWxDn3bVY99mOzT3GklINOyRj2 uutqHkULtrBoDGGPVjbatCagG60Bx9hq71d3HCuaHLuKwW+LQYOZnBGsWA0gyqAZC1Dd A7CA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=bupoFsCuB4wIEE6yTajOpUXs8f4zPHEQe9ygmCk08zM=; b=xlAdjtbz4fxmvTjmHy9xaAI+2FCrxoJk5IH0DjwpIAPCjN2e5SZ/okpBCMs9PcPzAv pr0ALqbVHiR919Oj/VuKYU4+St72uDV8Nq3Z0gu3uveUEH2hi0nl0bmgjOajnxvbqtIt +AixRKx14xtp1s9g54ZzQbBV+Qk6RyfRciXIYkMhcyVwR74mzf3zUrzAXCohIpEEfrGw vV2lAsWn9VL+kgoHOiRmRoBlMYOQ5GSEkfadOOsR2Vn0kYJU4iA5zMP9twRAIwx9wreH 7MsrOgM6iR9cZMBwfayF8Ae//hytlUV3mMZRCxU0RdgnnDNwkvGoczl4Jr/1oGqUtja4 oZ3A== 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 t42si3551189qvc.92.2019.04.09.03.02.13 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Apr 2019 03:02:13 -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-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 16EEC3001A68; Tue, 9 Apr 2019 10:02:13 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-49.ams2.redhat.com [10.36.117.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id 37FE75D71F; Tue, 9 Apr 2019 10:02:07 +0000 (UTC) From: David Hildenbrand To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, David Hildenbrand , Andrew Morton , Oscar Salvador , Michal Hocko , Pavel Tatashin , Qian Cai , Wei Yang , Arun KS , Mathieu Malaterre Subject: [PATCH v1 3/4] mm/memory_hotplug: Make __remove_section() never fail Date: Tue, 9 Apr 2019 12:01:47 +0200 Message-Id: <20190409100148.24703-4-david@redhat.com> In-Reply-To: <20190409100148.24703-1-david@redhat.com> References: <20190409100148.24703-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Tue, 09 Apr 2019 10:02:13 +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 just warn in case a section is not valid instead of failing to remove somewhere in the middle of the process, returning an error that will be mostly ignored by callers. 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 Signed-off-by: David Hildenbrand Reviewed-by: Oscar Salvador --- mm/memory_hotplug.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index b0cb05748f99..17a60281c36f 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -517,15 +517,15 @@ static void __remove_zone(struct zone *zone, unsigned long start_pfn) pgdat_resize_unlock(zone->zone_pgdat, &flags); } -static int __remove_section(struct zone *zone, struct mem_section *ms, - unsigned long map_offset, struct vmem_altmap *altmap) +static void __remove_section(struct zone *zone, struct mem_section *ms, + unsigned long map_offset, + struct vmem_altmap *altmap) { unsigned long start_pfn; int scn_nr; - int ret = -EINVAL; - if (!valid_section(ms)) - return ret; + if (WARN_ON_ONCE(!valid_section(ms))) + return; unregister_memory_section(ms); @@ -534,7 +534,6 @@ static int __remove_section(struct zone *zone, struct mem_section *ms, __remove_zone(zone, start_pfn); sparse_remove_one_section(zone, ms, map_offset, altmap); - return 0; } /** @@ -554,7 +553,7 @@ int __remove_pages(struct zone *zone, unsigned long phys_start_pfn, { unsigned long i; unsigned long map_offset = 0; - int sections_to_remove, ret = 0; + int sections_to_remove; /* In the ZONE_DEVICE case device driver owns the memory region */ if (is_dev_zone(zone)) { @@ -575,16 +574,13 @@ int __remove_pages(struct zone *zone, unsigned long phys_start_pfn, unsigned long pfn = phys_start_pfn + i*PAGES_PER_SECTION; cond_resched(); - ret = __remove_section(zone, __pfn_to_section(pfn), map_offset, - altmap); + __remove_section(zone, __pfn_to_section(pfn), map_offset, + altmap); map_offset = 0; - if (ret) - break; } set_zone_contiguous(zone); - - return ret; + return 0; } #endif /* CONFIG_MEMORY_HOTREMOVE */ From patchwork Tue Apr 9 10:01: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: 10890853 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 C0F951390 for ; Tue, 9 Apr 2019 10:02:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A67CA28895 for ; Tue, 9 Apr 2019 10:02:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 99A672889B; Tue, 9 Apr 2019 10:02:27 +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 2A85B28895 for ; Tue, 9 Apr 2019 10:02:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1CA316B0266; Tue, 9 Apr 2019 06:02:25 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 17B976B0269; Tue, 9 Apr 2019 06:02: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 0418F6B026A; Tue, 9 Apr 2019 06:02:24 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by kanga.kvack.org (Postfix) with ESMTP id D5AFD6B0266 for ; Tue, 9 Apr 2019 06:02:24 -0400 (EDT) Received: by mail-qt1-f199.google.com with SMTP id q12so15398762qtr.3 for ; Tue, 09 Apr 2019 03:02: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; bh=a/tN9TnrR5De10wKWpMYgYMrOCjvKExDFMseAllPzSw=; b=dj4NCnAaS8sAGEg7QNHE1nK69DwV2W/0AnoEgCkygY1HBYC/zgxw2Nl+ANreK59Zqx vP40xcZ4qqd8tFth1Xidmc1KktKsyVtN1BpRpZTHUpUXKjMPSOzAGCy5IrKgFoOqpz5Q zat2YG/a4qyqTgwwq0YN2Z8sBxWuylfRKk/M674LwLVuuqLys6Q3cJWT8go6Sp0qXL8o ijZjKChTW0vsYnKwLLmIiWXJlWDJrvOceGxDiELKmUYvLmhbuW+aSC9tFIiZAoHprRUr 2//0UOkAShOi59qiUE+r4YTkakXLvl51N3YNLJOjO0TinOYJSj65AjN0eUPgx9xyl0rH oofA== 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: APjAAAVezPPPGDekW3SbtUrSoDyS7/Sd4UGa9poS7dw6Zzl6OBRuGYGh 3aHksLxGHuQfQKMuxNIuVtI6Mc9Ks6Y1gBQS9mrAGfD4UvtGWcK5OgJYUA0nAYD7SYWCCUFKBXu Jip+xGXhO4g+DKaIk/qZNFAkrAEXK+MchA+gvOMRL2jVWFYsFOVeIdfFTpJetB50t2g== X-Received: by 2002:ac8:234e:: with SMTP id b14mr28798435qtb.271.1554804144531; Tue, 09 Apr 2019 03:02:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqx59LuZ7N9Z+idFgzqQ2ovzmTPlYBWltNpww9VgNWFhcaOWe/MP1hCr/b83GIweD9H0b9xj X-Received: by 2002:ac8:234e:: with SMTP id b14mr28798324qtb.271.1554804143205; Tue, 09 Apr 2019 03:02:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554804143; cv=none; d=google.com; s=arc-20160816; b=m1D+uQ3AxT6QvA6TIBH1oDGWYWofmf/F04RA6hIYALB6DJcJIQMbRNQJpy/F9F1mMQ TX0c5ZEtMcLT5v0BOXXoKO/+ajA8zBBhCQIbAajojl2XkxaXlh9ZZBrLFgz6GhavVD6y b8adJdoukSKKBbNDqweRYXYocu+b68gylxbNHvvqohxCY4OVIv4YDuNKtFM742+Os6Dh cT5CDQjjyI/RX9E9cSXUp/QwReEA1JD4bAotEVYDv0dY+cJtLaKZtYBNK61HnFmL4R82 GoPtvPPr8s7RgVJpqSbZMOY7NGGNcO91OzebPETdIeryjpQUcAhvuH4UlztAt6KpieZO Z/bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=a/tN9TnrR5De10wKWpMYgYMrOCjvKExDFMseAllPzSw=; b=I7Tc1i04Vh/q68DlXysjMFVGJCu56qqhEKASbbufFvkuCp6ZQXV/TTFon2U0SZvEYA MCW82I4eOm8mVcO03IK4AxV09yCD/vi9bZ4eZIhGVWIqp3GKy2CRGmKNOJRXOdG8fxmN y8FMEIEUi2U1Ik9dm5on89t+RZeMF9oP2u+ifShnRZvkpdkvya1kekmhh7fedf06hRNY VeFfO6ukpAPtTUYnQVGoXUnuSUACEIbMlWryGlcsWU9kDUakW5DyX/itEGH8kzf+ZFuK Kzk7fV1d38CHHL7whLrgyzPWXNivUesoYF2+TFNSyqClaPDWJPsPc6TptaYBoPYMiOQE 3kdQ== 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 x22si4114081qvc.42.2019.04.09.03.02.23 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Apr 2019 03:02:23 -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-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DE6FB30018EA; Tue, 9 Apr 2019 10:02:21 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-49.ams2.redhat.com [10.36.117.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id 67F095D71F; Tue, 9 Apr 2019 10:02:13 +0000 (UTC) From: David Hildenbrand To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, 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" , x86@kernel.org, Andrew Morton , Michal Hocko , Mike Rapoport , Oscar Salvador , "Kirill A. Shutemov" , Christophe Leroy , Stefan Agner , Nicholas Piggin , Pavel Tatashin , Vasily Gorbik , Arun KS , Geert Uytterhoeven , Masahiro Yamada , Rob Herring , Joonsoo Kim , Wei Yang , Qian Cai , Mathieu Malaterre , linux-ia64@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org, linux-s390@vger.kernel.org Subject: [PATCH v1 4/4] mm/memory_hotplug: Make __remove_pages() and arch_remove_memory() never fail Date: Tue, 9 Apr 2019 12:01:48 +0200 Message-Id: <20190409100148.24703-5-david@redhat.com> In-Reply-To: <20190409100148.24703-1-david@redhat.com> References: <20190409100148.24703-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Tue, 09 Apr 2019 10:02:22 +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 All callers of arch_remove_memory() ignore errors. And we should really try to remove any errors from the memory removal path. No more errors are reported from __remove_pages(). BUG() in s390x code in case arch_remove_memory() is triggered. We may implement that properly later. WARN in case powerpc code failed to remove the section mapping, which is better than ignoring the error completely right now. 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: x86@kernel.org Cc: Andrew Morton Cc: Michal Hocko Cc: Mike Rapoport Cc: Oscar Salvador Cc: "Kirill A. Shutemov" Cc: Christophe Leroy Cc: Stefan Agner Cc: Nicholas Piggin Cc: Pavel Tatashin Cc: Vasily Gorbik Cc: Arun KS Cc: Geert Uytterhoeven Cc: Masahiro Yamada Cc: Rob Herring Cc: Joonsoo Kim Cc: Wei Yang Cc: Qian Cai Cc: Mathieu Malaterre Cc: linux-ia64@vger.kernel.org Cc: linuxppc-dev@lists.ozlabs.org Cc: linux-sh@vger.kernel.org Cc: linux-s390@vger.kernel.org Signed-off-by: David Hildenbrand --- arch/ia64/mm/init.c | 11 +++-------- arch/powerpc/mm/mem.c | 11 ++++------- arch/s390/mm/init.c | 5 +++-- arch/sh/mm/init.c | 11 +++-------- arch/x86/mm/init_32.c | 5 +++-- arch/x86/mm/init_64.c | 10 +++------- include/linux/memory_hotplug.h | 8 ++++---- mm/memory_hotplug.c | 5 ++--- 8 files changed, 25 insertions(+), 41 deletions(-) diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c index 379eb1f9adc9..d28e29103bdb 100644 --- a/arch/ia64/mm/init.c +++ b/arch/ia64/mm/init.c @@ -682,20 +682,15 @@ int arch_add_memory(int nid, u64 start, u64 size, } #ifdef CONFIG_MEMORY_HOTREMOVE -int arch_remove_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap) +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; - int ret; zone = page_zone(pfn_to_page(start_pfn)); - ret = __remove_pages(zone, start_pfn, nr_pages, altmap); - if (ret) - pr_warn("%s: Problem encountered in __remove_pages() as" - " ret=%d\n", __func__, ret); - - return ret; + __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 76deaa8525db..cc9425fb9056 100644 --- a/arch/powerpc/mm/mem.c +++ b/arch/powerpc/mm/mem.c @@ -131,8 +131,8 @@ int __meminit arch_add_memory(int nid, u64 start, u64 size, } #ifdef CONFIG_MEMORY_HOTREMOVE -int __meminit arch_remove_memory(int nid, u64 start, u64 size, - struct vmem_altmap *altmap) +void __meminit 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; @@ -147,14 +147,13 @@ int __meminit arch_remove_memory(int nid, u64 start, u64 size, if (altmap) page += vmem_altmap_offset(altmap); - ret = __remove_pages(page_zone(page), start_pfn, nr_pages, altmap); - if (ret) - return ret; + __remove_pages(page_zone(page), start_pfn, nr_pages, altmap); /* Remove htab bolted mappings for this section of memory */ start = (unsigned long)__va(start); flush_inval_dcache_range(start, start + size); ret = remove_section_mapping(start, start + size); + WARN_ON_ONCE(ret); /* Ensure all vmalloc mappings are flushed in case they also * hit that section of memory @@ -162,8 +161,6 @@ int __meminit arch_remove_memory(int nid, u64 start, u64 size, vm_unmap_aliases(); resize_hpt_for_hotplug(memblock_phys_mem_size()); - - return ret; } #endif #endif /* CONFIG_MEMORY_HOTPLUG */ diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c index f5db961ad792..31b1071315d7 100644 --- a/arch/s390/mm/init.c +++ b/arch/s390/mm/init.c @@ -234,14 +234,15 @@ int arch_add_memory(int nid, u64 start, u64 size, } #ifdef CONFIG_MEMORY_HOTREMOVE -int arch_remove_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap) +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. */ - return -EBUSY; + BUG(); } #endif #endif /* CONFIG_MEMORY_HOTPLUG */ diff --git a/arch/sh/mm/init.c b/arch/sh/mm/init.c index 168d3a6b9358..5aeb4d7099a1 100644 --- a/arch/sh/mm/init.c +++ b/arch/sh/mm/init.c @@ -429,20 +429,15 @@ EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid); #endif #ifdef CONFIG_MEMORY_HOTREMOVE -int arch_remove_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap) +void arch_remove_memory(int nid, u64 start, u64 size, + struct vmem_altmap *altmap) { unsigned long start_pfn = PFN_DOWN(start); unsigned long nr_pages = size >> PAGE_SHIFT; struct zone *zone; - int ret; zone = page_zone(pfn_to_page(start_pfn)); - ret = __remove_pages(zone, start_pfn, nr_pages, altmap); - if (unlikely(ret)) - pr_warn("%s: Failed, __remove_pages() == %d\n", __func__, - ret); - - return ret; + __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 755dbed85531..075e568098f2 100644 --- a/arch/x86/mm/init_32.c +++ b/arch/x86/mm/init_32.c @@ -860,14 +860,15 @@ int arch_add_memory(int nid, u64 start, u64 size, } #ifdef CONFIG_MEMORY_HOTREMOVE -int arch_remove_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap) +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; zone = page_zone(pfn_to_page(start_pfn)); - return __remove_pages(zone, start_pfn, nr_pages, altmap); + __remove_pages(zone, start_pfn, nr_pages, altmap); } #endif #endif diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c index db42c11b48fb..20d14254b686 100644 --- a/arch/x86/mm/init_64.c +++ b/arch/x86/mm/init_64.c @@ -1141,24 +1141,20 @@ kernel_physical_mapping_remove(unsigned long start, unsigned long end) remove_pagetable(start, end, true, NULL); } -int __ref arch_remove_memory(int nid, u64 start, u64 size, - struct vmem_altmap *altmap) +void __ref 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 page *page = pfn_to_page(start_pfn); struct zone *zone; - int ret; /* With altmap the first mapped page is offset from @start */ if (altmap) page += vmem_altmap_offset(altmap); zone = page_zone(page); - ret = __remove_pages(zone, start_pfn, nr_pages, altmap); - WARN_ON_ONCE(ret); + __remove_pages(zone, start_pfn, nr_pages, altmap); kernel_physical_mapping_remove(start, start + size); - - return ret; } #endif #endif /* CONFIG_MEMORY_HOTPLUG */ diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h index d0a145ffa4fe..9d0efac902ec 100644 --- a/include/linux/memory_hotplug.h +++ b/include/linux/memory_hotplug.h @@ -112,10 +112,10 @@ static inline bool movable_node_is_enabled(void) } #ifdef CONFIG_MEMORY_HOTREMOVE -extern int arch_remove_memory(int nid, u64 start, u64 size, - struct vmem_altmap *altmap); -extern int __remove_pages(struct zone *zone, unsigned long start_pfn, - unsigned long nr_pages, struct vmem_altmap *altmap); +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 */ /* diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 17a60281c36f..52fef4a81e4c 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -548,8 +548,8 @@ static void __remove_section(struct zone *zone, struct mem_section *ms, * sure that pages are marked reserved and zones are adjust properly by * calling offline_pages(). */ -int __remove_pages(struct zone *zone, unsigned long phys_start_pfn, - unsigned long nr_pages, struct vmem_altmap *altmap) +void __remove_pages(struct zone *zone, unsigned long phys_start_pfn, + unsigned long nr_pages, struct vmem_altmap *altmap) { unsigned long i; unsigned long map_offset = 0; @@ -580,7 +580,6 @@ int __remove_pages(struct zone *zone, unsigned long phys_start_pfn, } set_zone_contiguous(zone); - return 0; } #endif /* CONFIG_MEMORY_HOTREMOVE */