linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Yury Norov <yury.norov@gmail.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Marc Zyngier <maz@kernel.org>,
	Paolo Bonzini <pbonzini@redhat.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>,
	James Morse <james.morse@arm.com>,
	Alexandru Elisei <alexandru.elisei@arm.com>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	Oliver Upton <oliver.upton@linux.dev>,
	linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev,
	kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org,
	Sean Christopherson <seanjc@google.com>
Subject: [PATCH 0/9] tools: Make {clear,set}_bit() atomic for reals
Date: Sat, 19 Nov 2022 01:34:41 +0000	[thread overview]
Message-ID: <20221119013450.2643007-1-seanjc@google.com> (raw)

For obvious reasons I'd like to route the this through Paolo's tree.
In theory, taking just patch 5 through tip would work, but creating a
topic branch seems like the way to go, though maybe I'm being overly
paranoid.  The current tip/perf/core doesn't have any conflicts, nor does
it have new set_bit() or clear_bit() users.

 
Code sitting in kvm/queue for 6.2 adds functionality that relies on
clear_bit() being an atomic operation.  Unfortunately, despite being
implemented in atomic.h (among other strong hits that they should be
atomic), clear_bit() and set_bit() aren't actually atomic (and of course
I realized this _just_ after everything got queued up).

Move current tools/ users of clear_bit() and set_bit() to the
double-underscore versions (which tools/ already provides and documents
as being non-atomic), and then implement clear_bit() and set_bit() as
actual atomics to fix the KVM selftests bug.

Perf and KVM are the only affected users.  NVDIMM also has test code
in tools/, but that builds against the kernel proper.  The KVM code is
well tested and fully audited.  The perf code is lightly tested; if I
understand the build system, it's probably not even fully compile tested.

Patches 1 and 2 are completely unrelated and are fixes for patches
sitting in kvm/queue.  Paolo, they can be squashed if you want to rewrite
history.

Patch 3 fixes a hilarious collision in a KVM ARM selftest that will arise
when clear_bit() is converted to an atomic.

Patch 4 changes clear_bit() and set_bit() to take an "unsigned long"
instead of an "int" so that patches 5-6 aren't accompanied by functional
changes.  I.e. if something in perf is somehow relying on "bit" being a
signed int, failures will bisect to patch 4 and not to the
supposed-to-be-a-nop conversion to __clear_bit() and __set_bit().

Patch 5-9 switch perf+KVM and complete the conversion.

Applies on:
  
  git://git.kernel.org/pub/scm/virt/kvm/kvm.git queue

Sean Christopherson (9):
  KVM: selftests: Add rdmsr_from_l2() implementation in Hyper-V eVMCS
    test
  KVM: selftests: Remove unused "vcpu" param to fix build error
  KVM: arm64: selftests: Enable single-step without a "full" ucall()
  tools: Take @bit as an "unsigned long" in {clear,set}_bit() helpers
  perf tools: Use dedicated non-atomic clear/set bit helpers
  KVM: selftests: Use non-atomic clear/set bit helpers in KVM tests
  tools: Drop conflicting non-atomic test_and_{clear,set}_bit() helpers
  tools: Drop "atomic_" prefix from atomic test_and_set_bit()
  tools: KVM: selftests: Convert clear/set_bit() to actual atomics

 tools/arch/x86/include/asm/atomic.h           |  6 +++-
 tools/include/asm-generic/atomic-gcc.h        | 13 ++++++-
 tools/include/asm-generic/bitops/atomic.h     | 15 ++++----
 tools/include/linux/bitmap.h                  | 34 -------------------
 tools/perf/bench/find-bit-bench.c             |  2 +-
 tools/perf/builtin-c2c.c                      |  6 ++--
 tools/perf/builtin-kwork.c                    |  6 ++--
 tools/perf/builtin-record.c                   |  6 ++--
 tools/perf/builtin-sched.c                    |  2 +-
 tools/perf/tests/bitmap.c                     |  2 +-
 tools/perf/tests/mem2node.c                   |  2 +-
 tools/perf/util/affinity.c                    |  4 +--
 tools/perf/util/header.c                      |  8 ++---
 tools/perf/util/mmap.c                        |  6 ++--
 tools/perf/util/pmu.c                         |  2 +-
 .../util/scripting-engines/trace-event-perl.c |  2 +-
 .../scripting-engines/trace-event-python.c    |  2 +-
 tools/perf/util/session.c                     |  2 +-
 tools/perf/util/svghelper.c                   |  2 +-
 .../selftests/kvm/aarch64/arch_timer.c        |  2 +-
 .../selftests/kvm/aarch64/debug-exceptions.c  | 21 ++++++------
 tools/testing/selftests/kvm/dirty_log_test.c  | 34 +++++++++----------
 .../selftests/kvm/include/ucall_common.h      |  8 +++++
 .../testing/selftests/kvm/lib/ucall_common.c  |  2 +-
 .../selftests/kvm/x86_64/hyperv_evmcs.c       | 13 +++++--
 .../selftests/kvm/x86_64/hyperv_svm_test.c    |  4 +--
 .../selftests/kvm/x86_64/hyperv_tlb_flush.c   |  2 +-
 27 files changed, 102 insertions(+), 106 deletions(-)


base-commit: 3321eef4acb51c303f0598d8a8493ca58528a054
-- 
2.38.1.584.g0f3c55d4c2-goog


             reply	other threads:[~2022-11-19  1:52 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-19  1:34 Sean Christopherson [this message]
2022-11-19  1:34 ` [PATCH 1/9] KVM: selftests: Add rdmsr_from_l2() implementation in Hyper-V eVMCS test Sean Christopherson
2022-11-19  1:34 ` [PATCH 2/9] KVM: selftests: Remove unused "vcpu" param to fix build error Sean Christopherson
2022-11-19  1:34 ` [PATCH 3/9] KVM: arm64: selftests: Enable single-step without a "full" ucall() Sean Christopherson
2022-11-19  1:34 ` [PATCH 4/9] tools: Take @bit as an "unsigned long" in {clear,set}_bit() helpers Sean Christopherson
2022-11-19  1:34 ` [PATCH 5/9] perf tools: Use dedicated non-atomic clear/set bit helpers Sean Christopherson
2022-12-02 18:16   ` Namhyung Kim
2022-12-02 18:27     ` Arnaldo Carvalho de Melo
2022-11-19  1:34 ` [PATCH 6/9] KVM: selftests: Use non-atomic clear/set bit helpers in KVM tests Sean Christopherson
2022-11-19  1:34 ` [PATCH 7/9] tools: Drop conflicting non-atomic test_and_{clear,set}_bit() helpers Sean Christopherson
2022-11-19  1:34 ` [PATCH 8/9] tools: Drop "atomic_" prefix from atomic test_and_set_bit() Sean Christopherson
2022-11-19  1:34 ` [PATCH 9/9] tools: KVM: selftests: Convert clear/set_bit() to actual atomics Sean Christopherson
2022-12-02 18:23 ` [PATCH 0/9] tools: Make {clear,set}_bit() atomic for reals Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221119013450.2643007-1-seanjc@google.com \
    --to=seanjc@google.com \
    --cc=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=alexandru.elisei@arm.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=james.morse@arm.com \
    --cc=jolsa@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=mark.rutland@arm.com \
    --cc=maz@kernel.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=oliver.upton@linux.dev \
    --cc=pbonzini@redhat.com \
    --cc=peterz@infradead.org \
    --cc=suzuki.poulose@arm.com \
    --cc=yury.norov@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).