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=-13.8 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,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 7AEC2C433FE for ; Thu, 10 Dec 2020 07:00:19 +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 2862122D5B for ; Thu, 10 Dec 2020 07:00:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2862122D5B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.ibm.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:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=JxzebRBTYuqpcjvWYSYzBJ9dB2IjuoKdvTgebsWdwzM=; b=dePSyjtXrPmYSPAScMiXD1waL vXERLJMtxb/AOFiW7AAc9f0COyhx2SrebfnkyjBR96q0u+GfnQQKpo57YQ9S9U936DkwZFr97PuRF eoCSfxSOhegyqlgOzv0flgcJ8AuyUYGsMT+ffgegPTU9eRpaq/E0vkgV1dG+Y0R98tSNFuQI8m8AY 2nVcGP0kV1YAWB3cYec6QuOMnYx0bJaGY/VfQFbpwIfoujGno7BbebgHEv0wWbE1yMrcXs4/bvKS2 il0QOZod6+1zP+AnQ2sr5RvWHxgVmubm5fQ8q1JC9ZWDyBgGKlNaaPOcr/BdYS/o4aKCmBi9qiAGa mb+ULVVMA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1knFun-0004E1-KG; Thu, 10 Dec 2020 06:59:02 +0000 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5] helo=mx0a-001b2d01.pphosted.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1knFul-0004DD-Hf for linux-arm-kernel@lists.infradead.org; Thu, 10 Dec 2020 06:59:00 +0000 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0BA6k3wX053355; Thu, 10 Dec 2020 01:58:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=pp1; bh=ATakwJINK6jnXKdq0dMDiMbEb7rzVkjImDTQ3oeVrrs=; b=qs+VAx5Pa/t45KFXarmsKvAgoxHH70Ora3rKINoRs45ItPoFIZ6Npaa5rL5KyuOczDbM qjT4mQ3udtD0FmB8OJyJjIm5pdeIk2icVLqjUer5pCefz98PqdTZ9HXGN8JfmdXDM8/V cI29jt1UQ0Cj/xfUomiVZ2RFQlMQKWnS3l/s2MfssYkWXCWc3JI0YUt2bfT0KNI6QA3g F/bD2e2OU5VfTHZUyUMab7EcD0AnuaR8xmUk4/3vhq+7KhFv6QKkguRXIIMpfw3pLf9D opsXsLFnAIT6+g9V518GqG8irmX8L5gW8Uum5+4mPctK+AM5MA385vFHOu5RcJa6SaH9 jA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 35beps88b5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Dec 2020 01:58:51 -0500 Received: from m0098414.ppops.net (m0098414.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 0BA6wpo4096854; Thu, 10 Dec 2020 01:58:51 -0500 Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0b-001b2d01.pphosted.com with ESMTP id 35beps88ah-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Dec 2020 01:58:51 -0500 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 0BA6vdl9005466; Thu, 10 Dec 2020 06:58:49 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma03ams.nl.ibm.com with ESMTP id 3581u85fhc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Dec 2020 06:58:49 +0000 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0BA6wlLW22479132 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 10 Dec 2020 06:58:47 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 55EFF42042; Thu, 10 Dec 2020 06:58:47 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D241F4203F; Thu, 10 Dec 2020 06:58:46 +0000 (GMT) Received: from osiris (unknown [9.171.82.177]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Thu, 10 Dec 2020 06:58:46 +0000 (GMT) Date: Thu, 10 Dec 2020 07:58:45 +0100 From: Heiko Carstens To: Anshuman Khandual Subject: Re: [PATCH 3/3] s390/mm: Define arch_get_mappable_range() Message-ID: <20201210065845.GA20691@osiris> References: <1607400978-31595-1-git-send-email-anshuman.khandual@arm.com> <1607400978-31595-4-git-send-email-anshuman.khandual@arm.com> <20201208152709.GA26979@osiris> <7484e153-6c77-8325-6195-621fe144011e@arm.com> <20201209145717.GD7160@osiris> <04da0f9c-d50e-7729-5e4c-b0dc4e76d608@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <04da0f9c-d50e-7729-5e4c-b0dc4e76d608@arm.com> X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.343, 18.0.737 definitions=2020-12-10_01:2020-12-09, 2020-12-10 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 spamscore=0 adultscore=0 mlxlogscore=999 impostorscore=0 malwarescore=0 phishscore=0 lowpriorityscore=0 priorityscore=1501 bulkscore=0 suspectscore=1 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2012100039 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201210_015859_695365_B4AF51E4 X-CRM114-Status: GOOD ( 31.33 ) 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 , david@redhat.com, catalin.marinas@arm.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, Will Deacon , Ard Biesheuvel , linux-arm-kernel@lists.infradead.org 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 Thu, Dec 10, 2020 at 09:48:11AM +0530, Anshuman Khandual wrote: > >> Alternatively leaving __segment_load() and vmem_add_memory() unchanged > >> will create three range checks i.e two memhp_range_allowed() and the > >> existing VMEM_MAX_PHYS check in vmem_add_mapping() on all the hotplug > >> paths, which is not optimal. > > > > Ah, sorry. I didn't follow this discussion too closely. I just thought > > my point of view would be clear: let's not have two different ways to > > check for the same thing which must be kept in sync. > > Therefore I was wondering why this next version is still doing > > that. Please find a way to solve this. > > The following change is after the current series and should work with > and without memory hotplug enabled. There will be just a single place > i.e vmem_get_max_addr() to update in case the maximum address changes > from VMEM_MAX_PHYS to something else later. Still not. That's way too much code churn for what you want to achieve. If the s390 specific patch would look like below you can add Acked-by: Heiko Carstens But please make sure that the arch_get_mappable_range() prototype in linux/memory_hotplug.h is always visible and does not depend on CONFIG_MEMORY_HOTPLUG. I'd like to avoid seeing sparse warnings because of this. Thanks. diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c index 77767850d0d0..e0e78234ae57 100644 --- a/arch/s390/mm/init.c +++ b/arch/s390/mm/init.c @@ -291,6 +291,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, 1)); 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 b239f2ba93b0..ccd55e2f97f9 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 range; + + range.start = 0; + range.end = VMEM_MAX_PHYS; + return 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(); + if (start < range.start || + start + size > range.end || 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