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=-8.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 8BD92C07E95 for ; Tue, 20 Jul 2021 07:23:55 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id ED68061165 for ; Tue, 20 Jul 2021 07:23:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ED68061165 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 97EBF8D0003; Tue, 20 Jul 2021 03:23:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 954438D0001; Tue, 20 Jul 2021 03:23:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 81C618D0003; Tue, 20 Jul 2021 03:23:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0102.hostedemail.com [216.40.44.102]) by kanga.kvack.org (Postfix) with ESMTP id 5B58C8D0001 for ; Tue, 20 Jul 2021 03:23:55 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id DD0E118259C5B for ; Tue, 20 Jul 2021 07:23:53 +0000 (UTC) X-FDA: 78382126746.26.42CDAA0 Received: from mail-vk1-f176.google.com (mail-vk1-f176.google.com [209.85.221.176]) by imf09.hostedemail.com (Postfix) with ESMTP id 8292C3000108 for ; Tue, 20 Jul 2021 07:23:53 +0000 (UTC) Received: by mail-vk1-f176.google.com with SMTP id az15so4376683vkb.9 for ; Tue, 20 Jul 2021 00:23:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=oHPiE5WIZuBAQynBajx7q1K/yloXb10bOcX9t96Cp50=; b=IIU6e7eHizdyUHxI0PkRbcIFNGgUN7GlbJtnkGPL6UP6QSVA4Xw3AX0laZfptj2cn4 K4flLz1h2h0vXXl4uY0oYXpHy8X/rtR6FXCaeJ9S6aa8cduXrAeVQrEdhqhK4lxKSt4v R4NTMaXErStDla7jrggL9PSc0zD1tJM1KlTUp+VARrjNXyFrsGxhCqiTPIMr4VFSSKYx NrIymzma8jsKyPQvY0uZ8s2S2fT2/No1ovZwEyHTj6/nFb5bZNGnOFwikyZf6aGeUUHl Yg89r33NMKyiUl1OiPAOz0TgxDYhtVyOylDt7342RhrGhCySGSmEg6ahmZWdsCHf4vq9 UqIA== X-Gm-Message-State: AOAM531x/xcsSNMyvG95B8CdtaEwIDDmBz3kyJyzWTWqdZfCUCLTXHcq Oc43fJRuCyARDfdx1tSYJsLHWPEAF/0zoilNc9M= X-Google-Smtp-Source: ABdhPJxf33tE/UC6sAZ53pbsOTH+XynQf1vrWzPcAah8VYz4w/NMs8y9Z6qAKLx4GP83D3FxP9bWIDXUegsSRZB+qCI= X-Received: by 2002:a1f:2746:: with SMTP id n67mr24782587vkn.5.1626765832884; Tue, 20 Jul 2021 00:23:52 -0700 (PDT) MIME-Version: 1.0 References: <04c4d231fb03a3810d72a45c8a5bc2272c5975f3.1626266516.git.geert+renesas@glider.be> <20210714135101.GB2441138@robh.at.kernel.org> In-Reply-To: From: Geert Uytterhoeven Date: Tue, 20 Jul 2021 09:23:41 +0200 Message-ID: Subject: Re: [PATCH v4 02/10] memblock: Add variables for usable memory limitation To: Mike Rapoport Cc: Rob Herring , Russell King , Nicolas Pitre , Ard Biesheuvel , Linus Walleij , Catalin Marinas , Will Deacon , Nick Kossifidis , Paul Walmsley , Palmer Dabbelt , Albert Ou , Frank Rowand , Dave Young , Baoquan He , Vivek Goyal , Andrew Morton , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Linux ARM , linux-riscv , kexec@lists.infradead.org, Linux MM , Linux-Renesas , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Authentication-Results: imf09.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf09.hostedemail.com: domain of geertuytterhoeven@gmail.com designates 209.85.221.176 as permitted sender) smtp.mailfrom=geertuytterhoeven@gmail.com X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 8292C3000108 X-Stat-Signature: 58fdsfcaqid5i36b4484n3op1utn7w8f X-HE-Tag: 1626765833-406156 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: Hi Mike, On Tue, Jul 20, 2021 at 7:41 AM Mike Rapoport wrote: > On Mon, Jul 19, 2021 at 08:59:03AM +0200, Geert Uytterhoeven wrote: > > On Sun, Jul 18, 2021 at 11:31 AM Mike Rapoport wrote: > > > On Wed, Jul 14, 2021 at 07:51:01AM -0600, Rob Herring wrote: > > > > On Wed, Jul 14, 2021 at 02:50:12PM +0200, Geert Uytterhoeven wrote: > > > > > Add two global variables (cap_mem_addr and cap_mem_size) for storing a > > > > > base address and size, describing a limited region in which memory may > > > > > be considered available for use by the kernel. If enabled, memory > > > > > outside of this range is not available for use. > > > > > > > > > > These variables can by filled by firmware-specific code, and used in > > > > > calls to memblock_cap_memory_range() by architecture-specific code. > > > > > An example user is the parser of the "linux,usable-memory-range" > > > > > property in the DT "/chosen" node. > > > > > > > > > > Signed-off-by: Geert Uytterhoeven > > > > > --- > > > > > This is similar to how the initial ramdisk (phys_initrd_{start,size}) > > > > > and ELF core headers (elfcorehdr_{addr,size})) are handled. > > > > > > > > > > Does there exist a suitable place in the common memblock code to call > > > > > "memblock_cap_memory_range(cap_mem_addr, cap_mem_size)", or does this > > > > > have to be done in architecture-specific code? > > > > > > > > Can't you just call it from early_init_dt_scan_usablemem? If the > > > > property is present, you want to call it. If the property is not > > > > present, nothing happens. > > > > I will have a look... > > > > > For memblock_cap_memory_range() to work properly it should be called after > > > memory is detected and added to memblock with memblock_add[_node]() > > > > > > I'm not huge fan of adding more globals to memblock so if such ordering can > > > be implemented on the DT side it would be great. > > > > Me neither ;-) > > > > > I don't see a way to actually enforce this ordering, so maybe we'd want to > > > add warning in memblock_cap_memory_range() if memblock.memory is empty. Sorry, I misread "if memblock.memory is empty" as "if capmem is empty". > > "linux,usable-memory-range" is optional, and typically used only in > > crashdump kernels, so it would be a bad idea to add such a warning. > > If I remember correctly, memblock_cap_memory_range() was added to support > "linux,usable-memory-range" for crasdump kernels on arm64 and if it would > be called before memory is registered we may silently corrupt the memory > because the crash kernel will see all the memory as available. >" > So while WARN() maybe too much a pr_warn() seems to me quite appropriate. Yes, makes perfect sense now. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds