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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E353C021BB for ; Mon, 24 Feb 2025 14:37:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AA11B6B0099; Mon, 24 Feb 2025 09:37:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A502F6B009A; Mon, 24 Feb 2025 09:37:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 93FA16B009B; Mon, 24 Feb 2025 09:37:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 76E856B0099 for ; Mon, 24 Feb 2025 09:37:13 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 4DB3D1616CB for ; Mon, 24 Feb 2025 14:37:02 +0000 (UTC) X-FDA: 83155090284.13.A2C796B Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by imf24.hostedemail.com (Postfix) with ESMTP id 5DC7518000F for ; Mon, 24 Feb 2025 14:37:00 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=HMR9ZyF5; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf24.hostedemail.com: domain of rppt@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1740407820; a=rsa-sha256; cv=none; b=1Z+PN9/3dBuC0rEv7QwKU+T/LLD5K7wUO3KUhgqfH0gYNXsCDjfDD6KNYExUAspJ3qmTAv elL/cZ/2OsdXxctApSzIBMgI+fTqFO+narN+aj/hEyG07nQ+slSdwCSK5n5RjEPUm1qhLW RUt46Ka+MwQk1F0s741uGsDJwP34Byo= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=HMR9ZyF5; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf24.hostedemail.com: domain of rppt@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1740407820; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=U2kxLp8PGsF6no9olkoxvVLRBxQRM1JnR8fdH/vpckg=; b=J3UPdLHA6aLSCyUGT6x8NSBbl//AzXJaOmhqDaC4Tq0q3POIAzRRYym3OhQ/a2AXPbd1kl 8U5dxnMAqzQ1ynk2S77SId6XF2qouMyXtbVqkNFhd5S0fr9N79XduebG0go7Kw7DruXIa5 9D8toP+JxkPTVSlgKEBDy3Q4MohGbUE= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id 71174611B9; Mon, 24 Feb 2025 14:36:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C36ADC4CEE6; Mon, 24 Feb 2025 14:36:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740407819; bh=ZPkqFHkfpEEXBvv/JiiAXJD73VY1MQPjnfI68AzNmMg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=HMR9ZyF51+gCTr5O6+tVcp768/JhJHldAdQMuQdHABvUY7CdUug/Ab1wT3ObgQGAC 7NzdY7UbKVP+eM8BgNncEZMMwXw3Wso7TJk0q2VyeryHtrjfnrTE2e5UNcbDKvPLhE 5rK+17rtGXNWyA/lMLkVwP2uxrzQbGpoqpM86P+xp+fCHrb56wfT+YG6s+mEWHlMq7 +kkYVhJASr3nwSzp8WJx6sGZ3GtEKDCIWteAIxOWx0XP2wkAbG4nWMVBfM/fSU2Vi1 69Xel5I0sX2/L5q0XRAaPHw5kaC8vo10XnIAcPaeS8jvBssTAmWVUTy3s4cxy0sDjX NCx7zo+hSuMbw== Date: Mon, 24 Feb 2025 16:36:38 +0200 From: Mike Rapoport To: Wei Yang Cc: linux-kernel@vger.kernel.org, Alexander Graf , Andrew Morton , Andy Lutomirski , Anthony Yznaga , Arnd Bergmann , Ashish Kalra , Benjamin Herrenschmidt , Borislav Petkov , Catalin Marinas , Dave Hansen , David Woodhouse , Eric Biederman , Ingo Molnar , James Gowans , Jonathan Corbet , Krzysztof Kozlowski , Mark Rutland , Paolo Bonzini , Pasha Tatashin , "H. Peter Anvin" , Peter Zijlstra , Pratyush Yadav , Rob Herring , Rob Herring , Saravana Kannan , Stanislav Kinsburskii , Steven Rostedt , Thomas Gleixner , Tom Lendacky , Usama Arif , Will Deacon , devicetree@vger.kernel.org, kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org Subject: Re: [PATCH v4 12/14] x86: Add KHO support Message-ID: References: <20250206132754.2596694-1-rppt@kernel.org> <20250206132754.2596694-13-rppt@kernel.org> <20250224071355.xsl2dbupda4dhfzl@master> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250224071355.xsl2dbupda4dhfzl@master> X-Rspam-User: X-Rspamd-Queue-Id: 5DC7518000F X-Rspamd-Server: rspam12 X-Stat-Signature: m8535tt3trsojmtqojorgpz55dfkfg78 X-HE-Tag: 1740407820-535412 X-HE-Meta: U2FsdGVkX1/GdOTwfwbGHxl6wNV+PcpzfwQs/KHeA037Gv2/ZBtXgGIDqLeRgyKFY1TT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7Wgfb2he0yBiifcCYcpU4xWDu2CkQEz8offfaKj6mMuQU9dMG+D1MNhQ1sKMWf4rW4C9BwfDBRejQYOa9jw1WBFwdskWHE/bug2lB+4iSSy1VuXVZMN5NQKEmNovyvyUaQyOtNFPsOaHPMVA0s3j5lDYBInsrNVb/IP/XnHLeaD1M65yJE1xcsrcLHW+XepgGlGpA7vHOtmz+ 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: List-Subscribe: List-Unsubscribe: On Mon, Feb 24, 2025 at 07:13:55AM +0000, Wei Yang wrote: > On Thu, Feb 06, 2025 at 03:27:52PM +0200, Mike Rapoport wrote: > >From: Alexander Graf > [...] > >diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c > >index 82b96ed9890a..0b81cd70b02a 100644 > >--- a/arch/x86/kernel/e820.c > >+++ b/arch/x86/kernel/e820.c > >@@ -1329,6 +1329,24 @@ void __init e820__memblock_setup(void) > > memblock_add(entry->addr, entry->size); > > } > > > >+ /* > >+ * At this point with KHO we only allocate from scratch memory. > >+ * At the same time, we configure memblock to only allow > >+ * allocations from memory below ISA_END_ADDRESS which is not > >+ * a natural scratch region, because Linux ignores memory below > >+ * ISA_END_ADDRESS at runtime. Beside very few (if any) early > >+ * allocations, we must allocate real-mode trapoline below > >+ * ISA_END_ADDRESS. > >+ * > >+ * To make sure that we can actually perform allocations during > >+ * this phase, let's mark memory below ISA_END_ADDRESS as scratch > >+ * so we can allocate from there in a scratch-only world. > >+ * > >+ * After real mode trampoline is allocated, we clear scratch > >+ * marking from the memory below ISA_END_ADDRESS > >+ */ > >+ memblock_mark_kho_scratch(0, ISA_END_ADDRESS); > >+ > > At the beginning of e820__memblock_setup() we call memblock_allow_resize(), > which means during adding memory region it could double the array. And the > memory used here is from some region just added. There are large KHO scratch areas that will be used for most allocations. Marking the memory below ISA_END_ADDRESS as KHO scratch is required to satisfy allocations that explicitly limit the allocation to ISA_END_ADDRESS, e.g the real time trampoline. > But with KHO, I am afraid it would fail? > > > /* Throw away partial pages: */ > > memblock_trim_memory(PAGE_SIZE); > > > > -- > Wei Yang > Help you, Help me -- Sincerely yours, Mike.