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. .*/