Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp384734pxf; Thu, 8 Apr 2021 05:19:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxnCAcE7VrKb68zt8BR5Wg3rlfM0z/nlBDSHTUxw1+ueXQmBHSDlx0880ASWjUtpkdn7NEn X-Received: by 2002:a17:906:a052:: with SMTP id bg18mr9994690ejb.18.1617884377995; Thu, 08 Apr 2021 05:19:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617884377; cv=none; d=google.com; s=arc-20160816; b=uPxHQuZI03xTVe4TMaMKtUCHQWHRRFH3meF3Woih7mg4TWZQYVZWtSTKn26ctgFAQT VlY0KmZxy02aSKDMOoa1cjc3AM207DM18kSulT6X5BMrOXYS8vZBR7pN0KFpMPKpCB+I AfpRNFxyQMqtPm0lAUOUcd8lasyjoUbZoWHhSdmtNQMuZNJStpOgFi7dWs5AxVFx8NPo 3xi/JIwu4OZ1hxCJigrvrQJoawApamkKFrn8Cb2hbD3HkElSvO1M6VAZJGeI90E4hZJw d1SK8NrOVUGBzohjM9GAUF5AAVlSHVfvFkTX3CJxx4raqdgzxjrRLEX83BDerKnreW4J eiPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=7j93dHeuaik2ETy62AZbio77pE09fWTUhdv6Eq0U2hc=; b=T1mH/TOiKqLqx/oMgDtAdKDyqbOV8Rei5/zXc9qrrBgg6H0ujew4+PHx+X9h5W2jew ytQ7KwnlWcLYWceXP7ksCPkoUEA9qwshQ4JxG94GZOGBIy6e2tMQ+KnxoipTxZcme52r ZBbKmyNniCjfN3d9aQMZ+uLRDvp3OxN9plGcKcWNbnbWbUoG9y/NtHUS+0aR3mJeLXL3 Eiuk9YF7jACt31xMXW0BEk9EB/QODUkJmtnKaWMXeGpHGu5TIramHiNdmNOE9tHpLn0o oOrAfyzzQPlzn5xyLHXfuK9sXYRwpGTcxoI1npGsOYSllLVAYXA9ftsWzpfDimP6pxAP 60Xg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hc39si21446606ejc.125.2021.04.08.05.19.14; Thu, 08 Apr 2021 05:19:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231446AbhDHMSb (ORCPT + 99 others); Thu, 8 Apr 2021 08:18:31 -0400 Received: from mx2.suse.de ([195.135.220.15]:39390 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231248AbhDHMS3 (ORCPT ); Thu, 8 Apr 2021 08:18:29 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id B4130B007; Thu, 8 Apr 2021 12:18:17 +0000 (UTC) From: Oscar Salvador To: Andrew Morton Cc: David Hildenbrand , Michal Hocko , Anshuman Khandual , Pavel Tatashin , Vlastimil Babka , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Oscar Salvador Subject: [PATCH v7 2/8] mm,memory_hotplug: Relax fully spanned sections check Date: Thu, 8 Apr 2021 14:17:58 +0200 Message-Id: <20210408121804.10440-3-osalvador@suse.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210408121804.10440-1-osalvador@suse.de> References: <20210408121804.10440-1-osalvador@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When using self-hosted vmemmap pages, the number of pages passed to {online,offline}_pages might not fully span sections, but they always fully span pageblocks. Relax the check account for that case. Signed-off-by: Oscar Salvador Reviewed-by: David Hildenbrand --- mm/memory_hotplug.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 0cdbbfbc5757..25e59d5dc13c 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -838,9 +838,14 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages, int ret; struct memory_notify arg; - /* We can only online full sections (e.g., SECTION_IS_ONLINE) */ + /* We can only offline full sections (e.g., SECTION_IS_ONLINE). + * However, when using e.g: memmap_on_memory, some pages are initialized + * prior to calling in here. The remaining amount of pages must be + * pageblock aligned. + */ if (WARN_ON_ONCE(!nr_pages || - !IS_ALIGNED(pfn | nr_pages, PAGES_PER_SECTION))) + !IS_ALIGNED(pfn, pageblock_nr_pages) || + !IS_ALIGNED(pfn + nr_pages, PAGES_PER_SECTION))) return -EINVAL; mem_hotplug_begin(); @@ -1573,9 +1578,14 @@ int __ref offline_pages(unsigned long start_pfn, unsigned long nr_pages) int ret, node; char *reason; - /* We can only offline full sections (e.g., SECTION_IS_ONLINE) */ + /* We can only offline full sections (e.g., SECTION_IS_ONLINE). + * However, when using e.g: memmap_on_memory, some pages are initialized + * prior to calling in here. The remaining amount of pages must be + * pageblock aligned. + */ if (WARN_ON_ONCE(!nr_pages || - !IS_ALIGNED(start_pfn | nr_pages, PAGES_PER_SECTION))) + !IS_ALIGNED(start_pfn, pageblock_nr_pages) || + !IS_ALIGNED(start_pfn + nr_pages, PAGES_PER_SECTION))) return -EINVAL; mem_hotplug_begin(); -- 2.16.3