diff options
author | Glenn Elliott <gelliott@cs.unc.edu> | 2012-09-20 18:57:20 -0400 |
---|---|---|
committer | Glenn Elliott <gelliott@cs.unc.edu> | 2012-09-20 18:57:20 -0400 |
commit | 150c1d5ed8541f3a2bfcde3d5f3174b9af4ab4fc (patch) | |
tree | 7970735e676afc237e40e0971119001429bf56ae /litmus/litmus.c | |
parent | 33cb64c787070d6b60a02ea40064d717d3b9dc07 (diff) |
Generalized GPU cost predictors + EWMA. (untested)wip-gpu-rtas12
Diffstat (limited to 'litmus/litmus.c')
-rw-r--r-- | litmus/litmus.c | 194 |
1 files changed, 172 insertions, 22 deletions
diff --git a/litmus/litmus.c b/litmus/litmus.c index d368202ab8c3..8380c0f6a393 100644 --- a/litmus/litmus.c +++ b/litmus/litmus.c | |||
@@ -332,28 +332,183 @@ asmlinkage long sys_null_call(cycles_t __user *ts) | |||
332 | } | 332 | } |
333 | 333 | ||
334 | #if defined(CONFIG_LITMUS_NVIDIA) && defined(CONFIG_LITMUS_AFFINITY_LOCKING) | 334 | #if defined(CONFIG_LITMUS_NVIDIA) && defined(CONFIG_LITMUS_AFFINITY_LOCKING) |
335 | void init_gpu_affinity_state(struct task_struct* p) | 335 | static void create_gpu_cc_mr_avg(obs_history_t* obs, uint16_t window_size) |
336 | { | 336 | { |
337 | // under-damped | 337 | obs->window_size = window_size; |
338 | //p->rt_param.gpu_fb_param_a = _frac(14008, 10000); | 338 | obs->observations = kmalloc(sizeof(lt_t)*window_size, GFP_KERNEL); |
339 | //p->rt_param.gpu_fb_param_b = _frac(16024, 10000); | 339 | obs->range = kmalloc(sizeof(lt_t)*(window_size-1), GFP_KERNEL); |
340 | } | ||
340 | 341 | ||
341 | #if 0 | 342 | static void create_gpu_cc_brute_avg(obs_history_t* obs, uint16_t window_size) |
342 | // emperical; | 343 | { |
343 | p->rt_param.gpu_fb_param_a[0] = _frac(7550, 10000); | 344 | obs->window_size = window_size; |
344 | p->rt_param.gpu_fb_param_b[0] = _frac(45800, 10000); | 345 | obs->observations = kmalloc(sizeof(lt_t)*window_size, GFP_KERNEL); |
346 | obs->range = NULL; | ||
347 | } | ||
345 | 348 | ||
346 | p->rt_param.gpu_fb_param_a[1] = _frac(8600, 10000); | 349 | static void create_gpu_simple_avg(obs_history_t* obs, uint16_t window_size) |
347 | p->rt_param.gpu_fb_param_b[1] = _frac(40000, 10000); | 350 | { |
351 | obs->window_size = 0; | ||
352 | obs->observations = NULL; | ||
353 | obs->range = NULL; | ||
354 | } | ||
348 | 355 | ||
349 | p->rt_param.gpu_fb_param_a[2] = _frac(6890, 10000); | 356 | static void destroy_obs_history(obs_history_t* obs) |
350 | p->rt_param.gpu_fb_param_b[2] = _frac(40000, 10000); | 357 | { |
358 | if (obs->observations) | ||
359 | kfree(obs->observations); | ||
360 | if (obs->range) | ||
361 | kfree(obs->range); | ||
362 | } | ||
363 | |||
364 | static void create_gpu_cc_mr_ewma(obs_history_t* obs, uint16_t window_size) | ||
365 | { | ||
366 | obs->window_size = window_size; | ||
367 | obs->observations = NULL; | ||
368 | obs->range = kmalloc(sizeof(lt_t)*(window_size-1), GFP_KERNEL); | ||
369 | } | ||
370 | |||
371 | static void create_gpu_cc_brute_ewma(obs_history_t* obs, uint16_t window_size) | ||
372 | { | ||
373 | obs->window_size = window_size; | ||
374 | obs->observations = kmalloc(sizeof(lt_t)*window_size, GFP_KERNEL); | ||
375 | obs->range = NULL; | ||
376 | } | ||
377 | |||
378 | static void create_gpu_simple_ewma(obs_history_t* obs, uint16_t window_size) | ||
379 | { | ||
380 | obs->window_size = 0; | ||
381 | obs->observations = NULL; | ||
382 | obs->range = NULL; | ||
383 | } | ||
384 | |||
385 | |||
386 | static void create_gpu_affinity_state(struct task_struct* p, uint8_t sigmas, uint16_t window_size) | ||
387 | { | ||
388 | int i; | ||
351 | 389 | ||
352 | p->rt_param.gpu_fb_param_a[3] = _frac(7580, 10000); | ||
353 | p->rt_param.gpu_fb_param_b[3] = _frac(34590, 10000); | ||
354 | #endif | ||
355 | p->rt_param.gpu_migration = MIG_NONE; | 390 | p->rt_param.gpu_migration = MIG_NONE; |
356 | p->rt_param.last_gpu = -1; | 391 | p->rt_param.last_gpu = -1; |
392 | |||
393 | switch (p->rt_param.prediction_mode) { | ||
394 | case SIMPLE_AVG: | ||
395 | case CC_BRUTE_AVG: | ||
396 | case CC_MR_AVG: | ||
397 | memset(&p->rt_param.gpu_avg_est, 0, sizeof(p->rt_param.gpu_avg_est)); | ||
398 | break; | ||
399 | case SIMPLE_EWMA: | ||
400 | case CC_BRUTE_EWMA: | ||
401 | case CC_MR_EWMA: | ||
402 | memset(&p->rt_param.gpu_ewma_est, 0, sizeof(p->rt_param.gpu_ewma_est)); | ||
403 | break; | ||
404 | default: | ||
405 | BUG(); | ||
406 | break; | ||
407 | } | ||
408 | |||
409 | for (i = 0; i <= MIG_LAST; ++i) { | ||
410 | switch (p->rt_param.prediction_mode) { | ||
411 | case SIMPLE_AVG: | ||
412 | create_gpu_simple_avg(&p->rt_param.gpu_avg_est[i].history, window_size); | ||
413 | break; | ||
414 | case CC_BRUTE_AVG: | ||
415 | p->rt_param.gpu_avg_est[i].sigmas = sigmas; | ||
416 | create_gpu_cc_brute_avg(&p->rt_param.gpu_avg_est[i].history, window_size); | ||
417 | break; | ||
418 | case CC_MR_AVG: | ||
419 | p->rt_param.gpu_avg_est[i].sigmas = sigmas; | ||
420 | create_gpu_cc_mr_avg(&p->rt_param.gpu_avg_est[i].history, window_size); | ||
421 | break; | ||
422 | case SIMPLE_EWMA: | ||
423 | create_gpu_simple_ewma(&p->rt_param.gpu_avg_est[i].history, window_size); | ||
424 | break; | ||
425 | case CC_BRUTE_EWMA: | ||
426 | p->rt_param.gpu_ewma_est[i].sigmas = sigmas; | ||
427 | create_gpu_cc_brute_ewma(&p->rt_param.gpu_ewma_est[i].history, window_size); | ||
428 | break; | ||
429 | case CC_MR_EWMA: | ||
430 | p->rt_param.gpu_ewma_est[i].sigmas = sigmas; | ||
431 | create_gpu_cc_mr_ewma(&p->rt_param.gpu_ewma_est[i].history, window_size); | ||
432 | break; | ||
433 | default: | ||
434 | BUG(); | ||
435 | break; | ||
436 | } | ||
437 | } | ||
438 | } | ||
439 | |||
440 | static void destroy_gpu_affinity_state(struct task_struct* p) | ||
441 | { | ||
442 | int i; | ||
443 | |||
444 | if (p->rt_param.prediction_mode == CC_BRUTE_AVG || | ||
445 | p->rt_param.prediction_mode == CC_MR_AVG) { | ||
446 | for (i = 0; i <= MIG_LAST; ++i) { | ||
447 | destroy_obs_history(&p->rt_param.gpu_avg_est[i].history); | ||
448 | } | ||
449 | } | ||
450 | else if (p->rt_param.prediction_mode == CC_BRUTE_EWMA || | ||
451 | p->rt_param.prediction_mode == CC_MR_EWMA) { | ||
452 | for (i = 0; i <= MIG_LAST; ++i) { | ||
453 | destroy_obs_history(&p->rt_param.gpu_ewma_est[i].history); | ||
454 | } | ||
455 | } | ||
456 | } | ||
457 | |||
458 | asmlinkage long sys_config_gpu_affinity_predictor(void* __user arg) | ||
459 | { | ||
460 | struct task_struct *t = current; | ||
461 | predictor_t params; | ||
462 | |||
463 | if (!access_ok(VERIFY_READ, arg, sizeof(params))) { | ||
464 | return -EINVAL; | ||
465 | } | ||
466 | if (__copy_from_user(¶ms, arg, sizeof(params))) { | ||
467 | return -EINVAL; | ||
468 | } | ||
469 | |||
470 | if (params.type != SIMPLE_AVG && | ||
471 | params.type != SIMPLE_EWMA && | ||
472 | params.type != CC_BRUTE_AVG && | ||
473 | params.type != CC_BRUTE_EWMA && | ||
474 | params.type != CC_MR_AVG && | ||
475 | params.type != CC_MR_EWMA) { | ||
476 | return -EINVAL; | ||
477 | } | ||
478 | |||
479 | if (params.type != SIMPLE_AVG && params.type != SIMPLE_EWMA) { | ||
480 | if (params.window_size <= 10) { | ||
481 | return -EINVAL; | ||
482 | } | ||
483 | } | ||
484 | |||
485 | if (params.type == SIMPLE_EWMA || | ||
486 | params.type == CC_BRUTE_EWMA || | ||
487 | params.type == CC_MR_EWMA) { | ||
488 | if (params.alpha_num > params.alpha_denom) { | ||
489 | return -EINVAL; | ||
490 | } | ||
491 | if (params.alpha_num == 0) { | ||
492 | return -EINVAL; | ||
493 | } | ||
494 | if (params.alpha_denom == 0) { | ||
495 | params.alpha_denom = 1; | ||
496 | } | ||
497 | } | ||
498 | |||
499 | if (t->rt_param.prediction_mode != 0) { | ||
500 | destroy_gpu_affinity_state(t); | ||
501 | } | ||
502 | |||
503 | t->rt_param.prediction_mode = params.type; | ||
504 | create_gpu_affinity_state(t, params.sigmas, params.window_size); | ||
505 | |||
506 | return 0; | ||
507 | } | ||
508 | #else | ||
509 | asmlinkage long sys_config_gpu_affinity_predictor(void* __user arg) | ||
510 | { | ||
511 | return -EINVAL; | ||
357 | } | 512 | } |
358 | #endif | 513 | #endif |
359 | 514 | ||
@@ -426,10 +581,6 @@ static void reinit_litmus_state(struct task_struct* p, int restore) | |||
426 | p->rt_param.ctrl_page = ctrl_page; | 581 | p->rt_param.ctrl_page = ctrl_page; |
427 | } | 582 | } |
428 | 583 | ||
429 | #if defined(CONFIG_LITMUS_NVIDIA) && defined(CONFIG_LITMUS_AFFINITY_LOCKING) | ||
430 | init_gpu_affinity_state(p); | ||
431 | #endif | ||
432 | |||
433 | #ifdef CONFIG_LITMUS_NESTED_LOCKING | 584 | #ifdef CONFIG_LITMUS_NESTED_LOCKING |
434 | INIT_BINHEAP_HANDLE(&p->rt_param.hp_blocked_tasks, prio_order); | 585 | INIT_BINHEAP_HANDLE(&p->rt_param.hp_blocked_tasks, prio_order); |
435 | raw_spin_lock_init(&p->rt_param.hp_blocked_tasks_lock); | 586 | raw_spin_lock_init(&p->rt_param.hp_blocked_tasks_lock); |
@@ -467,9 +618,6 @@ long __litmus_admit_task(struct task_struct* tsk) | |||
467 | #ifdef CONFIG_LITMUS_NVIDIA | 618 | #ifdef CONFIG_LITMUS_NVIDIA |
468 | atomic_set(&tsk_rt(tsk)->nv_int_count, 0); | 619 | atomic_set(&tsk_rt(tsk)->nv_int_count, 0); |
469 | #endif | 620 | #endif |
470 | #if defined(CONFIG_LITMUS_NVIDIA) && defined(CONFIG_LITMUS_AFFINITY_LOCKING) | ||
471 | init_gpu_affinity_state(tsk); | ||
472 | #endif | ||
473 | #ifdef CONFIG_LITMUS_NESTED_LOCKING | 621 | #ifdef CONFIG_LITMUS_NESTED_LOCKING |
474 | tsk_rt(tsk)->blocked_lock = NULL; | 622 | tsk_rt(tsk)->blocked_lock = NULL; |
475 | raw_spin_lock_init(&tsk_rt(tsk)->hp_blocked_tasks_lock); | 623 | raw_spin_lock_init(&tsk_rt(tsk)->hp_blocked_tasks_lock); |
@@ -539,6 +687,8 @@ void litmus_exit_task(struct task_struct* tsk) | |||
539 | bheap_node_free(tsk_rt(tsk)->heap_node); | 687 | bheap_node_free(tsk_rt(tsk)->heap_node); |
540 | release_heap_free(tsk_rt(tsk)->rel_heap); | 688 | release_heap_free(tsk_rt(tsk)->rel_heap); |
541 | 689 | ||
690 | destroy_gpu_affinity_state(tsk); | ||
691 | |||
542 | atomic_dec(&rt_task_count); | 692 | atomic_dec(&rt_task_count); |
543 | reinit_litmus_state(tsk, 1); | 693 | reinit_litmus_state(tsk, 1); |
544 | } | 694 | } |