Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp305808pxy; Wed, 21 Apr 2021 03:33:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxUretHAPdqunU0CuvrFDmLLIT1F42N2aq1o33xwQrLjlr36MmBW8FXkh/yJ9wX4cdXoplZ X-Received: by 2002:a17:906:98c1:: with SMTP id zd1mr32201213ejb.447.1619001216622; Wed, 21 Apr 2021 03:33:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619001216; cv=none; d=google.com; s=arc-20160816; b=PQfC+19DZgoy0IOxP8WODF+zykmIx1F3HdfWOGHEPCRhPw1Ucyhn+WGPgnQPGwrkzi nPrvmAxWEL9TnBXfaRWIKOEK9qGdp1gWcnlgDorr/y9U0x/AnsA6bwQHXHCaZuAFmj28 6HOQ3hFz0Y0VirwIk/2HM46u59XQXtTzIzIFbhtX6s/VuO7018MJ8W0xZuI57Y0OD7w1 RhxldN3lkkqzfkU3xEaY3mYK7EfcN/RqEiRtjNdkiFhQH8b4cKG8cGeRfY0e+kR/YQin uwKBBtBH6tf7ap+vEBElEEUjHNezxj6eQe1xiCi0rOs0NXX+7hrmul5V7tZODYcnGmpF BmPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=By+JfLRe/7H07/RdILTSBqgid2qky8ntDMjOgJ1YiYI=; b=AcIfx4dskWv2+Nfzbz0SDGFfM+2KLKsWAeUextdnr1+T3C9sJeEKjo895+D5K/Svb2 Rk5qNdeW1MpdWuVdx6PcjQos/TtedMA/D6f8b0C2ZWoxeTWS/gZaP5ENIarv1ZjsFAn0 OmYoA7WPrPQ9cQmGhovTjj7BwltgoqEVSVgQZom2A1rFBnqj6MLfbZQnm/8w490kFXe+ 2Ybl305++pCs1YcmYV8M8CgjPaV9Kp0fO9uwCuMISGKsNlrl3mgZ5byV2bVhaDLlKJIi 9W3/Slend24cU3e0qhGtnX79CtX7CDxeN8bz4eruCFzo9GSM/pFZnHc3ER8/G9KQ5o3D xyHw== 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 b18si1724764edr.597.2021.04.21.03.33.13; Wed, 21 Apr 2021 03:33:36 -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 S239323AbhDUK1o (ORCPT + 99 others); Wed, 21 Apr 2021 06:27:44 -0400 Received: from mx2.suse.de ([195.135.220.15]:38072 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238557AbhDUK1k (ORCPT ); Wed, 21 Apr 2021 06:27:40 -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 08DF5AF0C; Wed, 21 Apr 2021 10:27:07 +0000 (UTC) From: Oscar Salvador To: Andrew Morton Cc: David Hildenbrand , Michal Hocko , Anshuman Khandual , Vlastimil Babka , Pavel Tatashin , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Oscar Salvador Subject: [PATCH v10 2/8] mm,memory_hotplug: Relax fully spanned sections check Date: Wed, 21 Apr 2021 12:26:55 +0200 Message-Id: <20210421102701.25051-3-osalvador@suse.de> X-Mailer: git-send-email 2.13.7 In-Reply-To: <20210421102701.25051-1-osalvador@suse.de> References: <20210421102701.25051-1-osalvador@suse.de> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We want {online,offline}_pages to operate on whole memblocks, but memmap_on_memory will poke pageblock_nr_pages aligned holes in the beginning, which is a special case we want to allow. Relax the check to account for that case. Signed-off-by: Oscar Salvador Reviewed-by: David Hildenbrand Acked-by: Michal Hocko --- mm/memory_hotplug.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 0cdbbfbc5757..e6aafd17a01a 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -838,9 +838,16 @@ 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) */ + /* + * {on,off}lining is constrained to full memory sections (or more + * precisly to memory blocks from the user space POV). + * memmap_on_memory is an exception because it reserves initial part + * of the physical memory space for vmemmaps. That space is 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 +1580,16 @@ 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) */ + /* + * {on,off}lining is constrained to full memory sections (or more + * precisly to memory blocks from the user space POV). + * memmap_on_memory is an exception because it reserves initial part + * of the physical memory space for vmemmaps. That space is 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