From patchwork Thu Feb 2 14:50:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Zijlstra X-Patchwork-Id: 13126373 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 DE0BEC636D4 for ; Thu, 2 Feb 2023 15:29:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 23A546B0074; Thu, 2 Feb 2023 10:29:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1EA106B0075; Thu, 2 Feb 2023 10:29:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0B2356B0078; Thu, 2 Feb 2023 10:29:19 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id EEA656B0074 for ; Thu, 2 Feb 2023 10:29:18 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 9FC44160757 for ; Thu, 2 Feb 2023 15:29:18 +0000 (UTC) X-FDA: 80422735596.24.77951A4 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf20.hostedemail.com (Postfix) with ESMTP id E656E1C001D for ; Thu, 2 Feb 2023 15:29:16 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=SutQsn5H; spf=none (imf20.hostedemail.com: domain of peterz@infradead.org has no SPF policy when checking 90.155.50.34) 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=1675351757; 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: references:references:dkim-signature; bh=LNTskqo5roGsovH+JFQKAebOFNRW3Kky7MgwbIWmzaM=; b=BiDql02lj2zJzMGjitkewpZjBgC+2XJRMLvb3N573m96zLhNn/r7wd21hzUcFeE2qC7Vyg u0b1RqyfSdrfoKQVb+BbhvsUoCpTANoZdqYr66ereNP0lAvu4Dg7X0/QZ65q5SBBEIUSwn avAp9W3byxrPUv1UuQDhgGxGIwinCp0= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=SutQsn5H; spf=none (imf20.hostedemail.com: domain of peterz@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=peterz@infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1675351757; a=rsa-sha256; cv=none; b=HtqlBxXnUAiXlj6m43TlHCHSpJCgMRE/R2AJeA+Mn9IKl/Q1JxNxdHkKSlW/AA/0WJ0333 alaw5lGbt6RsylJvmoMbUl/0sUAqTo+/WjxFZaRbYUC07htBxULJQtynqjIUHu8pZ78wjD zLZlGMnaqp7UBUvtyboCkyObMJ0LRv0= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=LNTskqo5roGsovH+JFQKAebOFNRW3Kky7MgwbIWmzaM=; b=SutQsn5HCDPd7RqYYJOqaRBAAw ghza+gVMb7VvZ8S5mXEBYv9fP8q8Y9wXALUK5q0pzocuZuyXrPepuT1+wCOd/OzB+ntZth6DaMT6B S8zOdGU0FmbWx9fMkVMCos7RUSpLps4sna/LO0IsKeshnyabCK7cNceYm4e+4Fmn11Z+jL+MTpNzN I6xv1Uhkv4ss9oJhXYo64MzEkqJxVqSn1hWToVBJlsAr9MjKCkQ2hdLEGzmvnX+l4DLFC6cT1hP4d 2/1/3QPc9YolaFPwoZcHS+Sn+GoiEBzfYylecr9r98dtv7EMTfckM+5a0Ow5UAFEBYeCLaBAG2mQU PcOP0H6w==; 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 1pNbW4-00DV2e-2G; Thu, 02 Feb 2023 15:28:48 +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)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 4121B302E1F; Thu, 2 Feb 2023 16:28:45 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 0) id AB09623F326C1; Thu, 2 Feb 2023 16:28:40 +0100 (CET) Message-ID: <20230202152655.805747571@infradead.org> User-Agent: quilt/0.66 Date: Thu, 02 Feb 2023 15:50:40 +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 10/10] s390/cpum_sf: Convert to cmpxchg128() References: <20230202145030.223740842@infradead.org> MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: E656E1C001D X-Rspam-User: X-Stat-Signature: a5pcz34ef7u1smwipogkw78kg5yp5xpz X-HE-Tag: 1675351756-910153 X-HE-Meta: U2FsdGVkX1+9aBANX0vKYqNwrlIo/cXfdR59M0RHm+pOoM+hbpj/K83ofTgWfS+rPf0WkLvI5Qjq/V9t3ISYeXO7ZyPZXplu9GO2XdgSh6ISi6EHskD51E22efqCafYR3Mw7oPsiI3AshWuGYhwIzYej1u6iy9Z/W2/1lct4auqe0e8KzBpulqXEOdMparYbg9yL4So1tf6XBsqGlx1nUFDgS3I2J52QN0xSNl72XRJ29KZjw9YO99s5Tsl2V5t0gMuN19jiS5GopLWa9xBm0Hr4cX1oz9PhefUNExFl8y1Jr1XKYBfwCuUI166iytcoLhKpjpkgIUdSpSqSr9kbMM+suZ5aKepYnPumrcvJoWYfXSHsCxs/Y40YSTrRxbEF8ofvHpNNzdX3mdXhJHquU2YyyP/nv/VNhjAEtymeagzSdTVJ4MrlGx55baHxru9qZXoHinGgV+dBCduKLDn8VYPqgs8N9rS0WeoFoDhGNrNt+5Gsjh6VCq6stMqn3NYvchsi2bSVrGQEyp1hY2k4vSe1C2H1VpbIL66YejjqE5FsctPCZvOznt6j3p4wfinoeeZxjuHfXuSP4pNY3Zv3byYrX/kVhKnpDJWijvCPu2Jr5CJ4a182sL1LecV3H866geQ3qVL5o9ma7wTUUZRqFmBFcj54hhQMVpOQpvn958ljzLxPvcCfEe0Nsnbn4tAhqszd7Ym/RpQEI6X8t3Pl4wFry3dL6JvLVAYXu9CVE7OoZA7nkH7iO7Sp4gx+qd3po/sY84TtrOz63Tw1dEWHsEsC62CWNY6I2eDrxxLd2RkIr912cFZThv8bil+LHPg8+FCaUbJqfvB94Wrte6kQGsQSYg18NrRwGh06B95Ks6WI1gLfQZT1K/25uxbUD+29DMkEZsU3Q6ZkmKH7hh/sNvfVxaNn/1vJ3lTSLQQYRZj3DwZndYQsz1NafciI/6U8agsxUPNgyU1mGzDWgbT xgS4UtyW /fYml+RIOfR32CSSrlglwY/uCwzu+Xo3IEXqLUs5fvKebQn6SJ3YkvmHJYc0PgdQ/BCkzNkUWUuelNWS/mHcYmqTq9XY+PbeogyBS+lPydsItv+Z4D2rW+BQ8Ug+s6g94BkjgtgzgvGX47lUEUTitqt42wc2+Qwrgu5yyTlBITZ3v7HcRlYqL9//7hBJ3uqTEIuS523yKty3DlVBpx9sTg8DZje9QcKUw1hM7bh8I0MVL0+7fCV9yINp2AG0I7qlNm7rrh1volH7V4KkCgxBepOuZRUd85XslOEmnap7biSOx+tIv1+i9V2AoZNi+2VpTQHnDAzK2JyLpMGjgbvQs6B5uej/53e+wDfaO7NcWmkjl39XMt9e6lJ7nxuHEa0eZd0XAZ/RHx/hYejJDjHORSWLFTEPiEoYRA7dky9SdUbcjLF5d4ctQsPFWq7FSe5qE10MN 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: Now that there is a cross arch u128 and cmpxchg128(), use those instead of the custom CDSG helper. Signed-off-by: Peter Zijlstra (Intel) Acked-by: Heiko Carstens --- arch/s390/include/asm/cpu_mf.h | 2 +- arch/s390/kernel/perf_cpum_sf.c | 22 ++++++---------------- 2 files changed, 7 insertions(+), 17 deletions(-) --- a/arch/s390/include/asm/cpu_mf.h +++ b/arch/s390/include/asm/cpu_mf.h @@ -141,7 +141,7 @@ union hws_trailer_header { unsigned int dsdes:16; /* 48-63: size of diagnostic SDE */ unsigned long long overflow; /* 64 - Overflow Count */ }; - __uint128_t val; + u128 val; }; struct hws_trailer_entry { --- a/arch/s390/kernel/perf_cpum_sf.c +++ b/arch/s390/kernel/perf_cpum_sf.c @@ -1228,16 +1228,6 @@ static void hw_collect_samples(struct pe } } -static inline __uint128_t __cdsg(__uint128_t *ptr, __uint128_t old, __uint128_t new) -{ - asm volatile( - " cdsg %[old],%[new],%[ptr]\n" - : [old] "+d" (old), [ptr] "+QS" (*ptr) - : [new] "d" (new) - : "memory", "cc"); - return old; -} - /* hw_perf_event_update() - Process sampling buffer * @event: The perf event * @flush_all: Flag to also flush partially filled sample-data-blocks @@ -1307,14 +1297,14 @@ static void hw_perf_event_update(struct /* Reset trailer (using compare-double-and-swap) */ /* READ_ONCE() 16 byte header */ - prev.val = __cdsg(&te->header.val, 0, 0); + prev.val = cmpxchg128(&te->header.val, 0, 0); do { old.val = prev.val; new.val = prev.val; new.f = 0; new.a = 1; new.overflow = 0; - prev.val = __cdsg(&te->header.val, old.val, new.val); + prev.val = cmpxchg128(&te->header.val, old.val, new.val); } while (prev.val != old.val); /* Advance to next sample-data-block */ @@ -1496,7 +1486,7 @@ static bool aux_set_alert(struct aux_buf te = aux_sdb_trailer(aux, alert_index); /* READ_ONCE() 16 byte header */ - prev.val = __cdsg(&te->header.val, 0, 0); + prev.val = cmpxchg128(&te->header.val, 0, 0); do { old.val = prev.val; new.val = prev.val; @@ -1511,7 +1501,7 @@ static bool aux_set_alert(struct aux_buf } new.a = 1; new.overflow = 0; - prev.val = __cdsg(&te->header.val, old.val, new.val); + prev.val = cmpxchg128(&te->header.val, old.val, new.val); } while (prev.val != old.val); return true; } @@ -1575,7 +1565,7 @@ static bool aux_reset_buffer(struct aux_ for (i = 0; i < range_scan; i++, idx++) { te = aux_sdb_trailer(aux, idx); /* READ_ONCE() 16 byte header */ - prev.val = __cdsg(&te->header.val, 0, 0); + prev.val = cmpxchg128(&te->header.val, 0, 0); do { old.val = prev.val; new.val = prev.val; @@ -1586,7 +1576,7 @@ static bool aux_reset_buffer(struct aux_ new.a = 1; else new.a = 0; - prev.val = __cdsg(&te->header.val, old.val, new.val); + prev.val = cmpxchg128(&te->header.val, old.val, new.val); } while (prev.val != old.val); *overflow += orig_overflow; }