Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4587363pxu; Wed, 9 Dec 2020 23:41:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJyzvttEkEWHyLMyRszfa999lzV2QcDL6cENExCeDSPs48Dt2SWcdUMWI2///a92EiymgJjQ X-Received: by 2002:a17:906:6010:: with SMTP id o16mr5321437ejj.55.1607586061677; Wed, 09 Dec 2020 23:41:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607586061; cv=none; d=google.com; s=arc-20160816; b=fjH+OG+P8/ruMGlTdeVwYTY+e+FNsy/FK4AAuUp09jvMxhgwOMBFPqpCGXUrzmzaRP nvQFxoO4PUJcbgXgTerLye1cYvCwLWKRkxOM5Us6E2D3O8mkQS0jCpW5YOxyPbjFimLm NHSmVEyQCdR42/e2hHFAfa1R3ru1qi/FvQXNFWpciXzwmPxwDmqa6Ig47hm+NU+AwKPu u1UaQBvnNlb/Z6/X9wDfWJCz7qMp1b3azZKU+DmaM2rzltKxxeB41jQbTxMk8f6jnYXg /QMdVsBRGuzuSYTxcrC5YP+tHM2ToGUQmdzcVghausNpGrs2w6BuoylBVeZH8RzZd2mn Ex2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:in-reply-to:cc:references:message-id:date :subject:mime-version:from:content-transfer-encoding:dkim-signature; bh=HcG7hVx/CRN4t/5i18tJCttaxP6IQshP6VJEl2g4fpM=; b=rd4WZmxLyRFxjK3PItQpqTEHDiYrx1eL6g0i119HnKM70FL+TVqEonLZUYwYLfnRmw 432e1+NiiKWvJc2e9Pf8lCRI+nQQVG01CvpXc3jD5efq7U0EvmbJvXbpRbPB9yU641bg 8n4w00DARo4tyDeOYKbG5EcQVshO1RiLb+5ug4SV50auq1sQDMBABjgqU5kHJcNnqtzP BsOOnXPdAs+zc9A67QhHT0PSlwXiiO8pCsBuyjTcfLv5yA+NxQKkc2m2wnNk5QGcGMBy jiAaXdMgriCvlkiyzXcP0TDil/iAvko2q8XuRj1rVIUKA6UzEwlE+MadF1rcFmrgjl5B tNWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=A6+IXha+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dm18si373933edb.422.2020.12.09.23.40.39; Wed, 09 Dec 2020 23:41:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=A6+IXha+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732603AbgLJHGF (ORCPT + 99 others); Thu, 10 Dec 2020 02:06:05 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:58312 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730497AbgLJHGF (ORCPT ); Thu, 10 Dec 2020 02:06:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607583878; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HcG7hVx/CRN4t/5i18tJCttaxP6IQshP6VJEl2g4fpM=; b=A6+IXha+DqFWDFAqkeJst1fUW4UpUXMtwt/7paPcQsnRqnzkpHois8SFth7lFXsPHaEsp1 qluF2v2kPr21QN8632/rQkF6BQ3CLwBgtyHzxpQDLJwHrFucFNaC/CeZAXGifjYgHHMQMj kA4/PiiMejk94VxqaOXHx4itBHKTOKY= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-108--AjKL-wtOL-PFoU-RMs5cA-1; Thu, 10 Dec 2020 02:04:36 -0500 X-MC-Unique: -AjKL-wtOL-PFoU-RMs5cA-1 Received: by mail-wm1-f71.google.com with SMTP id q17so837089wmc.1 for ; Wed, 09 Dec 2020 23:04:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:content-transfer-encoding:from:mime-version :subject:date:message-id:references:cc:in-reply-to:to; bh=HcG7hVx/CRN4t/5i18tJCttaxP6IQshP6VJEl2g4fpM=; b=Pfv/AwvIgJX34CIiKwmxMsmhOFDCN0npgkAadm3B5CWSKbquk/w+As0IH27vEUXjD6 f6kjUi9cbIc1vrEn+Qea701+7YnQuVEX0JzjTplyvzq4v6LEgAbGmbrGj0VNQjAm+Sty qiOMqhGBchKBs/7kVUyxJhN561nWK/3ZCHCIyYiFBrTjzikDXi9nCZl6jd5kVZRu1J1y Am/k+ez5rTlqA3kEObWMlmbHYQmKFlcwQAVYI1x1QLK5s2UljGcL7kSaoFJD4bOBsgbj h7a9WWv3AnuL+b35WPK4RAj6kAvv+USSNbQWNwHPNeNhswzW3rfvMDsGCrTV3+RhUIgw 6syw== X-Gm-Message-State: AOAM53252rk4w7zSRN4rPW1yJp4bKb3GaKpvl30aalU88q0tSviT/iVj izvhyC0XFyLXfRQODIiuqBYVXf7P8mWwNrGdUYqGv/ICgMvvYptH0KlQXlPytUWfABk1UEisoRC mMnn6iIKcqTldolFmm6Ikd6oy X-Received: by 2002:a5d:4112:: with SMTP id l18mr6419179wrp.116.1607583874813; Wed, 09 Dec 2020 23:04:34 -0800 (PST) X-Received: by 2002:a5d:4112:: with SMTP id l18mr6419156wrp.116.1607583874621; Wed, 09 Dec 2020 23:04:34 -0800 (PST) Received: from [192.168.3.114] (p4ff23fc5.dip0.t-ipconnect.de. [79.242.63.197]) by smtp.gmail.com with ESMTPSA id q17sm7350456wrr.53.2020.12.09.23.04.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 09 Dec 2020 23:04:33 -0800 (PST) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: David Hildenbrand Mime-Version: 1.0 (1.0) Subject: Re: [PATCH 3/3] s390/mm: Define arch_get_mappable_range() Date: Thu, 10 Dec 2020 08:04:32 +0100 Message-Id: References: <20201210065845.GA20691@osiris> Cc: Anshuman Khandual , linux-mm@kvack.org, akpm@linux-foundation.org, david@redhat.com, catalin.marinas@arm.com, linux-arm-kernel@lists.infradead.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, Vasily Gorbik , Will Deacon , Ard Biesheuvel , Mark Rutland In-Reply-To: <20201210065845.GA20691@osiris> To: Heiko Carstens X-Mailer: iPhone Mail (18B92) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > Am 10.12.2020 um 07:58 schrieb Heiko Carstens : >=20 > =EF=BB=BFOn 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. >>>=20 >>> 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. >>=20 >> 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. >=20 > 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 >=20 > Acked-by: Heiko Carstens >=20 > 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. >=20 > Thanks. >=20 > 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 !=3D PAGE_KERNEL.pgprot)) > return -EINVAL; >=20 > + VM_BUG_ON(!memhp_range_allowed(start, size, 1)); > rc =3D 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 > */ >=20 > +#include > #include > #include > #include > @@ -532,11 +533,23 @@ void vmem_remove_mapping(unsigned long start, unsign= ed long size) > mutex_unlock(&vmem_mutex); > } >=20 > +struct range arch_get_mappable_range(void) > +{ > + struct range range; > + > + range.start =3D 0; > + range.end =3D VMEM_MAX_PHYS; > + return range; > +} > + > int vmem_add_mapping(unsigned long start, unsigned long size) > { > + struct range range; > int ret; >=20 > - if (start + size > VMEM_MAX_PHYS || > + range =3D arch_get_mappable_range(); > + if (start < range.start || > + start + size > range.end || > start + size < start) > return -ERANGE; >=20 >=20 Right, what I had in mind as reply to v1. Not sure if we really need new che= cks in common code. Having a new memhp_get_pluggable_range() would be suffic= ient for my use case (virtio-mem).=