From patchwork Thu Feb 2 14:50:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Zijlstra X-Patchwork-Id: 13126375 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 36557C05027 for ; Thu, 2 Feb 2023 15:29:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 967286B0078; Thu, 2 Feb 2023 10:29:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 91A986B007B; Thu, 2 Feb 2023 10:29:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 76B546B007D; Thu, 2 Feb 2023 10:29:22 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 692826B0078 for ; Thu, 2 Feb 2023 10:29:22 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 38720C0F42 for ; Thu, 2 Feb 2023 15:29:22 +0000 (UTC) X-FDA: 80422735764.23.32C93CE Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) by imf10.hostedemail.com (Postfix) with ESMTP id 119C8C0024 for ; Thu, 2 Feb 2023 15:29:19 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=infradead.org header.s=desiato.20200630 header.b=O3BwLZ6B; spf=none (imf10.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=1675351760; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references:dkim-signature; bh=W8jT5092DDtlCmrawW/Uxx2BFUdyhIJzihgo65ygdd4=; b=Z0TKJBE158Rer86Wc7OU70FAoBfegCL1fmP0eSfg6gg6blaW7bLVkTvDHtnzH8mrKyN2bv EXhAEqQY+KuMTe1IxJZL4PPAcuOV0kNL7bCL//8lL91HEgE2l0w+oisyjTJ3lgkxCt2/zY kVcpr+zSJ2PADYzr0Fms1/YXu22iMDE= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=infradead.org header.s=desiato.20200630 header.b=O3BwLZ6B; spf=none (imf10.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1675351760; a=rsa-sha256; cv=none; b=pGm+AbRmrXwWjb9bS/rkNszR9xkh+2vfhJ7J1cKhtrwZ92zgBEMAWT7kFiV3o+BLmIzNlO qdA/LTE2lQDBwpJzJF5I6SHNlU4KuNovT/2opUbTB/+JmzTcMei+JoVRBbFEiI+DutC0Ns blHrQtCkGrtspe/CasMrlXOin/VAta8= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Subject:Cc:To:From:Date:Message-ID: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To:References; bh=W8jT5092DDtlCmrawW/Uxx2BFUdyhIJzihgo65ygdd4=; b=O3BwLZ6BbrBpkX4dSlLTVJddoL d+skGCA3LaLD1DjXUjhAZ+YXjWood4lIaETj8WAJCJtuCia+5JPoMriULzyTj05sSSbGGfFURgFzz uD8QxDHvTkyu9oqOWL1RbeWVgcL6nddQFkQjJ4QnQ5/nmWe4o+lp5X+xxotmAOSlzmYilLO3E3Xk0 ANMykPFl0gECdwfo83f9ou7ADvruw1TbUxoxZJvaKSQvsVQMerp6elTDLX0a3tYlZXS6u2n04NOdI Zs8Ix4DJGOUZPVkTu/0aNeptCV8+384RejNjk7s8CGcHbikNTJKexF74/3bjQT3gCLRoTujYu6QEQ af1EG2rQ==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1pNbVT-005CFd-1o; Thu, 02 Feb 2023 15:28:11 +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 F29F53001E5; Thu, 2 Feb 2023 16:28:40 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 0) id 7F28623F31FA6; Thu, 2 Feb 2023 16:28:40 +0100 (CET) Message-ID: <20230202145030.223740842@infradead.org> User-Agent: quilt/0.66 Date: Thu, 02 Feb 2023 15:50:30 +0100 From: Peter Zijlstra To: torvalds@linux-foundation.org Cc: corbet@lwn.net, will@kernel.org, peterz@infradead.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 Subject: [PATCH v2 00/10] Introduce cmpxchg128() -- aka. the demise of cmpxchg_double() X-Stat-Signature: 9upq76km5jt6bsmnbuy1xkhiy36qraon X-Rspam-User: X-Rspamd-Queue-Id: 119C8C0024 X-Rspamd-Server: rspam06 X-HE-Tag: 1675351759-882543 X-HE-Meta: U2FsdGVkX18RZ7dpl31od2v1D3memeFJ26NhgyMWuWmS8w7F703249b6N5SN6YMh1NNqniHsz3YmNjJm2ibpCt6fexYMVyGoHtorcjycncPl8UEXakt98LoeIT2FA/fVBvttpev2hI3QD6yjJvVFcZvADQrUdp+wyMnpovbcWYQzh7ZJCNaqhFwWQfoAevHQBJXnGvsXLwmyU954j6fVzfSCh6j36P7PKnEV7iAgOUT7QjNGwHtBSfj9ZwmAz1/YhWsoZwm+EWaXvar0QiyTvDFn1VBs30Nr4Ks6jXTE7NXS5QPerjt8mq2ZW6J7xcpyIbes4gFUIPXD44euOM8Pp3OlKGveq49ggqYaBzjsyNlxT2C+c+moVaVrJEKMSgm405ZTvsurr7FRr2ocNQHLuLd1fJE6/F8nz0OwFz/Db6H8dt7Edt0dFLNXlGMww6IEQIan/cw+qaAnQFGRwwSz0H3zZLHeii6ghxQMLcGQQ/zoWMvMJDCpDzvBWQxW7hgk6Fkfsk2cw/wOPLlEmx4mipFsVqhPl+K/Pij8nCzmjEm+Y726dgztMHfRoCFEM8QnvPV2EpNPOMHboUDzDLNzTJMTbgKQPHhzz+9ZE7j4mkQpPlEqv4xjMUpAP/QeT5tpJqDClM93dw+POCOJ9SzPPTEiyfxCME0OO6yWpnhcu0YszHKWlKOnd7up+TjortD+VE9CHOYGU6gxQses2ldu9dfnJGoDlDEgrAevV3s5a5AZoMtvtO+b12t5RPweSnR8fiJiJZeZGFwTbm79vOasqcVuDZOJQXwkIpZcbBdhoUdQJiJ/eO0012YdDw3faNf++E8TmakhFaumGZfiZFsrjCfCfQvMMbPhWLeiJNutS60nnXAIz60L0QdJ8lNcGDKHlepOcJ5yXBSXv8UZ1oW/kn/+GZx/5xolnwSuNUIvhhUPcFDf8v6HuG1/hGYw1JfwKAYDNdZ6BNcnoPiCob1 B1zIycDA l38OpsJJq9aeBi/HemKG7CMHrMrgJTmGs1JDpjEJQ/zGIE2RbH5CjGEB3u37dZTJclf5st3AJiy+zEcuLXwgf3ZxfaLWe302DKwReMTfn2MHYsR5nCpm0TiV4fMgoyGjhR069YPYoGGGdM12Yk9dsRyAHErGvm/hGSxYyJWVz3iOWZTULHsQjj770TJeF0BX0qChzmnASECEfhtYiFo514RZZALgP9Ug3w+9Y8ouenlUUiBhIK3FkfBCn4BCy+AlzUD6jMMr8oyXVe7trRR1BXG/q/nueGsGs0sMFj41Sk2X6zh2nvrA0TVYUZebp+LgVJmvjas2jpbKyWdnlVZHBsaOMzf7tE2WWK8BI1NQBfx8y0Y4xfDTwgWVfNYi/d5wlsUZcO+eUtm6FCS+1gwyoXN5daz+gzb8yrodgdW82vH2B108= 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: Hi! Since Linus hated on cmpxchg_double(), a few patches to get rid of it, as proposed here: https://lkml.kernel.org/r/Y2U3WdU61FvYlpUh@hirez.programming.kicks-ass.net These patches are based on 6.2.0-rc6 + cryptodev-2.6, but also apply to next/master. Available here: git://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git core/wip-u128 New since v1: - rebaed on Eric's ghash cleanups (hence the cryptodev-2.6 dependency) - rebased on Heiko's s390/cpum_sf CDSG patch - fixed up a bunch of arch code - fixed up the inline asm to use 'u128 *' mem argument so the compiler knows how wide the modification is. - reworked the percpu thing to use union based type-punning instead of _Generic() based casts. --- Documentation/core-api/this_cpu_ops.rst | 2 - arch/arm64/include/asm/atomic_ll_sc.h | 56 ++++++----- arch/arm64/include/asm/atomic_lse.h | 39 ++++---- arch/arm64/include/asm/cmpxchg.h | 48 +++------- arch/arm64/include/asm/percpu.h | 31 ++++-- arch/s390/include/asm/cmpxchg.h | 32 ++----- arch/s390/include/asm/cpu_mf.h | 2 +- arch/s390/include/asm/percpu.h | 35 ++++--- arch/s390/kernel/perf_cpum_sf.c | 22 ++--- arch/x86/include/asm/cmpxchg.h | 25 ----- arch/x86/include/asm/cmpxchg_32.h | 2 +- arch/x86/include/asm/cmpxchg_64.h | 54 ++++++++++- arch/x86/include/asm/percpu.h | 97 +++++++++++-------- drivers/iommu/amd/amd_iommu_types.h | 9 +- drivers/iommu/amd/iommu.c | 10 +- drivers/iommu/intel/irq_remapping.c | 8 +- include/asm-generic/percpu.h | 62 ++---------- include/crypto/b128ops.h | 14 +-- include/linux/atomic/atomic-arch-fallback.h | 95 ++++++++++++++++++- include/linux/atomic/atomic-instrumented.h | 88 ++++++++++++++--- include/linux/dmar.h | 125 ++++++++++++------------ include/linux/percpu-defs.h | 46 +++------ include/linux/slub_def.h | 12 ++- include/linux/types.h | 5 + include/uapi/linux/types.h | 4 + lib/crypto/curve25519-hacl64.c | 2 - lib/crypto/poly1305-donna64.c | 2 - mm/slab.h | 45 ++++++++- mm/slub.c | 142 +++++++++++++++++----------- scripts/atomic/gen-atomic-fallback.sh | 4 +- scripts/atomic/gen-atomic-instrumented.sh | 21 ++-- 31 files changed, 645 insertions(+), 494 deletions(-)