Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760644AbcDMMxs (ORCPT ); Wed, 13 Apr 2016 08:53:48 -0400 Received: from ozlabs.org ([103.22.144.67]:54798 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760625AbcDMMxq (ORCPT ); Wed, 13 Apr 2016 08:53:46 -0400 From: Michael Ellerman To: Cc: bsingharora@gmail.com, duwe@lst.de, , rostedt@goodmis.org, kamalesh@linux.vnet.ibm.com, pmladek@suse.com, jeyu@redhat.com, jikos@kernel.org, live-patching@vger.kernel.org, mbenes@suse.cz Subject: [PATCH 1/5] ftrace: Make ftrace_location_range() global Date: Wed, 13 Apr 2016 22:53:19 +1000 Message-Id: <1460552003-15409-2-git-send-email-mpe@ellerman.id.au> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1460552003-15409-1-git-send-email-mpe@ellerman.id.au> References: <1460552003-15409-1-git-send-email-mpe@ellerman.id.au> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2010 Lines: 50 In order to support live patching on powerpc we would like to call ftrace_location_range(), so make it global. Signed-off-by: Torsten Duwe Signed-off-by: Balbir Singh Signed-off-by: Michael Ellerman --- include/linux/ftrace.h | 1 + kernel/trace/ftrace.c | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h index dea12a6e413b..66a36a815f0a 100644 --- a/include/linux/ftrace.h +++ b/include/linux/ftrace.h @@ -455,6 +455,7 @@ int ftrace_update_record(struct dyn_ftrace *rec, int enable); int ftrace_test_record(struct dyn_ftrace *rec, int enable); void ftrace_run_stop_machine(int command); unsigned long ftrace_location(unsigned long ip); +unsigned long ftrace_location_range(unsigned long start, unsigned long end); unsigned long ftrace_get_addr_new(struct dyn_ftrace *rec); unsigned long ftrace_get_addr_curr(struct dyn_ftrace *rec); diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index b1870fbd2b67..7e8d792da963 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -1530,7 +1530,19 @@ static int ftrace_cmp_recs(const void *a, const void *b) return 0; } -static unsigned long ftrace_location_range(unsigned long start, unsigned long end) +/** + * ftrace_location_range - return the first address of a traced location + * if it touches the given ip range + * @start: start of range to search. + * @end: end of range to search (inclusive). @end points to the last byte + * to check. + * + * Returns rec->ip if the related ftrace location is a least partly within + * the given address range. That is, the first address of the instruction + * that is either a NOP or call to the function tracer. It checks the ftrace + * internal tables to determine if the address belongs or not. + */ +unsigned long ftrace_location_range(unsigned long start, unsigned long end) { struct ftrace_page *pg; struct dyn_ftrace *rec; -- 2.5.0