Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1905932rwl; Thu, 6 Apr 2023 03:06:01 -0700 (PDT) X-Google-Smtp-Source: AKy350aqKScLIUw2OggSi8mbdyRk3IFpQOP325WOjh/CTazbfTEUAdhu9B4Vf64ws8P5uoVUJLw/ X-Received: by 2002:a17:903:110d:b0:1a1:b36d:7803 with SMTP id n13-20020a170903110d00b001a1b36d7803mr12642486plh.36.1680775560869; Thu, 06 Apr 2023 03:06:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680775560; cv=none; d=google.com; s=arc-20160816; b=EeZrDJkUED6iZadkGuZqfek9D6tkmGTgR0NelYcbn+lbqBuwgLpaHFfj+mRUQnfIf4 iJijMN3/bB/iZIs7KpWClF+ul+QwcG2rT4zoyZ+9qtw50QuGJID/Nzht5WsduZJD+FjM g7D7cnpA9GWIYu2ugEvTzkxEJRkP5fQBRWFHFrjwA+naWXrdomu5uLq187zCNolc/NyM xBiAhwThkM/DcLUMOJAGM3ED022tfQ69Jk5c+G29ZKbC3XX7IuH53eWARYEsvL+GgCsX uyxOIJ/xhOfNd2tDM5GO6mcBBNFrhI8IjnJH3ZjGRHusx1aFKRwUWqda4fttB6PeN2nT pgqQ== 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=L4U473xiBwsWpVCNwCcEEXKybetROkdDo1lDqE9zYZc=; b=p+cL4klP4Cl+W9yEm78sXkI8CDwwr41WDWtvpTTy8JKRZQhWkGDCzHPJnhfd+6Scv1 s7qJVBnOBLm/tSH+XrfVdTrfrr+tj5c1eXBmdb8HD91gsq6dL3arrObiuMfmxfAKRnEv AlZhDjucoc1Ez8TXEAKuj9j7dPu1+AfvYGVTJvHAnOPpIxa3Hrriq5WwxRfpJPpr0mbw /c8PzhSIsHsdLb75kCCh4M8Z1e+zT7FvIM6nJoFsUR7vd8FBEDuaNl35KMfUFLeYU4xK gMUTp6YCOtbCOJ3Wze4+bJr6zhkCSZAx9mH2LpqSofF4D0Vql/y2N09Jq9fP0Hni692v r3+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=IuvRBVCG; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=ZeRDUUMR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lb6-20020a170902fa4600b001a1dd023021si1195936plb.542.2023.04.06.03.05.49; Thu, 06 Apr 2023 03:06:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=IuvRBVCG; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=ZeRDUUMR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236757AbjDFKFZ (ORCPT + 99 others); Thu, 6 Apr 2023 06:05:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229912AbjDFKFJ (ORCPT ); Thu, 6 Apr 2023 06:05:09 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38F6D4ED2; Thu, 6 Apr 2023 03:05:08 -0700 (PDT) Date: Thu, 06 Apr 2023 10:05:05 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1680775506; 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=L4U473xiBwsWpVCNwCcEEXKybetROkdDo1lDqE9zYZc=; b=IuvRBVCGpqZSxz2dJ+nMTmxpblUmFLfKzcC1to+zBR9n9AVzEsMSGGZzWuzBeF8Vok/TYM GbkNPweUVPTJFaxiGAl/hCou2NJTEInXjLtlIkJKdVVf6wIzoL9jtHOkFllaZpcqBhWsl3 oJRu/LXyM8yTsa+0TxfysEb5gvnLnllvobWQu3eeI2TKlLuHRy9bss6aty/IC30fP0Z1aN F8YAoHHdSDGAkREtHv/pwhc7lQ2kjpbyOBsIU2bG+26aAF9CIQ2bbWP5cXl8+WkgBqqPiV Cp78xpTu+knCWIqQN9bUa54FIGLW6X17H38mKZDgzVCePkB7DJErQF+pLdeUlQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1680775506; 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=L4U473xiBwsWpVCNwCcEEXKybetROkdDo1lDqE9zYZc=; b=ZeRDUUMRYXlc04IM+ZC4phXV2Njb5iVxmRqBwtVyNyks0AsyOBLG05e/y9KQwBR7ns/sYt KP/1Zf41WGBLxSAw== From: "tip-bot2 for Peter Zijlstra" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: perf/urgent] perf: Optimize perf_pmu_migrate_context() Cc: Thomas Gleixner , "Peter Zijlstra (Intel)" , "Paul E. McKenney" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230403090858.GT4253@hirez.programming.kicks-ass.net> References: <20230403090858.GT4253@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Message-ID: <168077550562.404.4256750619103519881.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 X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,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 lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the perf/urgent branch of tip: Commit-ID: b168098912926236bbeebaf7795eb7aab76d2b45 Gitweb: https://git.kernel.org/tip/b168098912926236bbeebaf7795eb7aab76d2b45 Author: Peter Zijlstra AuthorDate: Mon, 03 Apr 2023 11:08:58 +02:00 Committer: Peter Zijlstra CommitterDate: Wed, 05 Apr 2023 09:58:46 +02:00 perf: Optimize perf_pmu_migrate_context() Thomas reported that offlining CPUs spends a lot of time in synchronize_rcu() as called from perf_pmu_migrate_context() even though he's not actually using uncore events. Turns out, the thing is unconditionally waiting for RCU, even if there's no actual events to migrate. Fixes: 0cda4c023132 ("perf: Introduce perf_pmu_migrate_context()") Reported-by: Thomas Gleixner Signed-off-by: Peter Zijlstra (Intel) Tested-by: Thomas Gleixner Reviewed-by: Thomas Gleixner Reviewed-by: Paul E. McKenney Link: https://lkml.kernel.org/r/20230403090858.GT4253@hirez.programming.kicks-ass.net --- kernel/events/core.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/kernel/events/core.c b/kernel/events/core.c index fb3e436..115320f 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -12893,12 +12893,14 @@ void perf_pmu_migrate_context(struct pmu *pmu, int src_cpu, int dst_cpu) __perf_pmu_remove(src_ctx, src_cpu, pmu, &src_ctx->pinned_groups, &events); __perf_pmu_remove(src_ctx, src_cpu, pmu, &src_ctx->flexible_groups, &events); - /* - * Wait for the events to quiesce before re-instating them. - */ - synchronize_rcu(); + if (!list_empty(&events)) { + /* + * Wait for the events to quiesce before re-instating them. + */ + synchronize_rcu(); - __perf_pmu_install(dst_ctx, dst_cpu, pmu, &events); + __perf_pmu_install(dst_ctx, dst_cpu, pmu, &events); + } mutex_unlock(&dst_ctx->mutex); mutex_unlock(&src_ctx->mutex);