Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp583545pxb; Thu, 5 Nov 2020 07:48:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJyItnKTbR5NArNWUC2X1ODiKrxUX1tRIk/pe7PA2K9p5qFqgYHM9n0LtNpkps9ltLgF/u5a X-Received: by 2002:a50:eb96:: with SMTP id y22mr1672378edr.116.1604591294104; Thu, 05 Nov 2020 07:48:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604591294; cv=none; d=google.com; s=arc-20160816; b=nwxFbIPiOQ2mC25IDkhnUnJ2lzgnUMgDm1dEXw5/6TmD5W7oCgTzibHuwbdpqwVZg6 BgDJ+u5OHnPN0FEogglWODZ7hA2rVnq5xKP8pr1Drqc+NUHvlnSDst9Kb6uyTjpfFqP9 1UjjFYH2TD0m9zY1zi7oxTM++zN5EHsQElJ5emFJ39HruWAy0ikEUSQxMxJzaAcWCyag i6xKT/zxEENCcKQ4X31dOoPUDjTSvh+gPafWRI+jQX4Bngm9Wma8B8QyYqq43jxEX3sQ GNXHrzeZIHi8zlvlV+rO07ueaL2iASlcbrozCMEjMGC0lk4+4jPnsuLE3+cJIEaRO0nO xAFw== 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=W1nC8Ep9mivgJZksY7MG5lSo7fvXUWLe5EVSJUjtJ2w=; b=lAT1z73iJr4XlfCf0KkZO5MvFRfwz8Tj+1Ml/MqIjADACuTjqfYcABlHz5QJjzV+Vf T5aKlPCI/Pqsj9yoqWGVn11PaLhBGr0NigpdMr0Tubu0mrPCrk7Rj3CXLgRxPR2RbluX NbmOOAtgEYOX0LGvygUZ4H2jWlZ3UWq5kxQwPmdFFqP9W5mdBbCxsclC9bfBtUSIIc80 GAE/NND+q/gQ63899BE+s43lbpYxAJr1wnoV17MICzK4WE3YweBCk7kyzEbGWKGQW30D mI+kP1B3mtygOvCHpB+iUyf3kHxEneP/4dfSY0DRejuqXjHyFTCLHmKVoVPCcelX4SUn 5rug== 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 c91si1294861edf.313.2020.11.05.07.47.50; Thu, 05 Nov 2020 07:48:14 -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 S1731350AbgKEPpR (ORCPT + 99 others); Thu, 5 Nov 2020 10:45:17 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:36845 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731202AbgKEPpQ (ORCPT ); Thu, 5 Nov 2020 10:45:16 -0500 Received: by mail-wr1-f67.google.com with SMTP id x7so2321081wrl.3 for ; Thu, 05 Nov 2020 07:45:14 -0800 (PST) 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=W1nC8Ep9mivgJZksY7MG5lSo7fvXUWLe5EVSJUjtJ2w=; b=U21S6VzMslqV3hLOfEa+otU2dkuVBjSOietDRBn1QMnacHyhXOIeL07X2NIq2+2ay2 1BVuQkVnY7eW1frmNDm0cj66bAJhpyNivNfaWQ6dgmqRSwPaHL/SqwysYrQ+eb5u4Nhi ohCJtSGHUPSR9F/P4NBJYlyMv4kg9FbGaX1rs+Jc+lGQX43LFunlvRwEcajlzn/Jh+aJ Q27TPBtFXUYsxbXyx0jrlWPHSgyu4LwTeV+Dt7byimbJAXrRs078yNyxMXbFRuS+RtCW ueQyJ3oSVBg0kZKRkUp/sEeirlq04b2NVbp5+vmP9y5+Kv/DyHTRGyJek9JzDt06eVZS UT7Q== X-Gm-Message-State: AOAM531Ts2wmMzTxhRzG/a/BQkgSlkzvR6WAMydO5LfwJNT0x97c6gdf 4IE1z6tkNYdsgMXKZEAqlA6iufYj38JjKlr8oj0= X-Received: by 2002:adf:84a5:: with SMTP id 34mr3642106wrg.8.1604591113331; Thu, 05 Nov 2020 07:45:13 -0800 (PST) MIME-Version: 1.0 References: <20201102145221.309001-1-namhyung@kernel.org> <20201102145221.309001-2-namhyung@kernel.org> In-Reply-To: From: Namhyung Kim Date: Fri, 6 Nov 2020 00:45:02 +0900 Message-ID: Subject: Re: [RFC 1/2] perf/core: Enable sched_task callbacks if PMU has it To: "Liang, Kan" Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Jiri Olsa , LKML , Stephane Eranian , Andi Kleen , Ian Rogers , Gabriel Marin Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On Thu, Nov 5, 2020 at 11:47 PM Liang, Kan wrote: > > > > 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? I'm not sure, without this patch __perf_event_task_sched_in/out cannot be called for per-cpu events (w/o cgroups) IMHO. And I could not find any other place to check the perf_sched_cb_usages. Thanks Namhyung > > > 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) > >