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: 5217381 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 699F3C11AD for ; Mon, 3 Nov 2014 15:11:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A14E52012B for ; Mon, 3 Nov 2014 15:11:18 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C59D620127 for ; Mon, 3 Nov 2014 15:11:17 +0000 (UTC) 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-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=b+F7KWrp/Vm1zKlj09oqob/2g9B+nCtLTtHwOcJaBGc=; b=JZbPBz29VD68Wuzz3qX2Xo8f9Vn7eFfQ00oQXIn+rXyf+ISv5uEVpPzkbqGdNgBYa8 xIZdFO1v/9ea01BDAgIPli1s5l4WuBpbHwrH/UBL/S5EZ6BjjSqZjCESoTNQ0vtCQtR7 XMwfED2ywADB5zW1dk70jsn7hIS+kvg1y7xxdSnLcIcX8zn8MfRHKMhjeqsQGO/4K58n V0hFZ9E7IIBr8WGDnRHGcwfInUkHRtStUBWGIdYeQ1MIUjTC9mMyw1mzVc6HU/VMtUf3 WdSBeVhIpC3pn1B+cFCV3KHTwhbeWpkMro7SQku1TyKcEInBm8ySfqok5K6HUG+nFusD iNRA== X-Gm-Message-State: ALoCoQnBz0x/ogWOXrHWx06DaW5k12OGY9kWyU+SqN/NSa3tTddL6itTriEkqzTO6VazA4M/eMdV 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 (/) 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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; +}