• 検索結果がありません。

#define IHK_OS_PGSIZE_4KB 0

2467

#define IHK_OS_PGSIZE_2MB 1

2468

#define IHK_OS_PGSIZE_1GB 2

2469

3.1.6 ダンプ解析コマンド

2470

インターフェイスは第??節に記載する。

2471

3.1.7 ダンプ形式変換コマンド

2472

インターフェイスは第??節に記載する。

2473

46 t u r b o =””

47 i h k i r q =””

48

49 w h i l e g e t o p t s : t k : c :m: o : f : r : q : i : d : OPT

50 do

51 c a s e ${OPT} i n

52 f ) f a c i l i t y =${OPTARG}

53 ; ;

54 o ) c h o w n o p t i o n=${OPTARG}

55 ; ;

56 k ) r e d i r e c t k m s g=${OPTARG}

57 ; ;

58 c ) c p u s=${OPTARG}

59 ; ;

60 m) mem=${OPTARG}

61 ; ;

62 r ) i k c m a p=${OPTARG}

63 ; ;

64 q ) i h k i r q=${OPTARG}

65 ; ;

66 t ) t u r b o=”t u r b o ”

67 ; ;

68 d ) DUMP LEVEL=${OPTARG}

69 ; ;

70 i ) m o n i n t e r v a l=${OPTARG}

71 ; ;

72 ) e c h o ” i n v a l i d o p t i o n ${OPT} >&2

73 e x i t 1

74 e s a c

75 done

76

77 # S t a r t ihkmond 78 p i d =‘ p i d o f ihkmond ‘

79 i f [ ” ${p i d}” != ”” ] ; t h e n

80 sudo k i l l 9 ${p i d} > / dev / n u l l 2> / dev / n u l l 81 f i

82 i f [ ” ${r e d i r e c t k m s g}” != ”0” o ” ${m o n i n t e r v a l}” != ”1” ] ; t h e n

83 ${SBINDIR}/ ihkmond f ${f a c i l i t y} −k ${r e d i r e c t k m s g} −i ${m o n i n t e r v a l} 84 f i

85 #

86 # R e v e r t any s t a t e t h a t h a s been i n i t i a l i z e d b e f o r e t h e e r r o r o c c u r e d .

87 #

88 e r r o r e x i t ( ) {

89 l o c a l s t a t u s=$1

90

91 c a s e $ s t a t u s i n 92 m c o s s y s m o u n t e d )

93 i f [ ” $ e n a b l e m c o v e r l a y ” == ” y e s ” ] ; t h e n

94 umount /tmp/ mcos / m c o s 0 s y s

95 f i

96 ;&

97 m c o s p r o c m o u n t e d )

98 i f [ ” $ e n a b l e m c o v e r l a y ” == ” y e s ” ] ; t h e n

99 umount /tmp/ mcos / m c o s 0 p r o c

100 f i

101 ;&

102 m c o v e r l a y f s l o a d e d )

103 i f [ ” $ e n a b l e m c o v e r l a y ” == ” y e s ” ] ; t h e n

104 rmmod m c o v e r l a y 2>/dev / n u l l

105 f i

106 ;&

107 l i n u x p r o c b i n d m o u n t e d )

108 i f [ ” $ e n a b l e m c o v e r l a y ” == ” y e s ” ] ; t h e n

109 umount /tmp/ mcos / l i n u x p r o c

110 f i

111 ;&

112 tmp mcos mounted )

113 i f [ ” $ e n a b l e m c o v e r l a y ” == ” y e s ” ] ; t h e n

114 umount /tmp/ mcos

115 f i

116 ;&

117 t m p m c o s c r e a t e d )

118 i f [ ” $ e n a b l e m c o v e r l a y ” == ” y e s ” ] ; t h e n

119 rm r f /tmp/ mcos

120 f i

121 ;&

122 o s c r e a t e d )

123 # D e s t r o y a l l LWK i n s t a n c e s

124 i f l s / dev / mcos 1>/dev / n u l l 2>&1; t h e n

125 f o r i i n / dev / mcos; do

126 i n d =‘ e c h o $ i|c u t c10‘ ;

127 i f ! ${SBINDIR}/ i h k c o n f i g 0 d e s t r o y $ i n d ; t h e n

128 e c h o ” w a r n i n g : f a i l e d t o d e s t r o y LWK i n s t a n c e $ i n d ” >&2

129 f i

130 done

131 f i

132 ;&

133 m c c t r l l o a d e d )

134 rmmod m c c t r l 2>/dev / n u l l | | e c h o ” w a r n i n g : f a i l e d t o remove m c c t r l ” >&2

135 ;&

136 c p u s r e s e r v e d )

137 c p u s =‘ ${SBINDIR}/ i h k c o n f i g 0 q u e r y cpu ‘

138 i f [ ” ${c p u s}” != ”” ] ; t h e n

139 i f ! ${SBINDIR}/ i h k c o n f i g 0 r e l e a s e cpu $ c p u s > / dev / n u l l ; t h e n

140 e c h o ” w a r n i n g : f a i l e d t o r e l e a s e CPUs” >&2

141 f i

142 f i

143 ;&

144 m e m r e s e r v e d )

145 mem=‘ ${SBINDIR}/ i h k c o n f i g 0 q u e r y mem‘

146 i f [ ” ${mem}” != ”” ] ; t h e n

