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

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/powerpc/dscr/dscr_sysfs_thread_test.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ 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-only
  2 /*
  3  * POWER Data Stream Control Register (DSCR) sysfs thread test
  4  *
  5  * This test updates the system wide DSCR default value through
  6  * sysfs interface which should then update all the CPU specific
  7  * DSCR default values which must also be then visible to threads
  8  * executing on individual CPUs on the system.
  9  *
 10  * Copyright 2015, Anshuman Khandual, IBM Corporation.
 11  */
 12 #define _GNU_SOURCE
 13 #include "dscr.h"
 14 
 15 static int test_thread_dscr(unsigned long val)
 16 {
 17         unsigned long cur_dscr, cur_dscr_usr;
 18 
 19         cur_dscr = get_dscr();
 20         cur_dscr_usr = get_dscr_usr();
 21 
 22         if (val != cur_dscr) {
 23                 printf("[cpu %d] Kernel DSCR should be %ld but is %ld\n",
 24                                         sched_getcpu(), val, cur_dscr);
 25                 return 1;
 26         }
 27 
 28         if (val != cur_dscr_usr) {
 29                 printf("[cpu %d] User DSCR should be %ld but is %ld\n",
 30                                         sched_getcpu(), val, cur_dscr_usr);
 31                 return 1;
 32         }
 33         return 0;
 34 }
 35 
 36 static int check_cpu_dscr_thread(unsigned long val)
 37 {
 38         cpu_set_t mask;
 39         int cpu;
 40 
 41         for (cpu = 0; cpu < CPU_SETSIZE; cpu++) {
 42                 CPU_ZERO(&mask);
 43                 CPU_SET(cpu, &mask);
 44                 if (sched_setaffinity(0, sizeof(mask), &mask))
 45                         continue;
 46 
 47                 if (test_thread_dscr(val))
 48                         return 1;
 49         }
 50         return 0;
 51 
 52 }
 53 
 54 int dscr_sysfs_thread(void)
 55 {
 56         unsigned long orig_dscr_default;
 57         int i, j;
 58 
 59         SKIP_IF(!have_hwcap2(PPC_FEATURE2_DSCR));
 60 
 61         orig_dscr_default = get_default_dscr();
 62         for (i = 0; i < COUNT; i++) {
 63                 for (j = 0; j < DSCR_MAX; j++) {
 64                         set_default_dscr(j);
 65                         if (check_cpu_dscr_thread(j))
 66                                 goto fail;
 67                 }
 68         }
 69         set_default_dscr(orig_dscr_default);
 70         return 0;
 71 fail:
 72         set_default_dscr(orig_dscr_default);
 73         return 1;
 74 }
 75 
 76 int main(int argc, char *argv[])
 77 {
 78         return test_harness(dscr_sysfs_thread, "dscr_sysfs_thread_test");
 79 }
 80 

~ [ 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