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 2DE66C433DB for ; Wed, 20 Jan 2021 08:30:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CB24F20708 for ; Wed, 20 Jan 2021 08:30:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730778AbhATIaW (ORCPT ); Wed, 20 Jan 2021 03:30:22 -0500 Received: from foss.arm.com ([217.140.110.172]:49836 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730313AbhATI3I (ORCPT ); Wed, 20 Jan 2021 03:29:08 -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 CE2A611B3; Wed, 20 Jan 2021 00:28:13 -0800 (PST) Received: from [10.163.90.172] (unknown [10.163.90.172]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0FC453F68F; Wed, 20 Jan 2021 00:28:09 -0800 (PST) Subject: Re: [PATCH V3 3/3] s390/mm: Define arch_get_mappable_range() To: David Hildenbrand , linux-mm@kvack.org, akpm@linux-foundation.org, hca@linux.ibm.com, catalin.marinas@arm.com Cc: Oscar Salvador , Vasily Gorbik , Will Deacon , Ard Biesheuvel , Mark Rutland , linux-arm-kernel@lists.infradead.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org References: <1610975582-12646-1-git-send-email-anshuman.khandual@arm.com> <1610975582-12646-4-git-send-email-anshuman.khandual@arm.com> From: Anshuman Khandual Message-ID: Date: Wed, 20 Jan 2021 13:58:32 +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: 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/19/21 5:56 PM, David Hildenbrand wrote: > On 18.01.21 14:13, Anshuman Khandual wrote: >> This overrides arch_get_mappabble_range() on s390 platform which will be >> used with recently added generic framework. It modifies the existing range >> check in vmem_add_mapping() using arch_get_mappable_range(). It also adds a >> VM_BUG_ON() check that would ensure that memhp_range_allowed() has already >> been called on the hotplug path. >> >> Cc: Heiko Carstens >> Cc: Vasily Gorbik >> Cc: David Hildenbrand >> Cc: linux-s390@vger.kernel.org >> Cc: linux-kernel@vger.kernel.org >> Acked-by: Heiko Carstens >> Signed-off-by: Anshuman Khandual >> --- >> arch/s390/mm/init.c | 1 + >> arch/s390/mm/vmem.c | 15 ++++++++++++++- >> 2 files changed, 15 insertions(+), 1 deletion(-) >> >> diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c >> index 73a163065b95..97017a4bcc90 100644 >> --- a/arch/s390/mm/init.c >> +++ b/arch/s390/mm/init.c >> @@ -297,6 +297,7 @@ int arch_add_memory(int nid, u64 start, u64 size, >> if (WARN_ON_ONCE(params->pgprot.pgprot != PAGE_KERNEL.pgprot)) >> return -EINVAL; >> >> + VM_BUG_ON(!memhp_range_allowed(start, size, true)); >> rc = vmem_add_mapping(start, size); >> if (rc) >> return rc; >> diff --git a/arch/s390/mm/vmem.c b/arch/s390/mm/vmem.c >> index 01f3a5f58e64..afc39ff1cc8d 100644 >> --- a/arch/s390/mm/vmem.c >> +++ b/arch/s390/mm/vmem.c >> @@ -4,6 +4,7 @@ >> * Author(s): Heiko Carstens >> */ >> >> +#include >> #include >> #include >> #include >> @@ -532,11 +533,23 @@ void vmem_remove_mapping(unsigned long start, unsigned long size) >> mutex_unlock(&vmem_mutex); >> } >> >> +struct range arch_get_mappable_range(void) >> +{ >> + struct range memhp_range; > > You could do: > > memhp_range = { > .start = 0, > .end = VMEM_MAX_PHYS - 1, > }; > > Similar in the arm64 patch. There is a comment block just before this assignment on arm64. Also it seems like code style preference and Heiko had originally agreed on this particular patch. Could we just leave it unchanged please ? > >> + >> + memhp_range.start = 0; >> + memhp_range.end = VMEM_MAX_PHYS - 1; >> + return memhp_range; >> +} >> + >> int vmem_add_mapping(unsigned long start, unsigned long size) >> { >> + struct range range; >> int ret; >> >> - if (start + size > VMEM_MAX_PHYS || >> + range = arch_get_mappable_range(); > > You could do > > struct range range = arch_get_mappable_range(); Sure, will change this though. > >> + if (start < range.start || >> + start + size > range.end + 1 || >> start + size < start) >> return -ERANGE; >> >> > > 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.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,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 123BEC433DB for ; Wed, 20 Jan 2021 08:29:45 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id ADB4B22202 for ; Wed, 20 Jan 2021 08:29:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ADB4B22202 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=feBUpElGPZXi4728FwJbw8LzOc1zrBLp2Ro9LHxv5VQ=; b=J/y4CHUOp1zmfDK4Xt3TxAy9P /12G0zjhMwpQW/VHtkd2N3Kfamrmm4GchYuH05n6qP++X+nsOEFL2k72ayWwxrOBpsT5gA0wrI7Fq jJz8NK1NstUl1J7hP21Z+Mr1C1271mwQnaKRlh2AL8CAmGIiMGtQLswPUdDN1BG9cqC/a3gUAexfI Ryp1w1qbvnSQHlrnFYerUGyk7I1n/Ky4V92M8fVFZwJpWhuJDDbSVJM8uK9d3U5WA+E+Ul11Lb3EW 1GXk0oz4Q4kxHgXtESoJcXmC+aKWoBWZu3op74g15/t9dfKHyGXrr8zJjNcIfzbjI8ROfB4gJ+dFg 55U3PUOaw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l28qh-0003tw-PB; Wed, 20 Jan 2021 08:28:19 +0000 Received: from foss.arm.com ([217.140.110.172]) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l28qe-0003sx-TD for linux-arm-kernel@lists.infradead.org; Wed, 20 Jan 2021 08:28:17 +0000 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 CE2A611B3; Wed, 20 Jan 2021 00:28:13 -0800 (PST) Received: from [10.163.90.172] (unknown [10.163.90.172]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0FC453F68F; Wed, 20 Jan 2021 00:28:09 -0800 (PST) Subject: Re: [PATCH V3 3/3] s390/mm: Define arch_get_mappable_range() To: David Hildenbrand , linux-mm@kvack.org, akpm@linux-foundation.org, hca@linux.ibm.com, catalin.marinas@arm.com References: <1610975582-12646-1-git-send-email-anshuman.khandual@arm.com> <1610975582-12646-4-git-send-email-anshuman.khandual@arm.com> From: Anshuman Khandual Message-ID: Date: Wed, 20 Jan 2021 13:58:32 +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: Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210120_032817_128495_473B0D1E X-CRM114-Status: GOOD ( 23.12 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , linux-s390@vger.kernel.org, Vasily Gorbik , linux-kernel@vger.kernel.org, Will Deacon , Ard Biesheuvel , linux-arm-kernel@lists.infradead.org, Oscar Salvador Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 1/19/21 5:56 PM, David Hildenbrand wrote: > On 18.01.21 14:13, Anshuman Khandual wrote: >> This overrides arch_get_mappabble_range() on s390 platform which will be >> used with recently added generic framework. It modifies the existing range >> check in vmem_add_mapping() using arch_get_mappable_range(). It also adds a >> VM_BUG_ON() check that would ensure that memhp_range_allowed() has already >> been called on the hotplug path. >> >> Cc: Heiko Carstens >> Cc: Vasily Gorbik >> Cc: David Hildenbrand >> Cc: linux-s390@vger.kernel.org >> Cc: linux-kernel@vger.kernel.org >> Acked-by: Heiko Carstens >> Signed-off-by: Anshuman Khandual >> --- >> arch/s390/mm/init.c | 1 + >> arch/s390/mm/vmem.c | 15 ++++++++++++++- >> 2 files changed, 15 insertions(+), 1 deletion(-) >> >> diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c >> index 73a163065b95..97017a4bcc90 100644 >> --- a/arch/s390/mm/init.c >> +++ b/arch/s390/mm/init.c >> @@ -297,6 +297,7 @@ int arch_add_memory(int nid, u64 start, u64 size, >> if (WARN_ON_ONCE(params->pgprot.pgprot != PAGE_KERNEL.pgprot)) >> return -EINVAL; >> >> + VM_BUG_ON(!memhp_range_allowed(start, size, true)); >> rc = vmem_add_mapping(start, size); >> if (rc) >> return rc; >> diff --git a/arch/s390/mm/vmem.c b/arch/s390/mm/vmem.c >> index 01f3a5f58e64..afc39ff1cc8d 100644 >> --- a/arch/s390/mm/vmem.c >> +++ b/arch/s390/mm/vmem.c >> @@ -4,6 +4,7 @@ >> * Author(s): Heiko Carstens >> */ >> >> +#include >> #include >> #include >> #include >> @@ -532,11 +533,23 @@ void vmem_remove_mapping(unsigned long start, unsigned long size) >> mutex_unlock(&vmem_mutex); >> } >> >> +struct range arch_get_mappable_range(void) >> +{ >> + struct range memhp_range; > > You could do: > > memhp_range = { > .start = 0, > .end = VMEM_MAX_PHYS - 1, > }; > > Similar in the arm64 patch. There is a comment block just before this assignment on arm64. Also it seems like code style preference and Heiko had originally agreed on this particular patch. Could we just leave it unchanged please ? > >> + >> + memhp_range.start = 0; >> + memhp_range.end = VMEM_MAX_PHYS - 1; >> + return memhp_range; >> +} >> + >> int vmem_add_mapping(unsigned long start, unsigned long size) >> { >> + struct range range; >> int ret; >> >> - if (start + size > VMEM_MAX_PHYS || >> + range = arch_get_mappable_range(); > > You could do > > struct range range = arch_get_mappable_range(); Sure, will change this though. > >> + if (start < range.start || >> + start + size > range.end + 1 || >> start + size < start) >> return -ERANGE; >> >> > > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel