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,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=unavailable 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 9EE89C433E0 for ; Tue, 12 Jan 2021 03:44:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5F7AB225AC for ; Tue, 12 Jan 2021 03:44:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727939AbhALDoT (ORCPT ); Mon, 11 Jan 2021 22:44:19 -0500 Received: from foss.arm.com ([217.140.110.172]:39592 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727762AbhALDoT (ORCPT ); Mon, 11 Jan 2021 22:44:19 -0500 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.