From mboxrd@z Thu Jan 1 00:00:00 1970 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=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 4598FC433DB for ; Tue, 12 Jan 2021 03:43:36 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B31B4225AC for ; Tue, 12 Jan 2021 03:43:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B31B4225AC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 092826B00ED; Mon, 11 Jan 2021 22:43:35 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 01CD88D0051; Mon, 11 Jan 2021 22:43:34 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E27116B00F2; Mon, 11 Jan 2021 22:43:34 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0181.hostedemail.com [216.40.44.181]) by kanga.kvack.org (Postfix) with ESMTP id C87206B00ED for ; Mon, 11 Jan 2021 22:43:34 -0500 (EST) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 8DFEA1EE6 for ; Tue, 12 Jan 2021 03:43:34 +0000 (UTC) X-FDA: 77695728348.11.box06_4311ae927512 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin11.hostedemail.com (Postfix) with ESMTP id 6FEFE180F8B82 for ; Tue, 12 Jan 2021 03:43:34 +0000 (UTC) X-HE-Tag: box06_4311ae927512 X-Filterd-Recvd-Size: 4585 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf48.hostedemail.com (Postfix) with ESMTP for ; Tue, 12 Jan 2021 03:43:33 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id CFC95101E; Mon, 11 Jan 2021 19:43:32 -0800 (PST) Received: from [192.168.0.130] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E5A053F66E; Mon, 11 Jan 2021 19:43:28 -0800 (PST) Subject: Re: [PATCH V2 1/3] mm/hotplug: Prevalidate the address range being added with platform To: David Hildenbrand , linux-mm@kvack.org, akpm@linux-foundation.org, hca@linux.ibm.com, catalin.marinas@arm.com Cc: linux-arm-kernel@lists.infradead.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, Vasily Gorbik , Will Deacon , Ard Biesheuvel , Mark Rutland References: <1608218912-28932-1-git-send-email-anshuman.khandual@arm.com> <1608218912-28932-2-git-send-email-anshuman.khandual@arm.com> <10e733fa-4568-d38f-9b95-2ccc5dc627b8@redhat.com> From: Anshuman Khandual Message-ID: Date: Tue, 12 Jan 2021 09:13:49 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <10e733fa-4568-d38f-9b95-2ccc5dc627b8@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit 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: On 1/11/21 4:21 PM, David Hildenbrand wrote: > On 17.12.20 16:28, Anshuman Khandual wrote: >> This introduces memhp_range_allowed() which can be called in various memory >> hotplug paths to prevalidate the address range which is being added, with >> the platform. Then memhp_range_allowed() calls memhp_get_pluggable_range() >> which provides applicable address range depending on whether linear mapping >> is required or not. For ranges that require linear mapping, it calls a new >> arch callback arch_get_mappable_range() which the platform can override. So >> the new callback, in turn provides the platform an opportunity to configure >> acceptable memory hotplug address ranges in case there are constraints. >> >> This mechanism will help prevent platform specific errors deep down during >> hotplug calls. This drops now redundant check_hotplug_memory_addressable() >> check in __add_pages() but instead adds a VM_BUG_ON() check which would >> ensure that the range has been validated with memhp_range_allowed() earlier >> in the call chain. Besides memhp_get_pluggable_range() also can be used by >> potential memory hotplug callers to avail the allowed physical range which >> would go through on a given platform. >> >> This does not really add any new range check in generic memory hotplug but >> instead compensates for lost checks in arch_add_memory() where applicable >> and check_hotplug_memory_addressable(), with unified memhp_range_allowed(). >> > > Subject s/mm\/hotplug/mm\/memory_hotplug/ Sure, will do. > > Everywhere in this patch: Use "true/false" for boolean values. Sure, will change. > >> Cc: David Hildenbrand >> Cc: Andrew Morton >> Cc: linux-mm@kvack.org >> Cc: linux-kernel@vger.kernel.org >> Suggested-by: David Hildenbrand >> Signed-off-by: Anshuman Khandual >> --- >> include/linux/memory_hotplug.h | 10 +++++ >> mm/memory_hotplug.c | 79 +++++++++++++++++++++++++--------- >> mm/memremap.c | 6 +++ >> 3 files changed, 75 insertions(+), 20 deletions(-) >> >> diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h >> index 551093b74596..8d72354758c8 100644 >> --- a/include/linux/memory_hotplug.h >> +++ b/include/linux/memory_hotplug.h >> @@ -70,6 +70,9 @@ typedef int __bitwise mhp_t; >> */ >> #define MEMHP_MERGE_RESOURCE ((__force mhp_t)BIT(0)) >> >> +bool memhp_range_allowed(u64 start, u64 size, bool need_mapping); >> +struct range memhp_get_pluggable_range(bool need_mapping); > > AFAIKs, all memhp_get_pluggable_range() users pass "1". Right. > > What about the "add_pages()-only" path? I had dropped memhp_range_allowed() changes for add_pages() in pagemap_range() because you had mentioned not to add any new checks in the generic code. Will add it back if that is preferred.