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 D3606C3ABDA for ; Wed, 14 May 2025 07:11:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3AD0E6B00D6; Wed, 14 May 2025 03:11:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 35B566B00D7; Wed, 14 May 2025 03:11:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 223926B00D8; Wed, 14 May 2025 03:11:56 -0400 (EDT) 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 0373D6B00D6 for ; Wed, 14 May 2025 03:11:55 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 51F365BDB7 for ; Wed, 14 May 2025 07:11:57 +0000 (UTC) X-FDA: 83440643874.21.95A8900 Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) by imf05.hostedemail.com (Postfix) with ESMTP id 41022100003 for ; Wed, 14 May 2025 07:11:54 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=infradead.org header.s=desiato.20200630 header.b=oC7vMgk+; spf=none (imf05.hostedemail.com: domain of peterz@infradead.org has no SPF policy when checking 90.155.92.199) smtp.mailfrom=peterz@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1747206715; 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=EFvseOXYys5kITisJ1qS0WFaJXYFq3Ac6sONg0UaglM=; b=wtIHKApSbCxaIoFCcwhRGwaQMktoIXuYtqNzND+S3BSjcjWI52i+tAeKpxK4MW3k9wxYb0 1J2zbUq09Q+H3DG1rWC1LUBkEEkp0vYuw/SP2CX2UIMzE9ASIiKfBVEfKmNSIJbFZQ8+Fr VIbb2YPDixcYwbMVbtLhDup5OszyUpU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1747206715; a=rsa-sha256; cv=none; b=Ft0DCvJ8/JXaOpJwfWrAhp03VywNIpRy6/HG7YfwWhsAD1YyXEGjG2ejIB/a6GxqlEbiph qB82w3mSro+wuOaNx81pbeHL/xligfT/rQDAoAtK5NsMig5jSy0+KnBtFq+jFuWwjLmjJb pj8KRF7A7DOVCMuAVoZc4KEUep+AEzI= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=infradead.org header.s=desiato.20200630 header.b=oC7vMgk+; spf=none (imf05.hostedemail.com: domain of peterz@infradead.org has no SPF policy when checking 90.155.92.199) smtp.mailfrom=peterz@infradead.org; dmarc=none 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=EFvseOXYys5kITisJ1qS0WFaJXYFq3Ac6sONg0UaglM=; b=oC7vMgk+wnSJF6DewHj87tRCxe 3cRn1Wp1stx5BqyOYvm+qSvY65/J7pAPeF4N16Ud9Q+78FIzTmx5M4wj2aO29pfmZWHhLE+XRIn0B ivTv2XpYYyPw9ZuhqLaZyNLk+yhZSlKg2v/Fmc51mDktuvLIUbaWKQZ3oT7ynUE/GkYK9W+px1TpI PR7ugF4g8BWDhhRZV2IIXX+iORDvARjoTlpAjcuVmV3BN+YYpv5iWChCBeetfFhp0z8pzO81sNTWs WpbknI8uCulAXd7eHDNuhGjfct2nArqTuRkVbSWoH1YDOWhwInjKww+/mwCa201L+lilEvPk00eZU 3aIyPujA==; 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.98.1 #2 (Red Hat Linux)) id 1uF6HJ-0000000H6V6-0WhV; Wed, 14 May 2025 07:11:45 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 8D3B8300717; Wed, 14 May 2025 09:11:44 +0200 (CEST) Date: Wed, 14 May 2025 09:11:44 +0200 From: Peter Zijlstra To: Shakeel Butt Cc: Vlastimil Babka , Andrew Morton , Tejun Heo , Johannes Weiner , Michal Hocko , Roman Gushchin , Muchun Song , Alexei Starovoitov , Sebastian Andrzej Siewior , bpf@vger.kernel.org, linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, Meta kernel team , Mathieu Desnoyers , npiggin@gmail.com Subject: Re: [PATCH 0/4] memcg: nmi-safe kmem charging Message-ID: <20250514071144.GB24938@noisy.programming.kicks-ass.net> References: <20250509232859.657525-1-shakeel.butt@linux.dev> <2e2f0568-3687-4574-836d-c23d09614bce@suse.cz> <07e4e8d9-2588-41bf-89d4-328ca6afd263@suse.cz> <20250513114125.GE25763@noisy.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 41022100003 X-Stat-Signature: zp374iakrp7hutsi5r9h3mt9dkd8hepp X-Rspam-User: X-HE-Tag: 1747206714-774060 X-HE-Meta: U2FsdGVkX1/txxqBVjKPA8p5/OcuUB+z7W6MedS+iPb0eG9ZpwfAifpr5+q5MINe3NUou7ksbAcNaPZgml3mnipBJtValdReywt9A5A6PtZSbu7cl2mvVfANVncCBL9Kvp4Ib/2THjwp1dnbXbz2YMqZAh/n0Njs6yCOQw1v4BqbAE3Tuj7kuukVLQWFL03MlCcUa4YM2fMpSDs5xBrLsvmi39fgHfFRh5ajPMbpxZ986wlH3ajIloo29NrMeB2ZRa8rlZ6ilGpvxb4acI407STDiUdtVlbFheQ1pOn2Y7yPX2tsVWj8Kbd9Qf/geAfJETX65qiVJakCf3zSulpR5qHRrs0Vkav5xk9nsb1el/C7LwtlswDz4kmw2cfnO1/ISR5xHHjWzcL24pI/EyJX0ylJbvU4cyfCEVjqALP+sPsgG08KZy/lLG1rYMR8rdMXoJ2OOBWnV/0t1ND0JYyjoZWqSeXZlUzfcA8VIpRuv9lKAEMKnjf0wIDaUsP2Eyz4e6qFo0TkOQ/WpsSJ9K7REwFCUfZtFaIV+SLu9LftGzcCRE/D4hIIpZXufhhiIuJBNULmrxM+VFP62LY/hDFq201hHUMvEl4ku4o+bQsZcZfbYKWuPVR+DNp1oN/jl3U3BheRhj8SN60FETzd6Pu8vKB3TdzjFoxasdMuFViLp4RZrInD4DYYHSIaBQunqdUH2oKntUZ3+AoZiT4rJxnhxIC5frglgI7Kl4EFaMRN5HfEcr3qGedvt4Xm0qymjfE5rG+RcDVBQDO0cYqoEkyDfuN3IFNe3MeJWbDUWQ442v078d5WtXPneduFhGZiLb07f/Qi8phe4M8q7ITDUH+mOJSu3QME055bq17i/rwM2WOq2kGdwjPXdKmisQMYpHj8UVp7accssmEeu5v4YAoVBjC62DH+24GjFdOGbTs3n+IiAD04Zbt61gNCb2GIU7JgbzGnzupvBzHTvjcGMSB NBsM3v3t GCzx6JQRb6LfpZeQgPfRxoueEa+0v01fCY+f4a0aGpVkOEMld4pxKhztHTCKaSjNtBWOWdZO6hKnTtt+7pEYs0sBr3gaG0Ekx0yHZxlm25J+VamHlWwNM5sMs0lxcz4WSu7j/i6OO8sc2nt82YKX88BIcuTm/wiMwKnU+h/eKmTM9SC4ljVUPw9NujzR0jpuUEd1r 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 Tue, May 13, 2025 at 03:17:00PM -0700, Shakeel Butt wrote: > > IIRC Power64 has issues here, 'funnily' their local_t is NMI safe. > > Perhaps we could do the same for their this_cpu_*(), but ideally someone > > with actual power hardware should do this ;-) > > > > Is CONFIG_ARCH_HAS_NMI_SAFE_THIS_CPU_OPS the right config to > differentiate between such archs? I see Power64 does not have that > enabled. > > There is no config symbol for this presently. > > Hmm what about CONFIG_ARCH_HAS_NMI_SAFE_THIS_CPU_OPS? Hmm, I didn't know about that one, and it escaped my grep yesterday. Anyway, PPC is fixable, just not sure its worth it for them. > > > > > - (if the above leaves any 64bit arch) its 64bit atomics implementation is safe > > > > True, only because HPPA does not in fact have NMIs. > > What is HPPA? arch/parisc the worst 64bit arch ever. They saw sparc32-smp and thought that was a great idea, or something along those lines. Both are quite terrible. Sparc64 realized the mistake and fixed it -- it has cmpxchg. Nick, is this something that's useful for you guys? --- diff --git a/arch/powerpc/include/asm/percpu.h b/arch/powerpc/include/asm/percpu.h index ecf5ac70cfae..aa188db68ef5 100644 --- a/arch/powerpc/include/asm/percpu.h +++ b/arch/powerpc/include/asm/percpu.h @@ -25,6 +25,11 @@ DECLARE_STATIC_KEY_FALSE(__percpu_first_chunk_is_paged); #define percpu_first_chunk_is_paged false #endif +#ifdef CONFIG_PPC_BOOK3S_64 +#define __pcpu_local_irq_save(f) powerpc_local_irq_pmu_save(f) +#define __pcpu_local_irq_restore(s) powerpc_local_irq_pmu_restore(f) +#endif + #include #include diff --git a/include/asm-generic/percpu.h b/include/asm-generic/percpu.h index 02aeca21479a..5c8376588dfb 100644 --- a/include/asm-generic/percpu.h +++ b/include/asm-generic/percpu.h @@ -75,6 +75,11 @@ extern void setup_per_cpu_areas(void); #define PER_CPU_ATTRIBUTES #endif +#ifndef __pcpu_local_irq_save +#define __pcpu_local_irq_save(x) raw_local_irq_save(x) +#define __pcpu_local_irq_restore(x) raw_local_irq_restore(x) +#endif + #define raw_cpu_generic_read(pcp) \ ({ \ *raw_cpu_ptr(&(pcp)); \ @@ -146,9 +151,9 @@ do { \ ({ \ TYPEOF_UNQUAL(pcp) ___ret; \ unsigned long ___flags; \ - raw_local_irq_save(___flags); \ + __pcpu_local_irq_save(___flags); \ ___ret = raw_cpu_generic_read(pcp); \ - raw_local_irq_restore(___flags); \ + __pcpu_local_irq_restore(___flags); \ ___ret; \ }) @@ -165,9 +170,9 @@ do { \ #define this_cpu_generic_to_op(pcp, val, op) \ do { \ unsigned long __flags; \ - raw_local_irq_save(__flags); \ + __pcpu_local_irq_save(__flags); \ raw_cpu_generic_to_op(pcp, val, op); \ - raw_local_irq_restore(__flags); \ + __pcpu_local_irq_restore(__flags); \ } while (0) @@ -175,9 +180,9 @@ do { \ ({ \ TYPEOF_UNQUAL(pcp) __ret; \ unsigned long __flags; \ - raw_local_irq_save(__flags); \ + __pcpu_local_irq_save(__flags); \ __ret = raw_cpu_generic_add_return(pcp, val); \ - raw_local_irq_restore(__flags); \ + __pcpu_local_irq_restore(__flags); \ __ret; \ }) @@ -185,9 +190,9 @@ do { \ ({ \ TYPEOF_UNQUAL(pcp) __ret; \ unsigned long __flags; \ - raw_local_irq_save(__flags); \ + __pcpu_local_irq_save(__flags); \ __ret = raw_cpu_generic_xchg(pcp, nval); \ - raw_local_irq_restore(__flags); \ + __pcpu_local_irq_restore(__flags); \ __ret; \ }) @@ -195,9 +200,9 @@ do { \ ({ \ bool __ret; \ unsigned long __flags; \ - raw_local_irq_save(__flags); \ + __pcpu_local_irq_save(__flags); \ __ret = raw_cpu_generic_try_cmpxchg(pcp, ovalp, nval); \ - raw_local_irq_restore(__flags); \ + __pcpu_local_irq_restore(__flags); \ __ret; \ }) @@ -205,9 +210,9 @@ do { \ ({ \ TYPEOF_UNQUAL(pcp) __ret; \ unsigned long __flags; \ - raw_local_irq_save(__flags); \ + __pcpu_local_irq_save(__flags); \ __ret = raw_cpu_generic_cmpxchg(pcp, oval, nval); \ - raw_local_irq_restore(__flags); \ + __pcpu_local_irq_restore(__flags); \ __ret; \ })