Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3841047pxb; Mon, 1 Feb 2021 06:11:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJybGOOJbIl7ZNWCbFA+IK2QQGycYEmBkKu/X4h/cxrNVB9clDBqmhSekS++qvmrTMQKhUjj X-Received: by 2002:a2e:a550:: with SMTP id e16mr10013022ljn.264.1612188666842; Mon, 01 Feb 2021 06:11:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612188666; cv=none; d=google.com; s=arc-20160816; b=r0mN5a+A7RqLXNftrUxaovwvb/Dnqi9R2gcJE+83IUEInHBS/gl6brcddw+rFd0PCs dzmFh72MLUPB0MWuWy2iDieWzA9ThZUn13VbvJ+SadgOxIe9gDyoACPR3Xdgx0uvIekf o3vTLWP+6ly4WrnirM6FM2X5d2MR6vSYAOlgs+rOOYbch53cQJeFJ2PDRM2stE2EYwyG tLQDXdRVIWdUs2W1npbxH0yk6n4IJ2APk78KNMxngSbHvydAIrlwup9L593++UNAI0f+ giBle2QMhxAHph/TfHZiAyv5K+ioA1Vptds0slUAazpsIY8Fu+pjnU9IVdN8vDtODOo2 6SPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=HZOJyXD6h0J1dPw61LQB+3SuCZyUdgcdMue+Lex4U5E=; b=a/urD98QCJDOwDw2WTOPgCMjbmHb4TCVzEEajYZWrnyu3kqF+72n7Q3NTyLv6d4r/T 731Jbkp5z8Ul5YvYhqc7SLoQnjWkbVWWuDmIw2S9dM1KDobN9dL5Cdul+XdcV09/40mK ZPvHA7Pe6YyJUdr9bVnhScdg5Ser+cr5ZZotXZHh2ThsxS6lXtZKco0o/eEq4gdZ9Gg7 h4bdHfP/YJv/h9JZgnvZgqIuVNJm18N8/WoZNuxVE6ApkoJp07QwCavru9z3JmY03vd2 Tixf2psOs6f2rLZxm45NU0sagnEM90F7UnwwQadzsDrKunDCmkzED14P+J8+nCIkI8L8 5Wsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UL5SEVGE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z2si10316472eja.539.2021.02.01.06.10.40; Mon, 01 Feb 2021 06:11:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UL5SEVGE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232607AbhBAOHI (ORCPT + 99 others); Mon, 1 Feb 2021 09:07:08 -0500 Received: from mail.kernel.org ([198.145.29.99]:51194 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231511AbhBAOHA (ORCPT ); Mon, 1 Feb 2021 09:07:00 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9ED6764EA1; Mon, 1 Feb 2021 14:06:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612188377; bh=tQ4WmAzlyE4k3CyxrsslSldFLnH7v9mWZ6r3RsrN92o=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=UL5SEVGET2SxXOjmGMFgkjoD6BYDZRygtnBjTNJu8V+/pemWyIGsJvG9bgE7KLyje Lj0fREqDV8/aSZzmEAC740HLoqXoVG8YqsDmdtGjgNYIh4bifIIX4bgm9L2Vgn6Qf/ skfj+H8rithoJoc6YyhJjD5NsHlPBaL1DNXlpEOI3++atJAMJ/RAF4wjCfZWEiyizL b3v4OtZj7m63wkIDoMx+H025TmfyvnDFwsqtqVWV8MWE793bhKAI75OWUW/xLAwoFI +7e+KAO1E4+vH6oUMtql/UMjfj+ECQfyOhDT3uXO8MgZzW6B1/vWG//Ibrwenv7RS0 RycHCDmybViNw== Date: Mon, 1 Feb 2021 16:06:05 +0200 From: Mike Rapoport To: Linus Torvalds Cc: Andrew Morton , Andrea Arcangeli , Baoquan He , Borislav Petkov , Chris Wilson , David Hildenbrand , "H. Peter Anvin" , Ingo Molnar , =?utf-8?Q?=C5=81ukasz?= Majczak , Mel Gorman , Michal Hocko , Mike Rapoport , Qian Cai , "Sarvela, Tomi P" , Thomas Gleixner , Vlastimil Babka , Linux Kernel Mailing List , Linux-MM , stable , the arch/x86 maintainers Subject: Re: [PATCH v4 1/2] x86/setup: always add the beginning of RAM as memblock.memory Message-ID: <20210201140605.GG242749@kernel.org> References: <20210130221035.4169-1-rppt@kernel.org> <20210130221035.4169-2-rppt@kernel.org> <20210131080356.GE242749@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Jan 31, 2021 at 01:49:27PM -0800, Linus Torvalds wrote: > On Sun, Jan 31, 2021 at 12:04 AM Mike Rapoport wrote: > > > > > > > > That's *particularly* true when the very line above it did a > > > "memblock_reserve()" of the exact same range that the memblock_add() > > > "adds". > > > > The most correct thing to do would have been to > > > > memblock_add(0, end_of_first_memory_bank); > > > > Somewhere at e820__memblock_setup(). > > You miss my complaint. > > Why does the memblock code care about this magical "memblock_add()", > when we just told it that the SAME REGION is reserved by doing a > "memblock_reserve()"? > > IOW, I'm not interested in "the correct thing to do would have been > [another memblock_add()]". I'm saying that the memblock code itself is > being confused, and no additional thing should have been required at > all, because we already *did* that memblock_reserve(). > > See? There is nothing magical about memblock_add(). Memblock presumes that arch code uses memblock_add() to register populated physical memory ranges and memblock_reserve() to protect memory ranges that should not be touched. These ranges do not necessarily overlap, so there maybe reserved ranges that do not have the corresponding registered memory. This lets architectures to say "here are the memory banks I have" and "this memory is in use" (or even "this memory _might_ be in use" ) independently of each other. The downside is that if there is a reserved range there is no way to tell whether it is backed by populated memory. We could change this semantics and enforce the overlap, e.g. by implicitly adding all the reserved ranges to the registered memory. I've already tried that and I've found out that there are systems that rely on memblock's ability to track reserved and available ranges independently. For example, arm systems I've mentioned in the previous mail always have a reserved chunk at 0xfe000000 in their DTS, but they may have only 2G of memory actually populated. Now, on x86 there is a gap between e820 and memblock since 2.6 times. As of now, only E820_TYPE_RAM is added to memblock as memory, some of the E820_*_RESERVED are reserved and on top there are reservations of the memory that's known to be used by BIOS or kernel. I'm trying to close this gap with small steps and with changes that I believe will not break too many things at once so it'll become unmanageable. > Honestly, I'm not seeing it being a good thing to move further towards > memblock code as the primary model for memory initialization, when the > memblock code is so confused. I'm not sure I follow you here. If I'm not mistaken, memblock is used as the primary model for memmap and page allocator initialization for almost a decade now... > Linus -- Sincerely yours, Mike.