smt_smp_affinity.sh 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #!/bin/sh
  2. ################################################################################
  3. ## ##
  4. ## This program is free software; you can redistribute it and#or modify ##
  5. ## it under the terms of the GNU General Public License as published by ##
  6. ## the Free Software Foundation; either version 2 of the License, or ##
  7. ## (at your option) any later version. ##
  8. ## ##
  9. ## This program is distributed in the hope that it will be useful, but ##
  10. ## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
  11. ## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ##
  12. ## for more details. ##
  13. ## ##
  14. ## You should have received a copy of the GNU General Public License ##
  15. ## along with this program; if not, write to the Free Software ##
  16. ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ##
  17. ## ##
  18. ################################################################################
  19. #
  20. # File: smt_smp_affinity.sh
  21. #
  22. # Description: This program tests the following:
  23. # Set affinity through system call sched_setaffinity
  24. # get affinity through system call sched_getaffinity
  25. # Inheritance of Affinity
  26. #
  27. # Author: Rohit Verma, rohit.170309@gmail.com
  28. #
  29. # History: May 21 2009 - Created. - Rohit Verma
  30. export TST_TOTAL=1
  31. export TCID=smt_smp_affinity
  32. export TST_COUNT=1
  33. TFAILCNT=0
  34. RC=0
  35. # check for HT/SMP System
  36. tst_resm TINFO "Begin: SMT/SMP Affinity"
  37. if [ -f ./ht_enabled ];then
  38. ./ht_enabled
  39. ret_value=$?
  40. if [ $ret_value -ne 0 ];then
  41. tst_resm TCONF "SMT/SMP is not supported"
  42. tst_resm TINFO "End: SMT/SMP Affinity"
  43. exit 0
  44. fi
  45. else
  46. tst_resm TBROK "ht_enabled:File not found"
  47. tst_resm TINFO "End: SMT/SMP Affinity"
  48. TFAILCNT=$(( $TFAILCNT+1 ))
  49. exit $TFAILCNT
  50. fi
  51. no_of_processor=`tst_ncpus`
  52. no_of_cpu=`tst_ncpus_conf`
  53. if [ $no_of_processor -lt $no_of_cpu ];then
  54. tst_resm TCONF "cpuX:offline"
  55. tst_resm TINFO "End: SMT/SMP Affinity"
  56. TFAILCNT=$(( $TFAILCNT+1 ))
  57. exit $TFAILCNT
  58. else
  59. cpu_cores=`cat /proc/cpuinfo | grep "cpu cores" | cut -f 2 -d ':'\
  60. | sed 's/ //' | uniq`
  61. if [ $cpu_cores -ge 1 ];then
  62. if [ -f ./ht_affinity ];then
  63. ./ht_affinity
  64. else
  65. tst_resm TBROK "ht_affinity:File not found"
  66. tst_resm TINFO "End: SMT/SMP Affinity"
  67. TFAILCNT=$(( $TFAILCNT+1 ))
  68. exit $TFAILCNT
  69. fi
  70. else
  71. tst_resm TINFO "TBD"
  72. fi
  73. fi
  74. tst_resm TINFO "End: SMT/SMP Affinity"
  75. exit