From patchwork Mon Apr 7 15:04:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean Pihet X-Patchwork-Id: 27909 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f72.google.com (mail-qa0-f72.google.com [209.85.216.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 279CD20490 for ; Mon, 7 Apr 2014 15:09:31 +0000 (UTC) Received: by mail-qa0-f72.google.com with SMTP id hw13sf14260015qab.3 for ; Mon, 07 Apr 2014 08:09:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=t6z9eO7y363Ai5obuO9Hlis/esBlPOP94Q2oz65+kwo=; b=C7vhJeZSOrKNHH4yZYwWYBFtUqP6SW9DzR4nd3rsDBTs/fag+ehvPzI3vmrB54NBvZ CdRTsG4QRvLNc760Busl8n7F6/kN6OC0vIuVSu9R8x6DFmAwzEk2izhEfyFGhhRMyce+ Lb3JtZp57i88ZTsKEU5BGnmFaxXpBOJmUjMqdFAlFP7dafX+nfN2ofs8kZdv6RqB21Sy 0Fau3Nk4iBMVfBGDg5sToK8ayLVdM/Btinq18TUivd3oCLwQJ3ZCMfBvahl96mPzWE31 9MYccU1Lx8JS7wuOxqrAHGJ/qOvJLKPF14a2Iqcq0Ev7LGWPd/W4l1LPsdNuAfo4T19g gfuQ== X-Gm-Message-State: ALoCoQmuWvy60UUqKXs3aUuisAb5uD90PiurFOZ2rkrYg+ooWnxqqfIm7c3tlWxS17m6nPLk+Oax X-Received: by 10.236.112.4 with SMTP id x4mr5341422yhg.56.1396883371699; Mon, 07 Apr 2014 08:09:31 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.41.169 with SMTP id z38ls1739549qgz.36.gmail; Mon, 07 Apr 2014 08:09:31 -0700 (PDT) X-Received: by 10.52.53.34 with SMTP id y2mr30731vdo.53.1396883371600; Mon, 07 Apr 2014 08:09:31 -0700 (PDT) Received: from mail-ve0-f174.google.com (mail-ve0-f174.google.com [209.85.128.174]) by mx.google.com with ESMTPS id tq2si3188436vdc.3.2014.04.07.08.09.31 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 07 Apr 2014 08:09:31 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.174 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.174; Received: by mail-ve0-f174.google.com with SMTP id oz11so3613270veb.19 for ; Mon, 07 Apr 2014 08:09:31 -0700 (PDT) X-Received: by 10.58.31.136 with SMTP id a8mr7367578vei.20.1396883371490; Mon, 07 Apr 2014 08:09:31 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.12.8 with SMTP id v8csp169963vcv; Mon, 7 Apr 2014 08:09:31 -0700 (PDT) X-Received: by 10.66.221.99 with SMTP id qd3mr22042709pac.46.1396883370751; Mon, 07 Apr 2014 08:09:30 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id qj1si8488906pbb.428.2014.04.07.08.09.29; Mon, 07 Apr 2014 08:09:30 -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; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755684AbaDGPJV (ORCPT + 27 others); Mon, 7 Apr 2014 11:09:21 -0400 Received: from mail-ee0-f43.google.com ([74.125.83.43]:51563 "EHLO mail-ee0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753057AbaDGPFL (ORCPT ); Mon, 7 Apr 2014 11:05:11 -0400 Received: by mail-ee0-f43.google.com with SMTP id e53so743155eek.16 for ; Mon, 07 Apr 2014 08:05:10 -0700 (PDT) X-Received: by 10.14.99.68 with SMTP id w44mr1395024eef.82.1396883110246; Mon, 07 Apr 2014 08:05:10 -0700 (PDT) Received: from localhost.localdomain (201-179-62-37.mobileinternet.proximus.be. [37.62.179.201]) by mx.google.com with ESMTPSA id o4sm42287649eef.20.2014.04.07.08.05.08 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 07 Apr 2014 08:05:09 -0700 (PDT) From: Jean Pihet To: Borislav Petkov , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Jiri Olsa , linux-kernel@vger.kernel.org, Robert Richter Cc: Robert Richter , Jean Pihet Subject: [PATCH 07/16] perf, persistent: Implementing a persistent pmu Date: Mon, 7 Apr 2014 17:04:29 +0200 Message-Id: <1396883078-25320-8-git-send-email-jean.pihet@linaro.org> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1396883078-25320-1-git-send-email-jean.pihet@linaro.org> References: <1396883078-25320-1-git-send-email-jean.pihet@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: jean.pihet@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.174 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Robert Richter We want to use the kernel's pmu design to later expose persistent events via sysfs to userland. Initially implement a persistent pmu. The format syntax is introduced allowing to set bits anywhere in struct perf_event_attr. This is used in this case to set the persistent flag (attr5:24). The syntax is attr where num is the index of the u64 array in struct perf_event_attr. Otherwise syntax is same as for config. Patches that implement this functionality for perf tools are sent in a separate patchset. Signed-off-by: Robert Richter Signed-off-by: Robert Richter Signed-off-by: Jean Pihet --- kernel/events/persistent.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/kernel/events/persistent.c b/kernel/events/persistent.c index 78fdd74..6b039f5 100644 --- a/kernel/events/persistent.c +++ b/kernel/events/persistent.c @@ -12,6 +12,7 @@ struct pevent { int id; }; +static struct pmu persistent_pmu; static DEFINE_PER_CPU(struct list_head, pevents); static DEFINE_PER_CPU(struct mutex, pevents_lock); @@ -210,10 +211,43 @@ int perf_get_persistent_event_fd(int cpu, int id) return event_fd; } +PMU_FORMAT_ATTR(persistent, "attr5:24"); + +static struct attribute *persistent_format_attrs[] = { + &format_attr_persistent.attr, + NULL, +}; + +static struct attribute_group persistent_format_group = { + .name = "format", + .attrs = persistent_format_attrs, +}; + +static const struct attribute_group *persistent_attr_groups[] = { + &persistent_format_group, + NULL, +}; + +static int persistent_pmu_init(struct perf_event *event) +{ + if (persistent_pmu.type != event->attr.type) + return -ENOENT; + + /* Not a persistent event. */ + return -EFAULT; +} + +static struct pmu persistent_pmu = { + .event_init = persistent_pmu_init, + .attr_groups = persistent_attr_groups, +}; + void __init perf_register_persistent(void) { int cpu; + perf_pmu_register(&persistent_pmu, "persistent", PERF_TYPE_PERSISTENT); + for_each_possible_cpu(cpu) { INIT_LIST_HEAD(&per_cpu(pevents, cpu)); mutex_init(&per_cpu(pevents_lock, cpu));