Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp552323pxb; Mon, 8 Nov 2021 18:29:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJzlbwQfCiMthDVWnuFqpnRpTc1wJU8dZa37XyQtTVHJKphY0X8+sJQwRusOGzXwdKX8syMz X-Received: by 2002:a17:906:2788:: with SMTP id j8mr4986457ejc.203.1636424941433; Mon, 08 Nov 2021 18:29:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636424941; cv=none; d=google.com; s=arc-20160816; b=UWtbuQ4y76cmhrtK2+BXJ+tj1HNZPgClurSUkBRi34P143xZX9uA7rgfl0+nT240hA BuvHJDbpzrZ9AO/CbsOOOhmjRFDEa5c62bLauQnskKQCasy7NQ4w4/EFHYeQu/FVeojT e9A2uU8YxGCo3eqDRN/yuBonNseSVwVmA0nf7ahvPfFU3gKzf6nFngphSJX8EcJTh2Cj 6+7i0RvQLNWP+x5zkC+Qa51nZexO8GRMU3S1N4V2LmQ0c/2eraipUZbm8R+WJ3L2OK7l XNGHwdDlQJpJ44BHK+S14Wj2ZQLuGQFXUb2s8tVrxXwRDBjUA1O8vODg1TeT1MvmwZFX QL0w== 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=zJ6kkjMcSrUKpNWGyLFF+NGVId+MBm2LNFWTxBNieZI=; b=UsxBL3XBGyTsUXKkz7mL1blmsMZ0mWmPECPzC8GZaQm7UZLSIGiuAjTTj0aAz8mVwl Holdmjp/lJEH+FjxPvqNjAjsM+5jMjDSuSCnnp1zkdiPgfO059NBpFGYcCpNfNsB+CBg 2e9YP+bdpEtBVlUwUxAmaI2Q6wRGxYHnf8zYMF9vXtiys9t0xvB223k5vn4l8PlF0HWT 7PT0zphssjwsPL/LlB1PhDAG2IyES70VVBRSibn9bI+W4Ubj1E1dcJZeLzDfDVL9E7tS CplKjRLrkQM3JAVO9aHfwRSHNJewDUb0psxAJpTNnPs5spvemrHpsw2zoY9RdMtfhhiN RfRg== 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 j16si34989211edj.201.2021.11.08.18.28.35; Mon, 08 Nov 2021 18:29:01 -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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236145AbhKHSxv (ORCPT + 99 others); Mon, 8 Nov 2021 13:53:51 -0500 Received: from mail-lj1-f169.google.com ([209.85.208.169]:45773 "EHLO mail-lj1-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236093AbhKHSxv (ORCPT ); Mon, 8 Nov 2021 13:53:51 -0500 Received: by mail-lj1-f169.google.com with SMTP id s24so31359805lji.12 for ; Mon, 08 Nov 2021 10:51:06 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=zJ6kkjMcSrUKpNWGyLFF+NGVId+MBm2LNFWTxBNieZI=; b=c0pgP6DuWK5+0otUxhMxI1PGPUPJ/yUwbvfv6pYuKmAF0PI8BhezzQHPncxeilRsQm fMXi0OtoFs1xABgNRtVcUC7BawRvC25YyE3Z+Kuv6sqmKKWnLJF39EejlhnWdfWLWBXE Q3k4QzN+2GqucE3ipI/AN6a/2Uj+kzQfw3ckw7Ko9feKdDXFiZNOGgutuDppkSFjIvZb QN/OwjDkZ+q9RVoR65Rl/US+kPuEH+IB6r8Lx1XVeUsjrWIHu6w9khES741cY/V/ty5X 8+qOe1pja13WLloW+4jZ1aGSUK5ZSDSq62CS9HXvJRBgg8DDwRiFnCRWBlykRbeCHaD8 DWxA== X-Gm-Message-State: AOAM533/XhX8dyAIBP6zE3bIKIo6oJBIFOmYf3lxsD8nsLJmVrbEx+6q oIBNJmxKJLn2xcY2H5/d3uU9aCfDwek/0hjW4YdgoC+V X-Received: by 2002:a2e:8841:: with SMTP id z1mr1227642ljj.180.1636397465370; Mon, 08 Nov 2021 10:51:05 -0800 (PST) MIME-Version: 1.0 References: <20211029224929.379505-1-namhyung@kernel.org> <20211103072112.32312-1-ravi.bangoria@amd.com> <11a4cec1-8169-0891-b9c8-4d3a7b689d86@amd.com> In-Reply-To: <11a4cec1-8169-0891-b9c8-4d3a7b689d86@amd.com> From: Namhyung Kim Date: Mon, 8 Nov 2021 10:50:54 -0800 Message-ID: Subject: Re: [PATCH v3] perf evsel: Fix missing exclude_{host,guest} setting To: Ravi Bangoria Cc: Arnaldo Carvalho de Melo , Jiri Olsa , Ingo Molnar , Peter Zijlstra , linux-kernel , Andi Kleen , Ian Rogers , Stephane Eranian , Kim Phillips Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Nov 7, 2021 at 2:26 AM Ravi Bangoria wrote: > > > > On 07-Nov-21 12:54 AM, Arnaldo Carvalho de Melo wrote: > > Em Fri, Nov 05, 2021 at 11:00:29AM -0700, Namhyung Kim escreveu: > >> Hello, > >> > >> On Wed, Nov 3, 2021 at 12:22 AM Ravi Bangoria wrote: > >>> > >>>> The current logic for the perf missing feature has a bug that it can > >>>> wrongly clear some modifiers like G or H. Actually some PMUs don't > >>>> support any filtering or exclusion while others do. But we check it > >>>> as a global feature. > >>> > >>> (Sorry to pitch in bit late) > >>> > >>> AMD has one more problem on a similar line. On AMD, non-precise and > >>> precise sampling are provided by core and IBS pmu respectively. Plus, > >>> core pmu has filtering capability but IBS does not. Perf by default > >>> sets precise_ip=3 and exclude_guest=1 and goes on decreasing precise_ip > >>> with exclude_guest set until perf_event_open() succeeds. This is > >>> causing perf to always fallback to core pmu (non-precise mode) even if > >>> it's perfectly feasible to do precise sampling. Do you guys think this > >>> problem should also be addressed while designing solution for Namhyung's > >>> patch or solve it seperately like below patch: > >>> > >>> ---><--- > >>> > >>> From 48808299679199c39ff737a30a7f387669314fd7 Mon Sep 17 00:00:00 2001 > >>> From: Ravi Bangoria > >>> Date: Tue, 2 Nov 2021 11:01:12 +0530 > >>> Subject: [PATCH] perf/amd/ibs: Don't set exclude_guest by default > >>> > >>> Perf tool sets exclude_guest by default while calling perf_event_open(). > >>> Because IBS does not have filtering capability, it always gets rejected > >>> by IBS PMU driver and thus perf falls back to non-precise sampling. Fix > >>> it by not setting exclude_guest by default on AMD. > >>> > >>> Before: > >>> $ sudo ./perf record -C 0 -vvv true |& grep precise > >>> precise_ip 3 > >>> decreasing precise_ip by one (2) > >>> precise_ip 2 > >>> decreasing precise_ip by one (1) > >>> precise_ip 1 > >>> decreasing precise_ip by one (0) > >>> > >>> After: > >>> $ sudo ./perf record -C 0 -vvv true |& grep precise > >>> precise_ip 3 > >>> decreasing precise_ip by one (2) > >>> precise_ip 2 > >>> > >>> Reported-by: Kim Phillips > >>> Signed-off-by: Ravi Bangoria > >> > >> It'd be nice if it can cover explicit -e cycles:pp as well. Anyway, > > > > Ravi, please consider Namhyung's request, a patch on top as I'm adding > > this already. > > For explicit :pp modifier, evsel->precise_max does not get set and thus perf > does not try with different attr->precise_ip values while exclude_guest set. > So no issue with explicit :pp: > > $ sudo ./perf record -C 0 -e cycles:pp -vvv |& grep "precise_ip\|exclude_guest" > precise_ip 2 > exclude_guest 1 > precise_ip 2 > exclude_guest 1 > switching off exclude_guest, exclude_host > precise_ip 2 > ^C > > Also, with :P modifier, evsel->precise_max gets set but exclude_guest does > not and thus :P also works fine: > > $ sudo ./perf record -C 0 -e cycles:P -vvv |& grep "precise_ip\|exclude_guest" > precise_ip 3 > decreasing precise_ip by one (2) > precise_ip 2 > ^C Ah, ok. Thanks for making it clear! Thanks, Namhyung