Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1045503pxx; Tue, 27 Oct 2020 07:05:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyFMZWrj18cwAJr8AAd0tBrb2Ja9K14JjHsOG4+1zqoa/iRTBSVCbg2VXp5mGFReZezIYY3 X-Received: by 2002:a17:906:4bc2:: with SMTP id x2mr2624818ejv.525.1603807517436; Tue, 27 Oct 2020 07:05:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603807517; cv=none; d=google.com; s=arc-20160816; b=TRJyTZRvNsFmF619b+p+4+LjCXQZQOY6cl63IBbaB9cdlWBVIey7XOI/19oeZp3vQo jzLaA1LdFaurEZhpy1HoHZilO2Fm2aob4JvCqA+C+kynSvK+rtvuAHGSMwwv9dRzXbp+ h/pSnTnjfpLCl+robCulGvp2ADcdU8Km7By51E8Tb3yLVlREQafaVFIPtEmt/FoDMtOa ekaxTpPETJoDWQSZbvfxBFYos/x6cBGUmODAAlcAi+MhNpJ30SRgwy7k2HDvMI06/Ost /lvoT45rT6xxxQEAxSc3KT1biIZUHRNZnmh3UytZ+EqKBBwMYI0nr+AVtp2WcBMSVsZV 9IsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=NEeHwxNbIj0xw5OLojL3uq8T/kSReBzeawWQZhpq2Hw=; b=uQHehZj55aAc8GwwZOdjVPNQGqvLe2lZJjt6OYnbQzVG69X4+WwHGllm2W5xvD19Wz 6IEuVrDjZKjSaNYufMyqV4BkViGTd0VQ2RNxRneeoYh5y5faJfGTO9nYx0DpwbjLBzMO j31GbJm5yVp/MMtJUPB+w3Qg8VHnecA+f9jntZgNN3ctGVhTsBCFpI8pcpyIwIycULcL aVDDCIM+B3kHvU0yZdYB3ZXjPWkuknxOuzBXLV5rhRak1/iGw0aD/+ZbqfggijJgeg77 0wT8PHeB1LmVG0/sL6Ysaxxn3dQabaoS5OFcjxDsSk3JyZmIEsL8KZHYW05CWpBnQ6KI V0ag== 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dc22si919474edb.475.2020.10.27.07.04.53; Tue, 27 Oct 2020 07:05:17 -0700 (PDT) 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2444541AbgJ0Ent (ORCPT + 99 others); Tue, 27 Oct 2020 00:43:49 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:36275 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2444442AbgJ0Ens (ORCPT ); Tue, 27 Oct 2020 00:43:48 -0400 Received: by mail-wr1-f67.google.com with SMTP id x7so369506wrl.3 for ; Mon, 26 Oct 2020 21:43:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=NEeHwxNbIj0xw5OLojL3uq8T/kSReBzeawWQZhpq2Hw=; b=sa7x4s9iAqF2PbucKTG1voBIvg0GQT3nyYjvrP4tjb2YBnrJChlbZRSEdEl3DF8ZWf dL+f67s5LjPuN4huS0SvFxIvAUX/ly4X4I76T8C71il2DR5N8odi8+1YSweXq6E6IqnJ qiGle4fQaVU1UHhciwpNzE9CvwuBlwZiUPnU38WgLHtxDZ4J4o2551Y0Uj5F7243Hm/T CaZSoLO5Gdju7rFbM0SBNg0yIFgXyMBfQ2/IG+DLXxsul9ayGOx64PU/kpxLI7dM4KV3 ji1NvWwK9ssnuJxdXtUtYv8yGcJS8VabE9xjnTznCehCVkprmaKXbaHSthZxXat194rr zRyA== X-Gm-Message-State: AOAM531g7YryswFZSreDFgAZSCdgumX3eSR8EzGDdUCN8pNlJ/4qI6mK EGdFW5seSQukqsuyIi8sb59IBrq8zTvj3HCvZSk= X-Received: by 2002:a05:6000:12c2:: with SMTP id l2mr451644wrx.76.1603773826967; Mon, 26 Oct 2020 21:43:46 -0700 (PDT) MIME-Version: 1.0 References: <20201026141937.582087-1-namhyung@kernel.org> <20201026152108.GW466880@tassilo.jf.intel.com> In-Reply-To: <20201026152108.GW466880@tassilo.jf.intel.com> From: Namhyung Kim Date: Tue, 27 Oct 2020 13:43:35 +0900 Message-ID: Subject: Re: [RFC] perf evlist: Warn if event group has mixed sw/hw events To: Andi Kleen Cc: Arnaldo Carvalho de Melo , Jiri Olsa , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , LKML , Stephane Eranian , Ian Rogers Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Andi, On Tue, Oct 27, 2020 at 12:21 AM Andi Kleen wrote: > > On Mon, Oct 26, 2020 at 11:19:37PM +0900, Namhyung Kim wrote: > > This patch just added a warning before running it. I'd really want to > > fix the kernel if possible but don't have a good idea. Thoughts? > > The easiest fix would be some multi threading in perf stat opening, then then > extra latencies could be mostly hidden. One thread per group would probably > be overkill, but just a few threads would lower the penalty significantly. Thanks for the suggestion. Yeah we could use threads to circumvent the problem in userspace. But I think it'd better to solve it in the kernel. Another problem I see is when there's a concurrent perf event in the same context. Since it holds ctx->mutex during the synchronize_rcu the other event should wait for it too. It'd be nice if it can release the ctx->mutex before going to sleep unless we can remove it. > > I think that would be better than this patch and it's likely not that much > more complicated, as this is already a lot of code. > > > +{ > > + const char *known_sw_pmu[] = { > > + "software", "tracepoint", "breakpoint", "kprobe", "uprobe", "msr" > > That's a non scalable approach. New pmus get added regularly. It would be better to > indicate this in a generic way from the kernel. Maybe we can add a new attribute (task_ctx?) for that. > > > + pr_warning("WARNING: Event group has mixed hw/sw events.\n" > > + "This will slow down the perf_event_open syscall.\n" > > + "Consider putting a hw event as a leader.\n\n"); > > You really need to tell the user which group, otherwise it is hard to find > in a large command line. OK Thanks Namhyung