Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5144525rwl; Mon, 3 Apr 2023 15:16:17 -0700 (PDT) X-Google-Smtp-Source: AKy350afOUwECkBFuCZiGeJW6gmP+jzHnl/+DyccAYQbMHdeYSQsYC9PffvCCzlir0J2vKiC+Vsg X-Received: by 2002:aa7:c488:0:b0:4fc:3f28:719c with SMTP id m8-20020aa7c488000000b004fc3f28719cmr515551edq.33.1680560177545; Mon, 03 Apr 2023 15:16:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680560177; cv=none; d=google.com; s=arc-20160816; b=KDqEuOQtmk97cs0n8I2nf6gZ0+tFljfScwd2Xo6Qo+DeW2c8+SRwvRYX1+qqTX9WLO 39Nz291fMaePpIHG0fNbXkMYkI52kPPLxZm89qb4wnEozPXpDScNqeLZcT+PnWbOQCHw 5viASF6QFPRd625WwHXtj3gUzm3Ni3Pqb+KtJ1pbKv0Fn5yaXoeb6v3n6bT3tRwH3XoK i7dxEGyiKVAjxlWuV9BIOYR/p3Jcjb6nX1RR1KjZwmsko5jfZLMCn/t++oC1R/S9ZR9n eVISx1PjUpn3xOVUJOVRYBPVeaxJUgT2Ultf8Emha7UpsVxPdYG0JMStYu72nd/UVDOR 9S4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=vAvtMfEQqqct4AWZHCiEowGKxwaBoH/2w4q0y2AQHjE=; b=UAgzRFCx+up8IWziIBhsuU1FSVMQ46KogU4ej3UQKpqZ7jlktYZaRoCYUm/UvpjuC1 I3hZ3MJ3Xt6AOXjplVR3mtbnNda77byCa4GqTV73P+6l37AQJB0mJXbmW6wBE9p7fOXs n3KMH91yp5e+atk0FiJQuQyeoa2OoU6/EDgf0AVL7AiNTCr3nh6ZY0RWoywLb3EuO7I0 0KX1eVILfgBKNdcZ7rzplKB6Evd7ThObREvFlWhI2Z8kxVoVIAw1m4UCZ5LIX8XJ9J09 ze37tKtqS/TwJ/A9y4oZFh7Bha625eS53erh5x1zbDgRZmoOeBwJq+aeMqbdomnCNKJp DLiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=0xfgb68o; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 i6-20020aa7c706000000b005021f0d5766si9025283edq.685.2023.04.03.15.15.50; Mon, 03 Apr 2023 15:16:17 -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=0xfgb68o; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 S233740AbjDCWHg (ORCPT + 99 others); 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 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 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