From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24B59C76196 for ; Mon, 3 Apr 2023 22:07:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233753AbjDCWHg (ORCPT ); Mon, 3 Apr 2023 18:07:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233494AbjDCWHf (ORCPT ); Mon, 3 Apr 2023 18:07:35 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA703E5B for ; Mon, 3 Apr 2023 15:07:33 -0700 (PDT) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1680559651; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=vAvtMfEQqqct4AWZHCiEowGKxwaBoH/2w4q0y2AQHjE=; b=0xfgb68oTrIMfQ+CVG2z3/7V2K9K8a+MUmGW6RuRBoj4J5PIhRg8T7mcNHVjEg2Qst6TaA 4uW8/+AbrEagGfu+DxzBeqSl9bQ5yqNftjufOC0+UzUv7edyUZIGEMDHU/sCqBwqAL3bAo 0/uf/5IWDXiFu39Zt13qiK5Wj8osrAhRnHiS9co40BYB73qL3+npyh8Tf7YZrKa3DKEDZ0 TIgdTSEvT3cdNRFjbgatNTRVJQovb5NbLWp4BhtRZFYLiv2KaJoK4IKFglCikzFybYuD8x JpNx5Fz42EnHREKOqqlLAGw1x3UfpoYJ5PMbF1ZP5KZ1AClp9iG2HeWQs86N0A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1680559651; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=vAvtMfEQqqct4AWZHCiEowGKxwaBoH/2w4q0y2AQHjE=; b=nDbHfK4Ete28h4npijXgkjZ/0jFIH9+CNpGGW0vR0I4qXRjJrv6CwBgK1/ojhisLtw72l7 MdoXpwFKdRvIj2Bw== To: Peter Zijlstra , Ravi Bangoria , Ingo Molnar Cc: linux-kernel@vger.kernel.org, Arnaldo Carvalho de Melo , Mark Rutland , Jiri Olsa , "Paul E. McKenney" Subject: Re: [PATCH] perf: Optimize perf_pmu_migrate_context() In-Reply-To: <20230403090858.GT4253@hirez.programming.kicks-ass.net> References: <20230403090858.GT4253@hirez.programming.kicks-ass.net> Date: Tue, 04 Apr 2023 00:07:30 +0200 Message-ID: <87sfdgr55p.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 03 2023 at 11:08, Peter Zijlstra wrote: > 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. That happens when offlining CPUs from a socket > 0 in the same order how those CPUs have been brought up. On socket 0 this is not observable unless the bogus CPU0 offlining hack is enabled. If the offlining happens in the reverse order then all is shiny. The reason is that the first online CPU on a socket gets the uncore events assigned and when it is offlined then those are moved to the next online CPU in the same socket. On a SKL-X with 56 threads per sockets this results in a whopping _1_ second delay per thread (except for the last one which shuts down the per socket uncore events with no delay because there are no users) due to 62 times of pointless synchronize_rcu() invocations where each takes ~16ms on a HZ=250 kernel. Which in turn is interesting because that machine is completely idle other than running the offline muck... > 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