Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933020AbbENLjg (ORCPT ); Thu, 14 May 2015 07:39:36 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:21318 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932812AbbENLjb (ORCPT ); Thu, 14 May 2015 07:39:31 -0400 From: Wang Long To: , , CC: , , , , , , , , , Subject: [RFC PATCH 11/17] seq_buf: Move the seq_buf code to lib/ Date: Thu, 14 May 2015 11:34:58 +0000 Message-ID: <1431603304-162571-12-git-send-email-long.wanglong@huawei.com> X-Mailer: git-send-email 1.8.3.4 In-Reply-To: <1431603304-162571-1-git-send-email-long.wanglong@huawei.com> References: <1431603304-162571-1-git-send-email-long.wanglong@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.107.197.200] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020201.5554888C.01CF,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 5e6b8dffba6036e2fe5c572e3df721a6 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3034 Lines: 78 From: "Steven Rostedt (Red Hat)" commit 8d58e99af5980d444948720977b0976455885391 upstream. The seq_buf functions are rather useful outside of tracing. Instead of having it be dependent on CONFIG_TRACING, move the code into lib/ and allow other users to have access to it even when tracing is not configured. The seq_buf utility is similar to the seq_file utility, but instead of writing sending data back up to userland, it writes it into a buffer defined at seq_buf_init(). This allows us to send a descriptor around that writes printf() formatted strings into it that can be retrieved later. It is currently used by the tracing facility for such things like trace events to convert its binary saved data in the ring buffer into an ASCII human readable context to be displayed in /sys/kernel/debug/trace. It can also be used for doing NMI prints safely from NMI context into the seq_buf and retrieved later and dumped to printk() safely. Doing printk() from an NMI context is dangerous because an NMI can preempt a current printk() and deadlock on it. Link: http://lkml.kernel.org/p/20140619213952.058255809@goodmis.org Tested-by: Jiri Kosina Acked-by: Jiri Kosina Reviewed-by: Petr Mladek [wanglong: backport to 3.10 stable - adjust context ] Signed-off-by: Wang Long Signed-off-by: Steven Rostedt --- kernel/trace/Makefile | 1 - lib/Makefile | 2 +- {kernel/trace => lib}/seq_buf.c | 0 3 files changed, 1 insertion(+), 2 deletions(-) rename {kernel/trace => lib}/seq_buf.c (100%) diff --git a/kernel/trace/Makefile b/kernel/trace/Makefile index cfb86f1..d7e2068 100644 --- a/kernel/trace/Makefile +++ b/kernel/trace/Makefile @@ -27,7 +27,6 @@ obj-$(CONFIG_RING_BUFFER_BENCHMARK) += ring_buffer_benchmark.o obj-$(CONFIG_TRACING) += trace.o obj-$(CONFIG_TRACING) += trace_output.o -obj-$(CONFIG_TRACING) += seq_buf.o obj-$(CONFIG_TRACING) += trace_stat.o obj-$(CONFIG_TRACING) += trace_printk.o obj-$(CONFIG_CONTEXT_SWITCH_TRACER) += trace_sched_switch.o diff --git a/lib/Makefile b/lib/Makefile index 9efe480..4ecd2e4 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -13,7 +13,7 @@ lib-y := ctype.o string.o vsprintf.o cmdline.o \ sha1.o md5.o irq_regs.o reciprocal_div.o argv_split.o \ proportions.o flex_proportions.o prio_heap.o ratelimit.o show_mem.o \ is_single_threaded.o plist.o decompress.o kobject_uevent.o \ - earlycpio.o + earlycpio.o seq_buf.o obj-$(CONFIG_ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS) += usercopy.o lib-$(CONFIG_MMU) += ioremap.o diff --git a/kernel/trace/seq_buf.c b/lib/seq_buf.c similarity index 100% rename from kernel/trace/seq_buf.c rename to lib/seq_buf.c -- 1.8.3.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/