From patchwork Tue Feb 9 13:38:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 12078185 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4498AC433E0 for ; Tue, 9 Feb 2021 13:39:14 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C6D0D64ECC for ; Tue, 9 Feb 2021 13:39:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C6D0D64ECC Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 123636B0072; Tue, 9 Feb 2021 08:39:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0FD666B0073; Tue, 9 Feb 2021 08:39:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DF5676B0074; Tue, 9 Feb 2021 08:39:04 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0157.hostedemail.com [216.40.44.157]) by kanga.kvack.org (Postfix) with ESMTP id C49376B0072 for ; Tue, 9 Feb 2021 08:39:04 -0500 (EST) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 8DECBAC09 for ; Tue, 9 Feb 2021 13:39:04 +0000 (UTC) X-FDA: 77798835408.24.chain98_371089627607 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin24.hostedemail.com (Postfix) with ESMTP id 711571A4A0 for ; Tue, 9 Feb 2021 13:39:04 +0000 (UTC) X-HE-Tag: chain98_371089627607 X-Filterd-Recvd-Size: 2470 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf17.hostedemail.com (Postfix) with ESMTP for ; Tue, 9 Feb 2021 13:39:03 +0000 (UTC) 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 0C6A1B113; Tue, 9 Feb 2021 13:39:03 +0000 (UTC) From: Oscar Salvador To: Andrew Morton Cc: David Hildenbrand , Michal Hocko , VlastimilBabkavbabka@suse.cz, pasha.tatashin@soleen.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Anshuman Khandual , Oscar Salvador Subject: [PATCH v2 5/7] mm,memory_hotplug: Enforce pageblock alignment when memmap_on_memory Date: Tue, 9 Feb 2021 14:38:52 +0100 Message-Id: <20210209133854.17399-6-osalvador@suse.de> X-Mailer: git-send-email 2.13.7 In-Reply-To: <20210209133854.17399-1-osalvador@suse.de> References: <20210209133854.17399-1-osalvador@suse.de> 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: Many places expects us to pass a pageblock aligned range. E.g: memmap_init_zone() needs a pageblock aligned range in order to set the proper migrate type for it. online_pages() needs to operate on a pageblock aligned range for isolation purposes. Make sure we disable the feature in case we cannot guarantee the right alignment. Signed-off-by: Oscar Salvador --- mm/memory_hotplug.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index d3fb036d33fd..1a4d5dd1a2c8 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -56,12 +56,16 @@ static int memmap_on_memory_show(char *buffer, const struct kernel_param *kp) static __meminit int memmap_on_memory_store(const char *val, const struct kernel_param *kp) { + unsigned long pageblock_size = PFN_PHYS(pageblock_nr_pages); + /* * Fail silently in case we cannot enable it due to system constraints. * User can always check whether it is enabled or not via /sys/module. */ if (!IS_ENABLED(CONFIG_ARCH_MHP_MEMMAP_ON_MEMORY_ENABLE) || - (PMD_SIZE % sizeof(struct page))) + (PMD_SIZE % sizeof(struct page)) || + !(MIN_MEMORY_BLOCK_SIZE - PMD_SIZE) || + !(MIN_MEMORY_BLOCK_SIZE - PMD_SIZE) % pageblock_size) return 0; return param_set_bool(val, kp);