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]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A4D1BC53219 for ; Tue, 28 Jul 2026 15:30:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 653A46B008C; Tue, 28 Jul 2026 11:30:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 62AAC6B0093; Tue, 28 Jul 2026 11:30:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 569896B0095; Tue, 28 Jul 2026 11:30:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 2D4B46B008C for ; Tue, 28 Jul 2026 11:30:28 -0400 (EDT) Received: from smtpin21.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay04.hostedemail.com (Postfix) with ESMTP id AD8E81A03FF for ; Tue, 28 Jul 2026 15:30:27 +0000 (UTC) X-FDA: 85038572094.21.8233C4B Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) by imf28.hostedemail.com (Postfix) with ESMTP id 6F9FDC0010 for ; Tue, 28 Jul 2026 15:30:25 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=infradead.org header.s=desiato.20200630 header.b=C+NTxpFk; dmarc=pass (policy=none) header.from=infradead.org; spf=pass (imf28.hostedemail.com: domain of peterz@infradead.org designates 90.155.92.199 as permitted sender) smtp.mailfrom=peterz@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1785252625; 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=r7a5jh4qeutPWij5dNaVnpBg8RmqFNiNHJXuQhNtjlI=; b=Y64Q8Vr5y39BNsJQDr+1do/uu0nACimJG8pT5q3PjB7eAcKxr3Apin7xQIlbghsYWrvpFe qpVrwsf2u6lOTi/4ALwNGsSmJ6MzA0N09YyrswxNX61AGxzI9qO5UJWTiAy0HYdMAzGvOi omJKR27KWrKMo382JRx5hQ/CxsLaa2Q= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=infradead.org header.s=desiato.20200630 header.b=C+NTxpFk; dmarc=pass (policy=none) header.from=infradead.org; spf=pass (imf28.hostedemail.com: domain of peterz@infradead.org designates 90.155.92.199 as permitted sender) smtp.mailfrom=peterz@infradead.org ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1785252625; b=7s8SNV8tzmsU6vYrerxltEK5S2m6FqumFEegS7rLIkhevOLfNt1+7c701dx0xyo29+kH0g P60WPncpRhX/JsU5hJuxnWjD3PRC2Eod1Lh/+i8nT4jJW2yXx7Jt5tRIuwgtj8TlOFfQQH Cp1MFGKVPB/N+xqwRT9Xtz9JP3CCZ8c= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=r7a5jh4qeutPWij5dNaVnpBg8RmqFNiNHJXuQhNtjlI=; b=C+NTxpFk6RN70FEbbxxwCZACaE NKD0at/vSUIsbpF17jcNDIGkoYlGuJ5AWosQJ5EsVCZzWRFdtA3DJjcI8TBsWu2ja0A5VXsuxXbub LALrm0td7goVArnlPrHF6uiJmB32+SwGMdvQ0uqbN7hKgP3yhzLnVXvFiCy1NtgRBSbynF3/G/Jih JfAaHU0zd+25WVu9GnQQrsRy59s+M+tXRxEoS218dvjt82ncwTM+I8mpYTQjfJqt+ZoqU9um2Zxjt w5fbVe1PqoU22ZVBALqCI7H3jD4gCH1gYbx6hl6iIEkz9w+9nOo58UMDNYA+ZGPEd0EZVMsKLz+Pz S32mj23w==; Received: from 77-249-17-252.cable.dynamic.v4.ziggo.nl ([77.249.17.252] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.99.2 #2 (Red Hat Linux)) id 1wojl3-000000054s3-1WyI; Tue, 28 Jul 2026 15:30:17 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 8F4AE3004AB; Tue, 28 Jul 2026 17:30:15 +0200 (CEST) Date: Tue, 28 Jul 2026 17:30:15 +0200 From: Peter Zijlstra To: Mike Rapoport Cc: Dave Hansen , Dave Hansen , Andrew Morton , Andy Lutomirski , Borislav Petkov , David CARLIER , David Hildenbrand , Ingo Molnar , Jason Gunthorpe , Juergen Gross , Kevin Tian , Kiryl Shutsemau , "Liam R. Howlett" , Lorenzo Stoakes , Lu Baolu , "H. Peter Anvin" , Shakeel Butt , Suren Baghdasaryan , Thomas Gleixner , Toshi Kani , Vishal Moola , Vlastimil Babka , Will Deacon , iommu@lists.linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org, stable@vger.kernel.org, x86@kernel.org Subject: Re: [PATCH 1/5] x86/mm/pat: introcude cpa_lock() and cpa_unlock() Message-ID: <20260728153015.GD921102@noisy.programming.kicks-ass.net> References: <20260728-cpa-fixes-v1-0-2ed2352300b3@kernel.org> <20260728-cpa-fixes-v1-1-2ed2352300b3@kernel.org> <20260728142108.GW751831@noisy.programming.kicks-ass.net> <20260728143135.GG651302@noisy.programming.kicks-ass.net> <20260728145528.GI651302@noisy.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260728145528.GI651302@noisy.programming.kicks-ass.net> X-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wcipNa/j5rLD CYrT18+T JOlphiLWFpjHL9TcqrDOTSP9perTl0i3aP705cP92UUguiWyy9A97Sh/Clu1/nFmtswDvdT77akefGAr3mb7efPqe0AXiFkq9tztzstq7vk9wj/xgCLY6OerTKwf2zM7H5ZqhqFy9Pe1g0WIZ0Nrw88w0my83npstXlAm0TnfuhlWgDZH1KNL7H8bDDl4CKGhOF4HptxXMdgD/Ej2BaQw+9sWVXPlLP8F5R8C7aQFq34IFoYY8Cl0U12JfbIZhRnphAVj9tXGa8EkWWZp2A6LPFM/Rx/YbcFtfKcsPmguq3XV3PGLAAyJlr4U466M+QIHJqX8MgFhxeb0csw= Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Tue, Jul 28, 2026 at 04:55:28PM +0200, Peter Zijlstra wrote: > On Tue, Jul 28, 2026 at 05:46:30PM +0300, Mike Rapoport wrote: > > On Tue, Jul 28, 2026 at 04:31:35PM +0200, Peter Zijlstra wrote: > > > On Tue, Jul 28, 2026 at 07:30:27AM -0700, Dave Hansen wrote: > > > > On 7/28/26 07:21, Peter Zijlstra wrote: > > > > > There was already a patch merged that removed the shole debug_pagealloc > > > > > exception. Is that not better? > > > > > > > > As I'm scanning through email this morning, there's another issue that > > > > popped up with that patch. It's causing hangs on boot. > > > > > > > > It's looking like debug pagealloc not taking the lock is actually > > > > functional, not an optimization. Although, I hesitate to say > > > > "functional" and would prefer to use much less nice words to describe it. > > > > > > Yeah, lets figure out why that is before we retain this wart ;-) > > > > As Lorenzo said: > > > > __kernel_map_pages() can be called from irq context: > > > > < GFP_ATOMIC context > > > kfree() or whatever > > -> ... > > -> __free_pages_prepare() > > -> debug_pagealloc_unmap_pages() > > -> __kernel_map_pages() > > -> __change_page_attr_set_clr() > > -> cpa_lock > > > > The TLBI hack in __kernel_map_pages() makes me wonder how any of this is > correct to begin with. That comment isn't helping. > So in particular the from IRQ-disabled context thing seems to be clearing the 'present' bit. Not doing a full TLBI on that would allow other CPUs to still access the page, resulting a lack of faults. I suppose that is a non-fatal case. It makes the debug code less robust than it wants to be, but no malfunction. But debug_page_alloc_map_pages() as used from post_alloc_hook() for a GFP_ATOMIC alloc would result in not propagating the present bit, resulting in concurrent faults. And I'm not immediately seeing a fixup for that in the fault handler. Hmm, perhaps spurious_kernel_fault() handles it, after all, it would not actually observe !present anymore when reading the PTE, its just a stale TLB entry at that point. Hmmm...