Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cc5edb0e authored by Arnaldo Carvalho de Melo's avatar Arnaldo Carvalho de Melo
Browse files

perf hists: Factor out duplicated code



Introducing hists__remove_entry_filter.

Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
LKML-Reference: <new-submission>
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent b66ecd97
Loading
Loading
Loading
Loading
+18 −18
Original line number Original line Diff line number Diff line
@@ -795,6 +795,21 @@ enum hist_filter {
	HIST_FILTER__THREAD,
	HIST_FILTER__THREAD,
};
};


static void hists__remove_entry_filter(struct hists *self, struct hist_entry *h,
				       enum hist_filter filter)
{
	h->filtered &= ~(1 << filter);
	if (h->filtered)
		return;

	++self->nr_entries;
	self->stats.total_period += h->period;
	self->stats.nr_events[PERF_RECORD_SAMPLE] += h->nr_events;

	if (h->ms.sym && self->max_sym_namelen < h->ms.sym->namelen)
		self->max_sym_namelen = h->ms.sym->namelen;
}

void hists__filter_by_dso(struct hists *self, const struct dso *dso)
void hists__filter_by_dso(struct hists *self, const struct dso *dso)
{
{
	struct rb_node *nd;
	struct rb_node *nd;
@@ -814,15 +829,7 @@ void hists__filter_by_dso(struct hists *self, const struct dso *dso)
			continue;
			continue;
		}
		}


		h->filtered &= ~(1 << HIST_FILTER__DSO);
		hists__remove_entry_filter(self, h, HIST_FILTER__DSO);
		if (!h->filtered) {
			++self->nr_entries;
			self->stats.total_period += h->period;
			self->stats.nr_events[PERF_RECORD_SAMPLE] += h->nr_events;
			if (h->ms.sym &&
			    self->max_sym_namelen < h->ms.sym->namelen)
				self->max_sym_namelen = h->ms.sym->namelen;
		}
	}
	}
}
}


@@ -841,15 +848,8 @@ void hists__filter_by_thread(struct hists *self, const struct thread *thread)
			h->filtered |= (1 << HIST_FILTER__THREAD);
			h->filtered |= (1 << HIST_FILTER__THREAD);
			continue;
			continue;
		}
		}
		h->filtered &= ~(1 << HIST_FILTER__THREAD);

		if (!h->filtered) {
		hists__remove_entry_filter(self, h, HIST_FILTER__THREAD);
			++self->nr_entries;
			self->stats.total_period += h->period;
			self->stats.nr_events[PERF_RECORD_SAMPLE] += h->nr_events;
			if (h->ms.sym &&
			    self->max_sym_namelen < h->ms.sym->namelen)
				self->max_sym_namelen = h->ms.sym->namelen;
		}
	}
	}
}
}