Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp5288834imw; Wed, 20 Jul 2022 02:49:04 -0700 (PDT) X-Google-Smtp-Source: AGRyM1seGFHI6POQSm3EH+kro7EkphTvL8YAe8HwVbfuLQuhWCWt8zdc5CIgRtOuVU0OKcEkweWt X-Received: by 2002:a05:6402:2553:b0:43a:caa2:4956 with SMTP id l19-20020a056402255300b0043acaa24956mr48617453edb.406.1658310544170; Wed, 20 Jul 2022 02:49:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658310544; cv=none; d=google.com; s=arc-20160816; b=ncfI2IEm1pYdF0VpBY6NwyEFwtjSkazcTlh+vPLZouixqoTbMqw7BcTCUh5eUOrixn W7McUwxJTCE1U2VeBauyTtOGeuYoeF3KUREhDZhMZbWCaTxGD5nDGvAzmNmCPCjY2JLP YHAEY1hveTfJ7t4T/WdRVGtS6MpEClFy7Y2VjEDue9fiqCI9oEu937q5mkacutHXuQMH NLj83vnulchl6wTCd36ZvtO1kKNzSTzC89AxT6gHR5AUHe2WnhaZTIoT5uix+2n6ydSy KR2UObPCqwnG2yb9f1HNu1GYP7VZI0BianFtclqzyXzCEYSH42x0k+wjDa7cbqnwRElL EGHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=dZJQXt6doKuqhqmCeIdZMEV0KmUXZoYN8P0BVRcFtdM=; b=dPr4js9dIMQDh93cTIZsEgoRmmgg9Zy3rPghL1CB/EzJ8hzPYCpTYd3aR1zQxddRC5 b0T+CKd+BssZ9adsMpaITk4aHIwOfNv2LJyX5v8cJ4se1VIg8Tcmeo6yqjNRXrZXahbw gVKSfOOcq7BsK36r9Q7Jda74rwtP56GjFxVJTbmbK8/roL4JZmBetH4aRfjYmjI6Y5L6 8t0tkYl2CZmJF9BFMD1KeAlEm2d51CeUMJt18w6/bpww5Juj35223IGUsgEkqyNIVXyA VyEhxKLP+a6Gezlr0DZuUynzhHXZ/rBHVQqUZKz/pvJXZ85EmVwHjwU4lLNnHtKWDbHY 2w2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UJTlWW1w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qa8-20020a170907868800b0072f1be0dff8si17083222ejc.133.2022.07.20.02.48.39; Wed, 20 Jul 2022 02:49:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UJTlWW1w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S230348AbiGTJes (ORCPT + 99 others); Wed, 20 Jul 2022 05:34:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229712AbiGTJeq (ORCPT ); Wed, 20 Jul 2022 05:34:46 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2D94E5E323 for ; Wed, 20 Jul 2022 02:34:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1658309684; 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=UJTlWW1wXFjspHs3DAtPLwQB/mCEFIZ+AH1q1i66e7tYbp2IsVuCMPLfaIJQDPzfFwwZgE fYH5gkno+B2CQ5/9Oe/k+51zDC8rHtUD/7/GRLZwlwfWea/7iMWfdB1wvgRabndT920vbT Q2d5O6LzuOCet+Of60jnBy51crNvS0M= 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-oktWdLQHME6xgZoBbav73g-1; Wed, 20 Jul 2022 05:34:43 -0400 X-MC-Unique: oktWdLQHME6xgZoBbav73g-1 Received: by mail-wr1-f70.google.com with SMTP id q17-20020adfab11000000b0021e4c9ca970so141185wrc.20 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=r9stHjQdaxotMBS63TDFMjzCnfDq33Aae3InQ4c0awgDiYrbs5VnPB/qk+MdFGK9V8 ako4BjwCNt2v5fEHGVO1XdfptJtPNJ+gchsTh4xOn60ZbgpEkQ3ky6rQPr0QewLh/rGl 4HzyyyHtF5gHNNRNfEXNXT5K8VriKVZNBk5q9lTpdVBnJm2ZSx0W4KtL1k5fj/eTu2yb sMc/OWYKPqNns73Upfr6c5POQGpVPKNO3lYMU1Hs0WCV2ISzRuf93IvWleNmoTRswW/x dpUQd2s6TWrzjbXC8hco7VilgGwyX9LNxmli7XrvSVpWRlyFwP9KHhWIfLTG9TtPq5uT 1SSA== X-Gm-Message-State: AJIora/JEWGREqj39vPxWL9NLAl2eoI3k7cY5X7uE5ZXBkVlYzT0XwfD ZxoSWehLdcqfssAbz86wWQ5kQ423gBUEuQotj4QbBle6HxH7C/j1GYZP9wEXnBzXfK8ADgIkwcH L+t5oikW1lpgAWHrwvBceJoqB X-Received: by 2002:adf:e889:0:b0:21d:6510:b750 with SMTP id d9-20020adfe889000000b0021d6510b750mr31445079wrm.498.1658309681810; Wed, 20 Jul 2022 02:34:41 -0700 (PDT) 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() Content-Language: en-US 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: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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