Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp5314906ybg; Tue, 22 Oct 2019 01:04:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqxt8SWsmKpKtApzsrJDR10RdU/13aVVYhmsLgP94KI4shFI/3f0lQj1Oj2/Car71zn1f1AG X-Received: by 2002:a17:906:3903:: with SMTP id f3mr7036455eje.241.1571731456106; Tue, 22 Oct 2019 01:04:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571731456; cv=none; d=google.com; s=arc-20160816; b=L8FryaUXPHrn7W+sn2ec7Hjhni/lrXhiGXKEch/LOHexvhP/fRMbG0jLgNJnMVjbEu gIbtAM7Yecz3cWX4g41pmT0TFhYra05P3yp70s2y7YDr0rZjtrJndPjBGQSSBroqGiE9 l/xNTaToSOf7Y52UkY8EDoMcYo56DxzfQxCx8MPWoPK9w0lqTfX68RdgMo0E2pXBocw/ IEy1r2oBXK/epvQVin/VWf9H266UaXe+Fkn+47hR3bE6hhmQfh9XWOjnGK9g7Wje1LxY xNjfi4r5UDXxkeNTlJUAWRUmabUhO8pvz/39nRin/ZGVQJrKtCchFj8buYVZZdNEKzJZ S8/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:user-agent:in-reply-to:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=UUmCSC+sLU7Zo2ZV+nGJDedwwjTXgkes0+a1E3YaWyM=; b=J6gQ5qEDlPLoPIWv7HYy4LmPvaCk+6WUtEkj6g8Tc9KdXRxF+Iv2jnPtismVt3g7Br hZ8rjIweJ6VcW3TRHVujk1dGESd1zNKqsDD9SMZc46h1WEboXVduQPuYSDwzoPzsd/Sa 0Ai6LTczjz35rtqz2je87cvCkZnk6Ja+HsumidUm8x9br4fBdBLsGax51iJXOTVMH8kj P+GhQ9dvujm2lel8d7ccEsm0fToSgwth7DCgp18aTMommcqiIBAwnFkrOjINHwz5Di6F DDv0UyaBJdLHeGZZoT7iFwzQHRQFmbbJpld5+91z0pL8UxJcd2mRnh0GBkhNz/wwMRGk SZTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=jNFJypj+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ov32si9753014ejb.411.2019.10.22.01.03.51; Tue, 22 Oct 2019 01:04:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=jNFJypj+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388090AbfJVICc (ORCPT + 99 others); Tue, 22 Oct 2019 04:02:32 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:57041 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2387692AbfJVICb (ORCPT ); Tue, 22 Oct 2019 04:02:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571731350; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UUmCSC+sLU7Zo2ZV+nGJDedwwjTXgkes0+a1E3YaWyM=; b=jNFJypj+Vm5tqaLvR2Zp57IX9kDsmeRmPnfqfSiaBvKzqQfG+LUz6+fHutX/wc40tXzLfs TxkoWq46sTvJGPhBs2WAwaPnHDBmYphXHA8XSMsGDi7S8cAfww7R2ja2/2/tth2Vfp1rGg s2WE0h0XJ62GIlmgqYuDXoKqX6g+Q2I= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-208--dDvj_9EO8KO_b2HBCEXgA-1; Tue, 22 Oct 2019 04:02:27 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BEE0D107AD31; Tue, 22 Oct 2019 08:02:25 +0000 (UTC) Received: from krava (unknown [10.43.17.61]) by smtp.corp.redhat.com (Postfix) with SMTP id 4CD5460C4E; Tue, 22 Oct 2019 08:02:24 +0000 (UTC) Date: Tue, 22 Oct 2019 10:02:23 +0200 From: Jiri Olsa To: Andi Kleen Cc: acme@kernel.org, linux-kernel@vger.kernel.org, jolsa@kernel.org, eranian@google.com, kan.liang@linux.intel.com, peterz@infradead.org Subject: Re: Optimize perf stat for large number of events/cpus v2 Message-ID: <20191022080223.GC28177@krava> References: <20191020175202.32456-1-andi@firstfloor.org> MIME-Version: 1.0 In-Reply-To: <20191020175202.32456-1-andi@firstfloor.org> User-Agent: Mutt/1.12.1 (2019-06-15) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-MC-Unique: -dDvj_9EO8KO_b2HBCEXgA-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Oct 20, 2019 at 10:51:53AM -0700, Andi Kleen wrote: > [The earlier v1 version had a lot of conflicts against some > recent libperf changes in tip/perf/core. Resolve that and > also fix some minor issues.] >=20 > This patch kit optimizes perf stat for a large number of events=20 > on systems with many CPUs and PMUs. >=20 > Some profiling shows that the most overhead is doing IPIs to > all the target CPUs. We can optimize this by using sched_setaffinity > to set the affinity to a target CPU once and then doing > the perf operation for all events on that CPU. This requires > some restructuring, but cuts the set up time quite a bit. >=20 > In theory we could go further by parallelizing these setups > too, but that would be much more complicated and for now just batching it > per CPU seems to be sufficient. At some point with many more cores=20 > parallelization or a better bulk perf setup API might be needed though. >=20 > In addition perf does a lot of redundant /sys accesses with > many PMUs, which can be also expensve. This is also optimized. >=20 > On a large test case (>700 events with many weak groups) on a 94 CPU > system I go from >=20 > real=090m8.607s > user=090m0.550s > sys=090m8.041s >=20 > to=20 >=20 > real=090m3.269s > user=090m0.760s > sys=090m1.694s >=20 > so shaving ~6 seconds of system time, at slightly more cost > in perf stat itself. On a 4 socket system with the savings > are more dramatic: >=20 > real=090m15.641s > user=090m0.873s > sys=090m14.729s >=20 > to=20 >=20 > real=090m4.493s > user=090m1.578s > sys=090m2.444s >=20 > so 11s difference in the user visible set up time. >=20 > Also available in=20 >=20 > git://git.kernel.org/pub/scm/linux/kernel/git/ak/linux-misc perf/stat-sca= le-4 >=20 > v1: Initial post. > v2: Rebase. Fix some minor issues. looks really helpful, I ack-ed 1st 2 patches, I'll need more time for the rest thanks, jirka