diff options
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/trace/ftrace.c | 83 |
1 files changed, 36 insertions, 47 deletions
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index cc4219135dc9..b9f2e22faf2e 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c | |||
@@ -394,72 +394,62 @@ __ftrace_replace_code(struct dyn_ftrace *rec, int enable) | |||
394 | 394 | ||
395 | ip = rec->ip; | 395 | ip = rec->ip; |
396 | 396 | ||
397 | if (ftrace_filtered && enable) { | 397 | /* |
398 | * If this record is not to be traced and | ||
399 | * it is not enabled then do nothing. | ||
400 | * | ||
401 | * If this record is not to be traced and | ||
402 | * it is enabled then disabled it. | ||
403 | * | ||
404 | */ | ||
405 | if (rec->flags & FTRACE_FL_NOTRACE) { | ||
406 | if (rec->flags & FTRACE_FL_ENABLED) | ||
407 | rec->flags &= ~FTRACE_FL_ENABLED; | ||
408 | else | ||
409 | return 0; | ||
410 | |||
411 | } else if (ftrace_filtered && enable) { | ||
398 | /* | 412 | /* |
399 | * If filtering is on: | 413 | * Filtering is on: |
400 | * | ||
401 | * If this record is set to be filtered and | ||
402 | * is enabled then do nothing. | ||
403 | * | ||
404 | * If this record is set to be filtered and | ||
405 | * it is not enabled, enable it. | ||
406 | * | ||
407 | * If this record is not set to be filtered | ||
408 | * and it is not enabled do nothing. | ||
409 | * | ||
410 | * If this record is set not to trace then | ||
411 | * do nothing. | ||
412 | * | ||
413 | * If this record is set not to trace and | ||
414 | * it is enabled then disable it. | ||
415 | * | ||
416 | * If this record is not set to be filtered and | ||
417 | * it is enabled, disable it. | ||
418 | */ | 414 | */ |
419 | 415 | ||
420 | fl = rec->flags & (FTRACE_FL_FILTER | FTRACE_FL_NOTRACE | | 416 | fl = rec->flags & (FTRACE_FL_FILTER | FTRACE_FL_ENABLED); |
421 | FTRACE_FL_ENABLED); | ||
422 | 417 | ||
423 | if ((fl == (FTRACE_FL_FILTER | FTRACE_FL_ENABLED)) || | 418 | /* Record is filtered and enabled, do nothing */ |
424 | (fl == (FTRACE_FL_FILTER | FTRACE_FL_NOTRACE)) || | 419 | if (fl == (FTRACE_FL_FILTER | FTRACE_FL_ENABLED)) |
425 | !fl || (fl == FTRACE_FL_NOTRACE)) | ||
426 | return 0; | 420 | return 0; |
427 | 421 | ||
428 | /* | 422 | /* Record is not filtered and is not enabled do nothing */ |
429 | * If it is enabled disable it, | 423 | if (!fl) |
430 | * otherwise enable it! | 424 | return 0; |
431 | */ | 425 | |
432 | if (fl & FTRACE_FL_ENABLED) { | 426 | /* Record is not filtered but enabled, disable it */ |
433 | enable = 0; | 427 | if (fl == FTRACE_FL_ENABLED) |
434 | rec->flags &= ~FTRACE_FL_ENABLED; | 428 | rec->flags &= ~FTRACE_FL_ENABLED; |
435 | } else { | 429 | else |
436 | enable = 1; | 430 | /* Otherwise record is filtered but not enabled, enable it */ |
437 | rec->flags |= FTRACE_FL_ENABLED; | 431 | rec->flags |= FTRACE_FL_ENABLED; |
438 | } | ||
439 | } else { | 432 | } else { |
433 | /* Disable or not filtered */ | ||
440 | 434 | ||
441 | if (enable) { | 435 | if (enable) { |
442 | /* | 436 | /* if record is enabled, do nothing */ |
443 | * If this record is set not to trace and is | ||
444 | * not enabled, do nothing. | ||
445 | */ | ||
446 | fl = rec->flags & (FTRACE_FL_NOTRACE | FTRACE_FL_ENABLED); | ||
447 | if (fl == FTRACE_FL_NOTRACE) | ||
448 | return 0; | ||
449 | } | ||
450 | |||
451 | if (enable) { | ||
452 | if (rec->flags & FTRACE_FL_ENABLED) | 437 | if (rec->flags & FTRACE_FL_ENABLED) |
453 | return 0; | 438 | return 0; |
439 | |||
454 | rec->flags |= FTRACE_FL_ENABLED; | 440 | rec->flags |= FTRACE_FL_ENABLED; |
441 | |||
455 | } else { | 442 | } else { |
443 | |||
444 | /* if record is not enabled do nothing */ | ||
456 | if (!(rec->flags & FTRACE_FL_ENABLED)) | 445 | if (!(rec->flags & FTRACE_FL_ENABLED)) |
457 | return 0; | 446 | return 0; |
447 | |||
458 | rec->flags &= ~FTRACE_FL_ENABLED; | 448 | rec->flags &= ~FTRACE_FL_ENABLED; |
459 | } | 449 | } |
460 | } | 450 | } |
461 | 451 | ||
462 | if (enable) | 452 | if (rec->flags & FTRACE_FL_ENABLED) |
463 | return ftrace_make_call(rec, FTRACE_ADDR); | 453 | return ftrace_make_call(rec, FTRACE_ADDR); |
464 | else | 454 | else |
465 | return ftrace_make_nop(NULL, rec, FTRACE_ADDR); | 455 | return ftrace_make_nop(NULL, rec, FTRACE_ADDR); |
@@ -554,8 +544,7 @@ static void ftrace_startup(void) | |||
554 | 544 | ||
555 | mutex_lock(&ftrace_start_lock); | 545 | mutex_lock(&ftrace_start_lock); |
556 | ftrace_start_up++; | 546 | ftrace_start_up++; |
557 | if (ftrace_start_up == 1) | 547 | command |= FTRACE_ENABLE_CALLS; |
558 | command |= FTRACE_ENABLE_CALLS; | ||
559 | 548 | ||
560 | if (saved_ftrace_func != ftrace_trace_function) { | 549 | if (saved_ftrace_func != ftrace_trace_function) { |
561 | saved_ftrace_func = ftrace_trace_function; | 550 | saved_ftrace_func = ftrace_trace_function; |