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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 64AEFC0015E for ; Tue, 11 Jul 2023 15:46:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0054D6B0072; Tue, 11 Jul 2023 11:46:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EF8306B0074; Tue, 11 Jul 2023 11:46:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D99436B0075; Tue, 11 Jul 2023 11:46:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id C97826B0072 for ; Tue, 11 Jul 2023 11:46:38 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 6F16DA030C for ; Tue, 11 Jul 2023 15:46:38 +0000 (UTC) X-FDA: 80999758476.23.5B328C8 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by imf14.hostedemail.com (Postfix) with ESMTP id BB2CF100017 for ; Tue, 11 Jul 2023 15:46:35 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=lIjrzu+u; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf14.hostedemail.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689090395; h=from:from:sender: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:dkim-signature; bh=/qhqwF30d6k2BCAwsofqQx15bwd6kNY0EhDNEqxlBfc=; b=Znh5JVT9OroBBR8c5n1v4lIE41Tf+MvGzrbHl/7vNldmk6OqqBbWzxP8mdARSMgUR2D19y vcMju6X681DR3WIqGwMpK5NfC5kXHonF5d60rO4uP2YbxEnU/SuYPtDpL3ueF7HuLgbjeW fBQKDBZ9NkNAw5nfA3nNKlqpps0aGvA= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=lIjrzu+u; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf14.hostedemail.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689090395; a=rsa-sha256; cv=none; b=Ptgvscl628dVPb+7pgwTJJqmUtVMe6I6mDDcRdzFrrrG/has9EHGAqywuZ/PC6McWyOPxg gZ0rirZ7YwoSI28i5DFVWhAfylTCzymqhRhI0ky6TjBhT6wXO4N0hqXSqh7dD/zuDmQkz3 5qsoEJlnWCWJj8A7gdOLI+c5NRzoW5Y= Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36BFgCT5029476; Tue, 11 Jul 2023 15:46:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=pp1; bh=/qhqwF30d6k2BCAwsofqQx15bwd6kNY0EhDNEqxlBfc=; b=lIjrzu+uudO/zH/SZCnMB08p9xa/ms6NX/fC3g3pfeOzFfozj+judb1q9h2dz0fPXCxu 54OXVx64ZIhgUHNOWxl6neVqSQ5GbFaagencxbazdp87vNOJNjHoyj9s98hkAa5Bjzqj G9dgSlzsDBnosbsEPHye9CTBoBsSiHFcZFf70n8BwS1Thk3gmOe6GNm/sxFM30JeBoW1 coQpC/dsUAxHspcdmTy/JEiDgm8SDJCnwOdflcJxqs/36G15gZFIAQ3rpxpFnKSvnTI9 knpcuaAzC6t6ky1K6l8jZEoiHve++QNe7xO+tsJ4t2cZYtCg+3AvU36GbR+IcpP5VTqi Tg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs9y1r6gb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 15:46:26 +0000 Received: from m0356517.ppops.net (m0356517.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 36BFgJx3029879; Tue, 11 Jul 2023 15:46:25 GMT Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs9y1r6db-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 15:46:25 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 36B9Iv1S031161; Tue, 11 Jul 2023 15:46:22 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma04ams.nl.ibm.com (PPS) with ESMTPS id 3rpye59v11-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 15:46:21 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 36BFkJ7H54001970 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Jul 2023 15:46:19 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6FF512004D; Tue, 11 Jul 2023 15:46:19 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8D94620040; Tue, 11 Jul 2023 15:46:16 +0000 (GMT) Received: from [9.43.86.43] (unknown [9.43.86.43]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 11 Jul 2023 15:46:16 +0000 (GMT) Message-ID: Date: Tue, 11 Jul 2023 21:16:15 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [PATCH v3 5/7] powerpc/book3s64/memhotplug: Enable memmap on memory for radix Content-Language: en-US To: David Hildenbrand , linux-mm@kvack.org, akpm@linux-foundation.org, mpe@ellerman.id.au, linuxppc-dev@lists.ozlabs.org, npiggin@gmail.com, christophe.leroy@csgroup.eu Cc: Oscar Salvador , Michal Hocko , Vishal Verma References: <20230711044834.72809-1-aneesh.kumar@linux.ibm.com> <20230711044834.72809-6-aneesh.kumar@linux.ibm.com> <98285185-170f-10fb-67a7-09e35ab47650@redhat.com> <006e24f1-1261-1018-4125-02dd354da519@linux.ibm.com> From: Aneesh Kumar K V In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: A_O_COuI35zTXrXpRNfv3quKvrH-nXCG X-Proofpoint-ORIG-GUID: 5grsPnzlxC64_nv6MM-y4f5IE00i-SHi X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-11_08,2023-07-11_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 phishscore=0 clxscore=1015 priorityscore=1501 lowpriorityscore=0 impostorscore=0 bulkscore=0 adultscore=0 suspectscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2307110139 X-Rspamd-Queue-Id: BB2CF100017 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 4e96mnowxmeg6t411rwgxbje7bbh459r X-HE-Tag: 1689090395-677251 X-HE-Meta: U2FsdGVkX18uPb/ZHjBFtivzig9ArVwkgXjp6f/M3k8io8NMhYCoNEf5bWsHuYg1aezVN1EqR5/LFB9KwUri0DJ5+XCFOvr37gZHw4RW2B1zXe3ksCbfp1CwGo1icO4u4uFHVeX/M3/J65YMBZp+OB20jjdb7bhlnlQ5IXZXwX+wJbBMDpnHoJmn/i7vykYzPCuUAY0c24uvdGMZFLg0S7xM7i4sb9H1eqx9MKJGFrgUIfasUDfQiiEtS029SotrdHbhNArcrkgU8A3nfuvAOPgD9BA9M4MbVBk852qoB2w8mI4qVucJgZrhUlZNYE93b1QZthzbPAUHHujfsMZLlqmRA/FN3vhyHBPi/W+S/pedxipL+FJ2cc7s+g636gYVgOm9irtNdfyd7Zc+XLKV6tN3ZijUIMD3g1Ksb2dnEzUgmzrN4Tq5n6OQkADwqeP+YaAjUO7Mk3WpCvo6qapweydXYmD05qA2xMyn9vntMD8Ym8BeEwRQpnNf6XfO9TnCSa5n5FC6rBs0ZCAj+fOc1p97qVboO7YRbzP11YZ0Z68gBJSopQG9uCTGBIUoKkXDtra1CqavFT/yUVLEVrjNKT5OCZuBIxjLC1xa78qtcyrUdJNZLMpP/miSY7M4ZIcGiHRxkx7cdR7DOsc6KdkEbMc3k+lX0sdwjzHYvMZDD6ROgQh7UG43md7wReJSp5afHLkAZ2bNJ8aIfxCKTVSpR1yx1SVs74FXmfmNzmADowQGlaoVCEaWA5/+Y085bGJkA6rq4shKKFOJaGxOiEUjkgyFj1xD0f47lcLO6PteLdCr7WrKCurxUWSHXar4Drn9pSR9ezbiX85emS/BqQplsTjkjsuPQi7hD5+GlQGKKoe/HRP8W/+zdiYTeqMSNutah4MXj49D+CfHXGWuuus02dqpdab2c7SQo+++YsAKDM2s1y3lMG9OKndyisMWOScDVQa7izHpYEubn6LGjw+ coprjGWW I3hL/iaOLND5eUTfCeCJfWOZ9w3WRE/a/s7oFBF+6xFWCVA/djyiUFzK9v3KmhJDKVPFALjlBmue580cbSXz+IkBfTubyE6W+wNWXf7x78oHzMyKxBv1DDvcKC/W85Bi24QtcHYodtQR5cYBny42piLtp8A== 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: On 7/11/23 9:14 PM, David Hildenbrand wrote: > On 11.07.23 17:40, Aneesh Kumar K V wrote: >> On 7/11/23 8:56 PM, David Hildenbrand wrote: >>> On 11.07.23 06:48, Aneesh Kumar K.V wrote: >>>> Radix vmemmap mapping can map things correctly at the PMD level or PTE >>>> level based on different device boundary checks. Hence we skip the >>>> restrictions w.r.t vmemmap size to be multiple of PMD_SIZE. This also >>>> makes the feature widely useful because to use PMD_SIZE vmemmap area we >>>> require a memory block size of 2GiB >>>> >>>> We can also use MHP_RESERVE_PAGES_MEMMAP_ON_MEMORY to that the feature >>>> can work with a memory block size of 256MB. Using altmap.reserve feature >>>> to align things correctly at pageblock granularity. We can end up >>>> losing some pages in memory with this. For ex: with a 256MiB memory block >>>> size, we require 4 pages to map vmemmap pages, In order to align things >>>> correctly we end up adding a reserve of 28 pages. ie, for every 4096 >>>> pages 28 pages get reserved. >>>> >>>> Signed-off-by: Aneesh Kumar K.V >>>> --- >>>>    arch/powerpc/Kconfig                          |  1 + >>>>    arch/powerpc/include/asm/pgtable.h            | 28 +++++++++++++++++++ >>>>    .../platforms/pseries/hotplug-memory.c        |  3 +- >>>>    mm/memory_hotplug.c                           |  2 ++ >>>>    4 files changed, 33 insertions(+), 1 deletion(-) >>>> >>>> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig >>>> index 116d6add0bb0..f890907e5bbf 100644 >>>> --- a/arch/powerpc/Kconfig >>>> +++ b/arch/powerpc/Kconfig >>>> @@ -157,6 +157,7 @@ config PPC >>>>        select ARCH_HAS_UBSAN_SANITIZE_ALL >>>>        select ARCH_HAVE_NMI_SAFE_CMPXCHG >>>>        select ARCH_KEEP_MEMBLOCK >>>> +    select ARCH_MHP_MEMMAP_ON_MEMORY_ENABLE    if PPC_RADIX_MMU >>>>        select ARCH_MIGHT_HAVE_PC_PARPORT >>>>        select ARCH_MIGHT_HAVE_PC_SERIO >>>>        select ARCH_OPTIONAL_KERNEL_RWX        if ARCH_HAS_STRICT_KERNEL_RWX >>>> diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h >>>> index 68817ea7f994..8e6c92dde6ad 100644 >>>> --- a/arch/powerpc/include/asm/pgtable.h >>>> +++ b/arch/powerpc/include/asm/pgtable.h >>>> @@ -169,6 +169,34 @@ static inline bool is_ioremap_addr(const void *x) >>>>    int __meminit vmemmap_populated(unsigned long vmemmap_addr, int vmemmap_map_size); >>>>    bool altmap_cross_boundary(struct vmem_altmap *altmap, unsigned long start, >>>>                   unsigned long page_size); >>>> +/* >>>> + * mm/memory_hotplug.c:mhp_supports_memmap_on_memory goes into details >>>> + * some of the restrictions. We don't check for PMD_SIZE because our >>>> + * vmemmap allocation code can fallback correctly. The pageblock >>>> + * alignment requirement is met using altmap->reserve blocks. >>>> + */ >>>> +#define arch_supports_memmap_on_memory arch_supports_memmap_on_memory >>>> +static inline bool arch_supports_memmap_on_memory(unsigned long size) >>>> +{ >>>> +    unsigned long nr_pages = size >> PAGE_SHIFT; >>>> +    unsigned long vmemmap_size = nr_pages * sizeof(struct page); >>>> + >>>> +    if (!radix_enabled()) >>>> +        return false; >>>> + >>>> +#ifdef CONFIG_PPC_4K_PAGES >>>> +    return IS_ALIGNED(vmemmap_size, PMD_SIZE); >>>> +#else >>>> +    /* >>>> +     * Make sure the vmemmap allocation is fully contianed >>>> +     * so that we always allocate vmemmap memory from altmap area. >>>> +     * The pageblock alignment requirement is met by using >>>> +     * reserve blocks in altmap. >>>> +     */ >>>> +    return IS_ALIGNED(vmemmap_size,  PAGE_SIZE); >>> >>> Can we move that check into common code as well? >>> >>> If our (original) vmemmap size would not fit into a single page, we would be in trouble on any architecture. Did not check if it would be an issue for arm64 as well in case we would allow eventually wasting memory. >>> >> >> >> For x86 and arm we already do IS_ALIGNED(vmemmap_size, PMD_SIZE); in arch_supports_memmap_on_memory(). That should imply PAGE_SIZE alignment. >> If arm64 allow the usage of altmap.reserve, I would expect the arch_supports_memmap_on_memory to have the PAGE_SIZE check. >> >> Adding the PAGE_SIZE check in  mhp_supports_memmap_on_memory() makes it redundant check for x86 and arm currently? > > IMHO not an issue. The common code check is a bit weaker and the arch check a bit stronger. > >> ok will update >> modified   mm/memory_hotplug.c >> @@ -1293,6 +1293,13 @@ static bool mhp_supports_memmap_on_memory(unsigned long size) >>        */ >>       if (!mhp_memmap_on_memory() || size != memory_block_size_bytes()) >>           return false; >> + >> +    /* >> +     * Make sure the vmemmap allocation is fully contianed > > s/contianed/contained/ > >> +     * so that we always allocate vmemmap memory from altmap area. > > In theory, it's not only the vmemmap size, but also the vmemmap start (that it doesn't start somewhere in between a page, crossing a page). I suspect the start is always guaranteed to be aligned (of the vmemmap size is aligned), correct? > That is correct. >> +     */ >> +    if (!IS_ALIGNED(vmemmap_size,  PAGE_SIZE)) >> +        return false; >>        /* >>         * Without page reservation remaining pages should be pageblock aligned. >>         */ >> -aneesh >