Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp430683pxu; Thu, 3 Dec 2020 04:04:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJw8o8lcYm9AWqJRsrOTjSmSu/2Wsic4pV6K3kAm3TqhvdglyDCzn9In0S083ryiXDmMYtYA X-Received: by 2002:a17:906:8617:: with SMTP id o23mr2241298ejx.274.1606997099631; Thu, 03 Dec 2020 04:04:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606997099; cv=none; d=google.com; s=arc-20160816; b=FmDmQ5oZQ9ZAPyGsJLqWNA51jIn7aH851CdwprXYIMTTnQy7xU3Hi2FIcdz+6QIHi9 stpQccGS/1jwBcZQWRw9jacZdl66vWO7K4nV7hPrSUJxcTlJuskMRoH+DtLR2AdcaKn/ iJQhYo2l3/X+VdOcQ6M5XZEJFui0mtuVefsBHrOpXHDdg1QO2uLnVxEEm1OP9a1Q3lqc KTqvUHDtVZRMyaGHuRI4COsfqZT45cSyl8663iUYfBKyvXKVdfnZpgHTDdzYZwOTY20e UzUm9L/MwENtBsvQLHuUbYOL63CMvTVwlYkGwqKDbUr/ZAhsTC0tDsYeGWmm0rjM4Zpf g8IA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:organization :from:references:cc:to:subject:dkim-signature; bh=Xa3xb2moiuKougPYQgCIxOSC16hacVe+/4oGyGlf0T4=; b=EpAXAVUeqhxu6M/ZlhRJaBJ7JrZQfgma3zXwC6k36t/dB7TehnsGsF6coxNwrlkIT3 wQezdX3sSDzK1xE/yTKD5WxrdOLH/LvA3ViCiKMWpra4W81uuUbtpLIO77/0qP2qXpUQ Ap4uvHPcwXRD8l3N755pVHBNng2qlSxAdwZDnqLozwCwIJqqXwDz/6iKpDGqo13BUmB6 jwHEiXx1zqal6LtXTuj5sYd1I3PGRYqmd05HEQv7MV0q+Lc0ePLjwRLwlmRrSFPWf8l3 hQCDZhMKHQJRKX+5KQOjNqB6tnP3kmaDHcwbRSrUNFVqGyCERtU72iL2ywTwuZ7bgYSz VbgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=PXTf6g9L; 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 df12si742824edb.5.2020.12.03.04.04.34; Thu, 03 Dec 2020 04:04:59 -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=PXTf6g9L; 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 S1730215AbgLCMCf (ORCPT + 99 others); Thu, 3 Dec 2020 07:02:35 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:54191 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729035AbgLCMCe (ORCPT ); Thu, 3 Dec 2020 07:02:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606996867; 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=Xa3xb2moiuKougPYQgCIxOSC16hacVe+/4oGyGlf0T4=; b=PXTf6g9Le6h0mo4hVCC9KuUMZyUhwbHD7N2Gb0Atck03f0I18h4oelYJqx0QdzDMgY7wiS lRjGNbMmGGjRbZjnpNlQYke5sr3sWWq88WLV5DTUepD3MjrDjwUJqj61QhPtP78moA+7V8 tmrUFpUw4HJi/uIkTaVPT+ftmFUwGLQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-395-NokD7zRZPviXIiyVeOgD6Q-1; Thu, 03 Dec 2020 07:01:06 -0500 X-MC-Unique: NokD7zRZPviXIiyVeOgD6Q-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 08447A0C04; Thu, 3 Dec 2020 12:01:04 +0000 (UTC) Received: from [10.36.113.250] (ovpn-113-250.ams2.redhat.com [10.36.113.250]) by smtp.corp.redhat.com (Postfix) with ESMTP id 58E7B27C40; Thu, 3 Dec 2020 12:01:02 +0000 (UTC) Subject: Re: [RFC V2 3/3] s390/mm: Define arch_get_mappable_range() To: Heiko Carstens , Anshuman Khandual Cc: linux-mm@kvack.org, akpm@linux-foundation.org, linux-arm-kernel@lists.infradead.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, Vasily Gorbik References: <1606706992-26656-1-git-send-email-anshuman.khandual@arm.com> <1606706992-26656-4-git-send-email-anshuman.khandual@arm.com> <20201202203233.GB11274@osiris> <24905c32-f6c1-97a0-000f-f822b9870ea5@arm.com> <20201203115133.GB9994@osiris> From: David Hildenbrand Organization: Red Hat GmbH Message-ID: <4d6c9ec4-f1be-46b9-5d67-5c53f5afedc5@redhat.com> Date: Thu, 3 Dec 2020 13:01:01 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.4.0 MIME-Version: 1.0 In-Reply-To: <20201203115133.GB9994@osiris> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03.12.20 12:51, Heiko Carstens wrote: > On Thu, Dec 03, 2020 at 06:03:00AM +0530, Anshuman Khandual wrote: >>>> diff --git a/arch/s390/mm/extmem.c b/arch/s390/mm/extmem.c >>>> index 5060956b8e7d..cc055a78f7b6 100644 >>>> --- a/arch/s390/mm/extmem.c >>>> +++ b/arch/s390/mm/extmem.c >>>> @@ -337,6 +337,11 @@ __segment_load (char *name, int do_nonshared, unsigned long *addr, unsigned long >>>> goto out_free_resource; >>>> } >>>> >>>> + if (seg->end + 1 > VMEM_MAX_PHYS || seg->end + 1 < seg->start_addr) { >>>> + rc = -ERANGE; >>>> + goto out_resource; >>>> + } >>>> + >>>> rc = vmem_add_mapping(seg->start_addr, seg->end - seg->start_addr + 1); >>>> if (rc) >>>> goto out_resource; >>>> diff --git a/arch/s390/mm/vmem.c b/arch/s390/mm/vmem.c >>>> index b239f2ba93b0..06dddcc0ce06 100644 >>>> --- a/arch/s390/mm/vmem.c >>>> +++ b/arch/s390/mm/vmem.c >>>> @@ -532,14 +532,19 @@ 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; >>>> + >>>> + memhp_range.start = 0; >>>> + memhp_range.end = VMEM_MAX_PHYS; >>>> + return memhp_range; >>>> +} >>>> + >>>> int vmem_add_mapping(unsigned long start, unsigned long size) >>>> { >>>> int ret; >>>> >>>> - if (start + size > VMEM_MAX_PHYS || >>>> - start + size < start) >>>> - return -ERANGE; >>>> - >>> >>> I really fail to see how this could be considered an improvement for >>> s390. Especially I do not like that the (central) range check is now >>> moved to the caller (__segment_load). Which would mean potential >>> additional future callers would have to duplicate that code as well. >> >> The physical range check is being moved to the generic hotplug code >> via arch_get_mappable_range() instead, making the existing check in >> vmem_add_mapping() redundant. Dropping the check there necessitates >> adding back a similar check in __segment_load(). Otherwise there >> will be a loss of functionality in terms of range check. >> >> May be we could just keep this existing check in vmem_add_mapping() >> as well in order avoid this movement but then it would be redundant >> check in every hotplug path. >> >> So I guess the choice is to either have redundant range checks in >> all hotplug paths or future internal callers of vmem_add_mapping() >> take care of the range check. > > The problem I have with this current approach from an architecture > perspective: we end up having two completely different methods which > are doing the same and must be kept in sync. This might be obvious > looking at this patch, but I'm sure this will go out-of-sync (aka > broken) sooner or later. Exactly, there should be one function only that was the whole idea of arch_get_mappable_range(). > > Therefore I would really like to see a single method to do the range > checking. Maybe you could add a callback into architecture code, so > that such an architecture specific function could also be used > elsewhere. Dunno. > I think we can just switch to using "memhp_range_allowed()" here then after implementing arch_get_mappable_range(). Doesn't hurt to double check in vmem_add_mapping() - especially to keep extmem working without changes. At least for callers of memory hotplug it's then clear which values actually won't fail deep down in arch code. -- Thanks, David / dhildenb