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

Commit c0f964b7 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "perf: Fix race in swevent hash"

parents dbd3ba23 d5eeac8e
Loading
Loading
Loading
Loading
+1 −19
Original line number Diff line number Diff line
@@ -5731,9 +5731,6 @@ struct swevent_htable {

	/* Recursion avoidance in each contexts */
	int				recursion[PERF_NR_CONTEXTS];

	/* Keeps track of cpu being initialized/exited */
	bool				online;
};

static DEFINE_PER_CPU(struct swevent_htable, swevent_htable);
@@ -5980,14 +5977,8 @@ static int perf_swevent_add(struct perf_event *event, int flags)
	hwc->state = !(flags & PERF_EF_START);

	head = find_swevent_head(swhash, event);
	if (!head) {
		/*
		 * We can race with cpu hotplug code. Do not
		 * WARN if the cpu just got unplugged.
		 */
		WARN_ON_ONCE(swhash->online);
	if (WARN_ON_ONCE(!head))
		return -EINVAL;
	}

	hlist_add_head_rcu(&event->hlist_entry, head);

@@ -6054,7 +6045,6 @@ static int swevent_hlist_get_cpu(struct perf_event *event, int cpu)
	int err = 0;

	mutex_lock(&swhash->hlist_mutex);

	if (!swevent_hlist_deref(swhash) && cpu_online(cpu)) {
		struct swevent_hlist *hlist;

@@ -8190,7 +8180,6 @@ static void perf_event_init_cpu(int cpu)
	struct swevent_htable *swhash = &per_cpu(swevent_htable, cpu);

	mutex_lock(&swhash->hlist_mutex);
	swhash->online = true;
	if (swhash->hlist_refcount > 0) {
		struct swevent_hlist *hlist;

@@ -8290,14 +8279,7 @@ static void perf_event_start_swclock(int cpu)

static void perf_event_exit_cpu(int cpu)
{
	struct swevent_htable *swhash = &per_cpu(swevent_htable, cpu);

	perf_event_exit_cpu_context(cpu);

	mutex_lock(&swhash->hlist_mutex);
	swhash->online = false;
	swevent_hlist_release(swhash);
	mutex_unlock(&swhash->hlist_mutex);
}
#else
static inline void perf_event_exit_cpu(int cpu) { }