Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp276566pxb; Fri, 16 Apr 2021 05:32:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwWeSGdLeJpLvA3vd8xEphbFrhhXh0yCSgXuPsmVcIi9CUZ0TZZLgfhYfqrQ52p0rBOTtse X-Received: by 2002:a17:907:6289:: with SMTP id nd9mr8001481ejc.384.1618576345115; Fri, 16 Apr 2021 05:32:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618576345; cv=none; d=google.com; s=arc-20160816; b=LTRSuXEZw34XZ4cdv3TTj6EiwLuft3sLV+0d8yJxW1+d74JbhjltxIS38xiBq18VZJ 3cE+gBW2kPtHikY6fFzpX/k+ViWehjSyGSP/Yn+NVv0ZIgsZUhysMJZ9NiHWmG0Kvdg3 8tWtoqUb1juUAuPNWDpuM7v2Xsoi1+BRrhCvUW+GlUAA2R965Nzj5VYMkGNilFGAEZTx c9FjOQQXwD0pCOWEBpHdBySJFQpwjhmR1w+Gk5avYHuVk8ebxw3csWyhA0HSwgAHve0J sIYv4UqFOX1T/J87sFvdRd71Cij+1r6irVgwBZkKzI4UBfH12Tv4ZThjn60HThvXv+od lhbQ== 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=Zdu8a48z8N16DrhPTm7u6fI1vtLhZ1u1TFKoHMd24tPHrrhw10m8262wdztwBLckM/ YuMwvOWZbwIT0SPhIfNdKfM2JqyB0N8XNXfYYUDN69QLLYseiiIazbi21AbnulfpVmaC +SPYwTdL8gl+wyoYlERnHb/FSB/j/ehC72cUFScjmDQFAbpqv4yJpXJgjN+LU1+eLS0b 80I/C7WyeU+hENsDnmEWHmC2sVdscsL09XWVZ3Cy0y+87+768PPj69Iah62awbU5R/g1 bZZ45+C2+wTTxtWfljKSrwbc1qhlzzprtFPs5llK2VW5eWb5SiLIYj0xTdRB9lCBaao7 sMUg== 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 ay9si2046993edb.12.2021.04.16.05.32.01; Fri, 16 Apr 2021 05:32:25 -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 S241947AbhDPLYu (ORCPT + 99 others); Fri, 16 Apr 2021 07:24:50 -0400 Received: from mx2.suse.de ([195.135.220.15]:48596 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239904AbhDPLYr (ORCPT ); Fri, 16 Apr 2021 07:24:47 -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 9ABDAB029; Fri, 16 Apr 2021 11:24:22 +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 v9 2/8] mm,memory_hotplug: Relax fully spanned sections check Date: Fri, 16 Apr 2021 13:24:05 +0200 Message-Id: <20210416112411.9826-3-osalvador@suse.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210416112411.9826-1-osalvador@suse.de> References: <20210416112411.9826-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