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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CA33CC433EF for ; Wed, 20 Jul 2022 09:36:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To: Subject:MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=NAhtJCiCDNdwD5nIGVWlwUKjXjRNlxhssFDIqhGjaQA=; b=v4e/X8qjSOOfJ6 CKvCi3q9yN7z3lzpiGT035sK2mkqcF6EZTbUFEPC9bLZCs7hgCbSDYnbiXD0u2yBOe39Dc15wNA7e JKYAB2nZZSiSLSQ8tbptazk0jgWjrd3htSRBfqKElVBBygFzrwpx+xosa9fd7rKhN8xkFRLsGgbPy 9YaggEH5SaW4XF8eEilWK9wNQO16xOg7RF7wWpVsG+xyxawPnJqx+vjJ8yAQFWCmrJXakeZNe+MHn sSNOqvusp/W+Zf5wjUeHMz+fpWAPG15tV5nbXeyjp2zYNMm6woTXX8J+bgSp3TOum6H2b3GQUKFIW a8ODDcoTOx7iXJFsmtkw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oE66a-003MSJ-K0; Wed, 20 Jul 2022 09:34:56 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oE66W-003MQp-Mg for linux-arm-kernel@lists.infradead.org; Wed, 20 Jul 2022 09:34:54 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1658309691; 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=dZJQXt6doKuqhqmCeIdZMEV0KmUXZoYN8P0BVRcFtdM=; b=cXmHxafGXXoMVrDaotrczdfTix4ur93YVh2yhwzsFqnEOIi8HH8mXALkfidxOYDuR7KxnP 90Vw4i9mARkyywbqMAWu/ONldwUQhT6h4R7c1hzHlNpo0gtXxU06LsI0SXwx1Sw8kYP3zF zcKo8Wx+uh9ywY0pU9KJpE3w84ZANno= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-613-lB9r9Z7RNBWk4vjL5WZInQ-1; Wed, 20 Jul 2022 05:34:43 -0400 X-MC-Unique: lB9r9Z7RNBWk4vjL5WZInQ-1 Received: by mail-wr1-f70.google.com with SMTP id t13-20020adfe10d000000b0021bae3def1eso2992816wrz.3 for ; Wed, 20 Jul 2022 02:34:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:organization:in-reply-to :content-transfer-encoding; bh=dZJQXt6doKuqhqmCeIdZMEV0KmUXZoYN8P0BVRcFtdM=; b=GFnVjmFvvyKO288RDmTrrO/3Ri8GfJpWXjJGafuNTtoJdABO3EbxDOKcY62NlYnS/I IZ24mCCpH0LG1IHQfeSE0nxXROJO+PF4gGmkr2eAHQBC8omMCXyypE1SAdTBq9KVgMHN SQV7+fGmqxHL33Fh4Ym/0We6ocv86SG/pNtZ0PIrcS999h4C7+coknBkhypgYz6kRmMW Qz/50UCLDfgXoDI9TYc/CBiebsgWbS47IjY2QSybi46tKPrZiJCyoJDYhOGWBAvp3WdX qJXlRSzWm/fdHFi1vb1Ar3g9RxeRnuMfn9BA3M8j4rP+rhQj+pXlEX7bmiNq7mWfaq6V 6yBQ== X-Gm-Message-State: AJIora9KIlxyNpfVY1ydpF/QlDuKk/hM6/eZBaGbPOOEkfb+219pVJGa 8xxX2l+rR8LDjh/UToOkdDdaaiYPhstb8u8SoFboth17OCzEvWnVI2JdVn3mb6fxcHJJIF97a5A CiIc98lVdMC3FLU9giNrCrArnk6510DdU5Hs= X-Received: by 2002:adf:e889:0:b0:21d:6510:b750 with SMTP id d9-20020adfe889000000b0021d6510b750mr31445083wrm.498.1658309681810; Wed, 20 Jul 2022 02:34:41 -0700 (PDT) X-Google-Smtp-Source: AGRyM1ulf8qkNkDcp6dk1vwhLiwrg1+3SyvqKhWJWE97+JCOnPrgU25PgHyyorDQgXr5DMo4WjCfFQ== X-Received: by 2002:adf:e889:0:b0:21d:6510:b750 with SMTP id d9-20020adfe889000000b0021d6510b750mr31445053wrm.498.1658309681533; Wed, 20 Jul 2022 02:34:41 -0700 (PDT) Received: from ?IPV6:2003:cb:c706:e00:8d96:5dba:6bc4:6e89? (p200300cbc7060e008d965dba6bc46e89.dip0.t-ipconnect.de. [2003:cb:c706:e00:8d96:5dba:6bc4:6e89]) by smtp.gmail.com with ESMTPSA id n21-20020a05600c4f9500b003a2f2bb72d5sm2347014wmq.45.2022.07.20.02.34.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 20 Jul 2022 02:34:41 -0700 (PDT) Message-ID: <4216f48f-fdf1-ec1e-b963-6f7fe6ba0f63@redhat.com> Date: Wed, 20 Jul 2022 11:34:37 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH V4 3/4] mm/sparse-vmemmap: Generalise vmemmap_populate_hugepages() To: Huacai Chen , Will Deacon , Dan Williams , Sudarshan Rajagopalan Cc: Huacai Chen , Arnd Bergmann , Thomas Bogendoerfer , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Catalin Marinas , loongarch@lists.linux.dev, linux-arch , Xuefeng Li , Guo Ren , Xuerui Wang , Jiaxun Yang , Andrew Morton , Linux-MM , "open list:MIPS" , LKML , linux-arm-kernel , Feiyang Chen References: <20220704112526.2492342-1-chenhuacai@loongson.cn> <20220704112526.2492342-4-chenhuacai@loongson.cn> <20220705092937.GA552@willie-the-truck> <20220706161736.GC3204@willie-the-truck> From: David Hildenbrand Organization: Red Hat In-Reply-To: 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-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220720_023452_825198_6FB47D62 X-CRM114-Status: GOOD ( 24.68 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 14.07.22 14:34, Huacai Chen wrote: > Oh, Sudarshan Rajagopalan's Email has changed, Let's update. > > Huacai > > On Fri, Jul 8, 2022 at 5:47 PM Huacai Chen wrote: >> >> +Dan Williams >> +Sudarshan Rajagopalan >> >> On Thu, Jul 7, 2022 at 12:17 AM Will Deacon wrote: >>> >>> On Tue, Jul 05, 2022 at 09:07:59PM +0800, Huacai Chen wrote: >>>> On Tue, Jul 5, 2022 at 5:29 PM Will Deacon wrote: >>>>> On Mon, Jul 04, 2022 at 07:25:25PM +0800, Huacai Chen wrote: >>>>>> diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c >>>>>> index 33e2a1ceee72..6f2e40bb695d 100644 >>>>>> --- a/mm/sparse-vmemmap.c >>>>>> +++ b/mm/sparse-vmemmap.c >>>>>> @@ -686,6 +686,60 @@ int __meminit vmemmap_populate_basepages(unsigned long start, unsigned long end, >>>>>> return vmemmap_populate_range(start, end, node, altmap, NULL); >>>>>> } >>>>>> >>>>>> +void __weak __meminit vmemmap_set_pmd(pmd_t *pmd, void *p, int node, >>>>>> + unsigned long addr, unsigned long next) >>>>>> +{ >>>>>> +} >>>>>> + >>>>>> +int __weak __meminit vmemmap_check_pmd(pmd_t *pmd, int node, unsigned long addr, >>>>>> + unsigned long next) >>>>>> +{ >>>>>> + return 0; >>>>>> +} >>>>>> + >>>>>> +int __meminit vmemmap_populate_hugepages(unsigned long start, unsigned long end, >>>>>> + int node, struct vmem_altmap *altmap) >>>>>> +{ >>>>>> + unsigned long addr; >>>>>> + unsigned long next; >>>>>> + pgd_t *pgd; >>>>>> + p4d_t *p4d; >>>>>> + pud_t *pud; >>>>>> + pmd_t *pmd; >>>>>> + >>>>>> + for (addr = start; addr < end; addr = next) { >>>>>> + next = pmd_addr_end(addr, end); >>>>>> + >>>>>> + pgd = vmemmap_pgd_populate(addr, node); >>>>>> + if (!pgd) >>>>>> + return -ENOMEM; >>>>>> + >>>>>> + p4d = vmemmap_p4d_populate(pgd, addr, node); >>>>>> + if (!p4d) >>>>>> + return -ENOMEM; >>>>>> + >>>>>> + pud = vmemmap_pud_populate(p4d, addr, node); >>>>>> + if (!pud) >>>>>> + return -ENOMEM; >>>>>> + >>>>>> + pmd = pmd_offset(pud, addr); >>>>>> + if (pmd_none(READ_ONCE(*pmd))) { >>>>>> + void *p; >>>>>> + >>>>>> + p = vmemmap_alloc_block_buf(PMD_SIZE, node, altmap); >>>>>> + if (p) { >>>>>> + vmemmap_set_pmd(pmd, p, node, addr, next); >>>>>> + continue; >>>>>> + } else if (altmap) >>>>>> + return -ENOMEM; /* no fallback */ >>>>> >>>>> Why do you return -ENOMEM if 'altmap' here? That seems to be different to >>>>> what we currently have on arm64 and it's not clear to me why we're happy >>>>> with an altmap for the pmd case, but not for the pte case. >>>> The generic version is the same as X86. It seems that ARM64 always >>>> fallback whether there is an altmap, but X86 only fallback in the no >>>> altmap case. I don't know the reason of X86, can Dan Williams give >>>> some explaination? >>> >>> Right, I think we need to understand the new behaviour here before we adopt >>> it on arm64. >> Hi, Dan, >> Could you please tell us the reason? Thanks. >> >> And Sudarshan, >> You are the author of adding a fallback mechanism to ARM64, do you >> know why ARM64 is different from X86 (only fallback in no altmap >> case)? I think that's a purely theoretical issue: I assume that in any case we care about, the altmap should be reasonably sized and aligned such that this will always succeed. To me it even sounds like the best idea to *consistently* fail if there is no more space in the altmap, even if we'd have to fallback to PTE (again, highly unlikely that this is relevant in practice). Could indicate an altmap-size configuration issue. -- Thanks, David / dhildenb _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel