~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/perf/tests/shell/coresight/memcpy_thread/memcpy_thread.c

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0
  2 // Carsten Haitzler <carsten.haitzler@arm.com>, 2021
  3 #include <stdio.h>
  4 #include <stdlib.h>
  5 #include <unistd.h>
  6 #include <string.h>
  7 #include <pthread.h>
  8 
  9 struct args {
 10         unsigned long loops;
 11         unsigned long size;
 12         pthread_t th;
 13         void *ret;
 14 };
 15 
 16 static void *thrfn(void *arg)
 17 {
 18         struct args *a = arg;
 19         unsigned long i, len = a->loops;
 20         unsigned char *src, *dst;
 21 
 22         src = malloc(a->size * 1024);
 23         dst = malloc(a->size * 1024);
 24         if ((!src) || (!dst)) {
 25                 printf("ERR: Can't allocate memory\n");
 26                 exit(1);
 27         }
 28         for (i = 0; i < len; i++)
 29                 memcpy(dst, src, a->size * 1024);
 30 }
 31 
 32 static pthread_t new_thr(void *(*fn) (void *arg), void *arg)
 33 {
 34         pthread_t t;
 35         pthread_attr_t attr;
 36 
 37         pthread_attr_init(&attr);
 38         pthread_create(&t, &attr, fn, arg);
 39         return t;
 40 }
 41 
 42 int main(int argc, char **argv)
 43 {
 44         unsigned long i, len, size, thr;
 45         struct args args[256];
 46         long long v;
 47 
 48         if (argc < 4) {
 49                 printf("ERR: %s [copysize Kb] [numthreads] [numloops (hundreds)]\n", argv[0]);
 50                 exit(1);
 51         }
 52 
 53         v = atoll(argv[1]);
 54         if ((v < 1) || (v > (1024 * 1024))) {
 55                 printf("ERR: max memory 1GB (1048576 KB)\n");
 56                 exit(1);
 57         }
 58         size = v;
 59         thr = atol(argv[2]);
 60         if ((thr < 1) || (thr > 256)) {
 61                 printf("ERR: threads 1-256\n");
 62                 exit(1);
 63         }
 64         v = atoll(argv[3]);
 65         if ((v < 1) || (v > 40000000000ll)) {
 66                 printf("ERR: loops 1-40000000000 (hundreds)\n");
 67                 exit(1);
 68         }
 69         len = v * 100;
 70         for (i = 0; i < thr; i++) {
 71                 args[i].loops = len;
 72                 args[i].size = size;
 73                 args[i].th = new_thr(thrfn, &(args[i]));
 74         }
 75         for (i = 0; i < thr; i++)
 76                 pthread_join(args[i].th, &(args[i].ret));
 77         return 0;
 78 }
 79 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php