From patchwork Mon Nov 3 15:04:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yogesh Tillu X-Patchwork-Id: 40031 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f70.google.com (mail-ee0-f70.google.com [74.125.83.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id CEB2021894 for ; Mon, 3 Nov 2014 15:10:50 +0000 (UTC) Received: by mail-ee0-f70.google.com with SMTP id b57sf2962511eek.9 for ; Mon, 03 Nov 2014 07:10:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id :in-reply-to:references:cc:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version:sender :errors-to:x-original-sender:x-original-authentication-results :mailing-list:content-type:content-transfer-encoding; bh=v6vnL0vC2OdaXUS1b8NR/vdUMUZmyV1FOcE4KMyHw3I=; b=EyoS4yRoe+foJqsFaU5AmPEGahB9ENo8wqfgn2FcI9ptAhzEdBSZX5t5w4ePiWx8Cv 5m+ZG9zHRmYsbJCaaMXu5N6vg+4J8thThegwCEPnqzh9C1QXBErM3RUFZf2UXyqUHjgF cMeh26lp/cKv81hfpfoAGOmKPByDHaU1v19r7zRKsGewhjj/tsdJU/6JoEc2uK9h/XCb 1ssehIUlSrBXS1BqYd+1M9SkOMNTYD5XTq7B+N8dz9HOutE1kenOFF+Eb6LXsSnyz4dF VV+zuCBVk7MOf8u6vdVtX9xlMzMcd3cJfHCgDgYVDljL+gQ67ci4qA1hJlZ0RcZZP9R7 bYpQ== X-Gm-Message-State: ALoCoQkilEdvvKVfryKGuHP5gwFMlFEOSkQDopkyNH/xfYteLmzbY1Vy55KYN5kLser/NlpBw3DK X-Received: by 10.180.98.165 with SMTP id ej5mr3022837wib.1.1415027450113; Mon, 03 Nov 2014 07:10:50 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.6.100 with SMTP id z4ls748702laz.60.gmail; Mon, 03 Nov 2014 07:10:49 -0800 (PST) X-Received: by 10.152.42.226 with SMTP id r2mr20524643lal.29.1415027449939; Mon, 03 Nov 2014 07:10:49 -0800 (PST) Received: from mail-lb0-f179.google.com (mail-lb0-f179.google.com. [209.85.217.179]) by mx.google.com with ESMTPS id l10si32882160lbd.29.2014.11.03.07.10.49 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 03 Nov 2014 07:10:49 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.179 as permitted sender) client-ip=209.85.217.179; Received: by mail-lb0-f179.google.com with SMTP id l4so2762905lbv.38 for ; Mon, 03 Nov 2014 07:10:49 -0800 (PST) X-Received: by 10.152.29.8 with SMTP id f8mr51664082lah.56.1415027449747; Mon, 03 Nov 2014 07:10:49 -0800 (PST) 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.112.141.34 with SMTP id rl2csp2960lbb; Mon, 3 Nov 2014 07:10:48 -0800 (PST) X-Received: by 10.68.162.100 with SMTP id xz4mr2028924pbb.138.1415027448194; Mon, 03 Nov 2014 07:10:48 -0800 (PST) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id cq3si15413931pbb.193.2014.11.03.07.10.47 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Nov 2014 07:10:48 -0800 (PST) Received-SPF: none (google.com: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) client-ip=2001:1868:205::9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XlJGA-000524-GW; Mon, 03 Nov 2014 15:09:34 +0000 Received: from mail-pa0-f46.google.com ([209.85.220.46]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XlJFo-0004gm-I2 for linux-arm-kernel@lists.infradead.org; Mon, 03 Nov 2014 15:09:13 +0000 Received: by mail-pa0-f46.google.com with SMTP id lf10so12333963pab.33 for ; Mon, 03 Nov 2014 07:08:51 -0800 (PST) X-Received: by 10.70.93.65 with SMTP id cs1mr43582589pdb.80.1415027331644; Mon, 03 Nov 2014 07:08:51 -0800 (PST) Received: from yogesh-Dell-System-Vostro-3360.Airtel4Grouter.cpe ([14.140.2.178]) by mx.google.com with ESMTPSA id mp5sm17413005pbc.33.2014.11.03.07.08.45 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 03 Nov 2014 07:08:50 -0800 (PST) From: Yogesh Tillu To: linux-arm-kernel@lists.infradead.org Subject: [RFC PATCH 5/5] Application: to read PMU counter through vdso Date: Mon, 3 Nov 2014 20:34:05 +0530 Message-Id: <1415027045-6573-6-git-send-email-yogesh.tillu@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1415027045-6573-1-git-send-email-yogesh.tillu@linaro.org> References: <1415027045-6573-1-git-send-email-yogesh.tillu@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141103_070912_618994_B8726529 X-CRM114-Status: GOOD ( 11.90 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.220.46 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.220.46 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders Cc: magnus.karlsson@avagotech.com, tillu.yogesh@gmail.com, Prasun.Kapoor@caviumnetworks.com, linux-perf-users@vger.kernel.org, Andrew.Pinski@caviumnetworks.com, mike.holmes@linaro.org, ola.liljedahl@linaro.org, Yogesh Tillu , linaro-networking@linaro.org, jean.pihet@linaro.org, arnd@linaro.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: yogesh.tillu@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.179 as permitted sender) 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 Test application to read PMU cycle counter through vDSO path. Signed-off-by: Yogesh Tillu --- vdso_userspace_perf.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 vdso_userspace_perf.c diff --git a/vdso_userspace_perf.c b/vdso_userspace_perf.c new file mode 100644 index 0000000..42d2682 --- /dev/null +++ b/vdso_userspace_perf.c @@ -0,0 +1,58 @@ +#include +#include +#include +#include +/* Simple loop body to keep things interested. Make sure it gets inlined. */ +static inline int +loop(int* __restrict__ a, int* __restrict__ b, int n) +{ + unsigned sum = 0; + for (int i = 0; i < n; ++i) + if(a[i] > b[i]) + sum += a[i] + 5; + return sum; +} + +int +main(int ac, char **av) +{ + uint32_t time_start = 0; + uint32_t time_end = 0; + int result=0; + int *a = NULL; + int *b = NULL; + int len = 0; + int sum = 0; + int i; + struct timeval tv; + + if (ac != 2) return -1; + len = atoi(av[1]); + + a = malloc(len*sizeof(*a)); + b = malloc(len*sizeof(*b)); + + for (int i = 0; i < len; ++i) { + a[i] = i+128; + b[i] = i+64; + } +/* Read Counter with Busy loop */ + perf_open_counter(); + time_start = perf_read_counter(); + sum = loop(a, b, len); + time_end = perf_read_counter(); + printf("**********************************************************************\n"); + printf("Busyloop sum = %d\nTime delta Including Busyloop = %lu [clockcycle]\n", sum, time_end - time_start); + +/* Read Counter with profiling read_counter */ + time_start = perf_read_counter(); + perf_read_counter(); + time_end = perf_read_counter(); + printf("\nTime delta Without Busyloop = %lu [clockcycle]\n", time_end - time_start); + printf("**********************************************************************\n"); + + free(a); free(b); + return 0; +cleanup: + return -1; +}