Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2296526yba; Mon, 15 Apr 2019 08:46:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqzvIh+b5UP+tPwAKdvWJn6AHUgEoLFIe/A8EsRFQdqr5VGt4iUINPWt99UXmTzfBONBQRPz X-Received: by 2002:aa7:8392:: with SMTP id u18mr49860004pfm.217.1555343213532; Mon, 15 Apr 2019 08:46:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555343213; cv=none; d=google.com; s=arc-20160816; b=WUktx3sCsW1i1FHp8Bel+S88SdmqUVJdLXJ4MVM8b9trXgGst3jgKJR25B8983ia4u mcP/3HAi7+K08Sc6n4VRXlUTIioO4wR3I4kunHUqwUEAEU2LxO6pCalRYXUnJ0uMetVu Ps0ckf5dDUrKPu5bp/el0NifUhlimGGH7OgUoghf2ohaAR0aFIrmRZL6JzemGNgAWEuS gBiy0+lWid4Lu6Q2AzrNidKpQmdgQNDu3XFuYo3Z1atIAS5zWuHo+JJPlclZu0crV6ZU 7WqyEPx5Q3yAka567CIytvD6IColtPqh7O0ZX4dYRVPn49wekHiyMsalnYiMg5tfoo5k +EUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=YqvxI+lKC6silkLPCrlxAscBRtOSYUbAHi3pT+AHb60=; b=WXOpHfzA+vCA/fOn2izH1rLIGazMnMChJhhBIWAiwykdxZO9rfM2hslo4inCThHBHm q/fxdFi4H9d6T2rRUA7ebWbDgl/Mq5x+rlFI/1wLx/Ay/VDbfJOFwl5PF7WieY7bisrp 6arwF8Dh6MOEXgG4QPmShq2NFaGDVFV6NreFnzPvYlnhnU1uaTTUe7l0fe0wBUJXAKLw i5lMKM2j1y4WIvzCbnbXXl9dPQGxAFN+83DrN0pQTGkXWBoEnXcOrnw/uYwYSbl0jGXS 9ABVjUpy00LcnG9DnMej9TFWrQxe+oEvkjfYdI5dptltT/W2FbA0irPifT+ta5ZmHch7 Pr6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=ah5+xBtm; 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 f13si19198962pgb.568.2019.04.15.08.46.36; Mon, 15 Apr 2019 08:46:53 -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; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=ah5+xBtm; 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 S1727505AbfDOPpy (ORCPT + 99 others); Mon, 15 Apr 2019 11:45:54 -0400 Received: from merlin.infradead.org ([205.233.59.134]:34468 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726034AbfDOPpy (ORCPT ); Mon, 15 Apr 2019 11:45:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=YqvxI+lKC6silkLPCrlxAscBRtOSYUbAHi3pT+AHb60=; b=ah5+xBtmwioHqxjv4b4NPrHyd iTzSxEUe2wuyKSr1MYUst+KVofVceBfaTeJYQExpURbeBYKN4HFXqHfuqomnuCaH4bDVvl6SrF8UB 0PQxKe0B6k4HbfyPbf1mV52C6yH5YhTxLWLypwSLQxIlYALd4XFmVtElYvMmIlVKLJy8cJ8jwr3BC e5vFMd++earOmry7vCvLU/kpQsNaFhiOiB6ql+VZTsupV+Dz8M4EZSqpl1EdHOe4pNxD0ZOS9pW2K J5o2eUAr5rAvLt5cfhknp5zO5s5MOK2d7ShbNo91xYX8zS9MKuC+f8ITT5XD6tl67FrBqqxHtCW+q hSvbIz9PQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1hG3nf-0002au-6y; Mon, 15 Apr 2019 15:45:39 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id F34372038C257; Mon, 15 Apr 2019 17:45:37 +0200 (CEST) Date: Mon, 15 Apr 2019 17:45:37 +0200 From: Peter Zijlstra To: Stephane Eranian Cc: linux-kernel@vger.kernel.org, tglx@linutronix.de, ak@linux.intel.com, kan.liang@intel.com, mingo@elte.hu, nelson.dsouza@intel.com, jolsa@redhat.com, tonyj@suse.com Subject: Re: [PATCH v2 1/2] perf/core: add perf_ctx_resched() as global function Message-ID: <20190415154537.GH12232@hirez.programming.kicks-ass.net> References: <20190408173252.37932-1-eranian@google.com> <20190408173252.37932-2-eranian@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190408173252.37932-2-eranian@google.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 08, 2019 at 10:32:51AM -0700, Stephane Eranian wrote: > This patch add perf_ctx_resched() a global function that can be called > to force rescheduling of events based on event types. The function locks > both cpuctx and task_ctx internally. This will be used by a subsequent patch. I took out the task_ctx and event_type arguments. --- Subject: perf/core: Add perf_ctx_resched() as global function From: Stephane Eranian Date: Mon, 8 Apr 2019 10:32:51 -0700 This patch add perf_ctx_resched() a global function that can be called to force rescheduling of events. The function locks both cpuctx and task_ctx internally. This will be used by a subsequent patch. Cc: mingo@elte.hu Cc: ak@linux.intel.com Cc: jolsa@redhat.com Cc: tglx@linutronix.de Cc: kan.liang@intel.com Cc: nelson.dsouza@intel.com Cc: tonyj@suse.com Signed-off-by: Stephane Eranian [peterz: simplified calling convention] Signed-off-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/20190408173252.37932-2-eranian@google.com --- include/linux/perf_event.h | 3 +++ kernel/events/core.c | 9 +++++++++ 2 files changed, 12 insertions(+) --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h @@ -888,6 +888,9 @@ extern void perf_sched_cb_dec(struct 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_ctx_resched(struct perf_cpu_context *cpuctx); + 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); --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -2478,6 +2478,15 @@ static void ctx_resched(struct perf_cpu_ perf_pmu_enable(cpuctx->ctx.pmu); } +void perf_ctx_resched(struct perf_cpu_context *cpuctx) +{ + 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 *