Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp542592pxb; Thu, 5 Nov 2020 06:52:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJyGfEDRNDCrqxIqmIVGcYLMBxHp3fzdA82Ab4nhblkIGaOD/sk2QA2GYG4tD4J8dbZAgPT3 X-Received: by 2002:a17:906:d7b9:: with SMTP id pk25mr2630778ejb.486.1604587930989; Thu, 05 Nov 2020 06:52:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604587930; cv=none; d=google.com; s=arc-20160816; b=CZhitnNvYWO8VspxxFY3MsuHZt501VZbTk0a+NO9wUrAW6PEMHrm5NHYPo0nXKGqSe kuMqWncmH97WFbY98CCFUiHFvMpw1AqnW8gnCbGnRvgJeHrR0P6FGHj6F06KWAS4MMz5 /LmdNj5tyooN38YhU4vDyRTA+bhiHFlx9L1ySH3AgKU1YKTk5yrX479wSHlfJZKjuq09 vnViNIOJkQUA/7JCHuyM5wcKLXS+PQVzmUc45vUSUI+8u7IcsAGNjAWQ4H4XbVCcVqmr wQnhBR6xT2K2l4ihZMXgIX4iHd1mma9SKN2up9hjO8qQkExT256jLTcDIS51MQN76Nhc snIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:ironport-sdr:ironport-sdr; bh=oN9T6vk3YKjAdBeVuzwlphRiAKp+l2yUfltspWW1h48=; b=tk1HR6CEvES9zIzJkM/Bm1HUJdYzisiiGn/nkBaQdzSa0ut08oGxoTRUSzPESAkRsG IELTpQEeTZ3qPkPRe/nikIVD6QcBhp6j+bqkcjFSxu1ogoYissiZmqCtWX89aY+RHsm5 PREKAR/fGsk7XcOKkxDFMdViBv5khX8KjRC7GOkZUdOB5C6rr9a8cd3V5H95gah0lrxC jc6wIPQ6AHQI/+UPEmilogNLcla764CLlCvfcfC9nEVtGT/bJ1pHoyEYAnxzkXGLWLQ8 dz+LuJVe3b8y6uuiW11o0U+gJ7wJy+bnMmPjDtFT+Gr56leC4b0Zs96Rhrn2ScjVmguG tcWQ== 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 c19si1273929ejp.465.2020.11.05.06.51.47; Thu, 05 Nov 2020 06:52:10 -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 S1730906AbgKEOr6 (ORCPT + 99 others); Thu, 5 Nov 2020 09:47:58 -0500 Received: from mga12.intel.com ([192.55.52.136]:35491 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727275AbgKEOr6 (ORCPT ); Thu, 5 Nov 2020 09:47:58 -0500 IronPort-SDR: eYjb6cwsr2CpGty/ip9Ffb3lonFJen/wo2mX06undcstA30oOfvMGt7+Hzw7eNOnhcA/OkbIuZ eFwGKvzL0ZIg== X-IronPort-AV: E=McAfee;i="6000,8403,9795"; a="148671571" X-IronPort-AV: E=Sophos;i="5.77,453,1596524400"; d="scan'208";a="148671571" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Nov 2020 06:47:57 -0800 IronPort-SDR: xc6lYkzB0wsZKzibQC+/AVpt8xmjyABKWw+VKmE3YyNZRkkMJHBlxgJLw50Tzwo1RIYScWcGdb bD3UecaE0l/w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,453,1596524400"; d="scan'208";a="397270363" Received: from linux.intel.com ([10.54.29.200]) by orsmga001.jf.intel.com with ESMTP; 05 Nov 2020 06:47:56 -0800 Received: from [10.254.97.216] (kliang2-MOBL.ccr.corp.intel.com [10.254.97.216]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by linux.intel.com (Postfix) with ESMTPS id EA1F158073D; Thu, 5 Nov 2020 06:47:55 -0800 (PST) Subject: Re: [RFC 1/2] perf/core: Enable sched_task callbacks if PMU has it To: Namhyung Kim , Peter Zijlstra , Ingo Molnar Cc: Arnaldo Carvalho de Melo , Jiri Olsa , LKML , Stephane Eranian , Andi Kleen , Ian Rogers , Gabriel Marin References: <20201102145221.309001-1-namhyung@kernel.org> <20201102145221.309001-2-namhyung@kernel.org> From: "Liang, Kan" Message-ID: Date: Thu, 5 Nov 2020 09:47:54 -0500 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.12.1 MIME-Version: 1.0 In-Reply-To: <20201102145221.309001-2-namhyung@kernel.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/2/2020 9:52 AM, Namhyung Kim wrote: > If an event associated with a PMU which has a sched_task callback, > it should be called regardless of cpu/task context. For example, I don't think it's necessary. We should call it when we have to. Otherwise, it just waste cycles. Shouldn't the patch 2 be enough? Thanks, Kan > a per-cpu event might enable large PEBS buffers so it needs to flush > the buffer whenever task scheduling happens. > > The underlying PMU may or may not require this for the given event, > but it will be handled in the pmu::sched_task() callback anyway. > > Signed-off-by: Namhyung Kim > --- > kernel/events/core.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/kernel/events/core.c b/kernel/events/core.c > index b458ed3dc81b..aaa0155c4142 100644 > --- a/kernel/events/core.c > +++ b/kernel/events/core.c > @@ -4696,6 +4696,8 @@ static void unaccount_event(struct perf_event *event) > dec = true; > if (has_branch_stack(event)) > dec = true; > + if (event->pmu->sched_task) > + dec = true; > if (event->attr.ksymbol) > atomic_dec(&nr_ksymbol_events); > if (event->attr.bpf_event) > @@ -11225,6 +11227,8 @@ static void account_event(struct perf_event *event) > inc = true; > if (is_cgroup_event(event)) > inc = true; > + if (event->pmu->sched_task) > + inc = true; > if (event->attr.ksymbol) > atomic_inc(&nr_ksymbol_events); > if (event->attr.bpf_event) >