147 i f ! ${SBINDIR}/ i h k c o n f i g 0 r e l e a s e mem $mem> / dev / n u l l ; t h e n

148 e c h o ” w a r n i n g : f a i l e d t o r e l e a s e memory” >&2

149 f i

150 f i

151 ;&

152 i h k s m p l o a d e d )

153 rmmod i h k s m p x 8 6 2>/dev / n u l l | | e c h o ” w a r n i n g : f a i l e d t o remove i h k s m p x 8 6 ” >&2

154 ;&

155 i h k l o a d e d )

156 rmmod i h k 2>/dev / n u l l | | e c h o ” w a r n i n g : f a i l e d t o remove i h k ” >&2

157 ;&

158 i r q b a l a n c e s t o p p e d )

159 i f [ ” ‘ s y s t e m c t l s t a t u s i r q b a l a n c e m c k . s e r v i c e 2> / dev / n u l l |\ 160 ’ g r e p E ’ A c t i v e : a c t i v e ’ ‘ ” != ”” ] ; t h e n

161 i f ! s y s t e m c t l s t o p i r q b a l a n c e m c k . s e r v i c e 2>/dev / n u l l ; t h e n 162 e c h o ” w a r n i n g : f a i l e d t o s t o p i r q b a l a n c e m c k ” >&2

163 f i

164 i f ! s y s t e m c t l d i s a b l e i r q b a l a n c e m c k . s e r v i c e >/dev / n u l l 2>/dev / n u l l ; t h e n 165 e c h o ” w a r n i n g : f a i l e d t o d i s a b l e i r q b a l a n c e m c k ” >&2

166 f i

167 i f ! e t c d i r =/home/ t a k a g i / p r o j e c t / o s / i n s t a l l / e t c p e r l e \ 168 ’ $ e t c d i r=$ENV{’ e t c d i r ’}; @ f i l e s = g r e p { −f } g l o b ” $ e t c d i r / p r o c / i r q // s m p a f f i n i t y ” ; ’\ 169 f o r e a c h $ f i l e ( @ f i l e s ) { $ d e s t = s u b s t r ( $ f i l e , l e n g t h ( $ e t c d i r ) ) ; ’\

170 i f ( 0 ) {p r i n t ” cp $ f i l e $ d e s t\n ” ;} s y s t e m ( ” cp $ f i l e $ d e s t 2>/dev / n u l l ” ) ; }’ ; t h e n

171 e c h o ” w a r n i n g : f a i l e d t o r e s t o r e / p r o c / i r q // s m p a f f i n i t y ” >&2

172 f i

173 i f ! s y s t e m c t l s t a r t i r q b a l a n c e . s e r v i c e ; t h e n

174 e c h o ” w a r n i n g : f a i l e d t o s t a r t i r q b a l a n c e ” >&2;

175 f i

176 f i

177 ;&

178 i n i t i a l )

179 # N o t h i n g more t o r e v e r t

180 ; ;

181 e s a c

182

183 e x i t 1

184 }

185

186 i h k i k c i r q c o r e =0 187

188 r e l e a s e =‘uname r ‘

189 major =‘ e c h o ${r e l e a s e} | s e d e ’ s / ˆ\( [ 09 ]∗ \) ./\1 / ’ ‘

190 minor =‘ e c h o ${r e l e a s e} | s e d e ’ s / ˆ [ 09 ].\( [ 09 ]∗ \) ./\1 / ’ ‘

191 p a t c h =‘ e c h o ${r e l e a s e} | s e d −e ’ s / ˆ [ 0−9 ]∗. [ 0−9 ]∗.\( [ 0−9 ]∗ \) .∗/\1 / ’ ‘

192 l i n u x v e r s i o n c o d e =‘ e x p r \( ${major} \∗ 65 53 6 \) + \( ${minor} \∗ 256 \) + ${p a t c h} 193 r h e l r e l e a s e =‘ e c h o ${r e l e a s e} | s e d e ’ s / ˆ [ 09 ]. [ 09 ]. [ 09 ]∗ −\( [ 09 ]∗\) ./\1 / ’ ‘ 194 i f [ ” ${r e l e a s e}” == ” ${r h e l r e l e a s e} ] ; t h e n

195 r h e l r e l e a s e =””;

196 f i 197

198 e n a b l e m c o v e r l a y =”no ” 199

200 i f [ ” ${ENABLE MCOVERLAYFS}” == ” y e s ” ] ; t h e n 201 i f [ ” ${r h e l r e l e a s e}” == ”” ] ; t h e n

202 i f [ ${l i n u x v e r s i o n c o d e} −g e 2 6 2 1 4 4 a ${l i n u x v e r s i o n c o d e} −l t 2 6 2 4 0 0 ] ; t h e n

203 e n a b l e m c o v e r l a y =”y e s ”

204 f i

205 i f [ ${l i n u x v e r s i o n c o d e} −g e 2 6 3 6 8 0 a ${l i n u x v e r s i o n c o d e} −l t 2 6 3 9 3 6 ] ; t h e n

206 e n a b l e m c o v e r l a y =”y e s ”

207 f i

208 e l s e

209 i f [ ${l i n u x v e r s i o n c o d e} −eq 1 9 9 1 6 8 a ${r h e l r e l e a s e} −g e 327 a ${r h e l r e l e a s e} −l e 693 ] ; t h e n

210 e n a b l e m c o v e r l a y =”y e s ”

211 f i

212 i f [ ${l i n u x v e r s i o n c o d e} −g e 2 6 2 1 4 4 a ${l i n u x v e r s i o n c o d e} −l t 2 6 2 4 0 0 ] ; t h e n

213 e n a b l e m c o v e r l a y =”y e s ”

214 f i

215 f i

216 f i 217

218 # F i g u r e o u t CPUs i f n o t r e q u e s t e d by u s e r 219 i f [ ” $ c p u s ” == ”” ] ; t h e n

220 # Get t h e number o f CPUs on NUMA node 0

221 n r c p u s =‘ l s c p u −−p a r s e | awkF” , ” {i f ( $4 == 0 ) p r i n t $4} | wc l ‘ 222

223 # Use t h e s e c o n d h a l f o f t h e c o r e s 224 l e t n r c p u s =” $ n r c p u s / 2”

225 c p u s =‘ l s c p u −−p a r s e | awk F” , ” {i f ( $4 == 0 ) p r i n t $1} | t a i l n $ n r c p u s |\ 226 ’ x a r g s e c h o n | s e d ’ s / / , / g ’ ‘

227 i f [ ” $ c p u s ” == ”” ] ; t h e n

228 e c h o ” e r r o r : no a v a i l a b l e CPUs on NUMA node 0?” >&2

229 e x i t 1

230 f i

231 f i 232

233 # Remove m c o v e r l a y i f l o a d e d

234 i f [ ” $ e n a b l e m c o v e r l a y ” == ” y e s ” ] ; t h e n

235 i f g r e p m c o v e r l a y / p r o c / modules &>/dev / n u l l ; t h e n

236 i f [ ” ‘ c a t / p r o c / mounts | g r e p /tmp/ mcos / m c o s 0 s y s ‘ ” != ”” ] ; \ 237 t h e n umount l /tmp/ mcos / m c o s 0 s y s ; f i

238 i f [ ” ‘ c a t / p r o c / mounts | g r e p /tmp/ mcos / m c o s 0 p r o c ‘ ” != ”” ] ; \ 239 t h e n umount l /tmp/ mcos / m c o s 0 p r o c ; f i

240 i f [ ” ‘ c a t / p r o c / mounts | g r e p /tmp/ mcos / l i n u x p r o c ‘ ” != ”” ] ; \ 241 t h e n umount l /tmp/ mcos / l i n u x p r o c ; f i

242 i f [ ” ‘ c a t / p r o c / mounts | g r e p /tmp/ mcos ‘ ” != ”” ] ; t h e n umount l /tmp/ mcos ; f i

243 i f [ e /tmp/ mcos ] ; t h e n rm r f /tmp/ mcos ; f i

244 i f ! rmmod m c o v e r l a y 2>/dev / n u l l ; t h e n 245 e c h o ” e r r o r : r e m o v i n g m c o v e r l a y ” >&2

246 e x i t 1

247 f i

248 f i

249 f i

250

251 # Stop i r q b a l a n c e

252 i f [ ” ${i r q b a l a n c e u s e d}” == ” y e s ” ] ; t h e n

253 s y s t e m c t l s t o p i r q b a l a n c e m c k . s e r v i c e 2>/dev / n u l l

254 i f ! s y s t e m c t l s t o p i r q b a l a n c e . s e r v i c e 2>/dev / n u l l ; t h e n 255 e c h o ” e r r o r : s t o p p i n g i r q b a l a n c e ” >&2

256 e x i t 1

257 f i ;

258

259 i f ! e t c d i r =/home/ t a k a g i / p r o j e c t / o s / i n s t a l l / e t c p e r l −e \ 260 ’ u s e F i l e : : Copy qw ( copy ) ; $ e t c d i r=$ENV{’ e t c d i r ’}; \

261 ’ @ f i l e s = g r e p { −f } g l o b ”/ p r o c / i r q // s m p a f f i n i t y ” ; f o r e a c h $ f i l e ( @ f i l e s ) { \ 262 ’ $ r e l = s u b s t r ( $ f i l e , 1 ) ; $ d i r=s u b s t r ( $ r e l , 0 , l e n g t h ( $ r e l )l e n g t h ( ” / s m p a f f i n i t y ” ) ) ; \ 263 ’ i f ( 0 ) { p r i n t ” cp $ f i l e $ e t c d i r / $ r e l\n ” ;} i f ( s y s t e m ( ” mkdir p $ e t c d i r / $ d i r ” ) ){ e x i t 1 ;} \ 264 ’ i f ( ! copy ( $ f i l e , ” $ e t c d i r / $ r e l ” ) ){ e x i t 1 ;} }’ ; t h e n

265 e c h o ” e r r o r : s a v i n g / p r o c / i r q // s m p a f f i n i t y ” >&2 266 e r r o r e x i t ” m c o s s y s m o u n t e d ”

267 f i ;

268

269 # P r e v e n t / p r o c / i r q /∗/ s m p a f f i n i t y from g e t t i n g z e r o a f t e r o f f l i n i n g 270 # McKernel CPUs by u s i n g t h e f o l l o w i n g a l g o r i t h m .

271 # i f ( s m p a f f i n i t y & m c k c o r e s ) { 272 # s m p a f f i n i t y = ( m c k c o r e s ˆ 1);

273 # }

