From patchwork Tue Oct 3 19:19:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 148037 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp2299969vqb; Tue, 3 Oct 2023 12:19:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHEILXFPeJiYH4wLEH9HHaXSk755KOovQ4mMAm/7+HCDVvkTfA4LFrmV3dij7Sj1hULR1Ep X-Received: by 2002:a05:6a00:23c9:b0:68a:6018:a66f with SMTP id g9-20020a056a0023c900b0068a6018a66fmr293669pfc.2.1696360783797; Tue, 03 Oct 2023 12:19:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696360783; cv=none; d=google.com; s=arc-20160816; b=PVsJRcC+1gGBQFScveSZRLvPIZqEXkq4hnhCenVc49GDqS6NJ2eYnFgklcp9EgtVzM /CHxKbyn3mv36FVnqWckdqvhkZTnLjAGvyFQSfOy2gpwewJS/OFzVeD8n3HK3PX0YPmv kkypG/ep0JOKJMTROJuKpMykSdQ05qo/zUMstFtZ3I40InTWyWX7DRVa8yaNCdRiwxMg ULXwF746u0hRLYeknLWmBXf92WiIYJMOIli2hi490lZcvAFACbZakkNUt/f292V+yEe9 wiLKhZM+BZi8wiiavvOmkosmZlwMVi6tj3gFqPbP3QKu5EnZa1xasI9C3HMVkandzU01 2TUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=JLggR4hP0YNeCfk8Z90Zu+QllYjvLO9T0uR23xEQClA=; fh=uYmKPeV7trB4++Gfynlrb2b7CUiIMjAO75XF4cOkgXw=; b=mT/9N5RJRnX12UvqTtW/6PVmyAzAiNtO9jEP46u/1HwMvcl9xE2xIG6Lk2skxk+73D hgQn1Z6hUJaWxOqQ2N5Z/pt+vpl7FjXilRvdZfSxW4aAGOINSagsJaIzypi615CsnHRP tknEYTcA0cv6GljpWR/3yE8y0qddI495SxDMH1tg4SQuP5G9nyFqS+PNB0oVDGTyt8LR nxuoyZpctHmjbEwKU0OClF+MmXk7A8+wwuzxTPc1yhj0lnLPSAmOT+bGDJyRNcbI5/gJ rok5aXIEY+LRJJaxV83KfBQk21SQNugZ456yGbR5tp0kIgE0Q2EHY+v7JUXSPUVJ9z6m QjAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=bQnmu4hY; dkim=neutral (no key) header.i=@linutronix.de header.b=+lPAcBN0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id g62-20020a636b41000000b00569dfeb8123si1950065pgc.189.2023.10.03.12.19.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 12:19:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=bQnmu4hY; dkim=neutral (no key) header.i=@linutronix.de header.b=+lPAcBN0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id CC47181A2047; Tue, 3 Oct 2023 12:19:41 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230239AbjJCTTP (ORCPT + 17 others); Tue, 3 Oct 2023 15:19:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240870AbjJCTTN (ORCPT ); Tue, 3 Oct 2023 15:19:13 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0276DAC; Tue, 3 Oct 2023 12:19:08 -0700 (PDT) Date: Tue, 03 Oct 2023 19:19:06 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1696360747; 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=JLggR4hP0YNeCfk8Z90Zu+QllYjvLO9T0uR23xEQClA=; b=bQnmu4hYKw7J3LyK+af2GK9vmsSRkKqrzcR7+ueJHK3LTpZf9gfPpqNARp0n2IZ+yW3V2s ZGUBYx/0BCz1QW6+cLK2cW3ryrqUxkGpW0jg4mrkR1VL3kuNlbosEbUNWAitKumKRKg+9M FCWYNKaQjBjmRTq7axGt4o987Ia0RWUJVT6CONLbFh41cS8H9TqKdCoZ2kYcSJMFqaorp+ WEDZ8MBjjuA6oOS8WqdDTRzjrBbjhbNmEzOnamFiUw9S16JM80QNrZ6uJ2H9M1q/JSOIAs Af4S/8BbXw91CqEBViDduhO3ItYUV+n6Rzjy663DhUiamjCnvgSisErFWhhesA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1696360747; 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=JLggR4hP0YNeCfk8Z90Zu+QllYjvLO9T0uR23xEQClA=; b=+lPAcBN0DeKMgCmg54FuSJ8XFGdE38Ex5WRl1B0CjnTACt8RqwufKhnmhXNwTQzM4Q5Y/0 oci6aN9kH2IPvrDw== From: "tip-bot2 for Uros Bizjak" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: perf/core] perf/x86/rapl: Stop doing cpu_relax() in the local64_cmpxchg() loop in rapl_event_update() Cc: Uros Bizjak , Ingo Molnar , Peter Zijlstra , Linus Torvalds , "H. Peter Anvin" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230807145134.3176-1-ubizjak@gmail.com> References: <20230807145134.3176-1-ubizjak@gmail.com> MIME-Version: 1.0 Message-ID: <169636074660.3135.17644433006738661044.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Tue, 03 Oct 2023 12:19:41 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778719592868540313 X-GMAIL-MSGID: 1778763205182701584 The following commit has been merged into the perf/core branch of tip: Commit-ID: 1ce19bf90bd55bf54f9ed75d594029db63d395b0 Gitweb: https://git.kernel.org/tip/1ce19bf90bd55bf54f9ed75d594029db63d395b0 Author: Uros Bizjak AuthorDate: Mon, 07 Aug 2023 16:51:14 +02:00 Committer: Ingo Molnar CommitterDate: Tue, 03 Oct 2023 21:13:23 +02:00 perf/x86/rapl: Stop doing cpu_relax() in the local64_cmpxchg() loop in rapl_event_update() According to the following commit: f5fe24ef17b5 ("lockref: stop doing cpu_relax in the cmpxchg loop") "On the x86-64 architecture even a failing cmpxchg grants exclusive access to the cacheline, making it preferable to retry the failed op immediately instead of stalling with the pause instruction." Based on the above observation, remove cpu_relax() from the local64_cmpxchg() loop of rapl_event_update(). Signed-off-by: Uros Bizjak Signed-off-by: Ingo Molnar Cc: Peter Zijlstra Cc: Linus Torvalds Cc: "H. Peter Anvin" Link: https://lore.kernel.org/r/20230807145134.3176-1-ubizjak@gmail.com --- arch/x86/events/rapl.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/arch/x86/events/rapl.c b/arch/x86/events/rapl.c index 1579429..e8f53b2 100644 --- a/arch/x86/events/rapl.c +++ b/arch/x86/events/rapl.c @@ -184,10 +184,8 @@ again: rdmsrl(event->hw.event_base, new_raw_count); if (local64_cmpxchg(&hwc->prev_count, prev_raw_count, - new_raw_count) != prev_raw_count) { - cpu_relax(); + new_raw_count) != prev_raw_count) goto again; - } /* * Now we have the new raw value and have updated the prev