Commit 49bd97c2 authored by Sean Christopherson's avatar Sean Christopherson Committed by Arnaldo Carvalho de Melo
Browse files

perf tools: Use dedicated non-atomic clear/set bit helpers



Use the dedicated non-atomic helpers for {clear,set}_bit() and their
test variants, i.e. the double-underscore versions.  Depsite being
defined in atomic.h, and despite the kernel versions being atomic in the
kernel, tools' {clear,set}_bit() helpers aren't actually atomic.  Move
to the double-underscore versions so that the versions that are expected
to be atomic (for kernel developers) can be made atomic without
affecting users that don't want atomic operations.

No functional change intended.

Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: James Morse <james.morse@arm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Marc Zyngier <maz@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Oliver Upton <oliver.upton@linux.dev>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Sean Christopherson <seanjc@google.com>
Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
Cc: Yury Norov <yury.norov@gmail.com>
Cc: alexandru elisei <alexandru.elisei@arm.com>
Cc: kvm@vger.kernel.org
Cc: kvmarm@lists.cs.columbia.edu
Cc: kvmarm@lists.linux.dev
Cc: linux-arm-kernel@lists.infradead.org
Link: http://lore.kernel.org/lkml/20221119013450.2643007-6-seanjc@google.com


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 0c3852ad
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -70,7 +70,7 @@ static int do_for_each_set_bit(unsigned int num_bits)
		bitmap_zero(to_test, num_bits);
		skip = num_bits / set_bits;
		for (i = 0; i < num_bits; i += skip)
			set_bit(i, to_test);
			__set_bit(i, to_test);

		for (i = 0; i < outer_iterations; i++) {
			old = accumulator;
+3 −3
Original line number Diff line number Diff line
@@ -230,7 +230,7 @@ static void c2c_he__set_cpu(struct c2c_hist_entry *c2c_he,
		      "WARNING: no sample cpu value"))
		return;

	set_bit(sample->cpu, c2c_he->cpuset);
	__set_bit(sample->cpu, c2c_he->cpuset);
}

static void c2c_he__set_node(struct c2c_hist_entry *c2c_he,
@@ -247,7 +247,7 @@ static void c2c_he__set_node(struct c2c_hist_entry *c2c_he,
	if (WARN_ONCE(node < 0, "WARNING: failed to find node\n"))
		return;

	set_bit(node, c2c_he->nodeset);
	__set_bit(node, c2c_he->nodeset);

	if (c2c_he->paddr != sample->phys_addr) {
		c2c_he->paddr_cnt++;
@@ -2318,7 +2318,7 @@ static int setup_nodes(struct perf_session *session)
			continue;

		perf_cpu_map__for_each_cpu(cpu, idx, map) {
			set_bit(cpu.cpu, set);
			__set_bit(cpu.cpu, set);

			if (WARN_ONCE(cpu2node[cpu.cpu] != -1, "node/cpu topology bug"))
				return -EINVAL;
+3 −3
Original line number Diff line number Diff line
@@ -222,7 +222,7 @@ static struct kwork_atom *atom_new(struct perf_kwork *kwork,
	list_add_tail(&page->list, &kwork->atom_page_list);

found_atom:
	set_bit(i, page->bitmap);
	__set_bit(i, page->bitmap);
	atom->time = sample->time;
	atom->prev = NULL;
	atom->page_addr = page;
@@ -235,7 +235,7 @@ static void atom_free(struct kwork_atom *atom)
	if (atom->prev != NULL)
		atom_free(atom->prev);

	clear_bit(atom->bit_inpage,
	__clear_bit(atom->bit_inpage,
		    ((struct kwork_atom_page *)atom->page_addr)->bitmap);
}

+3 −3
Original line number Diff line number Diff line
@@ -3555,7 +3555,7 @@ static int record__mmap_cpu_mask_init(struct mmap_cpu_mask *mask, struct perf_cp
		/* Return ENODEV is input cpu is greater than max cpu */
		if ((unsigned long)cpu.cpu > mask->nbits)
			return -ENODEV;
		set_bit(cpu.cpu, mask->bits);
		__set_bit(cpu.cpu, mask->bits);
	}

	return 0;
@@ -3627,8 +3627,8 @@ static int record__init_thread_cpu_masks(struct record *rec, struct perf_cpu_map
	pr_debug("nr_threads: %d\n", rec->nr_threads);

	for (t = 0; t < rec->nr_threads; t++) {
		set_bit(perf_cpu_map__cpu(cpus, t).cpu, rec->thread_masks[t].maps.bits);
		set_bit(perf_cpu_map__cpu(cpus, t).cpu, rec->thread_masks[t].affinity.bits);
		__set_bit(perf_cpu_map__cpu(cpus, t).cpu, rec->thread_masks[t].maps.bits);
		__set_bit(perf_cpu_map__cpu(cpus, t).cpu, rec->thread_masks[t].affinity.bits);
		if (verbose) {
			pr_debug("thread_masks[%d]: ", t);
			mmap_cpu_mask__scnprintf(&rec->thread_masks[t].maps, "maps");
+1 −1
Original line number Diff line number Diff line
@@ -1573,7 +1573,7 @@ static int map_switch_event(struct perf_sched *sched, struct evsel *evsel,

	if (sched->map.comp) {
		cpus_nr = bitmap_weight(sched->map.comp_cpus_mask, MAX_CPUS);
		if (!test_and_set_bit(this_cpu.cpu, sched->map.comp_cpus_mask)) {
		if (!__test_and_set_bit(this_cpu.cpu, sched->map.comp_cpus_mask)) {
			sched->map.comp_cpus[cpus_nr++] = this_cpu;
			new_cpu = true;
		}
Loading