Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5174958rwl; Mon, 3 Apr 2023 15:53:19 -0700 (PDT) X-Google-Smtp-Source: AKy350ZJDZ+mFIMqtx80mI7QmBhr8dgRZmL0jxQ1IgrN0d/XKgfFZHSN3SHKG1kwks3rq0hcqi5Y X-Received: by 2002:a05:6a20:4f24:b0:d4:e980:9f90 with SMTP id gi36-20020a056a204f2400b000d4e9809f90mr224642pzb.44.1680562399155; Mon, 03 Apr 2023 15:53:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680562399; cv=none; d=google.com; s=arc-20160816; b=CHOlToHmSc7qJniY249rJipCm1+ju+SmkoWrUW89NhHQe1UKfWjOYP8PdHQ9qWLImb WBmr6q+ybpJem8onSDOZyElmTGviQstYwLXCGaYeP1BDjSd9pfCySK3NPTKrQBmEE+wp OYARcc1bSBk8BU9cCMGq4xxcw9oimEYv5JdqyAGejjUgW17nzv2alBRm7o+HeBEUKxNa XFooQwzEen3PN7d7RE3OuELHnrsC2lJ48odWvDvJN45vDu6gQDmEdS7/s5Y1cUfQm+Rg PU5+vvpPyn58N37n2WujEDoGCYMQRzZbn9v9c0NXrCByR36ey1eMYg9ckXjRFtYRT8Vm xdHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=75o465Ik68D0XXG2VukCyY4DnnCDMzLUh7p1sgAPWBs=; b=t7gYUQdGAJQcUITxunYXH88Mz1sooqZszTM0TWDKUGEOsjtCZyF8g9C4c07gRJddpq cDSFbHjTKn/DP6cIBxN+JJgVHaTzzWDFCKFalZR9OnHRMznQQzLx2+Xr+1k6Jo87FacI ECIbuk5l20IfOCwR3qHC9F8TFV8WogYESO4XBGda3YY/CUTTCBfoQ1v8L/nRYXAlmD16 Lp+18tGORgeza066MKJQXGFV54tNy1WdE5C/08SMxmkpr7O34IRjDuWSdN5LwGTH6/oZ xAVhtewxwqVImO0i7w3STHvDgzrKP8NdyuzAVIIqzDj6A6VMv1rIQR3d9lAJAAIGLYoo tabA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=k+H1E3v9; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q195-20020a632acc000000b00513f9dbbdb9si2366387pgq.275.2023.04.03.15.53.07; Mon, 03 Apr 2023 15:53:19 -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=@kernel.org header.s=k20201202 header.b=k+H1E3v9; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233692AbjDCWvl (ORCPT + 99 others); Mon, 3 Apr 2023 18:51:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232676AbjDCWvk (ORCPT ); Mon, 3 Apr 2023 18:51:40 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CFD03ABF for ; Mon, 3 Apr 2023 15:51:29 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E631062B8D for ; Mon, 3 Apr 2023 22:51:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 56743C433EF; Mon, 3 Apr 2023 22:51:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680562288; bh=nCHk3zkvWXwY10cczA6sRnQuIsGC+f6S2QWO3f6TtSA=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=k+H1E3v9KPcuvuvUuQBBW2BO21aPZplS0jyY9MsNd4oz8IgDdyYDucwIyM5K8m1Qw 7jfixJSGkO3jKGDHNPIG4AO20rLHYAwREtYw/b1FYv+hfO6hlNv344Ec3i84te65l5 yf8nFjrGDhogTn5mabLnsZdzBi4cTmYG0DUS4KRvqFZ/QMVi3yRKhFQEZYsP/qyNzn Nt6iMp/T2KQ5tjD6MBqbdacuo0tURaW4sZ7Kz7KSYgXUmnnO790/z8IZDcONWc6c/Y L43rtjojajfBuHhppauFI7Y3ETpyBxn5QjrlGWGcsyvvZEWqt0u7HpuCT8s59XtGt1 oZDGNDa7rX9Hg== Received: by paulmck-ThinkPad-P72.home (Postfix, from userid 1000) id D5FBA15404B4; Mon, 3 Apr 2023 15:51:27 -0700 (PDT) Date: Mon, 3 Apr 2023 15:51:27 -0700 From: "Paul E. McKenney" To: Thomas Gleixner Cc: Peter Zijlstra , Ravi Bangoria , Ingo Molnar , linux-kernel@vger.kernel.org, Arnaldo Carvalho de Melo , Mark Rutland , Jiri Olsa Subject: Re: [PATCH] perf: Optimize perf_pmu_migrate_context() Message-ID: Reply-To: paulmck@kernel.org References: <20230403090858.GT4253@hirez.programming.kicks-ass.net> <87sfdgr55p.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87sfdgr55p.ffs@tglx> X-Spam-Status: No, score=-5.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,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 Tue, Apr 04, 2023 at 12:07:30AM +0200, Thomas Gleixner wrote: > 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 Yow! ;-) Assuming that all the events run under RCU protection, as in preemption disabled: Reviewed-by: Paul E. McKenney