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 X-Spam-Level: X-Spam-Status: No, score=-12.3 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 00DC4C433F5 for ; Fri, 24 Sep 2021 02:49:10 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id B27CB610C9 for ; Fri, 24 Sep 2021 02:49:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B27CB610C9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding: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=kIrc4gQGmcP1XscBLpePMfqqqc4ndrXrj1n/ggWt7kU=; b=4PkUqQJdrFlEmY e0wdaJV36fDSIWMvayZ4FGoymBgpj1K7z2klZ4pB+0RZ/A5Bm1tAB1QXBLQTRjubrvvR0R2A7DQqn FL6uZVV2ZkXg0pKY8P+s1V55XUXVytyzh2CFOqZx5LUBGx/RlM8r1LyKlEbERS3whF63x5W+2bAiA aqdtbur2dFWo0cyudrVpX3SnD1ZzfSmWEmS1Go2h6p0bDe3epZvdPeFQuo3magabJ6LX1MJKg3+rU 6TfU7K/Y6QqmGhUbZXJs0VfE55eW+TqFtqDucO3kh6TvmFOD8NjzwT04WAM0TaNLJZd4Cw5oiPECO J6iYZ1Uqosxs39AOi5VA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mTbFA-00CwRn-Vf; Fri, 24 Sep 2021 02:47:21 +0000 Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mTbF5-00CwQt-Iv for linux-arm-kernel@lists.infradead.org; Fri, 24 Sep 2021 02:47:18 +0000 Received: by mail-pg1-x533.google.com with SMTP id t1so8500704pgv.3 for ; Thu, 23 Sep 2021 19:47:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=FEVFO1LUZkGAI7jrBtWeyG1oEu1in197SjBUjEFqaBo=; b=bFN4ME187FOK6Ne7xCgrtXgrNL4Arg6ETp1sVuwSuEpwcXDEEw+0nOjsg17lZr/MPg B4vcZT0jqymc9PtGUcIVOSz1YMZ6QJ8M4onZ3ElEVS4OVy3Ph2aCGn9+ix/KWUSfyW/3 Xoah4qiEYvixvl5qc3M94eQ57JmIy1pSHYrB/q+OKSPdtuXnXFLxO64QqzoFArPA3+6a D35FDD2PtCO62UNhpvOiFcmMiYd2SE0wLfknkdZKWBLKp8UBELpy1v4rXWRjEnbEn4QD GvBEu5n/kg5wLEKmY6UD0IuJV6JTKywTZ9DWTFZdsw+vtqpUgNDKBj+HSBvpchuZ53yi Y4Tw== 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:in-reply-to :content-transfer-encoding; bh=FEVFO1LUZkGAI7jrBtWeyG1oEu1in197SjBUjEFqaBo=; b=wvJJyHXIYdw9X6PhcIeLsqGmqNYUcitLzVAfcEziRNzQXORcz6VHjzOpwCXfJCl35J tDkkI4YI9nyZQAicsOetHKb0LpXAx7ng9odc+1rUJvfcciOS6dFpi8Q9opIu6NkUrvpQ ZZJwGtGCg/UvmIvy7A8FpIwsstV/su73xcivoHs5AuU4ggW+evoabSchihZMXxrRfV6M /NhgU/kniP55hORtIFflcKCxaV46YWAonlA0b7FNQSJuML15ZqPluRmrDJHqRrFHel11 uavv7TrP2AC2DX3CGAEbbTuWlmIoS++nBKFEJO2cAlR8NCRTkveGiKtCAblxT+k/UBK+ tcQA== X-Gm-Message-State: AOAM532emEIZiITPygHNwImu2B5WOQEf9BFjRHte8UhXGJHyPDV07gnL OjA8/AZSc6p6ktDkfdAa0vY= X-Google-Smtp-Source: ABdhPJwQ66Az4BtCe3LR9g4AXjL9+g2UZM0qBW7WWQMktkugi/XVVaHm9tEwy67VXdWB6fl5jA+MuA== X-Received: by 2002:a63:b147:: with SMTP id g7mr1809053pgp.478.1632451634704; Thu, 23 Sep 2021 19:47:14 -0700 (PDT) Received: from [10.230.31.46] ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id x9sm7247327pfo.172.2021.09.23.19.47.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 23 Sep 2021 19:47:14 -0700 (PDT) Message-ID: <6eb8319d-acba-b69a-5db3-5dca9ef426e8@gmail.com> Date: Thu, 23 Sep 2021 19:47:06 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.1.1 Subject: Re: [RFC] arm64: mm: update max_pfn after memory hotplug Content-Language: en-US To: Chris Goldsworthy , Catalin Marinas , Will Deacon , Andrew Morton Cc: David Hildenbrand , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Sudarshan Rajagopalan , Doug Berger References: <595d09279824faf1f54961cef52b745609b05d97.1632437225.git.quic_cgoldswo@quicinc.com> From: Florian Fainelli In-Reply-To: <595d09279824faf1f54961cef52b745609b05d97.1632437225.git.quic_cgoldswo@quicinc.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210923_194715_679280_78F18130 X-CRM114-Status: GOOD ( 22.80 ) 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-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 9/23/2021 3:54 PM, Chris Goldsworthy wrote: > From: Sudarshan Rajagopalan > > After new memory blocks have been hotplugged, max_pfn and max_low_pfn > needs updating to reflect on new PFNs being hot added to system. > > Signed-off-by: Sudarshan Rajagopalan > Signed-off-by: Chris Goldsworthy > --- > arch/arm64/mm/mmu.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c > index cfd9deb..fd85b51 100644 > --- a/arch/arm64/mm/mmu.c > +++ b/arch/arm64/mm/mmu.c > @@ -1499,6 +1499,11 @@ int arch_add_memory(int nid, u64 start, u64 size, > if (ret) > __remove_pgd_mapping(swapper_pg_dir, > __phys_to_virt(start), size); > + else { > + max_pfn = PFN_UP(start + size); > + max_low_pfn = max_pfn; > + } This is a drive by review, but it got me thinking about your changes a bit: - if you raise max_pfn when you hotplug memory, don't you need to lower it when you hot unplug memory as well? - suppose that you have a platform which maps physical memory into the CPU's address space at 0x00_4000_0000 (1GB offset) and the kernel boots with 2GB of DRAM plugged by default. At that point we have not registered a swiotlb because we have less than 4GB of addressable physical memory, there is no IOMMU in that system, it's a happy world. Now assume that we plug an additional 2GB of DRAM into that system adjacent to the previous 2GB, from 0x00_C0000_0000 through 0x14_0000_0000, now we have physical addresses above 4GB, but we still don't have a swiotlb, some of our DMA_BIT_MASK(32) peripherals are going to be unable to DMA from that hot plugged memory, but they could if we had a swiotlb. - now let's go even further but this is very contrived. Assume that the firmware has somewhat created a reserved memory region with a 'no-map' attribute thus indicating it does not want a struct page to be created for a specific PFN range, is it valid to "blindly" raise max_pfn if that region were to be at the end of the just hot-plugged memory? -- Florian _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel