From: tip-bot for Jiri Olsa <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: hpa@zytor.com, yao.jin@linux.intel.com,
sukadev@linux.vnet.ibm.com, mingo@kernel.org, tglx@linutronix.de,
chabbi.milind@gmail.com, mpe@ellerman.id.au, dsahern@gmail.com,
kan.liang@intel.com, fweisbec@gmail.com, jolsa@redhat.com,
linux-kernel@vger.kernel.org, torvalds@linux-foundation.org,
jolsa@kernel.org, onestero@redhat.com, acme@redhat.com,
hbathini@linux.vnet.ibm.com, peterz@infradead.org,
will.deacon@arm.com, alexander.shishkin@linux.intel.com,
namhyung@kernel.org
Subject: [tip:perf/core] hw_breakpoint: Factor out __modify_user_hw_breakpoint() function
Date: Mon, 12 Mar 2018 23:20:19 -0700 [thread overview]
Message-ID: <tip-18ff57b220610a699947f20b156a8245ca7eee98@git.kernel.org> (raw)
In-Reply-To: <20180312134548.31532-5-jolsa@kernel.org>
Commit-ID: 18ff57b220610a699947f20b156a8245ca7eee98
Gitweb: https://git.kernel.org/tip/18ff57b220610a699947f20b156a8245ca7eee98
Author: Jiri Olsa <jolsa@kernel.org>
AuthorDate: Mon, 12 Mar 2018 14:45:44 +0100
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Tue, 13 Mar 2018 06:56:08 +0100
hw_breakpoint: Factor out __modify_user_hw_breakpoint() function
Moving out all the functionality without the events
disabling/enabling calls, because we want to call another
disabling/enabling functions in following change.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Hari Bathini <hbathini@linux.vnet.ibm.com>
Cc: Jin Yao <yao.jin@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Milind Chabbi <chabbi.milind@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Oleg Nesterov <onestero@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Will Deacon <will.deacon@arm.com>
Link: http://lkml.kernel.org/r/20180312134548.31532-5-jolsa@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
kernel/events/hw_breakpoint.c | 46 +++++++++++++++++++++++++++----------------
1 file changed, 29 insertions(+), 17 deletions(-)
diff --git a/kernel/events/hw_breakpoint.c b/kernel/events/hw_breakpoint.c
index 776948beb4ac..a556aba223da 100644
--- a/kernel/events/hw_breakpoint.c
+++ b/kernel/events/hw_breakpoint.c
@@ -456,6 +456,33 @@ register_user_hw_breakpoint(struct perf_event_attr *attr,
}
EXPORT_SYMBOL_GPL(register_user_hw_breakpoint);
+static int __modify_user_hw_breakpoint(struct perf_event *bp, struct perf_event_attr *attr)
+{
+ 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;
+ int err = 0;
+
+ bp->attr.bp_addr = attr->bp_addr;
+ bp->attr.bp_type = attr->bp_type;
+ bp->attr.bp_len = attr->bp_len;
+
+ err = validate_hw_breakpoint(bp);
+ if (!err && modify)
+ err = modify_bp_slot(bp, old_type);
+
+ if (err) {
+ bp->attr.bp_addr = old_addr;
+ bp->attr.bp_type = old_type;
+ bp->attr.bp_len = old_len;
+ return err;
+ }
+
+ bp->attr.disabled = attr->disabled;
+ return 0;
+}
+
/**
* modify_user_hw_breakpoint - modify a user-space hardware breakpoint
* @bp: the breakpoint structure to modify
@@ -465,11 +492,7 @@ EXPORT_SYMBOL_GPL(register_user_hw_breakpoint);
*/
int modify_user_hw_breakpoint(struct perf_event *bp, struct perf_event_attr *attr)
{
- 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;
- int err = 0;
+ int err;
/*
* modify_user_hw_breakpoint can be invoked with IRQs disabled and hence it
@@ -482,18 +505,9 @@ int modify_user_hw_breakpoint(struct perf_event *bp, struct perf_event_attr *att
else
perf_event_disable(bp);
- bp->attr.bp_addr = attr->bp_addr;
- bp->attr.bp_type = attr->bp_type;
- bp->attr.bp_len = attr->bp_len;
-
- err = validate_hw_breakpoint(bp);
- if (!err && modify)
- err = modify_bp_slot(bp, old_type);
+ err = __modify_user_hw_breakpoint(bp, attr);
if (err) {
- bp->attr.bp_addr = old_addr;
- bp->attr.bp_type = old_type;
- bp->attr.bp_len = old_len;
if (!bp->attr.disabled)
perf_event_enable(bp);
@@ -502,8 +516,6 @@ int modify_user_hw_breakpoint(struct perf_event *bp, struct perf_event_attr *att
if (!attr->disabled)
perf_event_enable(bp);
-
- bp->attr.disabled = attr->disabled;
return 0;
}
EXPORT_SYMBOL_GPL(modify_user_hw_breakpoint);
next prev parent reply other threads:[~2018-03-13 6:21 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-12 13:45 [PATCHv3 0/8] hw_breakpoint: Breakpoint modification fixes and new modify ioctl Jiri Olsa
2018-03-12 13:45 ` [PATCH 1/8] hw_breakpoint: Pass bp_type directly as find_slot_idx argument Jiri Olsa
2018-03-13 6:18 ` [tip:perf/core] hw_breakpoint: Pass bp_type directly as find_slot_idx() argument tip-bot for Jiri Olsa
2018-03-12 13:45 ` [PATCH 2/8] hw_breakpoint: Pass bp_type argument to __reserve_bp_slot|__release_bp_slot Jiri Olsa
2018-03-13 6:19 ` [tip:perf/core] hw_breakpoint: Pass bp_type argument to __reserve_bp_slot|__release_bp_slot() tip-bot for Jiri Olsa
2018-03-12 13:45 ` [PATCH 3/8] hw_breakpoint: Add modify_bp_slot function Jiri Olsa
2018-03-13 6:19 ` [tip:perf/core] hw_breakpoint: Add modify_bp_slot() function tip-bot for Jiri Olsa
2018-03-12 13:45 ` [PATCH 4/8] hw_breakpoint: Factor out __modify_user_hw_breakpoint function Jiri Olsa
2018-03-13 6:20 ` tip-bot for Jiri Olsa [this message]
2018-03-12 13:45 ` [PATCH 5/8] hw_breakpoint: Add perf_event_attr fields check in __modify_user_hw_breakpoint Jiri Olsa
2018-03-13 6:20 ` [tip:perf/core] hw_breakpoint: Add perf_event_attr fields check in __modify_user_hw_breakpoint() tip-bot for Jiri Olsa
2018-03-12 13:45 ` [PATCH 6/8] perf/core: Move perf_event_attr::sample_max_stack into perf_copy_attr Jiri Olsa
2018-03-13 6:21 ` [tip:perf/core] perf/core: Move perf_event_attr::sample_max_stack into perf_copy_attr() tip-bot for Jiri Olsa
2018-03-12 13:45 ` [PATCH 7/8] perf/core: fast breakpoint modification via _IOC_MODIFY_ATTRIBUTES Jiri Olsa
2018-03-13 6:21 ` [tip:perf/core] perf/core: Implement " tip-bot for Milind Chabbi
2018-03-13 15:14 ` tip-bot for Milind Chabbi
2018-03-12 13:45 ` [PATCH 8/8] perf tests: Add breakpoint accounting/modify test Jiri Olsa
2018-03-13 6:22 ` [tip:perf/core] " tip-bot for Jiri Olsa
2018-03-13 15:13 ` tip-bot for Jiri Olsa
2018-03-13 6:37 ` [PATCHv3 0/8] hw_breakpoint: Breakpoint modification fixes and new modify ioctl Ingo Molnar
2018-03-13 9:28 ` Jiri Olsa
2018-03-13 9:50 ` Jiri Olsa
2018-03-14 8:45 ` [PATCH] hw_breakpoint: Fix build for disabled CONFIG_HAVE_HW_BREAKPOINT Jiri Olsa
2018-03-14 12:28 ` Ingo Molnar
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=tip-18ff57b220610a699947f20b156a8245ca7eee98@git.kernel.org \
--to=tipbot@zytor.com \
--cc=acme@redhat.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=chabbi.milind@gmail.com \
--cc=dsahern@gmail.com \
--cc=fweisbec@gmail.com \
--cc=hbathini@linux.vnet.ibm.com \
--cc=hpa@zytor.com \
--cc=jolsa@kernel.org \
--cc=jolsa@redhat.com \
--cc=kan.liang@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=mpe@ellerman.id.au \
--cc=namhyung@kernel.org \
--cc=onestero@redhat.com \
--cc=peterz@infradead.org \
--cc=sukadev@linux.vnet.ibm.com \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=will.deacon@arm.com \
--cc=yao.jin@linux.intel.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).