From patchwork Thu Oct 16 13:52:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yogesh Tillu X-Patchwork-Id: 38817 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 183DD20973 for ; Thu, 16 Oct 2014 13:56:16 +0000 (UTC) Received: by mail-lb0-f198.google.com with SMTP id 10sf1951190lbg.1 for ; Thu, 16 Oct 2014 06:56:16 -0700 (PDT) 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:date:message-id:in-reply-to :references:cc:subject:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list:content-type :content-transfer-encoding; bh=iz9MsxCgazwo7zTjt7yurKpgi5+nkg7XAa/CymaSDWs=; b=PiI2hzwVq03hM5BmWcGoTyRjMC+5OIOvs1HbJ/RMXzvFS+INT10mfpwT8s1rziUXwh a1QGE5WpOkgNbTiTtGW5pOugpbWo8QNdDybfhPubsUno5l9FZLUn1KUIZou5LySOnG24 oV80Tux8uRSbvusELwjYAAH0NMSf0IH3CNEmL836jpYznNqOseFHB32zCWyDktndJjCm JBbcextG83dUe4NMykaAZry322c/SB4PNW3USyK2gM9dX0zLvdrHR0BufYPt2YsqjvYT vMj6GANbPGnd7G4RfDONV91g9MVlq9TVZcKWcD/pLavR8BsBMIUcOqrvxesLAtwtlvUv hVvA== X-Gm-Message-State: ALoCoQnZK5BTl/rb9R5PWAvJ6J0BNHuoO6KiSKjFLLGtRsaJWOmScI86f3jUrefZeVPe6uJRm9Wr X-Received: by 10.152.27.38 with SMTP id q6mr305879lag.5.1413467776017; Thu, 16 Oct 2014 06:56:16 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.170.227 with SMTP id ap3ls171449lac.31.gmail; Thu, 16 Oct 2014 06:56:15 -0700 (PDT) X-Received: by 10.112.56.171 with SMTP id b11mr1747154lbq.65.1413467775878; Thu, 16 Oct 2014 06:56:15 -0700 (PDT) Received: from mail-lb0-f177.google.com (mail-lb0-f177.google.com [209.85.217.177]) by mx.google.com with ESMTPS id lc6si34801367lbb.129.2014.10.16.06.56.15 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 16 Oct 2014 06:56:15 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) client-ip=209.85.217.177; Received: by mail-lb0-f177.google.com with SMTP id w7so2797026lbi.8 for ; Thu, 16 Oct 2014 06:56:15 -0700 (PDT) X-Received: by 10.112.173.134 with SMTP id bk6mr1858740lbc.66.1413467775753; Thu, 16 Oct 2014 06:56:15 -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.112.84.229 with SMTP id c5csp43499lbz; Thu, 16 Oct 2014 06:56:15 -0700 (PDT) X-Received: by 10.194.23.40 with SMTP id j8mr2021640wjf.77.1413467775119; Thu, 16 Oct 2014 06:56:15 -0700 (PDT) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id lv10si29672453wjb.131.2014.10.16.06.56.13 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 16 Oct 2014 06:56:15 -0700 (PDT) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XelXH-0008NB-RS; Thu, 16 Oct 2014 13:56:11 +0000 Received: from mail-pd0-f178.google.com ([209.85.192.178]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XelX6-0008MR-87 for lng-odp@lists.linaro.org; Thu, 16 Oct 2014 13:56:00 +0000 Received: by mail-pd0-f178.google.com with SMTP id y10so3323238pdj.9 for ; Thu, 16 Oct 2014 06:55:54 -0700 (PDT) X-Received: by 10.66.253.164 with SMTP id ab4mr1487416pad.59.1413467754710; Thu, 16 Oct 2014 06:55:54 -0700 (PDT) Received: from yogesh-Dell-System-Vostro-3360.Airtel4Grouter.cpe ([14.140.2.178]) by mx.google.com with ESMTPSA id 16sm19899221pdj.42.2014.10.16.06.55.52 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 16 Oct 2014 06:55:53 -0700 (PDT) From: Yogesh Tillu To: lng-odp@lists.linaro.org Date: Thu, 16 Oct 2014 19:22:04 +0530 Message-Id: <1413467525-30304-3-git-send-email-yogesh.tillu@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1413467525-30304-1-git-send-email-yogesh.tillu@linaro.org> References: <1413467525-30304-1-git-send-email-yogesh.tillu@linaro.org> X-Topics: patch Cc: Yogesh Tillu Subject: [lng-odp] [PATCH] Test application to read PMU counter through vdso Signed-off-by: Yogesh Tillu X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: lng-odp-bounces@lists.linaro.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.177 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 --- 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; +}