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.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 D17B3C433FE for ; Thu, 10 Dec 2020 07:04:40 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 746072332A for ; Thu, 10 Dec 2020 07:04:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 746072332A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id CF52C6B0036; Thu, 10 Dec 2020 02:04:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CA51E6B005D; Thu, 10 Dec 2020 02:04:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BBAB66B0068; Thu, 10 Dec 2020 02:04:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0063.hostedemail.com [216.40.44.63]) by kanga.kvack.org (Postfix) with ESMTP id B0A0B6B0036 for ; Thu, 10 Dec 2020 02:04:39 -0500 (EST) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 8A0F38249980 for ; Thu, 10 Dec 2020 07:04:39 +0000 (UTC) X-FDA: 77576484678.21.patch84_07018ca273f6 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin21.hostedemail.com (Postfix) with ESMTP id 69BCD180442C3 for ; Thu, 10 Dec 2020 07:04:39 +0000 (UTC) X-HE-Tag: patch84_07018ca273f6 X-Filterd-Recvd-Size: 6978 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by imf11.hostedemail.com (Postfix) with ESMTP for ; Thu, 10 Dec 2020 07:04:38 +0000 (UTC) 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=D+qsMk9P8msfU/UWlX9KuGHa6JZv3IFZ37amMy4Fu5I=; b=aP+MUm1vfnqkWrjVWwo6UsABjZZjvimQeGfEsT3YtnRY8h98fIItqNeiAYnkw8cZ/9CQB+ PLehI4pBwCDL4gXFSiimbG5lZjoLRAk0jjZvqiDr9ISTLqs6iLldOkksZH7ifobW5JjDJN zMvSo+xwo3TF6fauK50vx4LAlSrXgrk= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-102-wT3oREJ8MHiY4le2b34REA-1; Thu, 10 Dec 2020 02:04:36 -0500 X-MC-Unique: wT3oREJ8MHiY4le2b34REA-1 Received: by mail-wm1-f69.google.com with SMTP id u123so835107wmu.5 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=JbqMOdFRs1R5I2U8KTvyfoWOeITptpCmBlOQmyhaVssXfyMMD+EzlYG91rHGHCCrOa XnsuL3rtn/qLbsV4eE2530W8vcL6qWIF4S9AK6DBo2vpJW2IdiXqTCn9aSAVEvYpnItX 1lf/spV1Usj1/Kmv3W3w15lAS+6OORdKOWKhoYOuls6nl2BDzmSWClylUjMarjt/x/fN fsbPBrWGlmt+5CFsUrLoiP2PKcgBsjk8rtVl5J5iv49/SBwJWX1ahDkG9Os34T2T1zel aMrwraEHOlNdKGTCesdlbBxBypE9Tk4IchVqOo7Ys2LMYJNhUKVIWXGGiP4KEGX0BCJv 2Zow== X-Gm-Message-State: AOAM533pEx43egk04iETLF0UH19FjeqYJ87xmKmH6+6A0M+HHlMqHREk MDLDNYBDy3j+TQxtam879xgHjhMNvGWA3bscT1E4eaM/TFPquLTZdrlwkZyXG21nxi1eDcPhU4R oSGKrgnoOIT4= X-Received: by 2002:a5d:4112:: with SMTP id l18mr6419182wrp.116.1607583874830; Wed, 09 Dec 2020 23:04:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJy9ov4rxUQSJuQKQCETVo2JsPSa0cpqOkgVH6rYsEkEZsiespnxMc4OGEi1K5RhXAOlmCqPUQ== 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) 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) Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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: > 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 wrot= e: >>>> 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, unsig= ned 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 ch= ecks in common code. Having a new memhp_get_pluggable_range() would be suff= icient for my use case (virtio-mem).