Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp197059pxb; Mon, 2 Nov 2020 18:43:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJx+kcm/nox/Os/ikmh4vx9GXQD++765QnSqEC4tlkr5NsJbRNruF30xiqixYbHEGiC3iShq X-Received: by 2002:a05:6402:a53:: with SMTP id bt19mr9192654edb.26.1604371424369; Mon, 02 Nov 2020 18:43:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604371424; cv=none; d=google.com; s=arc-20160816; b=c8IFK4MOU37Bb0u1Eb5hnc/UAuAeH5W14ZxjUFUNzuHckFhBe360IAivRMZzCbNOoR w9+2PuP9Q9CXmF/KzIxffntMq0ty2NgbfLsL6JFq3HXHzwMocRTZio5phy2zFaM40/m+ WBtPk9OTdwe5XOy9SCjezAtH+0Xr5/YsTdGJqRnZ1/a/e/yCHzU8YDhAFsZFmVHu6GH6 89cO84dsSLGPE1M304xQo/1V7j3sa/lfN6XZYRvkcVxpeBjK/viBPExpJPR+w4DGO4z7 +IWu3fzih9JfJzFYbZT6wXPMoqya1wXomoPJ3QjhdR81d4hCM/WtiQ+yH1T36b40DqND CvKQ== 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:message-id:subject:cc:to:from:date:ironport-sdr :ironport-sdr; bh=nu2jjGXecgUh6lShGvagFqoUSBzKZHVzRFA48QRDM6g=; b=TT0JqM5hzYTbKasQRZh4NFNIcHUbiPpQCSHWZ+ZVeO+o/D0+cVg/MmJ+28eh2snWDe IRxuOB7ylVN490jDxp1NLw8mHaOaeadusHLM6QSfWbikCUYY2iHp7wZTQ3oVRl4ExWli 1tcRBSQq/asMfcEG4wY2XjqyL8X6cR9SFu1yL7MoPcj1IHp9LG8sC3PhNVTo31A/fvhP O2r2lPpYhgokBagN2HSml827Vef9U5zBe2noY5pOZUccwCOHzvBq9Ph+W4J6j8VsTm8X viZoy5WGXDfkyLPffpxTrngTDM2IVlrvxkGn82FLEu6Li6y4ejqi8pCoa2ZNmLBZGbJ0 /RXg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bu21si11589479edb.78.2020.11.02.18.43.21; Mon, 02 Nov 2020 18:43:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726139AbgKCClr (ORCPT + 99 others); Mon, 2 Nov 2020 21:41:47 -0500 Received: from mga06.intel.com ([134.134.136.31]:64732 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725997AbgKCClr (ORCPT ); Mon, 2 Nov 2020 21:41:47 -0500 IronPort-SDR: HSPhAwLuNlDfQn6/uDKAUOgVWUNhsc93Xsmtly94tBLxexv/+ynVA+aNIHUdFFX3agwCyIw8F2 eMs41RtLJhDg== X-IronPort-AV: E=McAfee;i="6000,8403,9793"; a="230617642" X-IronPort-AV: E=Sophos;i="5.77,446,1596524400"; d="scan'208";a="230617642" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Nov 2020 18:41:45 -0800 IronPort-SDR: pMCcW3vEUvHSzX/Ock69kEE8byVAxVvfoV2A2WPoGKJnKpPVPddXvRd2hKg4NRwuvbelKFfkqQ EtASVpEFLAAw== X-IronPort-AV: E=Sophos;i="5.77,446,1596524400"; d="scan'208";a="528240587" Received: from tassilo.jf.intel.com ([10.54.74.11]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Nov 2020 18:41:45 -0800 Date: Mon, 2 Nov 2020 18:41:43 -0800 From: Andi Kleen To: Peter Zijlstra Cc: Jiri Olsa , mingo@kernel.org, acme@kernel.org, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, namhyung@kernel.org, linux-kernel@vger.kernel.org, eranian@google.com Subject: Re: [PATCH v2 0/4] perf: Fix perf_event_attr::exclusive rotation Message-ID: <20201103024143.GK466880@tassilo.jf.intel.com> References: <20201029162719.519685265@infradead.org> <20201031234418.GE3380099@krava> <20201102035238.GI466880@tassilo.jf.intel.com> <20201102141625.GX2594@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201102141625.GX2594@hirez.programming.kicks-ass.net> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 02, 2020 at 03:16:25PM +0100, Peter Zijlstra wrote: > On Sun, Nov 01, 2020 at 07:52:38PM -0800, Andi Kleen wrote: > > The main motivation is actually that the "multiple groups" algorithm > > in perf doesn't work all that great: it has quite a few cases where it > > starves groups or makes the wrong decisions. That is because it is very > > difficult (likely NP complete) problem and the kernel takes a lot > > of short cuts to avoid spending too much time on it. > > The event scheduling should be starvation free, except in the presence > of pinned events. > > If you can show starvation without pinned events, it's a bug. > > It will also always do equal or better than exclusive mode wrt PMU > utilization. Again, if it doesn't it's a bug. Simple example (I think we've shown that one before): (on skylake) $ cat /proc/sys/kernel/nmi_watchdog 0 $ perf stat -e instructions,cycles,frontend_retired.latency_ge_2,frontend_retired.latency_ge_16 -a sleep 2 Performance counter stats for 'system wide': 654,514,990 instructions # 0.34 insn per cycle (50.67%) 1,924,297,028 cycles (74.28%) 21,708,935 frontend_retired.latency_ge_2 (75.01%) 1,769,952 frontend_retired.latency_ge_16 (24.99%) 2.002426541 seconds time elapsed The second frontend_retired should be both getting 50% and the fixed events should be getting 100%. So several events are starved. Another similar example is trying to schedule the topdown events on Icelake in parallel to other groups. It works with one extra group, but breaks with two. (on icelake) $ cat /proc/sys/kernel/nmi_watchdog 0 $ perf stat -e '{slots,topdown-bad-spec,topdown-be-bound,topdown-fe-bound,topdown-retiring},{branches,branches,branches,branches,branches,branches,branches,branches},{branches,branches,branches,branches,branches,branches,branches,branches}' -a sleep 1 Performance counter stats for 'system wide': 71,229,087 slots (60.65%) 5,066,320 topdown-bad-spec # 7.1% bad speculation (60.65%) 35,080,387 topdown-be-bound # 49.2% backend bound (60.65%) 22,769,750 topdown-fe-bound # 32.0% frontend bound (60.65%) 8,336,760 topdown-retiring # 11.7% retiring (60.65%) 424,584 branches (70.00%) 424,584 branches (70.00%) 424,584 branches (70.00%) 424,584 branches (70.00%) 424,584 branches (70.00%) 424,584 branches (70.00%) 424,584 branches (70.00%) 424,584 branches (70.00%) 3,634,075 branches (30.00%) 3,634,075 branches (30.00%) 3,634,075 branches (30.00%) 3,634,075 branches (30.00%) 3,634,075 branches (30.00%) 3,634,075 branches (30.00%) 3,634,075 branches (30.00%) 3,634,075 branches (30.00%) 1.001312511 seconds time elapsed A tool using exclusive hopefully will be able to do better than this. -Andi