Received: by 2002:ab2:7041:0:b0:1f4:bcc8:f211 with SMTP id x1csp7494lql; Fri, 12 Apr 2024 01:39:20 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVwb0mThOnxB9MWeVFvH0AvyogSzjbWdav1XJzHWHMVITZis4avNSiTU4XuI5CzDbh14qBu8vl+JXgZ3wq9pbeafu6amGh51uXbiHvEpQ== X-Google-Smtp-Source: AGHT+IGZAduUpJWEAgjsfWnpDQLb43RXuT7+eSZ7d6IsGX5J+6jbpEo+fIUqHxdzII/iki5oAaVI X-Received: by 2002:a17:90a:678f:b0:2a5:32fe:b834 with SMTP id o15-20020a17090a678f00b002a532feb834mr1868070pjj.23.1712911159909; Fri, 12 Apr 2024 01:39:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712911159; cv=pass; d=google.com; s=arc-20160816; b=YfQIoBdUDHDRczQScFtP9C2Uv2c137ehB7jB3B+xoVid7e2KxwTob/bOnjyUsY5Wt8 GutKSb5njiOPpmvNpHWjTa62i2effdH40ZopP42lkJTbzaWvm1dJuBCUbSkd/fruohol 6zHaS9wxEM5f0V1wmQeS/2Ny91sRtlw7FP2e2qkXRs0Hgdg3GGdmyi9VljLwQ8skWexG wSHVV0evaLZm0utBgrC1uA8+H2SMXjTiq7B9sNr4Yy+12CZ5MinK+hN7LtXGQ1d4Q1sl QlWeyKxf4B/kFOjFg6JkWtdibGqKEjzL6C2p45ttvkHaUSrElI/0SaYcN2npYShHWTYd BgwA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=e0J1yegJWFmYmKya5wd2c47UHSHOnE6ubSSo/EOMOjI=; fh=/NfDcPuXLiJEMJcfkNllcm7H8FALMuIebUOcn6l1y/M=; b=iuJc7sqz/GPHwfaEL25SVfV87X9/ykx7kiSuu03vsAHN68HiPxkZdYzoBhjYwJSEhw Ezxz8iUqufxbs1lK9sCyyYA1OUDpNJsJhWo09xjth8B3vwZaKLSkurwF4j4i6NJz8/AI CaR4xDZV5DgMmH2s30wRwdV1SMb+89FzHy5ePhASAWfi3jjtBJWX+mGFCrguT6KgrVfz cm8RoYCF56jP/A/HeDe8+zxrLJusK4Q/BGOnzX8S12yf7ydw/l9Fgd0GZiz4mg8R1PRB 3apNca6Xhek74FBP6Pv+OssXACzw0QOPOoTWJo+5lzj1zM5KyQ+p+o9Qw+UZc03o0eUR LJpA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=lrGkQ3RP; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-142246-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142246-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id h14-20020a17090aa88e00b002a2949ce3b7si2843301pjq.181.2024.04.12.01.39.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 01:39:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-142246-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=lrGkQ3RP; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-142246-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142246-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 90682287E0E for ; Fri, 12 Apr 2024 08:39:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7AD9438DD8; Fri, 12 Apr 2024 08:39:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lrGkQ3RP" Received: from mail-ed1-f41.google.com (mail-ed1-f41.google.com [209.85.208.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1FEF52C6B3 for ; Fri, 12 Apr 2024 08:39:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712911154; cv=none; b=AtBH1Sx7DDpDN6x15HM+BAENZEuddx9qoBdUCxPUxhPPPcx5J12xtPSVfAtf3JlIIs5y0Rslz5bRWO7hwSIyVK0Vdexv3Ei6tSZ6qfx84iiqKxpS0M/J08QnPWtU1gizd2F0bkyQ6NH9utV6HUUF3fStGQApXoUPY4PS0K4xbKk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712911154; c=relaxed/simple; bh=6C6aLpyj0Z+TA672hlz8aMVf1BHtqYDAkYSXq5qkj70=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=dXsq4eS7I7HFq1r6wQRzcUSRsHogFQ+GBsBpAmpjlRdklXkan68DBjWN+PTR5T7GTNisvf5jl95uHYf7EHE05iSLrzRvLs8qLLNU/Np17inxIw5K+e77upFU1FfI79zxb75o9/ap/vtYgnI6kkHgZXjJx8Oahj0l/fEJJYLXpxQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=lrGkQ3RP; arc=none smtp.client-ip=209.85.208.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-f41.google.com with SMTP id 4fb4d7f45d1cf-56e4a148aeeso261587a12.2 for ; Fri, 12 Apr 2024 01:39:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712911151; x=1713515951; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=e0J1yegJWFmYmKya5wd2c47UHSHOnE6ubSSo/EOMOjI=; b=lrGkQ3RPAFSfKIkPdJSV42t1zRnZ0xjoL91nyGYJIydQsfP0vo7iWlODAUDJpq8svF 1JNYJHD94Obg9g94cWLvB2wHI9wvrPQ+nqOMvH3oC7KdDX2qlsZItUuMV+i5QJeAwS63 gx2makBxDwiHTaDZ9f5YAzcB5Id2l2iKSM+q1P2ZhmGVPn7ya9BN+H3rVg4MryWLeAIw GN7bn7vF2HQPR1zww6xgwN2qynMSIZZ6gI2knPreSJ9P33QAOFTp1nJG35jOoZ3XDVxQ MAvf/i9GwvNuDpCIpiryuBDd1Qh6cWyUag1s9Avv49OXBu+o4+Hu41HMrpKMi37XSHXk 21Iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712911151; x=1713515951; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=e0J1yegJWFmYmKya5wd2c47UHSHOnE6ubSSo/EOMOjI=; b=t1xKPTIvpoF5XTwLrQxL4Gq7z8DUCk+wJbP2cSBUMPy2A9eiU6UezbHaKG5qbuypMA qBJ9cATVPYglF93E1UH5IjlSmA+deym+D5xuvr9bUZGbeyBHqc6g0+vTeIStPBTeowfz E+aSxQ5LDxiN9EnuxxCTvTj9U3ZRORKqLvrjl46yp9UxSB5v+CTxKqlX6mdZ2dI9you5 30CpQYz4Le8wrK3d0xYB71SHmGK6QKHnhBfxk8tH6IzjMNpRGObUHHvhjXzOFU2suUik WHs/JhN2JyJSNmeh6UcSdUgCHldl4Zl3OTm8oz/ID3PIWRbX9bL65zAC5H0nt9r9bwOR 8TTw== X-Forwarded-Encrypted: i=1; AJvYcCVlBZsJ81k8+hQSCUxnEV78FAQIIQ9Di9IswAv4UcrTs7buHj8YQNLWOjKMK4PhhySN4L5Xf5i8KGFCvsqGeARAWmQYf+6Wh5lhD7ZV X-Gm-Message-State: AOJu0Yx3n+aUGE8JN3G4QoZeobO6AOejW55c275ssi3iKG1H70Yb/yOx ALKK4ITmx0Jv0UGZYWoJCtg7sadqufAGz9kByWlP0Zr+LT2fkY4O X-Received: by 2002:a50:8e12:0:b0:56e:2433:a0ab with SMTP id 18-20020a508e12000000b0056e2433a0abmr1806709edw.34.1712911151080; Fri, 12 Apr 2024 01:39:11 -0700 (PDT) Received: from fedora.iskraemeco.si ([193.77.86.250]) by smtp.gmail.com with ESMTPSA id l11-20020aa7c30b000000b0056fe3d81b5bsm1454634edq.79.2024.04.12.01.39.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 01:39:10 -0700 (PDT) From: Uros Bizjak To: x86@kernel.org, linux-kernel@vger.kernel.org Cc: Uros Bizjak , Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , Boqun Feng Subject: [PATCH] locking/pvqspinlock/x86: Remove redundant CMP after CMPXCHG in __raw_callee_save___pv_queued_spin_unlock() Date: Fri, 12 Apr 2024 10:38:53 +0200 Message-ID: <20240412083908.282802-1-ubizjak@gmail.com> X-Mailer: git-send-email 2.44.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit x86 CMPXCHG instruction returns success in the ZF flag. Remove redundant CMP instruction after CMPXCHG that performs the same check. Also update the function comment to mention the modern version of the equivalent C code. Signed-off-by: Uros Bizjak Cc: Peter Zijlstra Cc: Ingo Molnar Cc: Will Deacon Cc: Waiman Long Cc: Boqun Feng --- arch/x86/include/asm/qspinlock_paravirt.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/arch/x86/include/asm/qspinlock_paravirt.h b/arch/x86/include/asm/qspinlock_paravirt.h index ef9697f20129..466af57b8ed6 100644 --- a/arch/x86/include/asm/qspinlock_paravirt.h +++ b/arch/x86/include/asm/qspinlock_paravirt.h @@ -25,9 +25,9 @@ __PV_CALLEE_SAVE_REGS_THUNK(__pv_queued_spin_unlock_slowpath, ".spinlock.text"); * * void __lockfunc __pv_queued_spin_unlock(struct qspinlock *lock) * { - * u8 lockval = cmpxchg(&lock->locked, _Q_LOCKED_VAL, 0); + * u8 lockval = _Q_LOCKED_VAL; * - * if (likely(lockval == _Q_LOCKED_VAL)) + * if (try_cmpxchg(&lock->locked, &lockval, 0)) * return; * pv_queued_spin_unlock_slowpath(lock, lockval); * } @@ -43,7 +43,6 @@ __PV_CALLEE_SAVE_REGS_THUNK(__pv_queued_spin_unlock_slowpath, ".spinlock.text"); "mov $0x1,%eax\n\t" \ "xor %edx,%edx\n\t" \ LOCK_PREFIX "cmpxchg %dl,(%rdi)\n\t" \ - "cmp $0x1,%al\n\t" \ "jne .slowpath\n\t" \ "pop %rdx\n\t" \ FRAME_END \ -- 2.44.0