login
Login
/
Register
Search
Search this site:
Forums
News
Blogs
Features
Site
Home
»
Mailing list archives
»
linux-kernel
»
2008
»
April
»
4
Re: [PATCH] relay: add buffer-only functionality, allowing for early kernel tracing
view
thread
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
[view in full thread]
From: Randy Dunlap
Subject:
Re: [PATCH] relay: add buffer-only functionality, allowing for early kernel tracing
Date: Friday, April 4, 2008 - 9:08 am
On Fri, 4 Apr 2008 18:33:03 +0300 Eduard - Gabriel Munteanu wrote:
quoted text
> relay_open() can now handle NULL base_filename, to register a > buffer-only channel. Using a new function, relay_late_setup_files(), one > can assign files after creating the channel, thus allowing for doing > early tracing in the kernel, before VFS is up. > > Signed-off-by: Eduard - Gabriel Munteanu <eduard.munteanu@linux360.ro> > --- > Documentation/filesystems/relay.txt | 11 ++++ > include/linux/relay.h | 4 ++ > kernel/relay.c | 102 ++++++++++++++++++++++++++--------- > 3 files changed, 91 insertions(+), 26 deletions(-) > > diff --git a/Documentation/filesystems/relay.txt b/Documentation/filesystems/relay.txt > index 094f2d2..b59c228 100644 > --- a/Documentation/filesystems/relay.txt > +++ b/Documentation/filesystems/relay.txt > @@ -161,6 +161,7 @@ TBD(curr. line MT:/API/) > relay_close(chan) > relay_flush(chan) > relay_reset(chan) > + relay_late_setup_files(chan, base_filename, parent) > > channel management typically called on instigation of userspace: > > @@ -294,6 +295,16 @@ user-defined data with a channel, and is immediately available > (including in create_buf_file()) via chan->private_data or > buf->chan->private_data. > > +Buffer-only channels > +-------------------- > + > +These channels have no files associated and can be created with > +relay_open(NULL, NULL, ...). Such channels are useful in scenarios such > +as when doing early tracing in the kernel, before the VFS is up. In these > +cases, one may open a channel a buffer-only channel and then call
~~~~~~~~~ d/a channel/
quoted text
> +relay_late_setup_files() when the kernel is ready to handle files, to expose > +the buffered data to the userspace. > + > Channel 'modes' > --------------- > > diff --git a/kernel/relay.c b/kernel/relay.c > index 4c035a8..4bea94a 100644 > --- a/kernel/relay.c > +++ b/kernel/relay.c > @@ -378,6 +378,35 @@ void relay_reset(struct rchan *chan) > } > EXPORT_SYMBOL_GPL(relay_reset); > > +static int relay_setup_buf_file(struct rchan *chan, > + struct rchan_buf *buf, > + unsigned int cpu) > +{ > + struct dentry *dentry; > + char *tmpname; > + > + tmpname = kzalloc(NAME_MAX + 1, GFP_KERNEL); > + if (!tmpname) > + goto failed; > + snprintf(tmpname, NAME_MAX, "%s%d", chan->base_filename, cpu); > + > + /* Create file in fs */ > + dentry = chan->cb->create_buf_file(tmpname, chan->parent, > + S_IRUSR, buf, > + &chan->is_global); > + > + if (!dentry) > + goto failed;
above leaks tmpname ?
quoted text
> + buf->dentry = dentry; > + > + kfree(tmpname); > + > + return 0; > + > +failed: > + return 1; > +} > + > /* > * relay_open_buf - create a new relay channel buffer > * > @@ -386,44 +415,30 @@ EXPORT_SYMBOL_GPL(relay_reset); > static struct rchan_buf *relay_open_buf(struct rchan *chan, unsigned int cpu) > { > struct rchan_buf *buf = NULL; > - struct dentry *dentry; > - char *tmpname; > > if (chan->is_global) > return chan->buf[0]; > > - tmpname = kzalloc(NAME_MAX + 1, GFP_KERNEL); > - if (!tmpname) > - goto end; > - snprintf(tmpname, NAME_MAX, "%s%d", chan->base_filename, cpu); > - > buf = relay_create_buf(chan); > if (!buf) > - goto free_name; > + goto end; > + > + if (chan->has_base_filename) > + if (relay_setup_buf_file(chan, buf, cpu)) goto free_buf;
Put 'goto free_buf;' on separate line.
quoted text
> > buf->cpu = cpu; > __relay_reset(buf, 1); > > - /* Create file in fs */ > - dentry = chan->cb->create_buf_file(tmpname, chan->parent, S_IRUSR, > - buf, &chan->is_global); > - if (!dentry) > - goto free_buf; > - > - buf->dentry = dentry; > - > if(chan->is_global) { > chan->buf[0] = buf; > buf->cpu = 0; > } > > - goto free_name; > + goto end; > > free_buf: > relay_destroy_buf(buf); > buf = NULL; > -free_name: > - kfree(tmpname); > end: > return buf; > } > @@ -576,6 +594,38 @@ free_bufs: > EXPORT_SYMBOL_GPL(relay_open); > > /** > + * relay_late_setup_files - triggers file creation > + * @chan: channel to operate on > + * @base_filename: base name of files to create > + * @parent: dentry of parent directory, %NULL for root directory > + * > + * Returns 0 is successful, non-zero otherwise.
s/is/if/
quoted text
> + * > + * Use to setup files for a previously buffer-only channel. > + * Useful to do early tracing in kernel, before VFS is up, for example. > + */ > +int relay_late_setup_files(struct rchan *chan, > + const char *base_filename, > + struct dentry *parent) > +{ > + unsigned int i; > + > + if (!chan || !base_filename) > + return 1; > + > + strlcpy(chan->base_filename, base_filename, NAME_MAX); > + chan->has_base_filename = 1; > + chan->parent = parent; > + > + mutex_lock(&relay_channels_mutex); > + for_each_present_cpu(i) > + relay_setup_buf_file(chan, chan->buf[i], i); > + mutex_unlock(&relay_channels_mutex); > + > + return 0; > +} > + > +/** > * relay_switch_subbuf - switch to a new sub-buffer > * @buf: channel buffer > * @length: size of current event
--- ~Randy --
unsubscribe notice
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/
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
Messages in current thread:
[PATCH] relay: add buffer-only functionality, allowing for ...
, Eduard - Gabriel Mun ...
, (Fri Apr 4, 8:33 am)
Re: [PATCH] relay: add buffer-only functionality, allowing ...
, Mathieu Desnoyers
, (Fri Apr 4, 9:06 am)
Re: [PATCH] relay: add buffer-only functionality, allowing ...
, Randy Dunlap
, (Fri Apr 4, 9:08 am)
Re: [PATCH] relay: add buffer-only functionality, allowing ...
, Eduard - Gabriel Mun ...
, (Fri Apr 4, 9:19 am)
Re: [PATCH] relay: add buffer-only functionality, allowing ...
, Eduard - Gabriel Mun ...
, (Fri Apr 4, 9:28 am)
Re: [PATCH] relay: add buffer-only functionality, allowing ...
, Mathieu Desnoyers
, (Fri Apr 4, 9:40 am)
Re: [PATCH] relay: add buffer-only functionality, allowing ...
, Eduard - Gabriel Mun ...
, (Fri Apr 4, 10:06 am)
Re: [PATCH] relay: add buffer-only functionality, allowing ...
, Eduard - Gabriel Mun ...
, (Sat Apr 5, 6:27 pm)
Navigation
Mailing list archives
Recent posts
Popular discussions
linux-kernel
:
Ken Chen
[patch] sched: fix inconsistency when redistribute per-cpu tg->cfs_rq shares.
Hugh Dickins
Re: Linux 2.6.26-rc1 - pgtable_32.c:178 pmd_bad
Bernhard Beck
[PATCH 001/001] usb-serial: Add ThinkOptics WavIT
Oleg Nesterov
Re: [PATCH 4/5] don't panic if /sbin/init exits or killed
Greg KH
[patch 07/21] rtc-pcf8563: detect polarity of century bit automatically
git
:
Jonathan del Strother
Re: [PATCH] Fixing path quoting issues
Gerrit Pape
[PATCH] fix skipping merge-order test with NO_OPENSSL=1.
Linus Torvalds
Re: Implementing branch attributes in git config
Johannes Schindelin
Re: Trying to use git-filter-branch to compress history by removing large, obsolet...
Gerrit Pape
[PATCH] hooks--update: fix test for properly set up project description file
linux-netdev
:
David Miller
Re: [PATCH 04/15] tg3: Preserve LAA when device control is released
Jean-Louis Dupond
Re: tg3 driver not advertising 1000mbit
Sven Wegener
[PATCH] ipvs: Add missing locking during connection table hashing and unhashing
David Miller
Re: [PATCH] qlcnic: dont assume NET_IP_ALIGN is 2
Stephen Hemminger
[PATCH 2/2] sky2: fix transmit state on resume
git-commits-head
:
Linux Kernel Mailing List
[SCSI] scsi ioctl: fix kernel-doc warning
Linux Kernel Mailing List
ALSA: HDA - Correct trivial typos in comments.
Linux Kernel Mailing List
i2c-viapro: Add support for SMBus Process Call transactions
Linux Kernel Mailing List
i2c: Documentation: upgrading clients HOWTO
Linux Kernel Mailing List
[PATCH] fix sysctl_nr_open bugs
openbsd-misc
:
Die Gestalt
Re: How to re-build openssl with SHA1 support?
Edwin Eyan Moragas
Re: managing routes for multiple PPPoE connections
Brian Candler
Re: OBSD's perspective on SELinux
Jonathan Schleifer
Why is getaddrinfo breaking POSIX?
Predrag Punosevac
Re: Kernel developers guide/tutorial
Colocation donated by:
Syndicate