From Wiki-UX.info

How to convert Kernel Allocator Superpage to bytes
Jump to: navigation, search

How to convert Kernel Allocator Superpage to bytes

The following AWK script (kas.awk) can be used to translate the kmeminfo -kas command output to bytes for easier reading.

BEGIN {
TCOUNT=0
TFREE=0
printf "     Size     sp_pool_head_t        count                    free                 highest                      spl_next\n"
}
$2 ~ /KB/ {
   split ($2, a, "KB")
   BSIZE=a[1] * 1024
   COUNT=$4 * BSIZE
   FREE=$5 * BSIZE
   HIGHEST=$6 * BSIZE
   TCOUNT=TCOUNT + COUNT; TFREE=TFREE + FREE
   printf "%3d %5s %18s %12d (%5d MB) %12d (%5d MB) %12d (%5d MB) %18s\n", $1, $2, $3, COUNT, COUNT / 1048576, FREE, FREE / 1048576, HIGHEST, HIGHEST / 1048576, $7
   }
$2 ~ /MB/ {
   split ($2, a, "MB")
   BSIZE=a[1] * 1048576
   COUNT=$4 * BSIZE
   FREE=$5 * BSIZE
   HIGHEST=$6 * BSIZE
   TCOUNT=TCOUNT + COUNT; TFREE=TFREE + FREE
   printf "%3d %5s %18s %12d (%5d MB) %12d (%5d MB) %12d (%5d MB) %18s\n", $1, $2, $3, COUNT, COUNT / 1048576, FREE, FREE / 1048576, HIGHEST, HIGHEST / 1048576, $7
   }
$2 ~ /GB/ {
   split ($2, a, "GB")
   BSIZE=a[1] * 1073741824
   COUNT=$4 * BSIZE
   FREE=$5 * BSIZE
   HIGHEST=$6 * BSIZE
   TCOUNT=TCOUNT + COUNT; TFREE=TFREE + FREE
   printf "%3d %5s %18s %12d (%5d MB) %12d (%5d MB) %12d (%5d MB) %18s\n", $1, $2, $3, COUNT, COUNT / 1048576, FREE, FREE / 1048576, HIGHEST, HIGHEST / 1048576, $7
   }
END {printf "\nTOTAL                        %12s (%5d MB) %12s (%5d MB)\n", TCOUNT, TCOUNT / 1048576, TFREE, TFREE / 1048576}

Example

# awk -f kas.awk test1
     Size     sp_pool_head_t        count                    free                 highest                      spl_next
  0   4KB 0xe000000104ddb5f0            0 (    0 MB)     10043392 (    9 MB)     10125312 (    9 MB) 0xe000000150007000
  1   8KB 0xe000000104ddb618            0 (    0 MB)      9805824 (    9 MB)     17121280 (   16 MB) 0xe000000167706000
  2  16KB 0xe000000104ddb640            0 (    0 MB)     37060608 (   35 MB)    107118592 (  102 MB) 0xe0000001bbd58000
  3  32KB 0xe000000104ddb668            0 (    0 MB)     63995904 (   61 MB)     96665600 (   92 MB) 0xe0000001b5c78000
  4  64KB 0xe000000104ddb690       458752 (    0 MB)     49152000 (   46 MB)     86704128 (   82 MB) 0xe000000427e20000
  5 128KB 0xe000000104ddb6b8            0 (    0 MB)     81788928 (   78 MB)    130023424 (  124 MB) 0xe000000421080000
  6 256KB 0xe000000104ddb6e0     20447232 (   19 MB)     71303168 (   68 MB)    135528448 (  129 MB) 0xe0000004220c0000
  7 512KB 0xe000000104ddb708            0 (    0 MB)     18874368 (   18 MB)     82837504 (   79 MB) 0xe000000412f80000
  8   1MB 0xe000000104ddb730    210763776 (  201 MB)      1048576 (    1 MB)     20971520 (   20 MB) 0xe0000001e6300000
  9   2MB 0xe000000104ddb758            0 (    0 MB)            0 (    0 MB)     50331648 (   48 MB) 0xe000000104ddb758
 10   4MB 0xe000000104ddb780    121634816 (  116 MB)            0 (    0 MB)     29360128 (   28 MB) 0xe000000104ddb780
 11   8MB 0xe000000104ddb7a8            0 (    0 MB)            0 (    0 MB)     41943040 (   40 MB) 0xe000000104ddb7a8
 12  16MB 0xe000000104ddb7d0    100663296 (   96 MB)            0 (    0 MB)     50331648 (   48 MB) 0xe000000104ddb7d0
 13  32MB 0xe000000104ddb7f8            0 (    0 MB)            0 (    0 MB)     67108864 (   64 MB) 0xe000000104ddb7f8
 14  64MB 0xe000000104ddb820    671088640 (  640 MB)            0 (    0 MB)            0 (    0 MB) 0xe000000104ddb820
 
TOTAL                         1.12506e+09 ( 1072 MB)  3.43073e+08 (  327 MB)
 
# awk -f kas.awk test2
     Size     sp_pool_head_t        count                    free                 highest                      spl_next
  0   4KB 0xe000000104ddb0f0            0 (    0 MB)    225603584 (  215 MB)    558292992 (  532 MB) 0xe00000040913e000
  1   8KB 0xe000000104ddb118            0 (    0 MB)    349331456 (  333 MB)    522878976 (  498 MB) 0xe0000001b3372000
  2  16KB 0xe000000104ddb140            0 (    0 MB)    416710656 (  397 MB)    494993408 (  472 MB) 0xe00000042ba34000
  3  32KB 0xe000000104ddb168            0 (    0 MB)    403636224 (  384 MB)    403636224 (  384 MB) 0xe0000001e8ad0000
  4  64KB 0xe000000104ddb190            0 (    0 MB)    138477568 (  132 MB)    242745344 (  231 MB) 0xe000000188560000
  5 128KB 0xe000000104ddb1b8            0 (    0 MB)     11796480 (   11 MB)    112721920 (  107 MB) 0xe000000440c60000
  6 256KB 0xe000000104ddb1e0     98041856 (   93 MB)     27525120 (   26 MB)     30408704 (   29 MB) 0xe00000043e2c0000
  7 512KB 0xe000000104ddb208            0 (    0 MB)      4718592 (    4 MB)      4718592 (    4 MB) 0xe000000444980000
  8   1MB 0xe000000104ddb230   1095761920 ( 1045 MB)            0 (    0 MB)      2097152 (    2 MB) 0xe000000104ddb230
  9   2MB 0xe000000104ddb258            0 (    0 MB)      2097152 (    2 MB)      4194304 (    4 MB) 0xe000000444a00000
 10   4MB 0xe000000104ddb280    545259520 (  520 MB)            0 (    0 MB)      4194304 (    4 MB) 0xe000000104ddb280
 11   8MB 0xe000000104ddb2a8            0 (    0 MB)            0 (    0 MB)      8388608 (    8 MB) 0xe000000104ddb2a8
 12  16MB 0xe000000104ddb2d0    637534208 (  608 MB)            0 (    0 MB)     16777216 (   16 MB) 0xe000000104ddb2d0
 13  32MB 0xe000000104ddb2f8            0 (    0 MB)            0 (    0 MB)     33554432 (   32 MB) 0xe000000104ddb2f8
 14  64MB 0xe000000104ddb320    335544320 (  320 MB)            0 (    0 MB)            0 (    0 MB) 0xe000000104ddb320
 
TOTAL                         2.71214e+09 ( 2586 MB)   1.5799e+09 ( 1506 MB)
This page was last modified on 3 December 2008, at 17:23. This page has been accessed 1,406 times.