From patchwork Tue Oct 3 07:45:55 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: 147690 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1919250vqb; Tue, 3 Oct 2023 00:46:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFwewuHHofpen/XdDo3lZis8DU27ewMYhGzwCtjKgJvKhGuD7WU/E00LUlOJfbeqW8KDtsF X-Received: by 2002:a05:6e02:1b8b:b0:351:5acb:281 with SMTP id h11-20020a056e021b8b00b003515acb0281mr17214846ili.31.1696319191608; Tue, 03 Oct 2023 00:46:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696319191; cv=none; d=google.com; s=arc-20160816; b=LOF0XA07G7D0i4n1eLbPfkw21rHZSvBdmgoNOQDB0I7r47peyulmn9vKWZcVixFH0f hfW7rdsqWlaYQbjhe3W47ye788mFQW7i9AmDqeBZkd1mbTgfVYa4Q1urNdlw7RF1VQDi AqnsqGYq2Q3skfT6NjNhG9YIApPQpJKW3racYA/0PcQ11enqGIku1SpzOXspCYHOY/+u +T9XBFNwruAeWJPDnxlFRHLzD8bcQfV8bhF4YAqTwgYuFq/q0TcE7iOpW+Ohq5CvEAdJ wpZhRZ7RQ7uszgo2W+mFg6NItpKeCUP/UC3uXNANPjGJxdLoCEvmRuCu9A0sR/03MEKS ROPQ== 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=rhLqVOfcPgrbB1gJ8W2N133NiucGxKXHBuTDVSwkgS8=; fh=xRT/60eH8V5tZx499pOjYeLuw8f4YGNwv7t9AgWjRVk=; b=ZZ402hmuvtOaxYPyaOORj9BM82N+/gLhcveuTFErITG/En9s/S3HygRne549i7vadb 6eGrcO2mVOTNdRgba7/E5hq7tYxvFLb1urOxtH79zgoYVVZ+tw4Opmh2+DYNX8Bilxbl 02+vqgaGC21Rft62mHKgevrMaSu6xmf5Shu1V8QVxYdwtIRNF61tSMZmvLdJQfWSq4Fa dY1uabPx8FwDkZKKvwH+P4n0cGJf/7BZqRXudvaupvkumdZgAZCg9TA/Ma5HFnrC7a7u Sxi9y86pkd3M+UqVzZsW3OxOGnNmrZ/CWD+bx+HW5hmsnWwKcVjP16aJJ8nmbVzQFh11 iBDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="A2oJNAX/"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id j70-20020a638049000000b0057763d820d7si910520pgd.835.2023.10.03.00.46.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 00:46:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="A2oJNAX/"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id F0D51801B437; Tue, 3 Oct 2023 00:46:11 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230403AbjJCHqG (ORCPT + 18 others); Tue, 3 Oct 2023 03:46:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230359AbjJCHqC (ORCPT ); Tue, 3 Oct 2023 03:46:02 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D5BCAC; Tue, 3 Oct 2023 00:45:57 -0700 (PDT) Date: Tue, 03 Oct 2023 07:45:55 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1696319155; 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=rhLqVOfcPgrbB1gJ8W2N133NiucGxKXHBuTDVSwkgS8=; b=A2oJNAX/gSsjG7Xk8/gQcJWGmetDkWiMCWk+WKLarSijWrEaKuY5D7+rafWpKNACuDzFYM K/MV50vqWugpCZ0mYX8sbPsZe815gOnlDrh5oGMcu0Mkek0hpMbvmzSCFLOQjudtwyAPTh bURZ8vrKH/OjEcZZ5CZp/vsHGdfm2X58ZuXcPHLi9Q8hzqpj4TLMitVeccpRJ9JIjp2opH T8fbEd7CK5xA2JQpbJv7fE/G6Wtdf0OP+W+7xhFMxNbt5tUKBl66fn5olQ2GC3AOqf8Uek 7xYX0Zsw0XeWgsKafcOGVaGuX+MmznPZ9KgPU45LfbFYgNCEQIojtjk6lwFaCw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1696319155; 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=rhLqVOfcPgrbB1gJ8W2N133NiucGxKXHBuTDVSwkgS8=; b=65cCUwwPp5uagRjrMJKk6FO3yN9nsdsNzuokoUfMsqAcl74yD7/J0VbQ35mMK3eyzgdWST hURngMWtyy0v7/Bg== 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 , 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: <169631915503.3135.14731625648889165839.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Tue, 03 Oct 2023 00:46:12 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778719592868540313 X-GMAIL-MSGID: 1778719592868540313 The following commit has been merged into the perf/core branch of tip: Commit-ID: df22fb4bcdd6f67c4f568e6321c9b0050819d213 Gitweb: https://git.kernel.org/tip/df22fb4bcdd6f67c4f568e6321c9b0050819d213 Author: Uros Bizjak AuthorDate: Mon, 07 Aug 2023 16:51:14 +02:00 Committer: Ingo Molnar CommitterDate: Tue, 03 Oct 2023 09:36:17 +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 Link: https://lore.kernel.org/r/20230807145134.3176-1-ubizjak@gmail.com Cc. "H. Peter Anvin" --- 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