274 ncpus =‘ l s c p u | g r e p E ’ ˆCPU\( s\) : ’ | awk ’{p r i n t $2}’ ‘ 275 s m p a f f i n i t y m a s k =‘ e c h o $ c p u s | ncpus=$ n c p u s p e r l e \ 276 ’ w h i l e (<>){@tokens = s p l i t / , / ; f o r e a c h $ t o k e n ( @tokens ) \

277 {@nums = s p l i t // , $ t o k e n ; f o r ( $num = $nums [ 0 ] ; $num<= $nums [ $#nums ] ; $num++) {\ 278 ’ $ndx=i n t ( $num / 3 2 ) ; $mask [ $ndx ] |= (1<<($num % 3 2 ) )}}}\

279 ’ $ n i n t 3 2 s = i n t ( ( $ENV{’ ncpus ’}+ 3 1 ) / 3 2 ) ; f o r ( $ j = $ n i n t 3 2 s 1 ; $ j >= 0 ; $ j−−) {\ 280 i f ( $ j != $ n i n t 3 2 s 1 ){p r i n t ” , ” ;}\

281 ’ $ n b l k s = ( $ j != $ n i n t 3 2 s 1 ) ? 8 : ($ENV{’ ncpus ’} % 32 != 0 ) ? \ 282 ’ i n t ( ( ( $ENV{’ ncpus ’} + 3 ) % 3 2 ) / 4 ) : 8 ; ’\

283 f o r ( $ i = $ n b l k s 1 ; $ i >= 0 ; $ i−−){ p r i n t f (”%01x ” , ( $mask [ $ j ] >> ( $ i4 ) ) & 0 x f ) ;} }’ ‘ 284 # e c h o c p u s=$ c p u s ncpus=$ n c p u s s m p a f f i n i t y m a s k=$ s m p a f f i n i t y m a s k

285

286 i f ! ncpus=$ n c p u s s m p a f f i n i t y m a s k=$ s m p a f f i n i t y m a s k p e r l e \ 287 ’ @ d i r s = g r e p { −d } g l o b ”/ p r o c / i r q /” ; f o r e a c h $ d i r ( @ d i r s ) {\

288 $ h i t = 0 ; $ a f f i n i t y s t r = ‘ c a t $ d i r / s m p a f f i n i t y ‘ ; chomp $ a f f i n i t y s t r ; ’\

289 @ i n t 3 2 s t r s = s p l i t / , / , $ a f f i n i t y s t r ; @ i n t 3 2 s t r s m a s k= s p l i t / , / , $ENV{’ s m p a f f i n i t y m a s k ’}; ’\ 290 f o r ( $ i =0; $ i <= $#i n t 3 2 s t r s m a s k ; $ i ++) {\

291 $ i n t 3 2 s t r s i n v [ $ i ] = s p r i n t f (”%08x ” , hex ( $ i n t 3 2 s t r s m a s k [ $ i ] ) ˆ 0 x f f f f f f f f ) ; ’\ 292 i f ( $ i == 0 ) { $ l e n = i n t ( ( ( $ENV{’ ncpus ’}% 3 2 ) + 3 ) / 4 ) ; i f ( $ l e n != 0 ) {\ 293 $ i n t 3 2 s t r s i n v [ $ i ] = s u b s t r ( $ i n t 3 2 s t r s i n v [ $ i ] , $ l e n , $ l e n ) ; } } }\ 294 ’ $ i n v = j o i n ( ” , ” , @ i n t 3 2 s t r s i n v ) ; $ n i n t 3 2 s = i n t ( ( $ENV{’ ncpus ’}+ 3 1 ) / 3 2 ) ; ’\ 295 f o r ( $ j = $ n i n t 3 2 s 1 ; $ j >= 0 ; $ j−−) {\

296 i f ( hex ( $ i n t 3 2 s t r s [ $ n i n t 3 2 s 1 $ j ] ) & hex ( $ i n t 3 2 s t r s m a s k [ $ n i n t 3 2 s 1 $ j ] ) ) {\ 297 $ h i t = 1 ; }} i f ( $ h i t == 1 ) {\

298 ’ $cmd = ” e c h o $ i n v > $ d i r / s m p a f f i n i t y 2>/dev / n u l l ” ; s y s t e m $cmd ;} }’ ; t h e n 299 e c h o ” e r r o r : m o d i f y i n g / p r o c / i r q // s m p a f f i n i t y ” >&2

300 e r r o r e x i t ” m c o s s y s m o u n t e d ”

301 f i

302 303 f i 304

305 # Load IHK i f n o t l o a d e d

306 i f ! g r e p E ’ i h k\s ’ / p r o c / modules &>/dev / n u l l ; t h e n

307 i f ! t a s k s e t c 0 insmod ${KMODDIR}/ i h k . ko 2>/dev / n u l l ; t h e n 308 e c h o ” e r r o r : l o a d i n g i h k ” >&2

309 e r r o r e x i t ” i r q b a l a n c e s t o p p e d ”

310 f i

311 f i 312

313 # I n c r e a s e s w a p p i n e s s s o t h a t we have b e t t e r c h a n c e t o a l l o c a t e memory f o r IHK 314 e c h o 100 > / p r o c / s y s /vm/ s w a p p i n e s s

315

316 # Drop Linux c a c h e s t o f r e e memory

317 s y n c && e c h o 3 > / p r o c / s y s /vm/ d r o p c a c h e s

318

319 # Merge f r e e memory a r e a s i n t o l a r g e , p h y s i c a l l y c o n t i g o u s o n e s 320 e c h o 1 > / p r o c / s y s /vm/ compact memory 2>/dev / n u l l

321 322 s y n c 323

324 # Load IHKSMP i f n o t l o a d e d and r e s e r v e CPUs and memory 325 i f ! g r e p i h k s m p x 8 6 / p r o c / modules &>/dev / n u l l ; t h e n 326 i f [ ” $ i h k i r q ” == ”” ] ; t h e n

327 f o r i i n ‘ s e q 64 2 5 5 ‘ ; do

328 i f [ ! d / p r o c / i r q / $ i ] && \

329 [ ” ‘ c a t / p r o c / i n t e r r u p t s | g r e p ” : ” | awk ’{p r i n t $1} | g r e p o ’ [ 09 ] | g r e p e ’ ˆ $ i $ ’ ‘ ”\ 330 == ”” ] ; t h e n

331 i h k i r q=$ i

332 b r e a k

333 f i

334 done

335 i f [ ” $ i h k i r q ” == ”” ] ; t h e n

336 e c h o ” e r r o r : no IRQ a v a i l a b l e ” >&2

337 e r r o r e x i t ” i h k l o a d e d ”

338 f i

339 f i

340 i f ! t a s k s e t c 0 insmod ${KMODDIR}/ i h ksmpx86 . ko i h k s t a r t i r q =$ i h k i r q\ 341 i h k i k c i r q c o r e =$ i h k i k c i r q c o r e 2>/dev / n u l l ; t h e n

342 e c h o ” e r r o r : l o a d i n g i h ksmpx86 ” >&2

343 e r r o r e x i t ” i h k l o a d e d ”

344 f i

345

346 # O f f l i n er e o n l i n e RAM ( s p e c i a l c a s e f o r OFP SNC4 mode )

347 i f [ ” ‘ hostname | g r e p ” c [ 09 ] [ 09 ] [ 09 ] [ 09 ] . o f p ” ‘ ” != ”” ] && [ ” ‘ c a t / s y s / d e v i c e s / s y s t e m / node / o n l i n e ‘ ” == ”07” ] ; t h e n

348 f o r i i n 0 1 2 3 ; do

349 f i n d / s y s / d e v i c e s / s y s t e m / node / n o d e $ i /memory/ name ” o n l i n e ” | \ 350 w h i l e r e a d f ; do

351 e c h o 0 > $ f 2>&1 > / dev / n u l l ;

352 done

353 f i n d / s y s / d e v i c e s / s y s t e m / node / n o d e $ i /memory/ name ” o n l i n e ” | \ 354 w h i l e r e a d f ; do

355 e c h o 1 > $ f 2>&1 > / dev / n u l l ;

356 done

357 done

358 f o r i i n 4 5 6 7 ; do

359 f i n d / s y s / d e v i c e s / s y s t e m / node / n o d e $ i /memory/ name ” o n l i n e ” | \ 360 w h i l e r e a d f ; do

361 e c h o 0 > $ f 2>&1 > / dev / n u l l ;

362 done

363 f i n d / s y s / d e v i c e s / s y s t e m / node / n o d e $ i /memory/ name ” o n l i n e ” | \ 364 w h i l e r e a d f ; do

365 e c h o 1 > $ f 2>&1 > / dev / n u l l ;

366 done

367 done

368 f i

369

370 i f ! ${SBINDIR}/ i h k c o n f i g 0 r e s e r v e mem ${mem}; t h e n 371 e c h o ” e r r o r : r e s e r v i n g memory” >&2

372 e r r o r e x i t ” i h k s m p l o a d e d ”

373 f i

374 i f ! ${SBINDIR}/ i h k c o n f i g 0 r e s e r v e cpu ${c p u s}; t h e n 375 e c h o ” e r r o r : r e s e r v i n g CPUs” >&2;

376 e r r o r e x i t ” m e m r e s e r v e d ”

377 f i

378 f i 379

380 # Load m c c t r l i f n o t l o a d e d

381 i f ! g r e p m c c t r l / p r o c / modules &>/dev / n u l l ; t h e n

382 i f ! t a s k s e t c 0 insmod ${KMODDIR}/ m c c t r l . ko 2>/dev / n u l l ; t h e n 383 e c h o ” e r r o r : i n s e r t i n g m c c t r l . ko ” >&2

384 e r r o r e x i t ” c p u s r e s e r v e d ”

385 f i

386 f i 387

388 # D e s t r o y a l l LWK i n s t a n c e s

389 i f l s / dev / mcos 1>/dev / n u l l 2>&1; t h e n

390 f o r i i n / dev / mcos; do

391 i n d =‘ e c h o $ i|c u t c10‘ ;

392 # R e t r y when c o n f l i c t i n g w i t h ihkmond

393 n r e t r y =0

394 u n t i l ${SBINDIR}/ i h k c o n f i g 0 d e s t r o y $ i n d | | [ $ n r e t r y l t 4 ] ; do

395 s l e e p 0 . 2 5

396 n r e t r y=$ [ $ n r e t r y + 1 ]

397 done

398 i f [ $ n r e t r y eq 4 ] ; t h e n

399 e c h o ” e r r o r : d e s t r o y i n g LWK i n s t a n c e $ i n d f a i l e d ” >&2

400 e r r o r e x i t ” m c c t r l l o a d e d ”

401 f i

402 done

403 f i 404

405 # C r e a t e OS i n s t a n c e

406 i f ! ${SBINDIR}/ i h k c o n f i g 0 c r e a t e ; t h e n 407 e c h o ” e r r o r : c r e a t i n g OS i n s t a n c e ” >&2 408 e r r o r e x i t ” m c c t r l l o a d e d ”

409 f i 410

411 # A s s i g n CPUs

412 i f ! ${SBINDIR}/ i h k o s c t l 0 a s s i g n cpu ${c p u s}; t h e n 413 e c h o ” e r r o r : a s s i g n CPUs” >&2

414 e r r o r e x i t ” o s c r e a t e d ” 415 f i

416

417 i f [ ” $ i k c m a p ” != ”” ] ; t h e n

418 # S p e c i f y IKC map

419 i f ! ${SBINDIR}/ i h k o s c t l 0 s e t i k c m a p ${i k c m a p}; t h e n 420 e c h o ” e r r o r : a s s i g n CPUs” >&2

421 e r r o r e x i t ” o s c r e a t e d ”

422 f i

423 f i 424

425 # A s s i g n memory

426 i f ! ${SBINDIR}/ i h k o s c t l 0 a s s i g n mem ${mem}; t h e n 427 e c h o ” e r r o r : a s s i g n memory” >&2

428 e r r o r e x i t ” o s c r e a t e d ” 429 f i

430

431 # Load k e r n e l image

432 i f ! ${SBINDIR}/ i h k o s c t l 0 l o a d ${KERNDIR}/ m c k e r n e l . img ; t h e n

433 e c h o ” e r r o r : l o a d i n g k e r n e l image : ${KERNDIR}/ m c k e r n e l . img ” >&2 434 e r r o r e x i t ” o s c r e a t e d ”

435 f i 436

437 # S e t k e r n e l a r g u m e n t s

438 i f ! ${SBINDIR}/ i h k o s c t l 0 k a r g s ” h i d o s $ t u r b o d u m p l e v e l=${DUMP LEVEL}” ; t h e n 439 e c h o ” e r r o r : s e t t i n g k e r n e l a r g u m e n t s ” >&2

440 e r r o r e x i t ” o s c r e a t e d ” 441 f i

442

443 # Boot OS i n s t a n c e

444 i f ! ${SBINDIR}/ i h k o s c t l 0 b o o t ; t h e n 445 e c h o ” e r r o r : b o o t i n g ” >&2 446 e r r o r e x i t ” o s c r e a t e d ” 447 f i

448

449 # S e t d e v i c e f i l e o w n e r s h i p

450 i f ! chown ${c h o w n o p t i o n} / dev /mcd / dev / mcos; t h e n 451 e c h o ” w a r n i n g : f a i l e d t o chown d e v i c e f i l e s ” >&2 452 f i

453

454 # O v e r l a y / p r o c , / s y s w i t h McKernel s p e c i f i c c o n t e n t s 455 i f [ ” $ e n a b l e m c o v e r l a y ” == ” y e s ” ] ; t h e n

456 i f [ ! e /tmp/ mcos ] ; t h e n

457 mkdir p /tmp/ mcos ;

458 f i

459 i f ! mount t t m p f s t m p f s /tmp/ mcos ; t h e n

460 e c h o ” e r r o r : mount /tmp/ mcos ” >&2

461 e r r o r e x i t ” t m p m c o s c r e a t e d ”

462 f i

463 i f [ ! −e /tmp/ mcos / l i n u x p r o c ] ; t h e n

464 mkdir p /tmp/ mcos / l i n u x p r o c ;

465 f i

466 i f ! mount −−b i n d / p r o c /tmp/ mcos / l i n u x p r o c ; t h e n 467 e c h o ” e r r o r : mount /tmp/ mcos / l i n u x p r o c ” >&2

468 e r r o r e x i t ” tmp mcos mounted ”

469 f i

470 i f ! t a s k s e t c 0 insmod ${KMODDIR}/ m c o v e r l a y . ko 2>/dev / n u l l ; t h e n 471 e c h o ” e r r o r : i n s e r t i n g m c o v e r l a y . ko ” >&2

472 e r r o r e x i t ” l i n u x p r o c b i n d m o u n t e d ”

473 f i

474 w h i l e [ ! e / p r o c / mcos0 ]

475 do

476 s l e e p 0 . 1

477 done

478 i f [ ! e /tmp/ mcos / m c o s 0 p r o c ] ; t h e n

479 mkdir p /tmp/ mcos / m c o s 0 p r o c ;

480 f i

481 i f [ ! e /tmp/ mcos / m c o s 0 p r o c u p p e r ] ; t h e n

482 mkdir p /tmp/ mcos / m c o s 0 p r o c u p p e r ;

483 f i

484 i f [ ! e /tmp/ mcos / m c o s 0 p r o c w o r k ] ; t h e n

485 mkdir p /tmp/ mcos / m c o s 0 p r o c w o r k ;

486 f i

487 i f ! mount t m c o v e r l a y m c o v e r l a y o\

488 l o w e r d i r =/p r o c / mcos0 : / p r o c , u p p e r d i r =/tmp/ mcos / m c o s 0 p r o c u p p e r ,\

489 w o r k d i r=/tmp/ mcos / m c o s 0 p r o c w o r k , nocopyupw , n o f s c h e c k /tmp/ mcos / m c o s 0 p r o c ; t h e n 490 e c h o ” e r r o r : mounting /tmp/ mcos / m c o s 0 p r o c ” >&2

491 e r r o r e x i t ” m c o v e r l a y f s l o a d e d ”

492 f i

493 # TODO: How de we r e v e r t t h i s i n c a s e o f f a i l u r e ? ? 494 mount −−maker p r i v a t e / p r o c

495

496 w h i l e [ ! e / s y s / d e v i c e s / v i r t u a l / mcos / mcos0 / s y s / s e t u p c o m p l e t e ]

497 do

498 s l e e p 0 . 1

499 done

500 i f [ ! e /tmp/ mcos / m c o s 0 s y s ] ; t h e n

501 mkdir p /tmp/ mcos / m c o s 0 s y s ;

502 f i

503 i f [ ! e /tmp/ mcos / m c o s 0 s y s u p p e r ] ; t h e n

504 mkdir p /tmp/ mcos / m c o s 0 s y s u p p e r ;

505 f i

506 i f [ ! e /tmp/ mcos / m c o s 0 s y s w o r k ] ; t h e n

507 mkdir p /tmp/ mcos / m c o s 0 s y s w o r k ;

508 f i

509 i f ! mount t m c o v e r l a y m c o v e r l a y o\

510 l o w e r d i r =/ s y s / d e v i c e s / v i r t u a l / mcos / mcos0 / s y s : / s y s , u p p e r d i r =/tmp/ mcos / m c o s 0 s y s u p p e r ,\ 511 w o r k d i r=/tmp/ mcos / m c o s 0 s y s w o r k , nocopyupw , n o f s c h e c k /tmp/ mcos / m c o s 0 s y s ; t h e n

512 e c h o ” e r r o r : mount /tmp/ mcos / m c o s 0 s y s ” >&2 513 e r r o r e x i t ” m c o s p r o c m o u n t e d ”

514 f i

515 # TODO: How de we r e v e r t t h i s i n c a s e o f f a i l u r e ? ? 516 mount −−maker p r i v a t e / s y s

517

518 t o u c h /tmp/ mcos / m c o s 0 p r o c / m c k e r n e l 519

520 rm r f /tmp/ mcos / m c o s 0 s y s / s e t u p c o m p l e t e 521

522 # Hide NUMA r e l a t e d f i l e s which a r e o u t s i d e t h e LWK p a r t i t i o n

523 f o r c p u i d i n \

524 ‘ f i n d / s y s / d e v i c e s / s y s t e m / cpu /∗ −maxdepth 0 name ” cpu [ 0 1 2 3 4 5 6 7 8 9 ] p r i n t f ”% f ” ‘ ; do

525 i f [ ! e ”/ s y s / d e v i c e s / v i r t u a l / mcos / mcos0 / s y s / d e v i c e s / s y s t e m / cpu / $ c p u i d ” ] ; t h e n 526 rm r f /tmp/ mcos / m c o s 0 s y s / d e v i c e s / s y s t e m / cpu / $ c p u i d

527 rm r f /tmp/ mcos / m c o s 0 s y s / bus / cpu / d e v i c e s / $ c p u i d

528 rm r f /tmp/ mcos / m c o s 0 s y s / bus / cpu / d r i v e r s / p r o c e s s o r / $ c p u i d

529 e l s e

530 f o r n o d e i d i n \

531 ‘ f i n d / s y s / d e v i c e s / s y s t e m / cpu / $ c p u i d /∗ −maxdepth 0 −name ” node [ 0 1 2 3 4 5 6 7 8 9 ] p r i n t f ”% f ” ‘ ; do

532 i f [ ! e \

533 ”/ s y s / d e v i c e s / v i r t u a l / mcos / mcos0 / s y s / d e v i c e s / s y s t e m / cpu / $ c p u i d / $ n o d e i d ” ] ; t h e n

534 rm f \

535 /tmp/ mcos / m c o s 0 s y s / d e v i c e s / s y s t e m / cpu / $ c p u i d / $ n o d e i d

536 f i

537 done

538 f i

539 done

540 f o r n o d e i d i n \

541 ‘ f i n d / s y s / d e v i c e s / s y s t e m / node /∗ −maxdepth 0 −name ” node [ 0 1 2 3 4 5 6 7 8 9 ] −p r i n t f ”% f ” ‘ ; do

542 i f [ ! e ”/ s y s / d e v i c e s / v i r t u a l / mcos / mcos0 / s y s / d e v i c e s / s y s t e m / node / $ n o d e i d ” ] ; \ 543 t h e n

544 rm r f /tmp/ mcos / m c o s 0 s y s / d e v i c e s / s y s t e m / node / $ n o d e i d / 545 rm r f /tmp/ mcos / m c o s 0 s y s / bus / node / d e v i c e s / $ n o d e i d

546 e l s e

547 # D e l e t e none x i s t e n t s y m l i n k s

548 f o r c p u i d i n \

549 ‘ f i n d / s y s / d e v i c e s / s y s t e m / node / $ n o d e i d /∗ −maxdepth 0 name ” cpu [ 0 1 2 3 4 5 6 7 8 9 ] p r i n t f ”% f ” ‘ ; do

550 i f [ ! e \

551 ”/ s y s / d e v i c e s / v i r t u a l / mcos / mcos0 / s y s / d e v i c e s / s y s t e m / node / $ n o d e i d / $ c p u i d ” ] ; t h e n

552 rm f \

553 /tmp/ mcos / m c o s 0 s y s / d e v i c e s / s y s t e m / node / $ n o d e i d / $ c p u i d

554 f i

555 done

556

557 rm f /tmp/ mcos / m c o s 0 s y s / d e v i c e s / s y s t e m / node / $ n o d e i d /memory

558 f i

559 done

560 rm f /tmp/ mcos / m c o s 0 s y s / d e v i c e s / s y s t e m / node / h a s

561 f o r c p u i d i n \

562 ‘ f i n d / s y s / bus / cpu / d e v i c e s /∗ −maxdepth 0 name ” cpu [ 0 1 2 3 4 5 6 7 8 9 ] p r i n t f ”% f ” ‘ ; do

563 i f [ ! e ”/ s y s / d e v i c e s / v i r t u a l / mcos / mcos0 / s y s / bus / cpu / d e v i c e s / $ c p u i d ” ] ; t h e n 564 rm r f /tmp/ mcos / m c o s 0 s y s / bus / cpu / d e v i c e s / $ c p u i d

565 f i

566 done

567 f i 568

569 # S t a r t i r q b a l a n c e w i t h CPUs and IRQ f o r McKernel banned 570 i f [ ” ${i r q b a l a n c e u s e d}” == ” y e s ” ] ; t h e n

571 b a n i r q =‘ c a t / p r o c / i n t e r r u p t s| \

572 p e r l e ’ w h i l e (<>) { i f ( / ˆ\s(\d + ) .IHK\−SMP\s$ / ) {p r i n t $1 ;} }’ ‘ 573

574 s e d ” s/%mask%/$ s m p a f f i n i t y m a s k / g ” $ETCDIR/ i r q b a l a n c e m c k . i n | \ 575 s e d ” s/%b a n i r q%/$ b a n i r q / g ” > /tmp/ i r q b a l a n c e m c k

576 s y s t e m c t l d i s a b l e i r q b a l a n c e m c k . s e r v i c e >/dev / n u l l 2>/dev / n u l l

577 i f ! s y s t e m c t l l i n k $ETCDIR/ i r q b a l a n c e m c k . s e r v i c e >/dev / n u l l 2>/dev / n u l l ; t h e n 578 e c h o ” e r r o r : l i n k i n g i r q b a l a n c e m c k ” >&2

579 e r r o r e x i t ” m c o s s y s m o u n t e d ”

580 f i

581

582 i f ! s y s t e m c t l s t a r t i r q b a l a n c e m c k . s e r v i c e 2>/dev / n u l l ; t h e n 583 e c h o ” e r r o r : s t a r t i n g i r q b a l a n c e m c k ” >&2

584 e r r o r e x i t ” m c o s s y s m o u n t e d ”

585 f i

586 # e c h o c p u s=$ c p u s ncpus=$ n c p u s b a n i r q=$ b a n i r q 587 f i

手順は以下の通り。

2476

1. ihkmondを起動する。ihkmondは任意のタイミングで起動してよい。これは、ihkmond

2477

はOSインスタンスの作成を検知して動作を開始するためである。(83行目)

2478

2. Linuxのカーネルバージョンが、mcoverlayfsが動作するものであるかを確認する。

2479

(200–216行目)

2480

3. irqbalanceを停止する。(251–257行目)

2481

4. /proc/irq/*/affinityの設定を保存した上でMcKernel CPUを担当から外す。担当

2482

CPUが無くなる場合は、全てのLinux CPUを指定する。(269–303行目)

2483

5. ihk.koinsmodする。(307行目)

2484

6. Linuxによるメモリフラグメンテーションを緩和するために以下を実施する。(313–320

2485

行目)

2486

(a) アクティブでないプロセスを積極的にスワップアウトするように設定する

2487

(b) クリーンなページキャッシュを無効化し、またdentriesinodeslabオブジェ

2488

クトのうち可能なものを破棄する

2489

(c) 連続する空き領域を結合してより大きな空き領域にまとめる

2490

7. ihk-smp-x86.koinsmodする。(340行目)ihk-smp-x86.koは関数をihk.koに登

2491

録する。このため、ihk-smp-x86.koihk.koinsmodした後にinsmodする必要が

2492

ある。

2493

8. メモリを予約する。(370行目)

2494

9. CPUを予約する。(374行目)

2495

10. McKernelのカーネルモジュールmcctrl.koをinsmodする。(382行目)mcctrl.ko

2496

はMcKernelブート時に呼ばれる関数をihk.koに登録する。このため、mcctrl.ko

2497

insmodihk.koinsmodの後に、またブートの前に行う必要がある。

2498

11. OSインスタンスを作成する。(406行目)

2499

12. OSインスタンスにCPUを割り当てる。(412行目)

2500

13. McKernel CPUIKCメッセージ送信先のLinux CPUを設定する。(419行目)

2501

14. OSインスタンスにメモリを割り当てる。(426行目)

2502

15. カーネルイメージをロードする。(432行目)

2503

16. カーネル引数をカーネルに渡す。(438行目)

2504

17. カーネルをブートする。(444行目)

2505

18. /proc, /sysファイルの準備をする。また、その中でmcoverlayfs.koinsmod

2506

る。mcoverlayfs.koは他モジュールとの依存関係を持たない。(454行目から567行

2507

目)なお、関数インターフェイスでの対応関数はihk os create pseudofs()である。

2508

19. irqbalanceを、Linux CPUのみを対象とする設定で開始する。(569–587行目)

2509