Hi Ingo,

I picked up this simple testcases written by you from:

http://lkml.org/lkml/2008/12/5/17,

If you do not have any issue(s), we would like to include the same
in LTP. The following patch does exactly that.

May i request you to kindly let us know if you are developing any
test case(s) for any kernel feature in future. Then kindly do,

Cc: Subrata Modak <[email protected]>,
Cc: ltp-list <[email protected]>,

Ported-To-And-Tested-On-LTP-By: Subrata Modak <[email protected]>,
---

--- ltp-full-20090331.orig/runalltests.sh       2009-04-01 17:35:09.000000000 
+0530
+++ ltp-full-20090331/runalltests.sh    2009-04-01 17:51:42.000000000 +0530
@@ -197,6 +197,9 @@ export RUN_CONTROLLER_AREA_NETWORK_TESTS
 ## as both of them cannot be tested in the same running kernel
 export RUN_SMACK_SECURITY_TESTS=0
 
+##Set this to 1 if you wish to run the Basic PERFORMANCE COUNTER tests
+export RUN_PERFORMANCE_COUNTERS_TESTS=0
+
 export LTP_VERSION=`./runltp -e`
 export TEST_START_TIME=`date +"%Y_%b_%d-%Hh_%Mm_%Ss"`
 export HARDWARE_TYPE=$(uname -i)
@@ -538,3 +541,13 @@ then
 fi
 ## END => Test Series 28                               ##
 
+## The next one i plan to run the PERFORMANCE COUNTERS tests
+## START => Test Series 29                             ##
+if [ $RUN_PERFORMANCE_COUNTERS_TESTS -eq 1 ]
+then
+     (cd $LTPROOT/testcases/kernel/performance_counters; make && make install)
+     ./runltp -f perfcounters
+fi
+## END => Test Series 29                               ##
+
+
--- ltp-full-20090331.orig/runtest/perfcounters 1970-01-01 05:30:00.000000000 
+0530
+++ ltp-full-20090331/runtest/perfcounters      2009-04-01 17:48:30.000000000 
+0530
@@ -0,0 +1,4 @@
+# Test some Basic Performance Counters
+
+performance_counter01 performance_counter01
+
--- ltp-full-20090331.orig/testcases/kernel/performance_counters/Makefile       
1970-01-01 05:30:00.000000000 +0530
+++ ltp-full-20090331/testcases/kernel/performance_counters/Makefile    
2009-04-01 17:45:40.000000000 +0530
@@ -0,0 +1,31 @@
+#
+#  Copyright (c) International Business Machines  Corp., 2009
+#
+#  This program is free software;  you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY;  without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
+#  the GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program;  if not, write to the Free Software
+#  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#
+
+CFLAGS += -I../../../include -Wall
+LDLIBS += -L../../../lib -lltp
+
+SRCS    = $(wildcard *.c)
+TARGETS = $(patsubst %.c,%,$(SRCS))
+
+all: $(TARGETS)
+
+install:
+       @set -e; for i in $(TARGETS); do ln -f $$i ../../bin/$$i ; done
+
+clean:
+       rm -f $(TARGETS)
diff -uprN 
ltp-full-20090331.orig/testcases/kernel/performance_counters/performance_counter01.c
 ltp-full-20090331/testcases/kernel/performance_counters/performance_counter01.c
--- 
ltp-full-20090331.orig/testcases/kernel/performance_counters/performance_counter01.c
        1970-01-01 05:30:00.000000000 +0530
+++ 
ltp-full-20090331/testcases/kernel/performance_counters/performance_counter01.c 
    2009-04-01 17:38:05.000000000 +0530
@@ -0,0 +1,98 @@
+/******************************************************************************/
+/*                                                                            
*/
+/* Ingo Molnar <[email protected]>, 2009                                         */
+/*                                                                            
*/
+/* This program is free software;  you can redistribute it and/or modify      
*/
+/* it under the terms of the GNU General Public License as published by       
*/
+/* the Free Software Foundation; either version 2 of the License, or          
*/
+/* (at your option) any later version.                                        
*/
+/*                                                                            
*/
+/* This program is distributed in the hope that it will be useful,            
*/
+/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            
*/
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  
*/
+/* the GNU General Public License for more details.                           
*/
+/*                                                                            
*/
+/* You should have received a copy of the GNU General Public License          
*/
+/* along with this program;  if not, write to the Free Software               
*/
+/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    
*/
+/*                                                                            
*/
+/******************************************************************************/
+
+/*
+ * Very simple performance counter testcase.
+ * Picked up from: http://lkml.org/lkml/2008/12/5/17
+ */
+#include <sys/syscall.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <sys/uio.h>
+#include <linux/unistd.h>
+
+#include <assert.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdio.h>
+#include <fcntl.h>
+
+/* Harness Specific Include Files. */
+#include "test.h"
+#include "usctest.h"
+
+#ifdef __x86_64__
+# define __NR_perf_counter_open        295
+#endif
+
+#ifdef __i386__
+# define __NR_perf_counter_open 333
+#endif
+
+/* Extern Global Variables */
+extern int  Tst_count;               /* counter for tst_xxx routines.         
*/
+extern char *TESTDIR;                /* temporary dir created by tst_tmpdir() 
*/
+/* Global Variables */
+char *TCID     = "performance_counter01"; /* test program identifier.          
*/
+int  TST_TOTAL = 1; 
+
+int perf_counter_open(int              hw_event_type,
+                      unsigned int     hw_event_period,
+                      unsigned int     record_type,
+                      pid_t            pid,
+                      int              cpu)
+{
+       return syscall(__NR_perf_counter_open, hw_event_type, hw_event_period,
+                       record_type, pid, cpu);
+}
+
+enum hw_event_types {
+       PERF_COUNT_CYCLES,
+       PERF_COUNT_INSTRUCTIONS,
+       PERF_COUNT_CACHE_REFERENCES,
+       PERF_COUNT_CACHE_MISSES,
+       PERF_COUNT_BRANCH_INSTRUCTIONS,
+       PERF_COUNT_BRANCH_MISSES,
+};
+
+int main(void) {
+       unsigned long long count1, count2;
+       int fd1, fd2, ret;
+       fd1 = perf_counter_open(PERF_COUNT_INSTRUCTIONS, 0, 0, 0, -1);
+       assert(fd1 >= 0);
+       fd2 = perf_counter_open(PERF_COUNT_CACHE_MISSES, 0, 0, 0, -1);
+       assert(fd1 >= 0);
+
+       for (;;) {
+               ret = read(fd1, &count1, sizeof(count1));
+               assert(ret == 8);
+               ret = read(fd2, &count2, sizeof(count2));
+               assert(ret == 8);
+               printf("counter1 value: %Ld instructions\n", count1);
+               printf("counter2 value: %Ld cachemisses\n",  count2);
+               sleep(1);
+       }
+       return 0;
+}
+

---
Regards--
Subrata


------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to