From patchwork Wed May 23 15:11:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 10421757 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 004406032A for ; Wed, 23 May 2018 15:13:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E2B1228FD3 for ; Wed, 23 May 2018 15:13:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E060828FEC; Wed, 23 May 2018 15:13:39 +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 02E802906E for ; Wed, 23 May 2018 15:12:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 751686B02AE; Wed, 23 May 2018 11:12:24 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 6B21D6B02AF; Wed, 23 May 2018 11:12:24 -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 551216B02B0; Wed, 23 May 2018 11:12:24 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt0-f197.google.com (mail-qt0-f197.google.com [209.85.216.197]) by kanga.kvack.org (Postfix) with ESMTP id 26E9D6B02AE for ; Wed, 23 May 2018 11:12:24 -0400 (EDT) Received: by mail-qt0-f197.google.com with SMTP id d5-v6so21176986qtg.17 for ; Wed, 23 May 2018 08: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; bh=sbCJ2Y9pqlCgGOwt2xLKG0P6GUoHRHwHggo9UFpgOwo=; b=ApsPcPM9hxNLeKaHPWhMEqyEJBj8xcb94+6AM/uqXba3mOF5tqAsX8RuIHiYwkdUaT KJKSAAp2inc6XkfIjqYoixKfu8GWhEY3u7mNVh3LXQae+fuXHDXNde4itBwWv7svt/m3 CQEdVMM9xXVh1DgI58IMeFmoVDqX0c+FyO2J73s3u861Vpal7hJzmIgu0JR20qGtIQrd 83vQ4RFdYj7TQUo/uNmpqiaHBkktYSxtKxFwO7uy8mXGvrF+HA0r8/y6B5HvN14yxKPl ouzTGsAn3mIFtp8AFrszNVB8h35NGw2PqgQs+tkK299m+6FyVDsYdl5ruk8NjX50fAwz X0lw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of david@redhat.com designates 66.187.233.73 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: ALKqPwfipVd4M10X4eQ/hdfPtjIQPodxqrfMCXFI2MiazmB3vKYl8BpN i2/wy7MxSyJpkIHutHtYTY2NO9nxQfsRF4aZoHeQI54uliZKOlZBw+DDE4qfn6325KRxIxwCL1k wXPZ7UfsDfhODio3wI50cAZoHaZ4jLZbTZhTAJ/x4iTdAfH41DTqlddng1RiDRIm4sw== X-Received: by 2002:ac8:376b:: with SMTP id p40-v6mr3164781qtb.282.1527088343896; Wed, 23 May 2018 08:12:23 -0700 (PDT) X-Google-Smtp-Source: ADUXVKINlMRhEa7yeIQcxUK14HcfibVFcwzRqp7MZFEKfwHHXcbyw0ZFkOHO2zXdMWxk6xzxpZbD X-Received: by 2002:ac8:376b:: with SMTP id p40-v6mr3164722qtb.282.1527088343244; Wed, 23 May 2018 08:12:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527088343; cv=none; d=google.com; s=arc-20160816; b=RXzYYzFoQ20uJvnM7D36v/MhganANz9ur+FK2FfeE56nBfmggzSKY3mG1wgM8n9/Uv xuzTLFZbOA1W6kpW6fyJn0r+45PLPh7oLfly28ySC2roofXbHOXrfcu3YDGR/XU7dU/v xUXiqZ+lBQEBM3SMGhSxUmLaMys66vt/DMCE3Ish82CUmeAf2NnVOW+oW+W3HWA58CgH XtQIj5Cl4sRPP2jr0w/VBx30EUsMF/vtRY48z1K6dIofLQgPPoWyPzSX7q8moTYyrm7p MK2ktsBEOuSsVwC/1qnPWuzQ8S8p+bPVH993wUH/xrfq9E+gVfeNaw+nDhHZ4vYFUFj1 QnGQ== 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 :arc-authentication-results; bh=sbCJ2Y9pqlCgGOwt2xLKG0P6GUoHRHwHggo9UFpgOwo=; b=oExD4HZglwz8/XUiKP9Cgd+eWGFEU8M08jvCYksr5U4eIh1LOhqfNDfUnp16k565Bf rMCClbOsAUqbIjZIyj2MAWMlKbPpPLKUF+nosHhoMDvrD5Dyw+dlsVVEFrG0Apqc67cc 972E4lVznPv7Rjd8dHG0ZAmZ6T9S3AMfI5Cfdp+DnwgF/SGF1jS7WIxTPI3t1wwP4Mk3 rpu7tqL5h3G6C7vVNz7jjKpyjUeee7/8DvgD7aHjxSjAjMaPSFt8kaH0AwsqmTS+hFfK jFFlg/uWwsrDEN1DAdV2E+UkCaTAz7sGVWJeO+DadluklbaUr8h9RPQ8AKwt1NLsgRx6 PicA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of david@redhat.com designates 66.187.233.73 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 (mx3-rdu2.redhat.com. [66.187.233.73]) by mx.google.com with ESMTPS id q27-v6si1188362qkj.363.2018.05.23.08.12.23 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 May 2018 08:12:23 -0700 (PDT) Received-SPF: pass (google.com: domain of david@redhat.com designates 66.187.233.73 as permitted sender) client-ip=66.187.233.73; Authentication-Results: mx.google.com; spf=pass (google.com: domain of david@redhat.com designates 66.187.233.73 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-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E2A27818BAF8; Wed, 23 May 2018 15:12:22 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-112.ams2.redhat.com [10.36.116.112]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5238810C564A; Wed, 23 May 2018 15:12:21 +0000 (UTC) From: David Hildenbrand To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, David Hildenbrand , Andrew Morton , Michal Hocko , Vlastimil Babka , Dan Williams , Reza Arbab , Pavel Tatashin , Thomas Gleixner Subject: [PATCH v1 06/10] mm/memory_hotplug: onlining pages can only fail due to notifiers Date: Wed, 23 May 2018 17:11:47 +0200 Message-Id: <20180523151151.6730-7-david@redhat.com> In-Reply-To: <20180523151151.6730-1-david@redhat.com> References: <20180523151151.6730-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 23 May 2018 15:12:22 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 23 May 2018 15:12:22 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'david@redhat.com' RCPT:'' 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 Onlining pages can only fail if a notifier reported a problem (e.g. -ENOMEM). Remove and restructure error handling. While at it, document how online_pages() can be used right now. Cc: Andrew Morton Cc: Michal Hocko Cc: Vlastimil Babka Cc: Dan Williams Cc: Reza Arbab Cc: Pavel Tatashin Cc: Thomas Gleixner Signed-off-by: David Hildenbrand --- mm/memory_hotplug.c | 47 +++++++++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index c971295a1100..8c0b7d85252b 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -902,7 +902,26 @@ static struct zone * __meminit move_pfn_range(int online_type, int nid, return zone; } -/* Must be protected by mem_hotplug_begin() or a device_lock */ +/** + * online_pages - online pages in a given range (that are currently offline) + * @start_pfn: start pfn of the memory range + * @nr_pages: the number of pages + * @online_type: how to online pages (esp. to which zone to add them) + * + * This function onlines the given pages. Usually, any alignemt / size + * can be used. However, all pages of memory to be removed later on in + * one piece via remove_memory() should be onlined the same way and at + * least the first page should be onlined if anything else is onlined. + * The zone of the first page is used to fixup zones when removing memory + * later on (see __remove_pages()). + * + * Returns 0 if sucessful, an error code if a memory notifier reported a + * problem (e.g. -ENOMEM). + * + * Bad things will happen if pages in the range are already online. + * + * Must be protected by mem_hotplug_begin() or a device_lock + */ int __ref online_pages(unsigned long pfn, unsigned long nr_pages, int online_type) { unsigned long flags; @@ -923,8 +942,13 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages, int online_typ ret = memory_notify(MEM_GOING_ONLINE, &arg); ret = notifier_to_errno(ret); - if (ret) - goto failed_addition; + if (ret) { + pr_debug("online_pages [mem %#010llx-%#010llx] failed\n", + (unsigned long long) pfn << PAGE_SHIFT, + (((unsigned long long) pfn + nr_pages) << PAGE_SHIFT) - 1); + memory_notify(MEM_CANCEL_ONLINE, &arg); + return ret; + } /* * If this zone is not populated, then it is not in zonelist. @@ -936,13 +960,9 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages, int online_typ setup_zone_pageset(zone); } - ret = walk_system_ram_range(pfn, nr_pages, &onlined_pages, - online_pages_range); - if (ret) { - if (need_zonelists_rebuild) - zone_pcp_reset(zone); - goto failed_addition; - } + /* onlining pages cannot fail */ + walk_system_ram_range(pfn, nr_pages, &onlined_pages, + online_pages_range); zone->present_pages += onlined_pages; @@ -972,13 +992,6 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages, int online_typ if (onlined_pages) memory_notify(MEM_ONLINE, &arg); return 0; - -failed_addition: - pr_debug("online_pages [mem %#010llx-%#010llx] failed\n", - (unsigned long long) pfn << PAGE_SHIFT, - (((unsigned long long) pfn + nr_pages) << PAGE_SHIFT) - 1); - memory_notify(MEM_CANCEL_ONLINE, &arg); - return ret; } #endif /* CONFIG_MEMORY_HOTPLUG_SPARSE */