From patchwork Thu Aug 22 14:13:22 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 19413 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f197.google.com (mail-qc0-f197.google.com [209.85.216.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 765C4248E6 for ; Thu, 22 Aug 2013 14:14:48 +0000 (UTC) Received: by mail-qc0-f197.google.com with SMTP id l13sf4297qcy.8 for ; Thu, 22 Aug 2013 07:14:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:delivered-to:sender:from:to:cc:subject:date:message-id :in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=ErPTU8z2TkTRz8PUvHg4VFzWt1fs632AlR+l+qH9kqk=; b=xDlQHa+L6xBQUZ2BmG0uQPvC0vFOjwUMTdo4pjWKVy1c95XlfQQ83BV5y17XPjthCd ZUY2jp7vS7r7VqCg1YUrKzOD8VxxE6FREql8v/tdbtJNN+zeyD5+PRHJFakqfBnbpbkz 5Un01RZgdkTolm12L6XOH6HlwDuIP/fqWI1NwXBfJ8eKuZZdefWQzt/d/T284vmG0fIN awA+W3kPMySy0GAweLEIYYir0GrT3EZXYpeUZ/yeOj7q18UincmMTAq7ZzWviT2KXdqP VoTe41ZZenvdFdz2X8v2dolp7zbiqsItUJIkDsqyrC8kZXbplWM05cMHN0o5iFBljZBY j++w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-gm-message-state:delivered-to:sender:from:to:cc :subject:date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=ErPTU8z2TkTRz8PUvHg4VFzWt1fs632AlR+l+qH9kqk=; b=iKmkMgiUU4tFewJZwPLc9v8UKOK9tiETgfhDjDmBWxhMYXeRaraoHaz+4Sp1XJBopC EZIoNsNLPBQYgSWKhs4k3hxumALfaib2F5ygemmIiOBeYH5/NCaaNXgjzRGEh1MutR9S WpGdINR6Z1IzwPFEiIO61kCMRB4Ob/9yhaH//ku6uxwNJvidIDaSh45zYQPjybc38oFq DWGoeyLIFgf/tJfmDM0s8OD9Dbocb7Nd9bEHJ0HLabMtqDxElY1AkpxPhriOccwcMlip 9KgCvTjRz7fwi68dpFHiWX3mMrMHBPSzutWMlXmCb3saU02SP4JoH0Cc93AB4X8Nk1ex /JHQ== X-Received: by 10.236.207.103 with SMTP id m67mr4593945yho.1.1377180888294; Thu, 22 Aug 2013 07:14:48 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.121.104 with SMTP id lj8ls1140895qeb.11.gmail; Thu, 22 Aug 2013 07:14:48 -0700 (PDT) X-Received: by 10.58.249.136 with SMTP id yu8mr95069vec.37.1377180888158; Thu, 22 Aug 2013 07:14:48 -0700 (PDT) Received: from mail-vb0-x235.google.com (mail-vb0-x235.google.com [2607:f8b0:400c:c02::235]) by mx.google.com with ESMTPS id wk9si4009956vdb.81.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 22 Aug 2013 07:14:48 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c02::235 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c02::235; Received: by mail-vb0-f53.google.com with SMTP id i3so1259794vbh.40 for ; Thu, 22 Aug 2013 07:14:48 -0700 (PDT) X-Gm-Message-State: ALoCoQnLuVc+6OGC3HhAGUVsoMsB/hPqGkdIlBMReTGa6d4Gs58xIrayVikghkU65tq0xAdPx0LM X-Received: by 10.58.100.234 with SMTP id fb10mr11896969veb.5.1377180888073; Thu, 22 Aug 2013 07:14:48 -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.220.174.196 with SMTP id u4csp33214vcz; Thu, 22 Aug 2013 07:14:47 -0700 (PDT) X-Received: by 10.204.241.75 with SMTP id ld11mr2283889bkb.35.1377180887263; Thu, 22 Aug 2013 07:14:47 -0700 (PDT) Received: from mail-bk0-x232.google.com (mail-bk0-x232.google.com [2a00:1450:4008:c01::232]) by mx.google.com with ESMTPS id oi6si2309113bkb.55.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 22 Aug 2013 07:14:47 -0700 (PDT) Received-SPF: pass (google.com: domain of rric.net@gmail.com designates 2a00:1450:4008:c01::232 as permitted sender) client-ip=2a00:1450:4008:c01::232; Received: by mail-bk0-f50.google.com with SMTP id mz11so722918bkb.9 for ; Thu, 22 Aug 2013 07:14:46 -0700 (PDT) X-Received: by 10.205.5.6 with SMTP id oe6mr2278673bkb.36.1377180886157; Thu, 22 Aug 2013 07:14:46 -0700 (PDT) Received: from rric.localhost (g224195237.adsl.alicedsl.de. [92.224.195.237]) by mx.google.com with ESMTPSA id jh13sm3079991bkb.13.1969.12.31.16.00.00 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 22 Aug 2013 07:14:45 -0700 (PDT) Sender: Robert Richter From: Robert Richter To: Peter Zijlstra Cc: Ingo Molnar , Arnaldo Carvalho de Melo , Borislav Petkov , Jiri Olsa , linux-kernel@vger.kernel.org, Robert Richter , Robert Richter Subject: [PATCH v3 07/12] perf, persistent: Implementing a persistent pmu Date: Thu, 22 Aug 2013 16:13:22 +0200 Message-Id: <1377180807-12758-8-git-send-email-rric@kernel.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1377180807-12758-1-git-send-email-rric@kernel.org> References: <1377180807-12758-1-git-send-email-rric@kernel.org> X-Original-Sender: rric.net@gmail.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c02::235 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 | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/kernel/events/persistent.c b/kernel/events/persistent.c index 926654f..ede95ab 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: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 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));