From patchwork Tue Jun 11 16:42:37 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 17898 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f200.google.com (mail-vc0-f200.google.com [209.85.220.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id ABC7C25DF1 for ; Thu, 13 Jun 2013 10:57:23 +0000 (UTC) Received: by mail-vc0-f200.google.com with SMTP id kw10sf4334085vcb.3 for ; Thu, 13 Jun 2013 03:57:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-beenthere:x-forwarded-to:x-forwarded-for :delivered-to:resent-from:resent-date:resent-message-id:resent-to :sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:x-google-group-id:list-post :list-help:list-archive:list-unsubscribe; bh=/9rrWcCLdHcDsk4Lh2CQ22Fpq+f2PWkGaCbu+a1XRpI=; b=avmNxAHF5Sv0xcI4U509S1cugtNC884JRLDzgNsaA0h+7+teEBzZlJcxZcFXImvxaJ UzpHJ4W+NknalCWj1U7SB6sNwkMwFM4T0G5b8LcuhA6QLZYIAtR4jO9R7hErF7eAHC8u /KaRrkfSmRm1Rhb73ZJk4EJdMjfg4nUEx0Lu+qR6n/8LYowmu3eRYjGDR5hxyD+KTsEJ S4fvoJlThYlIj7jicDJEgHqRQqMp1XVkcso69xvpgYmGPVt7UCqJ/MZ1y2e8DhZOLqY0 HwvqojXVRdWEqQV1yY41kfkPF3atkHY8n0CbQo806u/lOD0865KShsSRBLoTI98hPpMb jC7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-beenthere:x-forwarded-to:x-forwarded-for :delivered-to:resent-from:resent-date:resent-message-id:resent-to :sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe; bh=/9rrWcCLdHcDsk4Lh2CQ22Fpq+f2PWkGaCbu+a1XRpI=; b=mc79aUff9UaVnpnaE2U4gHK/d67id/h6X19cg0lcgGUapIyx8ViXOOXytTHwph4q8h ZzDnSnOvu9I/gCpRUmnYq13mJ9kkoAD1NkSfqzFd6QXoEmO5bntJ6HA6S7F3JBnLdNm7 EwA5lpd/CsV1y4jRhGw3Kp2YNNT7Ew7Z7D9IMHgczyK1SepMppQLgpfB7cg+K9xyDq7S +kL0p4dFJiy8r4UE1uSD8KkChYROul98wdGykfMFIh5VnAQWz9s61umE60RrrV4H3QiX Ffcl/CQy2gO17+U69h+sTsSU/CkyfWVZoLvb4yLxGnc21unkaqrOU74ipchL4X93MGqU NxJg== X-Received: by 10.236.70.170 with SMTP id p30mr147307yhd.5.1371121043462; Thu, 13 Jun 2013 03:57:23 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.83.102 with SMTP id p6ls1578328qey.63.gmail; Thu, 13 Jun 2013 03:57:23 -0700 (PDT) X-Received: by 10.58.106.77 with SMTP id gs13mr111545veb.22.1371121043311; Thu, 13 Jun 2013 03:57:23 -0700 (PDT) Received: from mail-vc0-f181.google.com (mail-vc0-f181.google.com [209.85.220.181]) by mx.google.com with ESMTPS id b16si10207557vcq.0.2013.06.13.03.57.23 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 13 Jun 2013 03:57:23 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.181 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.181; Received: by mail-vc0-f181.google.com with SMTP id lf11so6206674vcb.40 for ; Thu, 13 Jun 2013 03:57:23 -0700 (PDT) X-Received: by 10.52.53.36 with SMTP id y4mr90699vdo.51.1371121043191; Thu, 13 Jun 2013 03:57:23 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.58.191.99 with SMTP id gx3csp16620vec; Thu, 13 Jun 2013 03:57:22 -0700 (PDT) X-Received: by 10.205.1.198 with SMTP id nr6mr43336bkb.168.1371121042082; Thu, 13 Jun 2013 03:57:22 -0700 (PDT) Received: from mail-bk0-x22f.google.com (mail-bk0-x22f.google.com [2a00:1450:4008:c01::22f]) by mx.google.com with ESMTPS id kh7si2351449bkb.235.2013.06.13.03.57.21 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 13 Jun 2013 03:57:22 -0700 (PDT) Received-SPF: pass (google.com: domain of rric.net@gmail.com designates 2a00:1450:4008:c01::22f as permitted sender) client-ip=2a00:1450:4008:c01::22f; Received: by mail-bk0-f47.google.com with SMTP id jg1so4829137bkc.6 for ; Thu, 13 Jun 2013 03:57:21 -0700 (PDT) X-Received: by 10.205.25.198 with SMTP id rj6mr77592bkb.2.1371121041473; Thu, 13 Jun 2013 03:57:21 -0700 (PDT) Received: from rric.localhost (g224198135.adsl.alicedsl.de. [92.224.198.135]) by mx.google.com with ESMTPSA id v6sm9178117bko.3.2013.06.13.03.57.20 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 13 Jun 2013 03:57:20 -0700 (PDT) Resent-From: Robert Richter Resent-Date: Thu, 13 Jun 2013 12:57:18 +0200 Resent-Message-ID: <20130613105718.GL12218@rric.localhost> Resent-To: linaro-kernel@lists.linaro.org, patches@linaro.org Received: from rric.localhost (f053086247.adsl.alicedsl.de. [78.53.86.247]) by mx.google.com with ESMTPSA id b12sm6160884bkz.0.2013.06.11.09.43.06 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 11 Jun 2013 09:43:07 -0700 (PDT) Sender: Robert Richter From: Robert Richter To: Borislav Petkov Cc: Ingo Molnar , Peter Zijlstra , Arnaldo Carvalho de Melo , Jiri Olsa , linux-kernel@vger.kernel.org, Robert Richter , Robert Richter Subject: [PATCH v2 11/14] perf, persistent: Implementing a persistent pmu Date: Tue, 11 Jun 2013 18:42:37 +0200 Message-Id: <1370968960-22527-12-git-send-email-rric@kernel.org> X-Mailer: git-send-email 1.8.1.1 In-Reply-To: <1370968960-22527-1-git-send-email-rric@kernel.org> References: <1370968960-22527-1-git-send-email-rric@kernel.org> X-Gm-Message-State: ALoCoQlhM2HFFcVsVzsFW3czT5jUfH+OxLWLgI0BPhzOTRf9KKS37CfOsdO0dseLGvQ3DAtlpZ9d X-Original-Sender: rric.net@gmail.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.181 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; dkim=pass header.i=@gmail.com Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: 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:23). 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 --- kernel/events/persistent.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/kernel/events/persistent.c b/kernel/events/persistent.c index 4fcd071..97c57c9 100644 --- a/kernel/events/persistent.c +++ b/kernel/events/persistent.c @@ -175,10 +175,45 @@ out: return event_fd; } +PMU_FORMAT_ATTR(persistent, "attr5:23"); + +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 struct pmu persistent_pmu; + +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 persistent_events_init(void) { int cpu; + perf_pmu_register(&persistent_pmu, "persistent", -1); + for_each_possible_cpu(cpu) { INIT_LIST_HEAD(&per_cpu(pers_events, cpu)); mutex_init(&per_cpu(pers_events_lock, cpu));