[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <tip-26c6ccdf5c06aa83bb78518c72cb287f043db3df@git.kernel.org>
Date: Tue, 26 Jun 2018 03:31:57 -0700
From: tip-bot for Frederic Weisbecker <tipbot@...or.com>
To: linux-tip-commits@...r.kernel.org
Cc: benh@...nel.crashing.org, joel.opensrc@...il.com,
mark.rutland@....com, frederic@...nel.org, tglx@...utronix.de,
namhyung@...nel.org, acme@...nel.org, peterz@...radead.org,
will.deacon@....com, jolsa@...hat.com,
linux-kernel@...r.kernel.org, catalin.marinas@....com,
paulus@...ba.org, mingo@...nel.org, acme@...hat.com,
ysato@...rs.sourceforge.jp, dalias@...c.org, hpa@...or.com,
luto@...nel.org, chris@...kel.net, mpe@...erman.id.au,
torvalds@...ux-foundation.org, jcmvbkbc@...il.com,
alexander.shishkin@...ux.intel.com
Subject: [tip:perf/core] perf/hw_breakpoint: Clean up and consolidate
modify_user_hw_breakpoint_check()
Commit-ID: 26c6ccdf5c06aa83bb78518c72cb287f043db3df
Gitweb: https://git.kernel.org/tip/26c6ccdf5c06aa83bb78518c72cb287f043db3df
Author: Frederic Weisbecker <frederic@...nel.org>
AuthorDate: Tue, 26 Jun 2018 04:58:59 +0200
Committer: Ingo Molnar <mingo@...nel.org>
CommitDate: Tue, 26 Jun 2018 09:07:59 +0200
perf/hw_breakpoint: Clean up and consolidate modify_user_hw_breakpoint_check()
Remove the dance around old and new attributes. Just don't modify the
previous breakpoint at all until we have verified everything.
Original-patch-by: Andy Lutomirski <luto@...nel.org>
Reported-by: Linus Torvalds <torvalds@...ux-foundation.org>
Signed-off-by: Frederic Weisbecker <frederic@...nel.org>
Cc: Alexander Shishkin <alexander.shishkin@...ux.intel.com>
Cc: Andy Lutomirski <luto@...nel.org>
Cc: Arnaldo Carvalho de Melo <acme@...nel.org>
Cc: Arnaldo Carvalho de Melo <acme@...hat.com>
Cc: Benjamin Herrenschmidt <benh@...nel.crashing.org>
Cc: Catalin Marinas <catalin.marinas@....com>
Cc: Chris Zankel <chris@...kel.net>
Cc: Jiri Olsa <jolsa@...hat.com>
Cc: Joel Fernandes <joel.opensrc@...il.com>
Cc: Mark Rutland <mark.rutland@....com>
Cc: Max Filippov <jcmvbkbc@...il.com>
Cc: Michael Ellerman <mpe@...erman.id.au>
Cc: Namhyung Kim <namhyung@...nel.org>
Cc: Paul Mackerras <paulus@...ba.org>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: Rich Felker <dalias@...c.org>
Cc: Thomas Gleixner <tglx@...utronix.de>
Cc: Will Deacon <will.deacon@....com>
Cc: Yoshinori Sato <ysato@...rs.sourceforge.jp>
Link: http://lkml.kernel.org/r/1529981939-8231-13-git-send-email-frederic@kernel.org
Signed-off-by: Ingo Molnar <mingo@...nel.org>
---
kernel/events/hw_breakpoint.c | 44 ++++++++++++++++++++++++-------------------
1 file changed, 25 insertions(+), 19 deletions(-)
diff --git a/kernel/events/hw_breakpoint.c b/kernel/events/hw_breakpoint.c
index 71387703b5f1..b3814fce5ecb 100644
--- a/kernel/events/hw_breakpoint.c
+++ b/kernel/events/hw_breakpoint.c
@@ -461,37 +461,43 @@ register_user_hw_breakpoint(struct perf_event_attr *attr,
}
EXPORT_SYMBOL_GPL(register_user_hw_breakpoint);
+static void hw_breakpoint_copy_attr(struct perf_event_attr *to,
+ struct perf_event_attr *from)
+{
+ to->bp_addr = from->bp_addr;
+ to->bp_type = from->bp_type;
+ to->bp_len = from->bp_len;
+ to->disabled = from->disabled;
+}
+
int
modify_user_hw_breakpoint_check(struct perf_event *bp, struct perf_event_attr *attr,
bool check)
{
- u64 old_addr = bp->attr.bp_addr;
- u64 old_len = bp->attr.bp_len;
- int old_type = bp->attr.bp_type;
- bool modify = attr->bp_type != old_type;
struct arch_hw_breakpoint hw;
- int err = 0;
+ int err;
- bp->attr.bp_addr = attr->bp_addr;
- bp->attr.bp_type = attr->bp_type;
- bp->attr.bp_len = attr->bp_len;
+ err = hw_breakpoint_parse(bp, attr, &hw);
+ if (err)
+ return err;
- if (check && memcmp(&bp->attr, attr, sizeof(*attr)))
- return -EINVAL;
+ if (check) {
+ struct perf_event_attr old_attr;
- err = hw_breakpoint_parse(bp, attr, &hw);
- if (!err && modify)
- err = modify_bp_slot(bp, old_type, bp->attr.bp_type);
+ old_attr = bp->attr;
+ hw_breakpoint_copy_attr(&old_attr, attr);
+ if (memcmp(&old_attr, attr, sizeof(*attr)))
+ return -EINVAL;
+ }
- if (err) {
- bp->attr.bp_addr = old_addr;
- bp->attr.bp_type = old_type;
- bp->attr.bp_len = old_len;
- return err;
+ if (bp->attr.bp_type != attr->bp_type) {
+ err = modify_bp_slot(bp, bp->attr.bp_type, attr->bp_type);
+ if (err)
+ return err;
}
+ hw_breakpoint_copy_attr(&bp->attr, attr);
bp->hw.info = hw;
- bp->attr.disabled = attr->disabled;
return 0;
}
Powered by blists - more mailing lists