Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3087438yba; Tue, 16 Apr 2019 04:34:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqzpgX4h2OhYhEsaYY9lXgfJM+obb5DBZLucpfDAPcnKtwGakOiceTUjCsK+clUW+gpDVvX2 X-Received: by 2002:a63:7885:: with SMTP id t127mr73660333pgc.338.1555414464688; Tue, 16 Apr 2019 04:34:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555414464; cv=none; d=google.com; s=arc-20160816; b=WuIWMy/fEQ9e7GX2I4neTAbtM9yKqh4Ye/BFfDe/DJsiESP7ArtCDS6jyrWTxjQt4n PLRt38Q/OxHFd0UAoKg4RV4PQisfgu5fFmjJqDxedNgTcQL2dDHXMvaOFddJ26ZZ4HhI 3ssWfKp/pkIIBvzPom/61V6ZqxRaubLCZvU+5FUtDpt+vlIx4Xv8YorIvY6gtJ1J+tmr rzTxZeluGx6l3TUiaT/AiE1AZW9r7VSDqIx2wm0IJ0XIY+FU6VSn5jvvb+SrNlvIHQ6g b+mWTAuX07mtuxMqVT4Q08zTB/ciLwBajWUTfXrm/8HGKsLuBkGcv2OiEEAGmKbTBDJF 0IAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date; bh=Xo70NaYjRcW04emNvSuXoLDGWyW9HOTl7Lx2Z/AA//g=; b=o8CFVbS4Ic0iD4DMNBlsto0xaE0LjZuCzGTbDwgsAbLzX/mdliWPUnRWglqBYJJVyN 6m+rNUI9J5OTOH4SJxoXQp02GF3iNvDPedW3JrkgCI+XSXRU7RhaC2wLb4UG0xXjKQTg xKfsd7CHOvB7roD2M3cWehTGPn/SVht3Rji87LWTD9/E7MwJm0Qh5pevK5KRx2H6Llit lSDBMG8MseGjRJE+8ScNYk6sv3tY3t7tPu6OcoLTiuLnZBERXV2OkgMhe6Y+/iNqRXwe D/GDcQwErjgpn9btG3eOyA0x0XDV3E2EUWz28j1sph7S4bhyoS8/Cs9qLsbOqCk9JwXf ghEw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f1si22417548pgv.195.2019.04.16.04.34.08; Tue, 16 Apr 2019 04:34:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728963AbfDPLdZ (ORCPT + 99 others); Tue, 16 Apr 2019 07:33:25 -0400 Received: from terminus.zytor.com ([198.137.202.136]:46341 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726241AbfDPLdY (ORCPT ); Tue, 16 Apr 2019 07:33:24 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id x3GBX2Ht3427966 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Tue, 16 Apr 2019 04:33:02 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id x3GBX2pR3427953; Tue, 16 Apr 2019 04:33:02 -0700 Date: Tue, 16 Apr 2019 04:33:02 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Stephane Eranian Message-ID: Cc: linux-kernel@vger.kernel.org, tglx@linutronix.de, jolsa@redhat.com, vincent.weaver@maine.edu, eranian@google.com, acme@redhat.com, hpa@zytor.com, mingo@kernel.org, torvalds@linux-foundation.org, alexander.shishkin@linux.intel.com, peterz@infradead.org Reply-To: mingo@kernel.org, torvalds@linux-foundation.org, alexander.shishkin@linux.intel.com, peterz@infradead.org, vincent.weaver@maine.edu, linux-kernel@vger.kernel.org, tglx@linutronix.de, jolsa@redhat.com, acme@redhat.com, eranian@google.com, hpa@zytor.com In-Reply-To: <20190408173252.37932-2-eranian@google.com> References: <20190408173252.37932-2-eranian@google.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf/core: Add perf_pmu_resched() as global function Git-Commit-ID: c68d224e5ed15605e651e2482c6ffd95915ddf58 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=0.1 required=5.0 tests=ALL_TRUSTED,BAYES_00, DATE_IN_FUTURE_03_06 autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: c68d224e5ed15605e651e2482c6ffd95915ddf58 Gitweb: https://git.kernel.org/tip/c68d224e5ed15605e651e2482c6ffd95915ddf58 Author: Stephane Eranian AuthorDate: Mon, 8 Apr 2019 10:32:51 -0700 Committer: Ingo Molnar CommitDate: Tue, 16 Apr 2019 12:19:34 +0200 perf/core: Add perf_pmu_resched() as global function This patch add perf_pmu_resched() a global function that can be called to force rescheduling of events for a given PMU. The function locks both cpuctx and task_ctx internally. This will be used by a subsequent patch. Signed-off-by: Stephane Eranian [ Simplified the calling convention. ] Signed-off-by: Peter Zijlstra (Intel) Cc: Alexander Shishkin Cc: Arnaldo Carvalho de Melo Cc: Jiri Olsa Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Vince Weaver Cc: kan.liang@intel.com Cc: nelson.dsouza@intel.com Cc: tonyj@suse.com Link: https://lkml.kernel.org/r/20190408173252.37932-2-eranian@google.com Signed-off-by: Ingo Molnar --- include/linux/perf_event.h | 3 +++ kernel/events/core.c | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index 085a95e2582a..f3864e1c5569 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h @@ -888,6 +888,9 @@ extern void perf_sched_cb_dec(struct pmu *pmu); extern void perf_sched_cb_inc(struct pmu *pmu); extern int perf_event_task_disable(void); extern int perf_event_task_enable(void); + +extern void perf_pmu_resched(struct pmu *pmu); + extern int perf_event_refresh(struct perf_event *event, int refresh); extern void perf_event_update_userpage(struct perf_event *event); extern int perf_event_release_kernel(struct perf_event *event); diff --git a/kernel/events/core.c b/kernel/events/core.c index 30a572e4c6f1..abbd4b3b96c2 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -2478,6 +2478,16 @@ static void ctx_resched(struct perf_cpu_context *cpuctx, perf_pmu_enable(cpuctx->ctx.pmu); } +void perf_pmu_resched(struct pmu *pmu) +{ + struct perf_cpu_context *cpuctx = this_cpu_ptr(pmu->pmu_cpu_context); + struct perf_event_context *task_ctx = cpuctx->task_ctx; + + perf_ctx_lock(cpuctx, task_ctx); + ctx_resched(cpuctx, task_ctx, EVENT_ALL|EVENT_CPU); + perf_ctx_unlock(cpuctx, task_ctx); +} + /* * Cross CPU call to install and enable a performance event *