Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1224000ybh; Thu, 23 Jul 2020 03:44:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxffTXseVwX7/4BLDljP+7x1wc15CHP78znuJQYZA96pV8k3S+MEVG+676HhcvDAAJl4MT4 X-Received: by 2002:a17:906:af43:: with SMTP id ly3mr3636923ejb.381.1595501069606; Thu, 23 Jul 2020 03:44:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595501069; cv=none; d=google.com; s=arc-20160816; b=d/VFjw/VUgxZJLIu7fxVMQZkgFHsMyWuLCOCP4mZ19hx3g0aOIZYGcRUbFldCzzhvm atCrhBRm9oCPNcgKKb5OVB+fxXVKkTL72S3zJrDGpsAvVFOB80J6wYFadxUSik/cTuYE 5+cmIaPZlsNT/fW9RS1qC5qyusgu9GaJwTE8/qSzwBnV74nxOWzfPAlHynlCBuIqHB9U O999t454OUU+A3ZrCI2B+/6KqD9v4frPQrBCBMVK9q7OfPSjvQqodeHaHDodv/eLTaiF voLrLSJ+usM9frzUypfEGGvM3RgSqAp4hre7/C3JkbGOZSZY2N6nUM+/XBr2W6MxwpBC 7/FQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:dkim-signature :dkim-signature:date; bh=5ZCmVqk+9APQtNSGRxo90o6TkaEzzR5H4cD7Fa1F7PU=; b=wwRho3Bp1oqsg+hwK0l6xTKRbwuN9/4tz9BGclLoVDdj5YJBt1eRjAu9o8ehhmb9+R lHGiVb/UfXWMij0qLLqOwQpBo1gQpaXTgz+AYFZGfFKBtQvPQXsvwhicr0Fv8It22gyd +FvejbI3qp+ureKaZ5LHlig4OeUtDLjPZhoTM/6/JkJLaKkpVMKss/m3On/5IXqSM8X4 6jgty4evzEVgBgIkSZw/q0o/DPCScU681UvJv5SztDxCbYr5jVfK+l4xbX8nXFhzNZ4L kQbolhhQSP68nBHmp6dwYbqX7R21JIa/Q9PdSXu2GDSDFzJVZCAk2O1sAL8au9GXLMDj V0oA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linutronix.de header.s=2020 header.b=BSFkVVa8; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=2HR06Du3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bi3si1652632edb.391.2020.07.23.03.44.06; Thu, 23 Jul 2020 03:44:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@linutronix.de header.s=2020 header.b=BSFkVVa8; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=2HR06Du3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728509AbgGWKns (ORCPT + 99 others); Thu, 23 Jul 2020 06:43:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728472AbgGWKno (ORCPT ); Thu, 23 Jul 2020 06:43:44 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE377C0619DC; Thu, 23 Jul 2020 03:43:43 -0700 (PDT) Date: Thu, 23 Jul 2020 10:43:41 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1595501022; h=from:from:sender:sender:reply-to: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5ZCmVqk+9APQtNSGRxo90o6TkaEzzR5H4cD7Fa1F7PU=; b=BSFkVVa8yF3VQDJbn+ZYod98RU0SArS4g7j7xt9LMImzY4u8FNTLMfwKrmtMQGQoVFZ8YW GKwIiMsax9jNH01HYbJzMUthEb0o3/24NHcNCiK4h31PMb6LH/O/kuQEafgKF09Ng4Elzg 0Fy8EW70GX+TAfixQlFvZQpu2ytv8w9m/0ePYjYPX0DnJEQoGPWYSfzN7U3bvlfu4c3iDR yhbMeETgLOaeEAjS6xFt1xUKQ+8hufCima+3/aYOtCwUAHaV0sGUDeFBdkOvkZ5VHrRF0d HI30dsYjL31WwtwSkm0kZcvPuGZ4d+uo8Ps9UHOFe2xw6EqJ4SyT/lt+vUudQw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1595501022; h=from:from:sender:sender:reply-to: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5ZCmVqk+9APQtNSGRxo90o6TkaEzzR5H4cD7Fa1F7PU=; b=2HR06Du336lJwh6iFObdkvaKjN9TAaDnDTbMu0pU55LXqrGsINWPs/oy6MAHP8zcBsMNRA OgLywF5hhKAm45Bw== From: "tip-bot2 for Brian Gerst" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/asm] x86/percpu: Clean up percpu_add_return_op() Cc: Brian Gerst , Nick Desaulniers , Thomas Gleixner , Sedat Dilek , Linus Torvalds , "Peter Zijlstra (Intel)" , Dennis Zhou , x86 , LKML In-Reply-To: <20200720204925.3654302-7-ndesaulniers@google.com> References: <20200720204925.3654302-7-ndesaulniers@google.com> MIME-Version: 1.0 Message-ID: <159550102181.4006.3294680559178200499.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the x86/asm branch of tip: Commit-ID: bbff583b84a130d4d1234d68906c41690575be36 Gitweb: https://git.kernel.org/tip/bbff583b84a130d4d1234d68906c41690575be36 Author: Brian Gerst AuthorDate: Mon, 20 Jul 2020 13:49:20 -07:00 Committer: Thomas Gleixner CommitterDate: Thu, 23 Jul 2020 11:46:41 +02:00 x86/percpu: Clean up percpu_add_return_op() The core percpu macros already have a switch on the data size, so the switch in the x86 code is redundant and produces more dead code. Also use appropriate types for the width of the instructions. This avoids errors when compiling with Clang. Signed-off-by: Brian Gerst Signed-off-by: Nick Desaulniers Signed-off-by: Thomas Gleixner Tested-by: Nick Desaulniers Tested-by: Sedat Dilek Reviewed-by: Nick Desaulniers Acked-by: Linus Torvalds Acked-by: Peter Zijlstra (Intel) Acked-by: Dennis Zhou Link: https://lkml.kernel.org/r/20200720204925.3654302-7-ndesaulniers@google.com --- arch/x86/include/asm/percpu.h | 51 ++++++++++------------------------ 1 file changed, 16 insertions(+), 35 deletions(-) diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h index 9bb5440..0776a11 100644 --- a/arch/x86/include/asm/percpu.h +++ b/arch/x86/include/asm/percpu.h @@ -199,34 +199,15 @@ do { \ /* * Add return operation */ -#define percpu_add_return_op(qual, var, val) \ +#define percpu_add_return_op(size, qual, _var, _val) \ ({ \ - typeof(var) paro_ret__ = val; \ - switch (sizeof(var)) { \ - case 1: \ - asm qual ("xaddb %0, "__percpu_arg(1) \ - : "+q" (paro_ret__), "+m" (var) \ - : : "memory"); \ - break; \ - case 2: \ - asm qual ("xaddw %0, "__percpu_arg(1) \ - : "+r" (paro_ret__), "+m" (var) \ - : : "memory"); \ - break; \ - case 4: \ - asm qual ("xaddl %0, "__percpu_arg(1) \ - : "+r" (paro_ret__), "+m" (var) \ - : : "memory"); \ - break; \ - case 8: \ - asm qual ("xaddq %0, "__percpu_arg(1) \ - : "+r" (paro_ret__), "+m" (var) \ - : : "memory"); \ - break; \ - default: __bad_percpu_size(); \ - } \ - paro_ret__ += val; \ - paro_ret__; \ + __pcpu_type_##size paro_tmp__ = __pcpu_cast_##size(_val); \ + asm qual (__pcpu_op2_##size("xadd", "%[tmp]", \ + __percpu_arg([var])) \ + : [tmp] __pcpu_reg_##size("+", paro_tmp__), \ + [var] "+m" (_var) \ + : : "memory"); \ + (typeof(_var))(unsigned long) (paro_tmp__ + _val); \ }) /* @@ -377,16 +358,16 @@ do { \ #define this_cpu_xchg_2(pcp, nval) percpu_xchg_op(volatile, pcp, nval) #define this_cpu_xchg_4(pcp, nval) percpu_xchg_op(volatile, pcp, nval) -#define raw_cpu_add_return_1(pcp, val) percpu_add_return_op(, pcp, val) -#define raw_cpu_add_return_2(pcp, val) percpu_add_return_op(, pcp, val) -#define raw_cpu_add_return_4(pcp, val) percpu_add_return_op(, pcp, val) +#define raw_cpu_add_return_1(pcp, val) percpu_add_return_op(1, , pcp, val) +#define raw_cpu_add_return_2(pcp, val) percpu_add_return_op(2, , pcp, val) +#define raw_cpu_add_return_4(pcp, val) percpu_add_return_op(4, , pcp, val) #define raw_cpu_cmpxchg_1(pcp, oval, nval) percpu_cmpxchg_op(, pcp, oval, nval) #define raw_cpu_cmpxchg_2(pcp, oval, nval) percpu_cmpxchg_op(, pcp, oval, nval) #define raw_cpu_cmpxchg_4(pcp, oval, nval) percpu_cmpxchg_op(, pcp, oval, nval) -#define this_cpu_add_return_1(pcp, val) percpu_add_return_op(volatile, pcp, val) -#define this_cpu_add_return_2(pcp, val) percpu_add_return_op(volatile, pcp, val) -#define this_cpu_add_return_4(pcp, val) percpu_add_return_op(volatile, pcp, val) +#define this_cpu_add_return_1(pcp, val) percpu_add_return_op(1, volatile, pcp, val) +#define this_cpu_add_return_2(pcp, val) percpu_add_return_op(2, volatile, pcp, val) +#define this_cpu_add_return_4(pcp, val) percpu_add_return_op(4, volatile, pcp, val) #define this_cpu_cmpxchg_1(pcp, oval, nval) percpu_cmpxchg_op(volatile, pcp, oval, nval) #define this_cpu_cmpxchg_2(pcp, oval, nval) percpu_cmpxchg_op(volatile, pcp, oval, nval) #define this_cpu_cmpxchg_4(pcp, oval, nval) percpu_cmpxchg_op(volatile, pcp, oval, nval) @@ -418,7 +399,7 @@ do { \ #define raw_cpu_add_8(pcp, val) percpu_add_op(8, , (pcp), val) #define raw_cpu_and_8(pcp, val) percpu_to_op(8, , "and", (pcp), val) #define raw_cpu_or_8(pcp, val) percpu_to_op(8, , "or", (pcp), val) -#define raw_cpu_add_return_8(pcp, val) percpu_add_return_op(, pcp, val) +#define raw_cpu_add_return_8(pcp, val) percpu_add_return_op(8, , pcp, val) #define raw_cpu_xchg_8(pcp, nval) raw_percpu_xchg_op(pcp, nval) #define raw_cpu_cmpxchg_8(pcp, oval, nval) percpu_cmpxchg_op(, pcp, oval, nval) @@ -427,7 +408,7 @@ do { \ #define this_cpu_add_8(pcp, val) percpu_add_op(8, volatile, (pcp), val) #define this_cpu_and_8(pcp, val) percpu_to_op(8, volatile, "and", (pcp), val) #define this_cpu_or_8(pcp, val) percpu_to_op(8, volatile, "or", (pcp), val) -#define this_cpu_add_return_8(pcp, val) percpu_add_return_op(volatile, pcp, val) +#define this_cpu_add_return_8(pcp, val) percpu_add_return_op(8, volatile, pcp, val) #define this_cpu_xchg_8(pcp, nval) percpu_xchg_op(volatile, pcp, nval) #define this_cpu_cmpxchg_8(pcp, oval, nval) percpu_cmpxchg_op(volatile, pcp, oval, nval)