Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp1310846rdb; Fri, 1 Dec 2023 12:30:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IG2zAKJPsqLpZM+BZj56ANPDeflndlepIWKY12bpcWvGdTktd+kHZfjiX0t4QlvmvdPWgYM X-Received: by 2002:a05:6a00:1804:b0:6ce:2731:5f6c with SMTP id y4-20020a056a00180400b006ce27315f6cmr74406pfa.43.1701462611893; Fri, 01 Dec 2023 12:30:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701462611; cv=none; d=google.com; s=arc-20160816; b=sEiRhXy+8QMwYt01+/u/iWIA7F3Z/AU+4zikLrA9KFJH0KTz1widHX0pdX7eYiu/WT CLENALaTwAcqe25HsZi93LJW2Me9iEbzmt2l+ioOPLnXWVUp/hoDt2LGfrmSMGStNM2a IcJtbHx7CupYTWYp7/szJ0iAyoooApOq79xmr89dSHweOsHuD/pipFxRXK80QkUhl8q/ dFZZmBNQxUHpbYVL7exZghTwei+KzzCmZFds5Rg8/eE1B9YY84kl8QwCI8/PxiqZszSN +lv5xC9NuUyv39cy+ikERNvOMoqRrRkfJIMj0VB5YOdeTx+4gCChb5XI6iiJ10AwkQFx 15mQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=aZw1rUc6HD/qLPkf+WJeqrx3qRzofJw3dX2xht1kg+g=; fh=h0b1PQ5aNkAfB6MhdNeDW5pCY1NxSYG5QPOWV9aBmbM=; b=HF4ulEWB1dWN1S8OkIpnEzTMGpejpaYyIjw2DoG53Kq06dNm/yqH5RXMC/J0g3pipB JDOXr2sQ41tqf9/u9M2DHBAdwMM8OzhlnsSBqW3n85RbRxYi+1kuvpcmYNR6goh0iEJv HKoxGkw9fZfIL6jtRbbWJ5fWmBex07zCfJn7Uvcefjb77fGA6J6IpSv8oyIYVA/DMyBQ fpil+b5/a3qKclj8G+ylBaahmDXDi8SaQx6OPwp0zXEyWPQl8oN0kaAzQpqg/a68L05t HpKGL76FivyK2JQxpSC4qWms+gUqf+HIPdsFLX8pjtiE76DATuE+cSNmEodRc75AL5so g2KA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id z5-20020a656645000000b005a9e4c3d350si3710730pgv.743.2023.12.01.12.30.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 12:30:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id F3748813EA8C; Fri, 1 Dec 2023 12:30:09 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230221AbjLAUaA convert rfc822-to-8bit (ORCPT + 99 others); Fri, 1 Dec 2023 15:30:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229456AbjLAU37 (ORCPT ); Fri, 1 Dec 2023 15:29:59 -0500 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14B3E10C2 for ; Fri, 1 Dec 2023 12:30:06 -0800 (PST) Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-1cfc9c4acb6so8842645ad.0 for ; Fri, 01 Dec 2023 12:30:06 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701462605; x=1702067405; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/CeYIdWlsv5Nxg9Uu3to5cfBHN6j2D+aqFRVe9wb2aw=; b=miuKivTZrniRyiQKNvQmlkwwjd02zW8XU/9cGAHZIiMldh4EEtBRh9eMYD6dyvKi5e yK5CSyZSel9rwCd7vItwnzooDWxvZmB0NRJDaA+1kSDNiG4peqd65aKEmzZeBtSs9Sbo hdB6MboAOtBOwi0FQYluGrUJ2gR0Iqn1dm6SCRvkt+XSjO3LmhxdIaGhBz4eGyuvArwg wJXC7FDovHkBXHnLvzEL1JLXGrVzXyqEoR1YuzHKjciHuWnx+71erkle3jr39uc3mxuB 72waFje7jNC0BBXM/YV7YdaSRzD+Cd9Qc7WZImmNFVaDRhiZ/Rhdgs9Jb3/sP6CJuWBr j5ow== X-Gm-Message-State: AOJu0YzdRplLZZWAP1mrn/HAlBvKLamuKOr7f9A/2fKYjj4qP+IzjjUj ZwsMSZ736DUi3wnAIpk0I/B/tynWBLDNVNzBCeE= X-Received: by 2002:a17:902:f54d:b0:1d0:6ffd:6e56 with SMTP id h13-20020a170902f54d00b001d06ffd6e56mr68122plf.78.1701462605318; Fri, 01 Dec 2023 12:30:05 -0800 (PST) MIME-Version: 1.0 References: <20231120221932.213710-1-namhyung@kernel.org> <20231120221932.213710-3-namhyung@kernel.org> <66f74af2-21b6-477b-ada1-a8816ee115dc@linux.intel.com> <25e006f6-43a2-4046-a14e-a856285f5eed@linux.intel.com> In-Reply-To: <25e006f6-43a2-4046-a14e-a856285f5eed@linux.intel.com> From: Namhyung Kim Date: Fri, 1 Dec 2023 12:29:53 -0800 Message-ID: Subject: Re: [PATCH 3/3] perf/x86: Add CAP_NO_INTERRUPT for uncore PMUs To: "Liang, Kan" , Peter Zijlstra , Ingo Molnar Cc: Mark Rutland , Alexander Shishkin , Arnaldo Carvalho de Melo , LKML , Ian Rogers , Mingwei Zhang Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 01 Dec 2023 12:30:10 -0800 (PST) On Tue, Nov 21, 2023 at 11:26 AM Liang, Kan wrote: > > > > On 2023-11-21 1:30 p.m., Namhyung Kim wrote: > > Hi Kan, > > > > On Tue, Nov 21, 2023 at 7:59 AM Liang, Kan wrote: > >> > >> > >> > >> On 2023-11-20 5:19 p.m., Namhyung Kim wrote: > >>> It doesn't support sampling in uncore PMU events. While it's > >>> technically possible to generate interrupts, let's treat it as if it > >>> has no interrupt in order to skip the freq adjust/unthrottling logic > >>> in the timer handler which is only meaningful to sampling events. > >>> > >>> Also remove the sampling event check because it'd be done in the general > >>> code in the perf_event_open syscall. > >>> > >>> Signed-off-by: Namhyung Kim > >>> --- > >>> arch/x86/events/intel/uncore.c | 11 ++++++----- > >>> 1 file changed, 6 insertions(+), 5 deletions(-) > >>> > >>> diff --git a/arch/x86/events/intel/uncore.c b/arch/x86/events/intel/uncore.c > >>> index 69043e02e8a7..f7e6228bd1b1 100644 > >>> --- a/arch/x86/events/intel/uncore.c > >>> +++ b/arch/x86/events/intel/uncore.c > >>> @@ -744,10 +744,6 @@ static int uncore_pmu_event_init(struct perf_event *event) > >>> if (pmu->func_id < 0) > >>> return -ENOENT; > >>> > >>> - /* Sampling not supported yet */ > >>> - if (hwc->sample_period) > >>> - return -EINVAL; > >>> - > >>> /* > >>> * Place all uncore events for a particular physical package > >>> * onto a single cpu > >>> @@ -919,7 +915,12 @@ static int uncore_pmu_register(struct intel_uncore_pmu *pmu) > >>> .stop = uncore_pmu_event_stop, > >>> .read = uncore_pmu_event_read, > >>> .module = THIS_MODULE, > >>> - .capabilities = PERF_PMU_CAP_NO_EXCLUDE, > >>> + /* > >>> + * It doesn't allow sampling for uncore events, let's > >>> + * treat the PMU has no interrupts to skip them in the > >>> + * perf_adjust_freq_unthr_context(). > >>> + */ > >>> + .capabilities = PERF_PMU_CAP_NO_EXCLUDE | PERF_PMU_CAP_NO_INTERRUPT, > >>> .attr_update = pmu->type->attr_update, > >>> }; > >> > >> > >> There is a special customized uncore PMU which needs the flag as well. > > > > Ok, I will add that too. > > > > Btw, during the work I noticed many PMU drivers didn't set the > > CAP_NO_INTERRUPT flag even if they didn't support sampling and > > rejected the sampling events manually in the ->event_init() callback. > > > > I guess it's because the name of the flag is somewhat misleading. > > As the PMU drivers handle IRQ (for overflows), they thought they had > > interrupts and didn't set the flag. I think it'd be better to rename it to > > CAP_NO_SAMPLING to reveal the intention. And then we could just set > > the flag in the pmu.capabilities and remove the manual checks. > > > > The benefit is it can skip the PMUs in the timer tick handler even if > > it needs to unthrottle some events. What do you think? > > > > I agree. The current name is kind of misleading. > > The patch, which introduced the flag (commit id 53b25335dd60 ("perf: > Disable sampled events if no PMU interrupt")), also tried to disable the > sampled events on a no-sampling supported platform. > > The renaming sounds good to me. Thank Kan for the review. Peter and Ingo, would you please pick up the first two patches if you don't have any concerns? Then I can work on the renaming on top. Thanks, Namhyung