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 1514EC77B7E for ; Thu, 25 May 2023 10:30:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 888586B007D; Thu, 25 May 2023 06:30:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 810D2900003; Thu, 25 May 2023 06:30:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 68D12900002; Thu, 25 May 2023 06:30:45 -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 58B9D6B007D for ; Thu, 25 May 2023 06:30:45 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 259B71C7A87 for ; Thu, 25 May 2023 10:30:45 +0000 (UTC) X-FDA: 80828408850.01.EE5028F Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf02.hostedemail.com (Postfix) with ESMTP id 2A84380014 for ; Thu, 25 May 2023 10:30:40 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=mpUeLnCW; dmarc=none; spf=none (imf02.hostedemail.com: domain of peterz@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=peterz@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1685010642; a=rsa-sha256; cv=none; b=HyPA03VUYQJ+z79LRmBDR9X6LGEEt9diMCP2NQSQOCPP4y0aOIcISOsl1PdU50RXZSRzv4 aeN2CMHw7uzceUJIaOSgTqrg55aTm3ooIANJtnti33P5toLvfOvK9hYly4oZFsdCMLNLwi ozSKIXqJPACsYX37uePM4D99kTrPd24= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=mpUeLnCW; dmarc=none; spf=none (imf02.hostedemail.com: domain of peterz@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=peterz@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1685010642; 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=2b0PecxjqDga2q+GYKiWoz11cnthWs1G0M5GzyNmn34=; b=YUb9Slsc6ERw6clqxGNg8SQF+sNijGSORvzY+mHUeRfN/UUVeVDSXOSlJKSBEqD0vWDAyX DJgMZAOnGhIoXC/dON4nE2ZoyGvDg7+//8ZrXrsGFBiG5XT2a1yt6rcLKJo5M5/qaOaIQL acYrc+E/Na0sY7VCnIBpHgsPjdU8EBA= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; 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=2b0PecxjqDga2q+GYKiWoz11cnthWs1G0M5GzyNmn34=; b=mpUeLnCWo62XTpDTxX4burZAso 4r8I70jFGZVNknFGbGALewmKj5QyyPUMmDf6M1MerTWmgcKeUzUzEtXNEqaPjHyxCBnjAb3Lv70MZ l7lvU1Mx4eAPduZLZX2QpZh+U1lTy6ByReO1PgmZlX8E/iTEE/ijH39fUttPtdqP/o/tzowIaiOeF O0aQae7O5eq6uvs0Kg7tpmg/RNiZT6JSGFfKzy6eNymIVcT0hIlh6jkrpKYhbGwX6OJVtHYSd3YRk vziECqTmVDnUrcqh0m3alPjvQFSM6x2fyvISqjodfjXw1qSa6YkSNFLTMiO3Udk2pb+JeKz2f/QTx b49bAhdQ==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1q28EF-00C6Pg-2p; Thu, 25 May 2023 10:29:55 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 332303002C5; Thu, 25 May 2023 12:29:46 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id BE2BC24387C95; Thu, 25 May 2023 12:29:46 +0200 (CEST) Date: Thu, 25 May 2023 12:29:46 +0200 From: Peter Zijlstra To: torvalds@linux-foundation.org Cc: corbet@lwn.net, will@kernel.org, boqun.feng@gmail.com, mark.rutland@arm.com, catalin.marinas@arm.com, dennis@kernel.org, tj@kernel.org, cl@linux.com, hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com, borntraeger@linux.ibm.com, svens@linux.ibm.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, joro@8bytes.org, suravee.suthikulpanit@amd.com, robin.murphy@arm.com, dwmw2@infradead.org, baolu.lu@linux.intel.com, Arnd Bergmann , Herbert Xu , davem@davemloft.net, penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, Andrew Morton , vbabka@suse.cz, roman.gushchin@linux.dev, 42.hyeyoo@gmail.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-s390@vger.kernel.org, iommu@lists.linux.dev, linux-arch@vger.kernel.org, linux-crypto@vger.kernel.org, sfr@canb.auug.org.au, mpe@ellerman.id.au Subject: Re: [PATCH v3 08/11] slub: Replace cmpxchg_double() Message-ID: <20230525102946.GE38236@hirez.programming.kicks-ass.net> References: <20230515075659.118447996@infradead.org> <20230515080554.453785148@infradead.org> <20230524093246.GP83892@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230524093246.GP83892@hirez.programming.kicks-ass.net> X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 2A84380014 X-Stat-Signature: jzainebx539ymyp7q6prjhiw4ta7nu7t X-HE-Tag: 1685010640-814099 X-HE-Meta: U2FsdGVkX18AES5fsrJd4e/kFQCSHHQjy9J7NiEBEgniXebv7+QvPkknP4eZLZpcqlRdn1NcWM+26GTyrMYoMQZtziQY/PcOLUYYPc/wdEE0aesijHw8yNfjS87NPy82amqboThLkf3rqt7di7KnTKnaXjP1kGyiOWLKeVuq5HorcAyZoMJCzFkOph6LySHR+Pr5lKzSLpf45N3sZQ9FojHbWnihrbjzut2+EP3M1PabDK+vA+F80kQqwHrGSldrvQ0ciMK80SXJ5bx2nhkt30Yo1V8orF+afP5d6JN2isYh7uGmF83/k/hnQWfjyhvw4wqthxxsKRksam2lYRU2BHSwpI0UEN0o+6wLfqH5AFovgV4T+n2WQ1E+F8jzgS++fWhh/U0ald62JiH2YqzQVf0+7O97Qu7AgCIpnqT6MPxlCFhTBI1haUrfzSx/gy5T+q0gh1DUCBYKRw+yW+++jO6o2f0B4XPJyCOG7qTYm470IfI6EAyd8KP7K2LmuTenWhO+bG6lcxMiEdwJYuROUVDGA4wQScQRQevv+pY1XpyEUkMdDXIxw+MCZT27QZfTmLaE7jzMpqTwAEPk/uugBYg5sPLsKvOKxo6Kl+/i8rj5RnZo39fTAyE++Nrky+gDrQOTKZdPNWaqPsf0H9cbd+z9K6KzlghmCW5GnWeQdQ7ZyOkQoMhvFz6YrOdfwq6/RkJCJ7TAycu7SOMFtXGp5p3/JiBP7jZXESz6DW1o3/1zFBmlEYX9YPW+xSkdFjJXKvys366st99tXK6K8c1pPAI+LSfyfLHdY94MVa3opeYD9ijWW+cRAegxaIflZEPbg+PkQnkFOyfHPW2HHxLHppmllBqxqOM5yWl0s73znQYFyGdfuwqmbjwmQYuxE/zbG+x6TZzwE8jyZR7qTTt+yhQDt3BHfLlkPTJ1n0cufU4NWUX2P7LxBblxdH7WIF64CX2vXHEgsHRkHzs+4Am AGDcKOvo x+1qEkb5VYoVZca9916j6nWyBcrmMFvC9+ikdsu7rxLKOTDI2huy7tyErwwIqvHejUWPvJL8v/tNMGDPIhGGC00iUOYU7cS3BnlvxNXh4iYB0yMuunfdsfRFkk34bh0vawplUhtTGROngTBNJa84Z55gm/MxOETQ4IwYv/XYtuOTLqqo3YrFuXi5o6uuZV5ieVFBR+U4pEsxVBwFSISr2r3LPCbQEqu3lHn/0EOwO6w1ZzQgdzzhlYglmq6YpnR8RG5PM 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: On Wed, May 24, 2023 at 11:32:47AM +0200, Peter Zijlstra wrote: > On Mon, May 15, 2023 at 09:57:07AM +0200, Peter Zijlstra wrote: > > > @@ -3008,6 +3029,22 @@ static inline bool pfmemalloc_match(stru > > } > > > > #ifndef CONFIG_SLUB_TINY > > +static inline bool > > +__update_cpu_freelist_fast(struct kmem_cache *s, > > + void *freelist_old, void *freelist_new, > > + unsigned long tid) > > +{ > > +#ifdef system_has_freelist_aba > > + freelist_aba_t old = { .freelist = freelist_old, .counter = tid }; > > + freelist_aba_t new = { .freelist = freelist_new, .counter = next_tid(tid) }; > > + > > + return this_cpu_cmpxchg_freelist(s->cpu_slab->freelist_tid.full, > > + old.full, new.full) == old.full; > > +#else > > + return false; > > +#endif > > +} > > + > > /* > > * Check the slab->freelist and either transfer the freelist to the > > * per cpu freelist or deactivate the slab. > > @@ -3359,11 +3396,7 @@ static __always_inline void *__slab_allo > > * against code executing on this cpu *not* from access by > > * other cpus. > > */ > > - if (unlikely(!this_cpu_cmpxchg_double( > > - s->cpu_slab->freelist, s->cpu_slab->tid, > > - object, tid, > > - next_object, next_tid(tid)))) { > > - > > + if (unlikely(!__update_cpu_freelist_fast(s, object, next_object, tid))) { > > note_cmpxchg_failure("slab_alloc", s, tid); > > goto redo; > > } > > @@ -3736,11 +3769,7 @@ static __always_inline void do_slab_free > > > > set_freepointer(s, tail_obj, freelist); > > > > - if (unlikely(!this_cpu_cmpxchg_double( > > - s->cpu_slab->freelist, s->cpu_slab->tid, > > - freelist, tid, > > - head, next_tid(tid)))) { > > - > > + if (unlikely(!__update_cpu_freelist_fast(s, freelist, head, tid))) { > > note_cmpxchg_failure("slab_free", s, tid); > > goto redo; > > } > > This isn't right; the this_cpu_cmpxchg_double() was unconditional and > relied on the local_irq_save() fallback when no native cmpxchg128 is > present. This then also means I need to look at this_cpu_cmpxchg128 and this_cpu_cmoxchg64 behaviour when we dont have the CPUID feature. Because current verions seem to assume the instruction is present.