Skip to content
  1. Feb 08, 2011
    • Steven Rostedt's avatar
      tracing/filter: Swap entire filter of events · 75b8e982
      Steven Rostedt authored
      
      
      When creating a new filter, instead of allocating the filter to the
      event call first and then processing the filter, it is easier to
      process a temporary filter and then just swap it with the call filter.
      By doing this, it simplifies the code.
      
      A filter is allocated and processed, when it is done, it is
      swapped with the call filter, synchronize_sched() is called to make
      sure all callers are done with the old filter (filters are called
      with premption disabled), and then the old filter is freed.
      
      Cc: Tom Zanussi <tzanussi@gmail.com>
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      75b8e982
    • Steven Rostedt's avatar
      tracing/filter: Increase the max preds to 2^14 · bf93f9ed
      Steven Rostedt authored
      
      
      Now that the filter logic does not require to save the pred results
      on the stack, we can increase the max number of preds we allow.
      As the preds are index by a short value, and we use the MSBs as flags
      we can increase the max preds to 2^14 (16384) which should be way
      more than enough.
      
      Cc: Tom Zanussi <tzanussi@gmail.com>
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      bf93f9ed
    • Steven Rostedt's avatar
      tracing/filter: Move MAX_FILTER_PRED to local tracing directory · 4a3d27e9
      Steven Rostedt authored
      
      
      The MAX_FILTER_PRED is only needed by the kernel/trace/*.c files.
      Move it to kernel/trace/trace.h.
      
      Cc: Tom Zanussi <tzanussi@gmail.com>
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      4a3d27e9
    • Steven Rostedt's avatar
      tracing/filter: Optimize filter by folding the tree · 43cd4145
      Steven Rostedt authored
      
      
      There are many cases that a filter will contain multiple ORs or
      ANDs together near the leafs. Walking up and down the tree to get
      to the next compare can be a waste.
      
      If there are several ORs or ANDs together, fold them into a single
      pred and allocate an array of the conditions that they check.
      This will speed up the filter by linearly walking an array
      and can still break out if a short circuit condition is met.
      
      Cc: Tom Zanussi <tzanussi@gmail.com>
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      43cd4145
    • Steven Rostedt's avatar
      tracing/filter: Check the created pred tree · ec126cac
      Steven Rostedt authored
      
      
      Since the filter walks a tree to determine if a match is made or not,
      if the tree was incorrectly created, it could cause an infinite loop.
      
      Add a check to walk the entire tree before assigning it as a filter
      to make sure the tree is correct.
      
      Cc: Tom Zanussi <tzanussi@gmail.com>
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      ec126cac
    • Steven Rostedt's avatar
      tracing/filter: Optimize short ciruit check · 55719274
      Steven Rostedt authored
      
      
      The test if we should break out early for OR and AND operations
      can be optimized by comparing the current result with
        (pred->op == OP_OR)
      
      That is if the result is true and the op is an OP_OR, or
      if the result is false and the op is not an OP_OR (thus an OP_AND)
      we can break out early in either case. Otherwise we continue
      processing.
      
      Cc: Tom Zanussi <tzanussi@gmail.com>
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      55719274
    • Steven Rostedt's avatar
      tracing/filter: Use a tree instead of stack for filter_match_preds() · 61e9dea2
      Steven Rostedt authored
      
      
      Currently the filter_match_preds() requires a stack to push
      and pop the preds to determine if the filter matches the record or not.
      This has two drawbacks:
      
      1) It requires a stack to store state information. As this is done
         in fast paths we can't allocate the storage for this stack, and
         we can't use a global as it must be re-entrant. The stack is stored
         on the kernel stack and this greatly limits how many preds we
         may allow.
      
      2) All conditions are calculated even when a short circuit exists.
         a || b  will always calculate a and b even though a was determined
         to be true.
      
      Using a tree we can walk a constant structure that will save
      the state as we go. The algorithm is simply:
      
        pred = root;
        do {
      	switch (move) {
      	case MOVE_DOWN:
      		if (OR or AND) {
      			pred = left;
      			continue;
      		}
      		if (pred == root)
      			break;
      		match = pred->fn();
      		pred = pred->parent;
      		move = left child ? MOVE_UP_FROM_LEFT : MOVE_UP_FROM_RIGHT;
      		continue;
      
      	case MOVE_UP_FROM_LEFT:
      		/* Only OR or AND can be a parent */
      		if (match && OR || !match && AND) {
      			/* short circuit */
      			if (pred == root)
      				break;
      			pred = pred->parent;
      			move = left child ?
      				MOVE_UP_FROM_LEFT :
      				MOVE_UP_FROM_RIGHT;
      			continue;
      		}
      		pred = pred->right;
      		move = MOVE_DOWN;
      		continue;
      
      	case MOVE_UP_FROM_RIGHT:
      		if (pred == root)
      			break;
      		pred = pred->parent;
      		move = left child ? MOVE_UP_FROM_LEFT : MOVE_UP_FROM_RIGHT;
      		continue;
      	}
      	done = 1;
        } while (!done);
      
      This way there's no strict limit to how many preds we allow
      and it also will short circuit the logical operations when possible.
      
      Cc: Tom Zanussi <tzanussi@gmail.com>
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      61e9dea2
    • Steven Rostedt's avatar
      tracing/filter: Free pred array on disabling of filter · f76690af
      Steven Rostedt authored
      
      
      When a filter is disabled, free the preds.
      
      Cc: Tom Zanussi <tzanussi@gmail.com>
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      f76690af
    • Steven Rostedt's avatar
      tracing/filter: Allocate the preds in an array · 74e9e58c
      Steven Rostedt authored
      
      
      Currently we allocate an array of pointers to filter_preds, and then
      allocate a separate filter_pred for each item in the array.
      This adds slight overhead in the filters as it needs to derefernce
      twice to get to the op condition.
      
      Allocating the preds themselves in a single array removes a dereference
      as well as helps on the cache footprint.
      
      Cc: Tom Zanussi <tzanussi@gmail.com>
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      74e9e58c
    • Steven Rostedt's avatar
      tracing/filter: Call synchronize_sched() just once for system filters · 0fc3ca9a
      Steven Rostedt authored
      
      
      By separating out the reseting of the filter->n_preds to zero from
      the reallocation of preds for the filter, we can reset groups of
      filters first, call synchronize_sched() just once, and then reallocate
      each of the filters in the system group.
      
      Cc: Tom Zanussi <tzanussi@gmail.com>
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      0fc3ca9a
    • Steven Rostedt's avatar
      tracing/filter: Dynamically allocate preds · c9c53ca0
      Steven Rostedt authored
      
      
      For every filter that is made, we create predicates to hold every
      operation within the filter. We have a max of 32 predicates that we
      can hold. Currently, we allocate all 32 even if we only need to
      use one.
      
      Part of the reason we do this is that the filter can be used at
      any moment by any event. Fortunately, the filter is only used
      with preemption disabled. By reseting the count of preds used "n_preds"
      to zero, then performing a synchronize_sched(), we can safely
      free and reallocate a new array of preds.
      
      Cc: Tom Zanussi <tzanussi@gmail.com>
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      c9c53ca0
    • Steven Rostedt's avatar
      tracing/filter: Move OR and AND logic out of fn() method · 58d9a597
      Steven Rostedt authored
      
      
      The ops OR and AND act different from the other ops, as they
      are the only ones to take other ops as their arguements.
      These ops als change the logic of the filter_match_preds.
      
      By removing the OR and AND fn's we can also remove the val1 and val2
      that is passed to all other fn's and are unused.
      
      Cc: Tom Zanussi <tzanussi@gmail.com>
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      58d9a597
    • Steven Rostedt's avatar
      tracing/filter: Have no filter return a match · 6d54057d
      Steven Rostedt authored
      
      
      The n_preds field of a file can change at anytime, and even can become
      zero, just as the filter is about to be processed by an event.
      In the case that is zero on entering the filter, return 1, telling
      the caller the event matchs and should be trace.
      
      Also use a variable and assign it with ACCESS_ONCE() such that the
      count stays consistent within the function.
      
      Cc: Tom Zanussi <tzanussi@gmail.com>
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      6d54057d
  2. Feb 07, 2011
  3. Feb 06, 2011
  4. Feb 05, 2011