lowmemkiller_variant.sh 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #!/bin/bash
  2. #
  3. # Linux 2.6.32 and later Kernel module for VMware MVP Hypervisor Support
  4. #
  5. # Copyright (C) 2010-2013 VMware, Inc. All rights reserved.
  6. #
  7. # This program is free software; you can redistribute it and/or modify it
  8. # under the terms of the GNU General Public License version 2 as published by
  9. # the Free Software Foundation.
  10. #
  11. # This program is distributed in the hope that it will be useful, but WITHOUT
  12. # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13. # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  14. # more details.
  15. #
  16. # You should have received a copy of the GNU General Public License along with
  17. # this program; see the file COPYING. If not, write to the Free Software
  18. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  19. #
  20. # @brief Script providing the variant of the low memory killer implementation
  21. # to assist in mvpkm's export of the other_file calculation.
  22. if [ -z "$1" ]
  23. then
  24. echo "Usage: $0 <path to lowmemorykiller.c>"
  25. exit 1
  26. fi
  27. # We look at the relevant section of the lowmem_shrink function here. This
  28. # pattern is sufficient to distinguish between the known variants without
  29. # introducing too many false positives for new variants. I.e. we can spot the
  30. # lines that matter for the other_file calculation. In some cases the
  31. # lowmemorykiller uses only the other_file calculation instead of max(free,
  32. # file) - in the cases we've seen this is OK with the balloon policy, since the
  33. # free term isn't really significant when we get into low memory states anyway.
  34. tmp_file="lmk_md5sum_$RANDOM"
  35. cat $1 | tr -d '\ \t\n\r' > $tmp_file
  36. sed -i -e 's/.*\(intother_file.*other_file<\).*/;\1/' \
  37. -e 's/[;][^;]*other_file[^;]*/#<#&#>#/g' \
  38. -e 's/#>#[^#]*//g' $tmp_file
  39. MD5=`md5sum $tmp_file | cut -f1 -d\ `
  40. rm $tmp_file
  41. case $MD5 in
  42. 4af66fafb5e4cbd7b4092e29e071f152|\
  43. a0f18472eb53e52b38d6f85d4ec66842|\
  44. 590b89af56f57146edffceba60845ad8|\
  45. fddbb73a58e82ba1966fd862a561c2bd)
  46. #/*
  47. # * This is the same as the non-exported global_reclaimable_pages() when there
  48. # * is no swap.
  49. # */
  50. #other_file = global_page_state(NR_ACTIVE_FILE) +
  51. # global_page_state(NR_INACTIVE_FILE);
  52. V=1
  53. ;;
  54. 943372c447dd868845d71781292eae17|\
  55. 14d0cc4189c1f4fd7818c3393cc8c311)
  56. # other_file = global_page_state(NR_FILE_PAGES);
  57. V=2
  58. ;;
  59. 59f3bb678a855acfea2365b7a904bc5b|\
  60. c88eb5649a468e3f991972661ca7f906|\
  61. b211b3542c24205b203cf6c103951733|\
  62. 4798a9bc2c04e225cbec2d2107e92f48|\
  63. c1f73bb2771660d6e7e85f774d030a00|\
  64. df96cbb1784869ac7d017dd343e4e8f2)
  65. # other_file = global_page_state(NR_FILE_PAGES) - global_page_state(NR_SHMEM);
  66. V=3
  67. ;;
  68. ed03b69361c2881ed1a031c9b9a24d8a|\
  69. 8639aca416d3014d68548d6cb538405b)
  70. # other_file = global_page_state(NR_FREE_PAGES) + global_page_state(NR_FILE_PAGES);
  71. # (other_free not used, but max(other_free, other_file) = other_file in this
  72. # case.
  73. V=4
  74. ;;
  75. 00865dfbbc8d308d05ed017c9892b538|\
  76. 3e766830a787148a5540772630a5335f|\
  77. 85354de74c4a30ffe07d60b324be893b|\
  78. 97b9a5d6ac4bea28fea79f2723a78764)
  79. # other_file = global_page_state(NR_FILE_PAGES) - global_page_state(NR_SHMEM);
  80. # other_free and other_file are modified depending on zone index or/and
  81. # memory offlining and compared to "lowmem_minfree[i] - zone_adj".
  82. V=5
  83. ;;
  84. *)
  85. V=0
  86. ;;
  87. esac
  88. echo "$MD5 $V"