From: Changbin Du <changbin.du@gmail.com> To: Steven Rostedt <rostedt@goodmis.org>, Ingo Molnar <mingo@redhat.com> Cc: linux-arch@vger.kernel.org, Jonathan Corbet <corbet@lwn.net>, linux-parisc@vger.kernel.org, linux-doc@vger.kernel.org, linux-sh@vger.kernel.org, linux-s390@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, Jessica Yu <jeyu@kernel.org>, sparclinux@vger.kernel.org, linux-kbuild@vger.kernel.org, Thomas Gleixner <tglx@linutronix.de>, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Changbin Du <changbin.du@gmail.com> Subject: [PATCH 05/11] ftrace: create memcache for hash entries Date: Sun, 25 Aug 2019 21:23:24 +0800 Message-ID: <20190825132330.5015-6-changbin.du@gmail.com> (raw) In-Reply-To: <20190825132330.5015-1-changbin.du@gmail.com> When CONFIG_FTRACE_FUNC_PROTOTYPE is enabled, thousands of ftrace_func_entry instances are created. So create a dedicated memcache to enhance performance. Signed-off-by: Changbin Du <changbin.du@gmail.com> --- kernel/trace/ftrace.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index a314f0768b2c..cfcb8dad93ea 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -94,6 +94,8 @@ struct ftrace_ops *function_trace_op __read_mostly = &ftrace_list_end; /* What to set function_trace_op to */ static struct ftrace_ops *set_function_trace_op; +struct kmem_cache *hash_entry_cache; + static bool ftrace_pids_enabled(struct ftrace_ops *ops) { struct trace_array *tr; @@ -1169,7 +1171,7 @@ static int add_hash_entry(struct ftrace_hash *hash, unsigned long ip, { struct ftrace_func_entry *entry; - entry = kmalloc(sizeof(*entry), GFP_KERNEL); + entry = kmem_cache_alloc(hash_entry_cache, GFP_KERNEL); if (!entry) return -ENOMEM; @@ -6153,6 +6155,15 @@ void __init ftrace_init(void) if (ret) goto failed; + hash_entry_cache = kmem_cache_create("ftrace-hash", + sizeof(struct ftrace_func_entry), + sizeof(struct ftrace_func_entry), + 0, NULL); + if (!hash_entry_cache) { + pr_err("failed to create ftrace hash entry cache\n"); + goto failed; + } + count = __stop_mcount_loc - __start_mcount_loc; if (!count) { pr_info("ftrace: No functions to be traced?\n"); @@ -6172,6 +6183,10 @@ void __init ftrace_init(void) return; failed: + if (hash_entry_cache) { + kmem_cache_destroy(hash_entry_cache); + hash_entry_cache = NULL; + } ftrace_disabled = 1; } -- 2.20.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply index Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-08-25 13:23 [PATCH 00/11] ftrace: add support for recording function parameters and return value Changbin Du 2019-08-25 13:23 ` [PATCH 01/11] ftrace: move recordmcount tools to scripts/ftrace Changbin Du 2019-08-26 22:44 ` Steven Rostedt 2019-08-28 23:41 ` Changbin Du 2019-08-25 13:23 ` [PATCH 02/11] ftrace: introduce new building tool funcprototype Changbin Du 2019-08-25 13:23 ` [PATCH 03/11] asm-generic: add generic dwarf definition Changbin Du 2019-08-26 7:42 ` Peter Zijlstra 2019-08-26 22:25 ` Changbin Du 2019-08-25 13:23 ` [PATCH 04/11] ftrace/hash: add private data field Changbin Du 2019-08-25 13:23 ` Changbin Du [this message] 2019-08-26 7:44 ` [PATCH 05/11] ftrace: create memcache for hash entries Peter Zijlstra 2019-08-26 22:35 ` Changbin Du 2019-08-25 13:23 ` [PATCH 06/11] ftrace: process function prototype data in vmlinux and modules Changbin Du 2019-08-25 13:23 ` [PATCH 07/11] ftrace: prepare arch specific interfaces for function prototype feature Changbin Du 2019-08-25 13:23 ` [PATCH 08/11] ftrace: introduce core part of function prototype recording Changbin Du 2019-08-25 13:23 ` [PATCH 09/11] x86_64: add function prototype recording support Changbin Du 2019-08-25 13:23 ` [PATCH 10/11] ftrace: add doc for new option record-funcproto Changbin Du 2019-08-25 13:23 ` [PATCH 11/11] MAINTAINERS: make scripts/ftrace/ maintained Changbin Du
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=20190825132330.5015-6-changbin.du@gmail.com \ --to=changbin.du@gmail.com \ --cc=corbet@lwn.net \ --cc=jeyu@kernel.org \ --cc=linux-arch@vger.kernel.org \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-doc@vger.kernel.org \ --cc=linux-kbuild@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-mips@vger.kernel.org \ --cc=linux-parisc@vger.kernel.org \ --cc=linux-riscv@lists.infradead.org \ --cc=linux-s390@vger.kernel.org \ --cc=linux-sh@vger.kernel.org \ --cc=linuxppc-dev@lists.ozlabs.org \ --cc=mingo@redhat.com \ --cc=rostedt@goodmis.org \ --cc=sparclinux@vger.kernel.org \ --cc=tglx@linutronix.de \ --cc=x86@kernel.org \ /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
Linux-ARM-Kernel Archive on lore.kernel.org Archives are clonable: git clone --mirror https://lore.kernel.org/linux-arm-kernel/0 linux-arm-kernel/git/0.git git clone --mirror https://lore.kernel.org/linux-arm-kernel/1 linux-arm-kernel/git/1.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 linux-arm-kernel linux-arm-kernel/ https://lore.kernel.org/linux-arm-kernel \ linux-arm-kernel@lists.infradead.org public-inbox-index linux-arm-kernel Example config snippet for mirrors Newsgroup available over NNTP: nntp://nntp.lore.kernel.org/org.infradead.lists.linux-arm-kernel AGPL code for this site: git clone https://public-inbox.org/public-inbox.git