Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4590698pxu; Wed, 9 Dec 2020 23:48:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJzkobvTsusF7Jd0IQWvVbEltgyiLg+EjJryQ8oxANa3rKulZw9xBPMGKjh0866qMNA0UlVU X-Received: by 2002:a17:906:168f:: with SMTP id s15mr5148895ejd.180.1607586513199; Wed, 09 Dec 2020 23:48:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607586513; cv=none; d=google.com; s=arc-20160816; b=sjic38f0qzrXktNA1r+oj7jbNiA8rhQk7zHNlHsHlqQj7KOFwwuUmXptqdguREmC/X HpeaLOrWr8DRNwLBSlXFafXmbXpovDjaX/Hpu1rQCa+NPhhF/CSPYGUUU7Fm2mG0D5Ry wgnHK027/xf5wjKe1k0BB/Bz5rBSuRFqwSaOli6904mB6YdxoJBKG4yMF0bRFbKQJDOn rKqYfzHQiAq9gFIVJOmws/hKo4A5b6aPfW1I6Yf/EIASxr6Hlu1VLwePA76jj30TMZjM zbvvj+mKdvlGO97fgv5B66r9xlhjUnNIdCxfpY0BtGbgJRnR+fHB9Ny9oPyLPZ03A9MO JhPQ== 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:from:references :cc:to:subject; bh=KHcFkbKp40PfWoot3RUY6eVeZcCeCqyG29T74kZsOaw=; b=mO3Nhsxl3WcA3ZiQtMxKu3qwYE7nQuW//cfMyQc8TSaQLcHzSuqwhPbBnyAgqSU4rF UPqpkE2RqUVZCTpeCD3IwtWJu/HnkZ/dOi/v5Hub9lDdtVN/8NfCWoL617TurHJghSax v/uDQ4aVwIjwdB6fkt7DIlxxg7s9gIT/6ba7JtEe2yRpXihTtXtBVNpUnQpYJn2OOFAT ohdVLWMvz4JZ6PoEGErzVUeSWvflPerHUHQus4wHFZbb7Ya+bFKnQPkAmRtyLqGM8+0U iicsAr4HnEGY/EpP9eTbKW0JZZAluLvb+AqaK/QwjhqELe7549d65ZeFCOm/B0A07VBe 9QxA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a6si2035317ejj.398.2020.12.09.23.48.10; Wed, 09 Dec 2020 23:48:33 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730424AbgLJHla (ORCPT + 99 others); Thu, 10 Dec 2020 02:41:30 -0500 Received: from foss.arm.com ([217.140.110.172]:54170 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726513AbgLJHla (ORCPT ); Thu, 10 Dec 2020 02:41:30 -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 CB2CC1FB; Wed, 9 Dec 2020 23:40:43 -0800 (PST) Received: from [192.168.0.130] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4D4AC3F68F; Wed, 9 Dec 2020 23:40:39 -0800 (PST) Subject: Re: [PATCH 3/3] s390/mm: Define arch_get_mappable_range() To: David Hildenbrand , Heiko Carstens Cc: linux-mm@kvack.org, akpm@linux-foundation.org, 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 References: <20201210065845.GA20691@osiris> From: Anshuman Khandual Message-ID: <0a2f6eb1-c38b-9cc2-5c45-16f6c8999ce2@arm.com> Date: Thu, 10 Dec 2020 13:10:03 +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: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/10/20 12:34 PM, David Hildenbrand wrote: > >> Am 10.12.2020 um 07:58 schrieb Heiko Carstens : >> >> 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; >> >> > > Right, what I had in mind as reply to v1. Not sure if we really need new checks in common code. Having a new memhp_get_pluggable_range() would be sufficient for my use case (virtio-mem). Didn't quite understand "Not sure if we really need new checks in common code". Could you please be more specific. New checks as in pagemap_range() ? Because other places it is either replacing erstwhile check_hotplug_memory_addressable() or just moving existing checks from platform arch_add_memory() to the beginning of various hotplug paths.