From patchwork Thu Aug 16 10:06:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 10567273 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 C1F935A4 for ; Thu, 16 Aug 2018 10:06:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AFCD82856F for ; Thu, 16 Aug 2018 10:06:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A31C92A836; Thu, 16 Aug 2018 10:06:42 +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 3D7B62856F for ; Thu, 16 Aug 2018 10:06:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4FF556B000A; Thu, 16 Aug 2018 06:06:41 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4893E6B000C; Thu, 16 Aug 2018 06:06:41 -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 32A266B000D; Thu, 16 Aug 2018 06:06:41 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk0-f200.google.com (mail-qk0-f200.google.com [209.85.220.200]) by kanga.kvack.org (Postfix) with ESMTP id 01C6E6B000A for ; Thu, 16 Aug 2018 06:06:41 -0400 (EDT) Received: by mail-qk0-f200.google.com with SMTP id q3-v6so3857572qki.4 for ; Thu, 16 Aug 2018 03:06:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=GMxWoyaTfcY/teE3rvj2CFkSo11yCG42GDLXPss+Y88=; b=cUm9oGW8Z76FCFdI1ezuhEDeZMD/J2HbNXD22crFymNu9/rFFghmF0S4b2UjzkaJFT oc2IUsjCzcdwU1vDkLYfeIPdIZ5zGBdrDQrnUVOZH5WEOJsB4Z9KbAs/DbX1Upptj3xR YXZmokp3VMAJ8CPz32O/BdK1u6U46Hj6Sg6vZVM37+123HKpXJJL5CpgUeA43ijUXjAg 7KS95+i6JSvgq4iZq3Gqw33CQ0ItkVUPQRihtN6eTvsBecx+c2wDEVgqG6Miag/Iulup K3qjcIiXXwYIJs/LB09Qr4cVl+3lk1I2427khTnqyRNUPxtTsgMaD+lA0UAhHnWJzCFY cpaw== 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: AOUpUlFMqGcDopZxmpwPNpk5bEKRplLHPw7QOSmsEXFzjdVvQtjawfk3 Mo0RQbxTNoOo926XM2mil1HLZtvG9xDkE03GQDOUkRBBIYSfp1RCyEYXbKQqBhEh123yIJ8MYfr 3MPeqPRrCp8n84EaHpdZhJPtRjlbOilWHevjM22R8KMxAyemkcTyxj6Pk4T4tNwBP1Q== X-Received: by 2002:aed:25a2:: with SMTP id x31-v6mr28428113qtc.228.1534414000816; Thu, 16 Aug 2018 03:06:40 -0700 (PDT) X-Google-Smtp-Source: AA+uWPwkEaBjI8vn6sKkNLLD5kg9BxjPidN9kN0H80BCfVkRgNsidLC+p6jmuaQTqrikhgvHFOUR X-Received: by 2002:aed:25a2:: with SMTP id x31-v6mr28428077qtc.228.1534414000301; Thu, 16 Aug 2018 03:06:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534414000; cv=none; d=google.com; s=arc-20160816; b=agOVJZ17vDpQ1kqeHuk5YpI4ZnchEOVT6hDkYs/80ZuVxiRQQYwQ5vsyAfhKSbq+WW jqhfXGTGcBDGiuAV210wjgL18E3Y/a7mGMovuqU3NrfR3tcBVEf2gCCFt1uGdv9psb9W wez1HlO5bZAuk3Z18d/2RiDwAOQgeRd+t2eouVjY+OnKHukfWzKoe4OHYNXoX2dj1/2l Vu1NQJttccZ0EGJ4WBKbgEICxF69X2NV41E+XGveaNWpDjxqPUm1md6ymoNszAgE5lya r9RAfvACxcKrjrh3Q0X29W5rlGTjJZsBRL9HqeDUknpZAmFpidU/IJShA3nn+WvYJhb2 +6eg== 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=GMxWoyaTfcY/teE3rvj2CFkSo11yCG42GDLXPss+Y88=; b=YhzFGC65pbR/deJF1Sz+5biCECDjYWKvTYNMqJLRbjhqZMpZIoYBuJeYgLH6nrFcZx WGBUvBugzjeP6YsaFOLi2eW95me13y5rfXqGTl0lTTqkIJHnN2LxGZs8P0DjBtmcbEgY jmBau3OvmKIh2IDgLu84+Dr3xl0Z1sZ3NUSxQYEf+xOSjS5YBHZMVqW8AL69jwfGeeJQ 5DIrQjZUcQ7c+jlvUugtdwemYr+Ntj9q6uWO4F4CG38qizEZTXwdmgKSO/D0LQthwJ9d 6vulG4py82krHQVLe+8YtDb/RISQAhEfVvE/vP5tU3u5hoO+3dbLuAVYzdff6Dc33DsL k53g== 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 y2-v6si776193qkl.233.2018.08.16.03.06.40 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Aug 2018 03:06:40 -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 B7E20401C090; Thu, 16 Aug 2018 10:06:39 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-94.ams2.redhat.com [10.36.116.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id BD02210F1C1D; Thu, 16 Aug 2018 10:06:36 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, Andrew Morton , Michal Hocko , Vlastimil Babka , Stephen Rothwell , Pavel Tatashin , Kemi Wang , David Rientjes , Jia He , Oscar Salvador , Petr Tesarik , Andrey Ryabinin , Dan Williams , David Hildenbrand , Mathieu Malaterre , Baoquan He , Wei Yang , Ross Zwisler , "Kirill A . Shutemov" Subject: [PATCH v1 1/5] mm/memory_hotplug: drop intermediate __offline_pages Date: Thu, 16 Aug 2018 12:06:24 +0200 Message-Id: <20180816100628.26428-2-david@redhat.com> In-Reply-To: <20180816100628.26428-1-david@redhat.com> References: <20180816100628.26428-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.5]); Thu, 16 Aug 2018 10:06:39 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Thu, 16 Aug 2018 10:06:39 +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 Let's avoid this indirection and just call the function offline_pages(). Signed-off-by: David Hildenbrand Reviewed-by: Pavel Tatashin --- mm/memory_hotplug.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 6a2726920ed2..090cf474de87 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1589,10 +1589,10 @@ static void node_states_clear_node(int node, struct memory_notify *arg) node_clear_state(node, N_MEMORY); } -static int __ref __offline_pages(unsigned long start_pfn, - unsigned long end_pfn) +/* Must be protected by mem_hotplug_begin() or a device_lock */ +int offline_pages(unsigned long start_pfn, unsigned long nr_pages) { - unsigned long pfn, nr_pages; + unsigned long pfn, end_pfn = start_pfn + nr_pages; long offlined_pages; int ret, node; unsigned long flags; @@ -1612,7 +1612,6 @@ static int __ref __offline_pages(unsigned long start_pfn, zone = page_zone(pfn_to_page(valid_start)); node = zone_to_nid(zone); - nr_pages = end_pfn - start_pfn; /* set above range as isolated */ ret = start_isolate_page_range(start_pfn, end_pfn, @@ -1700,12 +1699,6 @@ static int __ref __offline_pages(unsigned long start_pfn, undo_isolate_page_range(start_pfn, end_pfn, MIGRATE_MOVABLE); return ret; } - -/* Must be protected by mem_hotplug_begin() or a device_lock */ -int offline_pages(unsigned long start_pfn, unsigned long nr_pages) -{ - return __offline_pages(start_pfn, start_pfn + nr_pages); -} #endif /* CONFIG_MEMORY_HOTREMOVE */ /** From patchwork Thu Aug 16 10:06:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 10567275 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 1F760139B for ; Thu, 16 Aug 2018 10:06:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0C36D2856F for ; Thu, 16 Aug 2018 10:06:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F3EE22A836; Thu, 16 Aug 2018 10:06:45 +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 926632856F for ; Thu, 16 Aug 2018 10:06:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7E7D16B000C; Thu, 16 Aug 2018 06:06:44 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 771B16B000D; Thu, 16 Aug 2018 06:06:44 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5E9E16B000E; Thu, 16 Aug 2018 06:06:44 -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 2EEDC6B000C for ; Thu, 16 Aug 2018 06:06:44 -0400 (EDT) Received: by mail-qt0-f197.google.com with SMTP id d18-v6so3304993qtj.20 for ; Thu, 16 Aug 2018 03:06:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=kyp7fPQclWGZBlYTNBuM7MhOM2Q42exOsD1g/XpCns8=; b=ZuDJmpX1pLBrZOBVzc0GWwbaX4Wj4EZ9aQmmEjFAH3w4W6KHqSDvXSp6T40VRe3+ve xcsIBDtBtYU9PgC4ovLTn3uEtkFpOVOGDo2E508HlWc2fJyjRiDSMoosGGzVJGCKf2w/ SgJpEsLzjOeVDMhTbk/7NvgXBjy/+tjWr5ViB2nUlAESW6waFagJiKoPG8v095+1Q3Dk 5q6wuVvq9WBnuNazsZpI33OG6/Kiy0UG0Sv+/2vwu8/CCIe/XBPgAsOCVjATym/KHQKj WogklZW8S14dX6TPgtzw2/+77AFrFTDBue47yyxGyvBqQxMSiySsfCsP/u/IlUjTu55D x9tQ== 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: AOUpUlHdgeBNQju9T6Z3X7rGK/WIwh2X4wwNqTNrW6Y+dA7q4z0M5vSX rlZdKHWcSfCCvAIezANPXHmv0Gc0NJNffU7MHmY872LxR2Qp/HK6XYOb9oJXDU1r7N6xdMKyAWD 6zkbuKOCAToBs/aSsBai8d3dPn5ywBVLhceLfIWSx70ENWF1VDW1092pSQdSOGARUnQ== X-Received: by 2002:a0c:f747:: with SMTP id e7-v6mr26000022qvo.96.1534414003963; Thu, 16 Aug 2018 03:06:43 -0700 (PDT) X-Google-Smtp-Source: AA+uWPz4DhNHQMOCwUSej8+HKonAsA0Uxx5rZKGHM28/Sb+e1ZWHxRajsb5mwe/XymlDjDfJyibN X-Received: by 2002:a0c:f747:: with SMTP id e7-v6mr25999999qvo.96.1534414003406; Thu, 16 Aug 2018 03:06:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534414003; cv=none; d=google.com; s=arc-20160816; b=wmPS/Un65MaBG5sOB6cOOjfRaIx8tx4sRHyPfxFW1ji2k3tlPLib+eaHN8XqyMAqgo Xx0AvX7N6qImvfT0zlUUTeaqWIe4dNY4luuF4zECigjNejvcddCBv+JxuYvgxMTRU/JQ +qjAmSJyU0DChmt9o3q06tV6LnoFpAOTxC62RmmoX7F1XgQRYxRlmM4i5VfRGRaT95jK zHJbx24jJebObkq2uOYMmGiFOtiQSNyhkQPuXbGbWK9zlEG/mfKKUAwL1ClaInu8Hn8i KoqH2qYavMH/CsXTKlwAfi4y+V2LHay52K8yks857ZBfW90EMLa99K9FQfNWlyFlUIsR TG2w== 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=kyp7fPQclWGZBlYTNBuM7MhOM2Q42exOsD1g/XpCns8=; b=nQuonqJQT38hFWCUUjNrqk51r0jYi3PAzeli4Lj6VBxjgS9jEx+ZWfeYSghzqbs8y3 am2iRyXU8j8aJR0/WxIpSGeF3lr1z/T9ryvSMf0kKoWnHwK8Wj4mqlyozuJgvsercFc/ WJD+C/bvF5HkBvuFBtWW20WRj5ScRLFmc6hsrDKaoYqJqA/2+TMNZogz6BIYMTlBqanh 3DbllcxUnuUC4eJbPmiIImEvMq9tpIpy5z0HUracBgNLR22+4KUph4nel2dBXpajphVI BXX+UQCMnmEl7IWAQQcrK3r2mPxMrLEVeyu0Ay0ihhH9AnjwlTUcN4q2oLIl+TaW4Q4F Lz0g== 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 d23-v6si6461778qtp.373.2018.08.16.03.06.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Aug 2018 03:06:43 -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 054E440122C4; Thu, 16 Aug 2018 10:06:43 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-94.ams2.redhat.com [10.36.116.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 020A510EE95C; Thu, 16 Aug 2018 10:06:39 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, Andrew Morton , Michal Hocko , Vlastimil Babka , Stephen Rothwell , Pavel Tatashin , Kemi Wang , David Rientjes , Jia He , Oscar Salvador , Petr Tesarik , Andrey Ryabinin , Dan Williams , David Hildenbrand , Mathieu Malaterre , Baoquan He , Wei Yang , Ross Zwisler , "Kirill A . Shutemov" Subject: [PATCH v1 2/5] mm/memory_hotplug: enforce section alignment when onlining/offlining Date: Thu, 16 Aug 2018 12:06:25 +0200 Message-Id: <20180816100628.26428-3-david@redhat.com> In-Reply-To: <20180816100628.26428-1-david@redhat.com> References: <20180816100628.26428-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.5]); Thu, 16 Aug 2018 10:06:43 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Thu, 16 Aug 2018 10:06:43 +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/offlining code works on whole sections, so let's enforce that. Existing code only allows to add memory in memory block size. And only whole memory blocks can be onlined/offlined. Memory blocks are always aligned to sections, so this should not break anything. online_pages/offline_pages will implicitly mark whole sections online/offline, so the code really can only handle such granularities. (especially offlining code cannot deal with pageblock_nr_pages but theoretically only MAX_ORDER-1) Signed-off-by: David Hildenbrand Reviewed-by: Oscar Salvador --- mm/memory_hotplug.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 090cf474de87..30d2fa42b0bb 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -897,6 +897,11 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages, int online_typ struct memory_notify arg; struct memory_block *mem; + if (!IS_ALIGNED(pfn, PAGES_PER_SECTION)) + return -EINVAL; + if (!IS_ALIGNED(nr_pages, PAGES_PER_SECTION)) + return -EINVAL; + /* * We can't use pfn_to_nid() because nid might be stored in struct page * which is not yet initialized. Instead, we find nid from memory block. @@ -1600,10 +1605,9 @@ int offline_pages(unsigned long start_pfn, unsigned long nr_pages) struct zone *zone; struct memory_notify arg; - /* at least, alignment against pageblock is necessary */ - if (!IS_ALIGNED(start_pfn, pageblock_nr_pages)) + if (!IS_ALIGNED(start_pfn, PAGES_PER_SECTION)) return -EINVAL; - if (!IS_ALIGNED(end_pfn, pageblock_nr_pages)) + if (!IS_ALIGNED(nr_pages, PAGES_PER_SECTION)) return -EINVAL; /* This makes hotplug much easier...and readable. we assume this for now. .*/ From patchwork Thu Aug 16 10:06:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 10567277 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 A8637139B for ; Thu, 16 Aug 2018 10:06:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 947572856F for ; Thu, 16 Aug 2018 10:06:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 888902A836; Thu, 16 Aug 2018 10:06:49 +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 1BE862856F for ; Thu, 16 Aug 2018 10:06:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D65476B000D; Thu, 16 Aug 2018 06:06:47 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id CED646B0266; Thu, 16 Aug 2018 06:06:47 -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 B8EB96B0269; Thu, 16 Aug 2018 06:06:47 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt0-f200.google.com (mail-qt0-f200.google.com [209.85.216.200]) by kanga.kvack.org (Postfix) with ESMTP id 882C86B000D for ; Thu, 16 Aug 2018 06:06:47 -0400 (EDT) Received: by mail-qt0-f200.google.com with SMTP id j9-v6so3248691qtn.22 for ; Thu, 16 Aug 2018 03:06:47 -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=9AmwCETxK5BLAns08GejjkVezlq4beKGZdoiq+TAw3o=; b=uVk2JMi+8OnNT2MOhJSVH8f/sbtuvs4Hl/rtBNJzHjG1R0xLtIqJEn1mCcGk2JWzXk h08hrJUNy3S2vIFlvEomx0hdGtBqupcvnfQTRIMSWXrcsi73AI6oQKJgonPdAvM8Afuw rdRp8cT+1w2MT7uG8EC9IJKztOITuhESnzJ8tK/6Q4BZCi7MPwoB/+qGTa6qYqQBJDC9 QZ1ooz5MeC6/L9jiCsFZWwYQW04oxQTbAOO8kFkdRu1SJTEGKtJeISPWi4sNtSWyq6r4 38CEfkr+XBcaURbBmGnW1lV2sv/OwV/INJxiK94HSPetgdn+HwDzIqTKBKHoPYnk9pbO ZDnQ== 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: AOUpUlFDdaCcmw1T/9gWntUR1ByviDsLmuUXsWBoRnfXP9o8kDLz1dwZ znQC8twzIL9ooyessH8qDzVNnUyMKmS1lQnEpESihUcjiIEFps7g870q4GSVy69W4/V5K/GR3XA NRlTE6Zg3vhngk2reIOneP7d1a3ju/StvloPOdKBhVreovQOfJGjq4FYOEIPrKKKOJQ== X-Received: by 2002:ae9:e606:: with SMTP id z6-v6mr11800756qkf.117.1534414007329; Thu, 16 Aug 2018 03:06:47 -0700 (PDT) X-Google-Smtp-Source: AA+uWPz/veLxseTEbyPhD7UCJLGAahsnnbgL7LhnZZWochG70e+T7UewlR02MsIisZF7JCy/7PZm X-Received: by 2002:ae9:e606:: with SMTP id z6-v6mr11800719qkf.117.1534414006707; Thu, 16 Aug 2018 03:06:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534414006; cv=none; d=google.com; s=arc-20160816; b=QpJscs9Sjta3f8los4RYXOJwbBNA8DHWFE87aQZ2+v48YSxc1zBbx53Rw8Vs4N68nN GyEyQwIrU2FM+O24c34bm2Z+6aYs0RsV9YAKROyE98RFsTCIjS5bbRmVYq9SlPexkKuO 3i38y7/6lgSgYqvLhitho3EeHacJVnwHnr3KdmC1LHPeGNO++h4BbiHQj9SOJrN5XS0g tkhB6SVPdlWoPl8Pm1noy3WI8ghaV8UEq3kJ/APSmmLECRijSVJvHNWbeHQZ1hQcTg5G fIqw86005R8t4xZ8YU0s4EiL6aXMUAVgbHhcqGft4Bj7xH0plUyFzNqeA0ClKuh6XVpk 4nhQ== 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=9AmwCETxK5BLAns08GejjkVezlq4beKGZdoiq+TAw3o=; b=hKojJCNg9hfgQGwCJjxQI9M/abpKxarh0Ob19L2YQvC38cpMsUnBMpJJLo6uzZol36 aWXRMvOtKVrRjP2b9tZpMAeFxDoff0tGoBUZhYoUP4fvF+9L57Lp9JNUzDMHBjVb/Vno JmHDXPShGjGzsHIdo7VtlK9jMn7nh5bRTtJoja1uJYeTW9XnMEaVSOlDcQjuaUPf9+OM /jVY1IwLCOc7w12Xy5LeFjFZzA1Y5ASr4235e572Ys689urpU8J1zU+95lMxLy+ApVsh 7TO7H5CV+y0+sjyqYqMjzqDxXLoxuCLyilT0fjnyRJ8lLaeGJKQAVfTbyhNuuQ3f57gE JFPw== 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 y131-v6si1655301qka.286.2018.08.16.03.06.46 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Aug 2018 03:06:46 -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 4878A814FDCE; Thu, 16 Aug 2018 10:06:46 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-94.ams2.redhat.com [10.36.116.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4326610EE784; Thu, 16 Aug 2018 10:06:43 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, Andrew Morton , Michal Hocko , Vlastimil Babka , Stephen Rothwell , Pavel Tatashin , Kemi Wang , David Rientjes , Jia He , Oscar Salvador , Petr Tesarik , Andrey Ryabinin , Dan Williams , David Hildenbrand , Mathieu Malaterre , Baoquan He , Wei Yang , Ross Zwisler , "Kirill A . Shutemov" Subject: [PATCH v1 3/5] mm/memory_hotplug: check if sections are already online/offline Date: Thu, 16 Aug 2018 12:06:26 +0200 Message-Id: <20180816100628.26428-4-david@redhat.com> In-Reply-To: <20180816100628.26428-1-david@redhat.com> References: <20180816100628.26428-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]); Thu, 16 Aug 2018 10:06:46 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 16 Aug 2018 10:06:46 +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 Let's add some more sanity checking now that onlining/offlining code works completely on section basis. This will make sure that we will never try to online/offline sections that are already (or partially) in the desired state. Signed-off-by: David Hildenbrand --- include/linux/mmzone.h | 2 ++ mm/memory_hotplug.c | 5 +++++ mm/sparse.c | 28 ++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 0859130e4db8..addfa41c047a 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -1228,6 +1228,8 @@ static inline int online_section_nr(unsigned long nr) } #ifdef CONFIG_MEMORY_HOTPLUG +bool mem_sections_online(unsigned long pfn, unsigned long end_pfn); +bool mem_sections_offline(unsigned long pfn, unsigned long end_pfn); void online_mem_sections(unsigned long start_pfn, unsigned long end_pfn); #ifdef CONFIG_MEMORY_HOTREMOVE void offline_mem_sections(unsigned long start_pfn, unsigned long end_pfn); diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 30d2fa42b0bb..3dc6d2a309c2 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -901,6 +901,8 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages, int online_typ return -EINVAL; if (!IS_ALIGNED(nr_pages, PAGES_PER_SECTION)) return -EINVAL; + if (!mem_sections_offline(pfn, pfn + nr_pages)) + return -EINVAL; /* * We can't use pfn_to_nid() because nid might be stored in struct page @@ -1609,6 +1611,9 @@ int offline_pages(unsigned long start_pfn, unsigned long nr_pages) return -EINVAL; if (!IS_ALIGNED(nr_pages, PAGES_PER_SECTION)) return -EINVAL; + if (!mem_sections_online(start_pfn, end_pfn)) + return -EINVAL; + /* This makes hotplug much easier...and readable. we assume this for now. .*/ if (!test_pages_in_a_zone(start_pfn, end_pfn, &valid_start, &valid_end)) diff --git a/mm/sparse.c b/mm/sparse.c index 10b07eea9a6e..44693cf38ca9 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -520,6 +520,34 @@ void __init sparse_init(void) #ifdef CONFIG_MEMORY_HOTPLUG +/* check if all mem sections are online */ +bool mem_sections_online(unsigned long pfn, unsigned long end_pfn) +{ + for (; pfn < end_pfn; pfn += PAGES_PER_SECTION) { + unsigned long section_nr = pfn_to_section_nr(pfn); + + if (WARN_ON(!valid_section_nr(section_nr))) + continue; + if (!online_section_nr(section_nr)) + return false; + } + return true; +} + +/* check if all mem sections are offline */ +bool mem_sections_offline(unsigned long pfn, unsigned long end_pfn) +{ + for (; pfn < end_pfn; pfn += PAGES_PER_SECTION) { + unsigned long section_nr = pfn_to_section_nr(pfn); + + if (WARN_ON(!valid_section_nr(section_nr))) + continue; + if (online_section_nr(section_nr)) + return false; + } + return true; +} + /* Mark all memory sections within the pfn range as online */ void online_mem_sections(unsigned long start_pfn, unsigned long end_pfn) { From patchwork Thu Aug 16 10:06:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 10567279 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 AD5715A4 for ; Thu, 16 Aug 2018 10:06:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9A9202856F for ; Thu, 16 Aug 2018 10:06:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8E0AC2A836; Thu, 16 Aug 2018 10:06:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 33B482856F for ; Thu, 16 Aug 2018 10:06:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F3C266B0269; Thu, 16 Aug 2018 06:06:50 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id EC3DD6B026A; Thu, 16 Aug 2018 06:06:50 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D63846B026B; Thu, 16 Aug 2018 06:06:50 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk0-f200.google.com (mail-qk0-f200.google.com [209.85.220.200]) by kanga.kvack.org (Postfix) with ESMTP id A3E926B0269 for ; Thu, 16 Aug 2018 06:06:50 -0400 (EDT) Received: by mail-qk0-f200.google.com with SMTP id a70-v6so3799283qkb.16 for ; Thu, 16 Aug 2018 03:06:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=58eppWzBrms+oicXZ8vv1kTgC2Dj9f4AShb64br5H2I=; b=DkL5WlzaZC6ztbsVPDrVI2KOA/Wss2jvxYzpMGC0KJWfZg34MDM4Q75BaG+PkBhLl2 aqpeGgFKiccyvLLAWKHzDBpjtrQXO9Ji8v8gE1Oi6mpBRa1Q8OpFP+0CU/V8mXrQWmP9 vZwXKw0RhihuoHWS9F/dxRd2JnFxb+p8rDqOOxpw56TNWVSgwIdWCEMLQvWsBK03boOH tMIjUKnStbPk/0eScXVig0bs78g7tUmDFc49O7Fr1UVnAcaI+L8cP7IPtnisWTd3Zfsv TwlWsVYEMB0VFj2Bn7HGBf8OiXuwuczaQ6vPvwAGTT7u2yvLbHMlqfC0wV91/OUGmPPh eijw== 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: AOUpUlHqzwWGAJeYbN2RdGcSkikWIqurEpj+dvtewOiZzy8MHogpyWlb TpE/ck8a9KLnafhcHfpIlYRoNbKfkClY0zl/L01+zCII7O0YC04OdibDoyORSqjAd3c8WQ9roaN DE8yRpfwcTvD8nPdc5BjCWJvN6jBfVUzunux1x2egul61kgGEyEU901f/Hpr6zckf9g== X-Received: by 2002:a0c:881c:: with SMTP id 28-v6mr26517616qvl.109.1534414010486; Thu, 16 Aug 2018 03:06:50 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxqwIX09UI9lX2kMiYTF2RAZJUB9Tzl3b7QlthLy55lAmvbtUS+x2czHlKmelQgbWUrwP6h X-Received: by 2002:a0c:881c:: with SMTP id 28-v6mr26517581qvl.109.1534414009932; Thu, 16 Aug 2018 03:06:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534414009; cv=none; d=google.com; s=arc-20160816; b=ZjLK5ATX/9wT2cjUuKqndruM9gWV4UdoXf0eJVdi0RnnbCyarlYXto429RZzhwrFo8 5NbRTB0IVjW3XyGy1dqKr08VTj7Bv5cmOd/PadXWaQmsM9cTcy7QJCuyWEiSilaByNQ4 SgSRYJiZf5VZku+A5vfpXpC9sJqJsrlJ2EsaHRE6F/T5CzKvfCP7xRgg4I2j+PQzR5L7 0kDzkH4e1pRynsfWdwbziP5HeRV5FQXtPmFku7r8u8qf6K57p0OF17S15oH0DCQbBL9v r6ncs79AqseqaZipvVDu8vrBe8l3AvALx0UlN5nxqVYQLSEHTqW1XvUQwkdhKUL7LXVS 096g== 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=58eppWzBrms+oicXZ8vv1kTgC2Dj9f4AShb64br5H2I=; b=OepO0qLUOcmdtiL48AZwBIJvC+jyGqiT9RH4ecGHHcrblYsgnwFgRfvNabRULcCBBq axzIJT9WgnZf5lKw6KUSAxhYzdNQXiefsvEG7VOC1buWfphFNRanUSyA/65Za71HCMqj SexjhemSxaZU8V+8gnaQEhn0n4NkR1qY9LEk9oUmcLPO5Y+hFAZOXWIfX81QXtOXo2NY OG2RCLcIODXvY7KP5Y/70tvKCwQVKECKDSJus+YDJkYXQ7schvPV/bhLFh9ENVwqdxVO rmCy4DiIjh4wmTKH1WXYX40wrnyzIriVkYn2uLPoah5PTvvDJqK2oFtLnz7L0LHfjnIV 3oDQ== 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 r4-v6si2863534qkc.173.2018.08.16.03.06.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Aug 2018 03:06:49 -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 88F7840122D7; Thu, 16 Aug 2018 10:06:49 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-94.ams2.redhat.com [10.36.116.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 87D1210FFE7E; Thu, 16 Aug 2018 10:06:46 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, Andrew Morton , Michal Hocko , Vlastimil Babka , Stephen Rothwell , Pavel Tatashin , Kemi Wang , David Rientjes , Jia He , Oscar Salvador , Petr Tesarik , Andrey Ryabinin , Dan Williams , David Hildenbrand , Mathieu Malaterre , Baoquan He , Wei Yang , Ross Zwisler , "Kirill A . Shutemov" Subject: [PATCH v1 4/5] mm/memory_hotplug: onlining pages can only fail due to notifiers Date: Thu, 16 Aug 2018 12:06:27 +0200 Message-Id: <20180816100628.26428-5-david@redhat.com> In-Reply-To: <20180816100628.26428-1-david@redhat.com> References: <20180816100628.26428-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.5]); Thu, 16 Aug 2018 10:06:49 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Thu, 16 Aug 2018 10:06:49 +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). online_pages_range() can never fail. Signed-off-by: David Hildenbrand Reviewed-by: Pavel Tatashin --- mm/memory_hotplug.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 3dc6d2a309c2..bbbd16f9d877 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -933,13 +933,8 @@ 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; - } + walk_system_ram_range(pfn, nr_pages, &onlined_pages, + online_pages_range); zone->present_pages += onlined_pages; From patchwork Thu Aug 16 10:06:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 10567281 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 E2EA8139B for ; Thu, 16 Aug 2018 10:06:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF7D32856F for ; Thu, 16 Aug 2018 10:06:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C165A2A836; Thu, 16 Aug 2018 10:06: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=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 641542856F for ; Thu, 16 Aug 2018 10:06:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 32B756B026B; Thu, 16 Aug 2018 06:06:57 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2B4A56B026C; Thu, 16 Aug 2018 06:06:57 -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 157FD6B026D; Thu, 16 Aug 2018 06:06:57 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk0-f198.google.com (mail-qk0-f198.google.com [209.85.220.198]) by kanga.kvack.org (Postfix) with ESMTP id D7E836B026B for ; Thu, 16 Aug 2018 06:06:56 -0400 (EDT) Received: by mail-qk0-f198.google.com with SMTP id m2-v6so3855289qka.9 for ; Thu, 16 Aug 2018 03:06: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; bh=ZK8vEAn6/4gnVz/ZB766goJEE7u/KMHw+ZZsajH12tA=; b=bVEuMXzLepzEir1m1FLPZWjBfK3p1CAS+S9KHG1Sj7G3bcE2JLZzfdEsm2w1sQ158l 36BvogwFblDsfgRckSF0hMrtwJncFbbHolmZ2QpKtCl95xmD0CN1+dgyD9+fB7NFOmpc f9C8qWwyuy2sM3NyKBawLszgqNwhlGwsG3OfVqfzu2PrXNJ7+V9ZXxl8Wb+QW7VayLht OsSm/atXVlIQqq6f9hU/OpE3y87SCDOtaUWtObGugvG5daE9yp2YZo6OMaY699rfVYuF RwZrD6/WfDOwcip5ZZ72QEG9v6rNRXKEg+BvRKkgeVNOCyCgY1wFV2X+XVEzQymgNKpM Xh5Q== 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: AOUpUlEdNn7xUE3GvCGBquYNKPVo2njrBWhAau4JX4Dt2uyM/pemePUj m/GCi0HziBCmqgtp2ciOThv+MoMRONKuqB2dtKJY6ALw9Anck1mFcnY4nM/nnU6V5EanakCSStX 0TrpYKa988kK9m0UX3qCd931ELYhZ+WqWRoY1QRiASDUHd+lbUfqD9ra7Lh2CM7s6CQ== X-Received: by 2002:ac8:1019:: with SMTP id z25-v6mr29182765qti.25.1534414016633; Thu, 16 Aug 2018 03:06:56 -0700 (PDT) X-Google-Smtp-Source: AA+uWPx2Pz4YkABXG+uiH4zzQKLZbbgCnghlkhkaSlOLBHVU8aRcwMOVLniYRCvqQTVJbql7W8m+ X-Received: by 2002:ac8:1019:: with SMTP id z25-v6mr29182728qti.25.1534414016052; Thu, 16 Aug 2018 03:06:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534414016; cv=none; d=google.com; s=arc-20160816; b=U6HJMDCzg08bNwfI9o4f1PTrYbUwYMA+Pmhsgj4QVtqijOL/qa0ZMjuTcWGvCYA+lq zqorWoUfP1b/wPYbrGuthSgQeWgNYgW9kSnV+3anIH+9J+91nsnIhfdzeVNuNvnk3+Oz fm0chN7yA1fo6q5DvMMqA+o9kAYHQPAawP8k9NntY+RLogPDMpcHmWU3+Nst0vhsP92G P5rqzDhmUJqglFgj4ZwvxeU2mB1BZt0Yg22e7s7+p1BJnxWSRtB7Vd/psCFXTjW9Qkuv tTwgCRMG9hLMMIJvCu0cJ9d1Q6LCNMWDwDDKPRRL9ke4rMUntKXsDgIsPl1eh4W8jPHy YPYg== 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=ZK8vEAn6/4gnVz/ZB766goJEE7u/KMHw+ZZsajH12tA=; b=T48nGp57nEnYijzqqii4jyMYak+oWg93yHLwTLHTNVxJkfGeadfCnes+n0a7wD0Apj xAIeonW0Sk7GncJP6Sa/6S5UbfEYIXZ6KgqCwdVNMK3Kw9OMlIm9cOsEyzA1TYOT2c30 uu2yOTsAd1xHcU2xRtbd9MUNi4KSGu/rCgGv/4VnIf15R+YKxLWPk7fBAojr8SxZgPks IQKmhUN+k/kYs8Z7ZYsxaim6/br0IevViWI7jD1LXA+NnmCdA1qoiWtMj6QkGqKguPNP Mt6fBnuH/rZHNKMfQ9UBpDfQUyKvES98YnvKVyJvjfrfub0j63IKazenf1Xympzjaz+d qneQ== 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 30-v6si2579993qvt.193.2018.08.16.03.06.55 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Aug 2018 03:06:56 -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 7D82C400E9BA; Thu, 16 Aug 2018 10:06:55 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-94.ams2.redhat.com [10.36.116.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id C70011010413; Thu, 16 Aug 2018 10:06:49 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, Andrew Morton , Michal Hocko , Vlastimil Babka , Stephen Rothwell , Pavel Tatashin , Kemi Wang , David Rientjes , Jia He , Oscar Salvador , Petr Tesarik , Andrey Ryabinin , Dan Williams , David Hildenbrand , Mathieu Malaterre , Baoquan He , Wei Yang , Ross Zwisler , "Kirill A . Shutemov" Subject: [PATCH v1 5/5] mm/memory_hotplug: print only with DEBUG_VM in online/offline_pages() Date: Thu, 16 Aug 2018 12:06:28 +0200 Message-Id: <20180816100628.26428-6-david@redhat.com> In-Reply-To: <20180816100628.26428-1-david@redhat.com> References: <20180816100628.26428-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.7]); Thu, 16 Aug 2018 10:06:55 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Thu, 16 Aug 2018 10:06:55 +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 Let's try to minimze the noise. Signed-off-by: David Hildenbrand --- mm/memory_hotplug.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index bbbd16f9d877..6fec2dc6a73d 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -966,9 +966,11 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages, int online_typ return 0; failed_addition: +#ifdef CONFIG_DEBUG_VM pr_debug("online_pages [mem %#010llx-%#010llx] failed\n", (unsigned long long) pfn << PAGE_SHIFT, (((unsigned long long) pfn + nr_pages) << PAGE_SHIFT) - 1); +#endif memory_notify(MEM_CANCEL_ONLINE, &arg); return ret; } @@ -1660,7 +1662,9 @@ int offline_pages(unsigned long start_pfn, unsigned long nr_pages) offlined_pages = check_pages_isolated(start_pfn, end_pfn); if (offlined_pages < 0) goto repeat; +#ifdef CONFIG_DEBUG_VM pr_info("Offlined Pages %ld\n", offlined_pages); +#endif /* Ok, all of our target is isolated. We cannot do rollback at this point. */ offline_isolated_pages(start_pfn, end_pfn); @@ -1695,9 +1699,11 @@ int offline_pages(unsigned long start_pfn, unsigned long nr_pages) return 0; failed_removal: +#ifdef CONFIG_DEBUG_VM pr_debug("memory offlining [mem %#010llx-%#010llx] failed\n", (unsigned long long) start_pfn << PAGE_SHIFT, ((unsigned long long) end_pfn << PAGE_SHIFT) - 1); +#endif memory_notify(MEM_CANCEL_OFFLINE, &arg); /* pushback to free area */ undo_isolate_page_range(start_pfn, end_pfn, MIGRATE_MOVABLE);