From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0ACB030EF90 for ; Wed, 22 Apr 2026 08:24:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776846288; cv=none; b=cUgFmFd+/9hNvkxqhi7KSFKvgAONUeT+eYHiTX7SUCkNa6OxioEalnELyZ7WFbK6RavhFYnRiFo22vegTRcKE919Lpxs8Tm+zyhuJJqVORqlYbx/vY2mdUw61sBMEqjq5IHpdG5AcpRPcIlMRbod0hDMp9Gl3OO5AYldX00sfTM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776846288; c=relaxed/simple; bh=O4CGkWR3yo72+GsjHY8NtS8RkGbc3ZGUxRZULeofgFg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=U8ZX/6V9PBp3rTJ4DEkoVw1D4hRqp/XQsGg/mxcSrpVAqJcSJZAg2CX2he0rk9Hr0TgJWe41OMyHpp/aqbPp5n/tUAS34t6HSoEgylu5i/scpJHw+ZydqzDSqvvvhSS/uLqjLMJgWUjxXYCZSaG7bsY0OzMOpRUaYjVEj48DSQI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cv0wwWgr; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cv0wwWgr" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C1779C19425; Wed, 22 Apr 2026 08:24:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1776846287; bh=O4CGkWR3yo72+GsjHY8NtS8RkGbc3ZGUxRZULeofgFg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=cv0wwWgrynQ5CA3sXK6hAWgNSFWM9M0Zf2+AiJn8U6B9PhZ8P+C4ZcFM2PTWH3/gS xunfJhdsw6QoZtFJ7iQZ1jD/zF3jHLpWq1U0LzJ1UqK6dYj9WCy5q36v2PwNmOUy92 +ddok9+Sq2osrJYGf7HRLV38oc6lizDVYyDKEbkCaWLBoeXywA/hrW+EJmemlReyHx A4tFlE44uBAEjEHQbhIY2BImZLll0veiNGSOAJpViaay+cnCilRb/Lf1uj4stLtM/3 yk99yteLjLs3RCIdvQqb8sXfx3R6zXyYAEYIw67qBRxVeD29gSj3H9EYJqOxWNRAEw bTUUsOhSinHig== Date: Wed, 22 Apr 2026 11:24:39 +0300 From: Mike Rapoport To: =?utf-8?B?TWljaGHFgiBDxYJhcGnFhHNraQ==?= Cc: Evangelos Petrongonas , Pasha Tatashin , Pratyush Yadav , Alexander Graf , Samiullah Khawaja , kexec@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton , Vlastimil Babka , Suren Baghdasaryan , Michal Hocko , Brendan Jackman , Johannes Weiner , Zi Yan Subject: Re: [PATCH v8 1/2] kho: fix deferred initialization of scratch areas Message-ID: References: <20260416110654.247398-1-mclapinski@google.com> <20260416110654.247398-2-mclapinski@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Tue, Apr 21, 2026 at 12:20:27PM +0200, Michał Cłapiński wrote: > On Tue, Apr 21, 2026 at 8:08 AM Mike Rapoport wrote: > > > > On Mon, Apr 20, 2026 at 03:11:03PM +0200, Michał Cłapiński wrote: > > > On Thu, Apr 16, 2026 at 6:13 PM Mike Rapoport wrote: > > > > > > > > On Thu, Apr 16, 2026 at 05:06:10PM +0200, Michał Cłapiński wrote: > > > > > On Thu, Apr 16, 2026 at 4:45 PM Mike Rapoport wrote: > > > > > > > > > > > > Hi Michal, > > > > > > > > > > > > On Thu, Apr 16, 2026 at 01:06:53PM +0200, Michal Clapinski wrote: > > > > > > > @@ -2262,6 +2253,12 @@ static void __init memmap_init_reserved_range(phys_addr_t start, > > > > > > > * access it yet. > > > > > > > */ > > > > > > > __SetPageReserved(page); > > > > > > > + > > > > > > > +#ifdef CONFIG_MEMBLOCK_KHO_SCRATCH > > > > > > > > > > > > No need for #ifdef here, there's a stub returning false for > > > > > > CONFIG_MEMBLOCK_KHO_SCRATCH=n case. > > > > > > > > > > In all 3 places the #ifdef is there because MIGRATE_CMA might be > > > > > undefined. I already broke mm-new branch in the past because of that. > > > > > > > > Hmm, that hurts :/ > > > > > > > > The best I can think of is to add a static inline in memblock.h and ifdefs > > > > around it. > > > > > > Sorry, I don't understand what you mean. What would that static inline contain? > > > > Something like this: > > > > #ifdef CONFIG_MEMBLOCK_KHO_SCRATCH > > static inline enum migratetype kho_scratch_migratetype(unsigned long pfn, > > enum migratetype mt) > > { > > if (memblock_is_kho_scratch_memory(PFN_PHYS(pfn))) > > return MIGRATE_CMA > > return mt; > > } > > #else > > static inline enum migratetype kho_scratch_migratetype(unsigned long pfn, > > enum migratetype mt) > > { > > return mt; > > } > > #endif > > How would I use it for this code? > > +#ifdef CONFIG_MEMBLOCK_KHO_SCRATCH > + if (memblock_is_kho_scratch_memory(PFN_PHYS(pfn)) && > + pageblock_aligned(pfn)) > + init_pageblock_migratetype(page, MIGRATE_CMA, false); > +#endif Something like this enum migratetype mt = kho_scratch_migratetype(pfn, MIGRATE_MOVABLE); ... if (memblock_is_kho_scratch_memory(PFN_PHYS(pfn)) && pageblock_aligned(pfn)) init_pageblock_migratetype(page, mt, false); seems better to me than ifdef, even though MIGRATE_MOVABLE is bogus here. And since we anyway changing init_pageblock_migratetype() callers in mm_init.c the entire block in memmap_init_reserved_range() can be dropped and the change can be done in __init_page_from_nid(). > > It doesn't invoke init_pageblock_migratetype unless pfn is kho scratch. > > > Can't say I'm happy about the name, but could not think of something > > better. > > > > > > > > > + if (memblock_is_kho_scratch_memory(PFN_PHYS(pfn)) && > > > > > > > + pageblock_aligned(pfn)) > > > > > > > + init_pageblock_migratetype(page, MIGRATE_CMA, false); > > > > > > > +#endif > > > > > > > } > > > > > > > } > > > > > > > > -- > > > > Sincerely yours, > > > > Mike. > > > > -- > > Sincerely yours, > > Mike. -- Sincerely yours, Mike.