relay: Add global mode support for buffer-only channels
PATCH 1/1 relay: Add global mode support for buffer-only channels
From: Akash Goel <[email protected]>
The following patch added support to use channels with no associated files.
relay: add buffer-only channels; useful for early logging
This is useful when the exact location of relay file is not known or the the parent directory of relay file is not available, while creating the channel and the logging has to start right from the boot.
But there was no provision to use global mode with buffer-only channels, which is added by this patch, without modifying the interface where initially there will be a dummy invocation of create_buf_file callback through which kernel client can convey the need of a global buffer.
For the use case where drivers/kernel clients want a simple interface for the userspace, which enables them to capture data/logs from relay file in order & without any post processing, support of Global buffer mode is warranted.
--- kernel/relay.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
kernel/relay.c +32 -0
@@ -451,6 +451,16 @@ static struct rchan_buf *relay_open_buf(struct rchan *chan, unsigned int cpu)if (!dentry) goto free_buf;relay_set_buf_dentry (buf, dentry); + }else { + dentry = chan->cb->create_buf_file (NULL ,NULL , +S_IRUSR , buf, + &chan->is_global); +/* We did not expected the client to return a valid dentry, +* was now just looking for the global info from the client. +* Now onus is on client only to release this dentry pointer. +*/ +if (WARN_ON (dentry)) + goto free_buf; } buf->cpu = cpu;
@@ -666,6 +676,27 @@ int relay_late_setup_files(struct rchan *chan, } chan->has_base_filename =1 ; chan->parent = parent; + +if (chan->is_global) { +if (unlikely (!chan->buf[0 ])) { +WARN_ONCE (1 ,KERN_ERR "CPU 0 has no buffer!\n" ); +mutex_unlock (&relay_channels_mutex); +return -EINVAL ; + } + + dentry =relay_create_buf_file (chan, chan->buf[0 ],0 ); + +if (unlikely (!dentry)) + err = -EINVAL ; +else if (WARN_ON (!chan->is_global)) + err = -EINVAL ; +else +relay_set_buf_dentry (chan->buf[0 ], dentry); + +mutex_unlock (&relay_channels_mutex); +return err; + } + curr_cpu =get_cpu ();/* * The CPU hotplug notifier ran before us and created buffers with
@@ -706,6 +737,7 @@ int relay_late_setup_files(struct rchan *chan,return err; } +EXPORT_SYMBOL_GPL (relay_late_setup_files);/** * relay_switch_subbuf - switch to a new sub-buffer
Signature · 1 line
1.9.2
Quoted 30 lines · On Sun, Jul 03, 2016 at 09:45:27PM +0530, [email protected] wrote:
From: Akash Goel <[email protected]>
The following patch added support to use channels with no associated files.
relay: add buffer-only channels; useful for early logging
This is useful when the exact location of relay file is not known or the the parent directory of relay file is not available, while creating the channel and the logging has to start right from the boot.But there was no provision to use global mode with buffer-only channels, which is added by this patch, without modifying the interface where initially there will be a dummy invocation of
create_buf_filecallback through which kernel client can convey the need of a global buffer.For the use case where
drivers/kernelclients want a simple interface for the userspace, which enables them to capture data/logs from relay file in order & without any post processing, support of Global buffer mode is warranted.Cc Eduard - Gabriel Munteanu <[email protected]>Cc Tom Zanussi <[email protected]>Cc Chris Wilson <[email protected]>Signed-off-by Akash Goel <[email protected]>--- kernel/relay.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)kernel/relay.c +0
-0
kernel/relay.c static struct rchan_buf *relay_open_buf(struct rchan *chan, unsigned int cpu) · line 454
Quoted 4 lines
kernel/relay.c +1
-0@@ -451,6 +451,16 @@ static struct rchan_buf *relay_open_buf(struct rchan *chan, unsigned int cpu)if (!dentry) goto free_buf;relay_set_buf_dentry (buf, dentry); + }else {
The trailing block can be replaced with:
/* Only retrieve global info, nothing more, nothing less */
kernel/relay.c static struct rchan_buf *relay_open_buf(struct rchan *chan, unsigned int cpu) · line 457
Quoted 3 lines
kernel/relay.c +3
-0+ dentry = chan->cb->create_buf_file (NULL ,NULL , +S_IRUSR , buf, + &chan->is_global);
Watch alignment, align to the opening bracket.
kernel/relay.c int relay_late_setup_files(struct rchan *chan, · line 681
Quoted 12 lines
kernel/relay.c +5
-0+if (WARN_ON (dentry)) + goto free_buf; } buf->cpu = cpu;@@ -666,6 +676,27 @@ int relay_late_setup_files(struct rchan *chan, } chan->has_base_filename =1 ; chan->parent = parent; + +if (chan->is_global) { +if (unlikely (!chan->buf[0 ])) {
if (WARN_ON_ONCE(!chan->buf[0])) {
kernel/relay.c int relay_late_setup_files(struct rchan *chan, · line 682
Quoted 1 line
kernel/relay.c +1
-0+WARN_ONCE (1 ,KERN_ERR "CPU 0 has no buffer!\n" );
The WARN includes the unlikely and the message here isn't any more informative than the line itself, plus has the erroneous KERN_ERR
kernel/relay.c int relay_late_setup_files(struct rchan *chan, · line 691
Quoted 9 lines
kernel/relay.c +9
-0+mutex_unlock (&relay_channels_mutex); +return -EINVAL ; + } + + dentry =relay_create_buf_file (chan, chan->buf[0 ],0 ); + +if (unlikely (!dentry)) + err = -EINVAL ; +else if (WARN_ON (!chan->is_global))
?
kernel/relay.c int relay_late_setup_files(struct rchan *chan, · line 697
Quoted 6 lines
kernel/relay.c +6
-0+ err = -EINVAL ; + else + relay_set_buf_dentry(chan->buf[0], dentry); + +mutex_unlock (&relay_channels_mutex); +return err;
This could be written:
if (chan->is_global) {
err = -EINVAL;
if (!WARN_ON_ONCE(!chan->buf[0])) {
dentry = relay_create_buf_file(chan, chan->buf[0], 0))
if (dentry) {
relay_set_buf_dentry(chan->buf[0], dentry);
err = 0;
}
}
mutex_unlock();
return err;
}for a single exit/unlock path in this block.
-Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Quoted 38 lines · Chris Wilson
Quoted 30 lines · On Sun, Jul 03, 2016 at 09:45:27PM +0530, [email protected] wrote:
From: Akash Goel <[email protected]>
The following patch added support to use channels with no associated files.
relay: add buffer-only channels; useful for early logging
This is useful when the exact location of relay file is not known or the the parent directory of relay file is not available, while creating the channel and the logging has to start right from the boot.But there was no provision to use global mode with buffer-only channels, which is added by this patch, without modifying the interface where initially there will be a dummy invocation of
create_buf_filecallback through which kernel client can convey the need of a global buffer.For the use case where
drivers/kernelclients want a simple interface for the userspace, which enables them to capture data/logs from relay file in order & without any post processing, support of Global buffer mode is warranted.Cc Eduard - Gabriel Munteanu <[email protected]>Cc Tom Zanussi <[email protected]>Cc Chris Wilson <[email protected]>Signed-off-by Akash Goel <[email protected]>--- kernel/relay.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)kernel/relay.c +0
-0kernel/relay.c static struct rchan_buf *relay_open_buf(struct rchan *chan, unsigned int cpu) · line 454
Quoted 4 lines
kernel/relay.c +1
-0@@ -451,6 +451,16 @@ static struct rchan_buf *relay_open_buf(struct rchan *chan, unsigned int cpu)if (!dentry) goto free_buf;relay_set_buf_dentry (buf, dentry); + }else {The trailing block can be replaced with:
Quoted 2 lines
/* Only retrieve global info, nothing more, nothing less */
Thanks, will do like this.
Quoted 21 lines
kernel/relay.c static struct rchan_buf *relay_open_buf(struct rchan *chan, unsigned int cpu) · line 457
Quoted 3 lines
kernel/relay.c +3
-0+ dentry = chan->cb->create_buf_file (NULL ,NULL , +S_IRUSR , buf, + &chan->is_global);Watch alignment, align to the opening bracket.
kernel/relay.c int relay_late_setup_files(struct rchan *chan, · line 681
Quoted 12 lines
kernel/relay.c +5
-0+if (WARN_ON (dentry)) + goto free_buf; } buf->cpu = cpu;@@ -666,6 +676,27 @@ int relay_late_setup_files(struct rchan *chan, } chan->has_base_filename =1 ; chan->parent = parent; + +if (chan->is_global) { +if (unlikely (!chan->buf[0 ])) {if (
WARN_ON_ONCE(!chan->buf[0])) {
Quoted 5 lines
kernel/relay.c int relay_late_setup_files(struct rchan *chan, · line 682
Quoted 1 line
kernel/relay.c +1
-0+WARN_ONCE (1 ,KERN_ERR "CPU 0 has no buffer!\n" );The WARN includes the unlikely and the message here isn't any more informative than the line itself, plus has the erroneous
KERN_ERR
Thanks will combine the WARN and if check.
Quoted 12 lines
kernel/relay.c int relay_late_setup_files(struct rchan *chan, · line 691
Quoted 9 lines
kernel/relay.c +9
-0+mutex_unlock (&relay_channels_mutex); +return -EINVAL ; + } + + dentry =relay_create_buf_file (chan, chan->buf[0 ],0 ); + +if (unlikely (!dentry)) + err = -EINVAL ; +else if (WARN_ON (!chan->is_global))?
Though have checked 'is_global' value before, but can't rule out the clients toggling its value (inadvertently or maliciously).
Actually create_buf_file() callback will be invoked again from therelay_create_buf_file() and pointer of 'chan->is_global' is passed in
that.
So to be on safer side, thought to validate the 'chan->is_global' value after the call to relay_create_buf_file().
Quoted 9 lines
kernel/relay.c int relay_late_setup_files(struct rchan *chan, · line 697
Quoted 6 lines
kernel/relay.c +6
-0+ err = -EINVAL ; + else + relay_set_buf_dentry(chan->buf[0], dentry); + +mutex_unlock (&relay_channels_mutex); +return err;This could be written:
Thanks this is much better.
Best Regards
Akash
Quoted 16 lines
if (chan->is_global) { err = -EINVAL; if (!WARN_ON_ONCE(!chan->buf[0])) { dentry = relay_create_buf_file(chan, chan->buf[0], 0)) if (dentry) { relay_set_buf_dentry(chan->buf[0], dentry); err = 0; } } mutex_unlock(); return err; }for a single exit/unlock path in this block.
-Chris
PATCH v2 1/1 relay: Add global mode support for buffer-only channels
From: Akash Goel <[email protected]>
The following patch added support to use channels with no associated files.
relay: add buffer-only channels; useful for early logging
This is useful when the exact location of relay file is not known or the the parent directory of relay file is not available, while creating the channel and the logging has to start right from the boot.
But there was no provision to use global mode with buffer-only channels, which is added by this patch, without modifying the interface where initially there will be a dummy invocation of create_buf_file callback through which kernel client can convey the need of a global buffer.
For the use case where drivers/kernel clients want a simple interface for the userspace, which enables them to capture data/logs from relay file in order & without any post processing, support of Global buffer mode is warranted.
v2: Minor refactoring of code & rephrase the comment to be succinct. (Chris)
--- kernel/relay.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
kernel/relay.c +22 -0
@@ -451,6 +451,13 @@ static struct rchan_buf *relay_open_buf(struct rchan *chan, unsigned int cpu)if (!dentry) goto free_buf;relay_set_buf_dentry (buf, dentry); + }else { +/* Only retrieve global info, nothing more, nothing less */ + dentry = chan->cb->create_buf_file (NULL ,NULL , +S_IRUSR , buf, + &chan->is_global); +if (WARN_ON (dentry)) + goto free_buf; } buf->cpu = cpu;
@@ -666,6 +673,20 @@ int relay_late_setup_files(struct rchan *chan, } chan->has_base_filename =1 ; chan->parent = parent; + +if (chan->is_global) { + err = -EINVAL ; +if (!WARN_ON_ONCE (!chan->buf[0 ])) { + dentry =relay_create_buf_file (chan, chan->buf[0 ],0 ); +if (dentry && !WARN_ON_ONCE (!chan->is_global)) { +relay_set_buf_dentry (chan->buf[0 ], dentry); + err =0 ; + } + } +mutex_unlock (&relay_channels_mutex); +return err; + } + curr_cpu =get_cpu ();/* * The CPU hotplug notifier ran before us and created buffers with
@@ -706,6 +727,7 @@ int relay_late_setup_files(struct rchan *chan,return err; } +EXPORT_SYMBOL_GPL (relay_late_setup_files);/** * relay_switch_subbuf - switch to a new sub-buffer
Signature · 1 line
1.9.2
Andrew Morton
maintainerQuoted 4 lines · On Mon, 11 Jul 2016 12:47:36 +0530 [email protected] wrote:
From: Akash Goel <[email protected]>
The following patch added support to use channels with no associated files.
relay: add buffer-only channels; useful for early logging
hm, 8 years ago. Normally we refer to previous commits using the form 20d8b67c06fa5e74f44e ("relay: add buffer-only channels; useful for early logging"). But this one is so old that we should inform readers about its vintage, so this form:
commit 20d8b67c06fa5e74f44e80b0a0fd68c8327f7c6a
Author: Eduard - Gabriel Munteanu <[email protected]> Date: Fri Jul 25 19:45:12 2008 -0700
relay: add buffer-only channels; useful for early logging
would be better.
Quoted 16 lines
This is useful when the exact location of relay file is not known or the the parent directory of relay file is not available, while creating the channel and the logging has to start right from the boot.
But there was no provision to use global mode with buffer-only channels, which is added by this patch, without modifying the interface where initially there will be a dummy invocation of
create_buf_filecallback through which kernel client can convey the need of a global buffer.For the use case where
drivers/kernelclients want a simple interface for the userspace, which enables them to capture data/logs from relay file in order & without any post processing, support of Global buffer mode is warranted....
kernel/relay.c int relay_late_setup_files(struct rchan *chan, · line 730
Quoted 4 lines
kernel/relay.c +1
-0@@ -706,6 +727,7 @@ int relay_late_setup_files(struct rchan *chan,return err; } +EXPORT_SYMBOL_GPL (relay_late_setup_files);
The export is unneeded and undocumented.
Quoted 35 lines · Andrew Morton
Quoted 4 lines · On Mon, 11 Jul 2016 12:47:36 +0530 [email protected] wrote:
From: Akash Goel <[email protected]>
The following patch added support to use channels with no associated files.
relay: add buffer-only channels; useful for early logginghm, 8 years ago. Normally we refer to previous commits using the form
20d8b67c06fa5e74f44e("relay: add buffer-only channels; useful for early logging"). But this one is so old that we should inform readers about its vintage, so this form:commit
20d8b67c06fa5e74f44e80b0a0fd68c8327f7c6aAuthor: Eduard - Gabriel Munteanu <[email protected]> Date: Fri Jul 25 19:45:12 2008 -0700relay: add buffer-only channels; useful for early logging
would be better.
Quoted 15 lines
This is useful when the exact location of relay file is not known or the the parent directory of relay file is not available, while creating the channel and the logging has to start right from the boot.
But there was no provision to use global mode with buffer-only channels, which is added by this patch, without modifying the interface where initially there will be a dummy invocation of
create_buf_filecallback through which kernel client can convey the need of a global buffer.For the use case where
drivers/kernelclients want a simple interface for the userspace, which enables them to capture data/logs from relay file in order & without any post processing, support of Global buffer mode is warranted....
Quoted 7 lines
Review int relay_late_setup_files(struct rchan *chan, · line 730
Quoted 5 lines
(quoted diff) +1
-0@@ -706,6 +727,7 @@ int relay_late_setup_files(struct rchan *chan, return err; } +EXPORT_SYMBOL_GPL(relay_late_setup_files);The export is unneeded and undocumented.
Something like:
kernel/relay.c +10 -2
@@ -562,6 +562,10 @@ static int relay_hotcpu_callback(struct notifier_block *nb,* attributes specified. The created channel buffer files * will be named base_filename0...base_filenameN-1. File * permissions will be %S_IRUSR. +* +* If opening a buffer (@parent = NULL) that you later wish to register +* in a filesystem, call relay_late_setup_files() once the @parent dentry +* is available. */ struct rchan *relay_open(const char *base_filename, struct dentry *parent,
@@ -640,8 +644,12 @@ static void __relay_set_buf_dentry(void *info)* * Returns 0 if successful, non-zero otherwise. * -* Use to setup files for a previously buffer-only channel. -* Useful to do early tracing in kernel, before VFS is up, for example. +* Use to setup files for a previously buffer-only channel created +* by relay_open() with a NULL parent dentry. +* +* For example, this is useful for perfomring early tracing in kernel, +* before VFS is up and then exposing the early results once the dentry +* is available. */ int relay_late_setup_files(struct rchan *chan, const char *base_filename,
with a comment in the changelog that modules using relay_open() in early init also want to later register their buffer-only relays once debugfs is available, e.g. i915.
-Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Quoted 78 lines · Chris Wilson
Quoted 35 lines · Andrew Morton
Quoted 4 lines · On Mon, 11 Jul 2016 12:47:36 +0530 [email protected] wrote:
From: Akash Goel <[email protected]>
The following patch added support to use channels with no associated files.
relay: add buffer-only channels; useful for early logginghm, 8 years ago. Normally we refer to previous commits using the form
20d8b67c06fa5e74f44e("relay: add buffer-only channels; useful for early logging"). But this one is so old that we should inform readers about its vintage, so this form:commit
20d8b67c06fa5e74f44e80b0a0fd68c8327f7c6aAuthor: Eduard - Gabriel Munteanu <[email protected]> Date: Fri Jul 25 19:45:12 2008 -0700relay: add buffer-only channels; useful for early logging
would be better.
Quoted 15 lines
This is useful when the exact location of relay file is not known or the the parent directory of relay file is not available, while creating the channel and the logging has to start right from the boot.
But there was no provision to use global mode with buffer-only channels, which is added by this patch, without modifying the interface where initially there will be a dummy invocation of
create_buf_filecallback through which kernel client can convey the need of a global buffer.For the use case where
drivers/kernelclients want a simple interface for the userspace, which enables them to capture data/logs from relay file in order & without any post processing, support of Global buffer mode is warranted....
Quoted 7 lines
Review int relay_late_setup_files(struct rchan *chan, · line 730
Quoted 5 lines
(quoted diff) +1
-0@@ -706,6 +727,7 @@ int relay_late_setup_files(struct rchan *chan, return err; } +EXPORT_SYMBOL_GPL(relay_late_setup_files);The export is unneeded and undocumented.
Something like:
kernel/relay.c +10
-2@@ -562,6 +562,10 @@ static int relay_hotcpu_callback(struct notifier_block *nb,* attributes specified. The created channel buffer files * will be named base_filename0...base_filenameN-1. File * permissions will be %S_IRUSR. +* +* If opening a buffer (@parent = NULL) that you later wish to register +* in a filesystem, call relay_late_setup_files() once the @parent dentry +* is available. */ struct rchan *relay_open(const char *base_filename, struct dentry *parent,@@ -640,8 +644,12 @@ static void __relay_set_buf_dentry(void *info)* * Returns 0 if successful, non-zero otherwise. * -* Use to setup files for a previously buffer-only channel. -* Useful to do early tracing in kernel, before VFS is up, for example. +* Use to setup files for a previously buffer-only channel created +* by relay_open() with a NULL parent dentry. +* +* For example, this is useful for perfomring early tracing in kernel, +* before VFS is up and then exposing the early results once the dentry +* is available. */ int relay_late_setup_files(struct rchan *chan, const char *base_filename,
Quoted 3 lines
with a comment in the changelog that modules using
relay_open()in early init also want to later register their buffer-only relays once debugfs is available, e.g. i915.
Thanks much, will update the documentation as well as the changelog as per the above.
But an export of symbol relay_late_setup_files() is still needed, just like relay_open() is exported, in order to make it accessible to modules like i915 ?
Best regards
Akash
Quoted 2 lines
-Chris
Quoted 6 lines · Akash
Thanks much, will update the documentation as well as the changelog as per the above.
But an export of symbol
relay_late_setup_files()is still needed, just likerelay_open()is exported, in order to make it accessible to modules like i915 ?
Yes, we need the companion function in i915.ko. That needs to be explained in the patch notes to justify adding the EXPORT_SYMBOL. Otherwise without that context, it looks unnecessary as Andrew objected to.
-Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Quoted 4 lines · Chris Wilson
Quoted 3 lines · Akash
Thanks much, will update the documentation as well as the changelog as per the above.
Quoted 8 lines
Quoted 3 lines
But an export of symbol
relay_late_setup_files()is still needed, just likerelay_open()is exported, in order to make it accessible to modules like i915 ?Yes, we need the companion function in i915.ko. That needs to be explained in the patch notes to justify adding the
EXPORT_SYMBOL. Otherwise without that context, it looks unnecessary as Andrew objected to.
Won't your suggested updates to Documentation & changelog suffice ?. relay_late_setup_files() is to be used in conjunction with relay_open(), hence need to be exported.
Do I also need to provide the corresponding i915 patch, which has a call to relay_late_setup_files() ?
Best regards
Akash
Quoted 2 lines
-Chris
Andrew Morton
maintainerQuoted 16 lines · Akash
Quoted 4 lines · Chris Wilson
Quoted 3 lines · Akash
Thanks much, will update the documentation as well as the changelog as per the above.
Quoted 8 lines
Quoted 3 lines
But an export of symbol
relay_late_setup_files()is still needed, just likerelay_open()is exported, in order to make it accessible to modules like i915 ?Yes, we need the companion function in i915.ko. That needs to be explained in the patch notes to justify adding the
EXPORT_SYMBOL. Otherwise without that context, it looks unnecessary as Andrew objected to.
Quoted 6 lines
Won't your suggested updates to Documentation & changelog suffice ?.
relay_late_setup_files()is to be used in conjunction withrelay_open(), hence need to be exported.Do I also need to provide the corresponding i915 patch, which has a call to
relay_late_setup_files()?
No, as long as i915 people promise to use the export, a note in the changelog is sufficient.
PATCH v3 1/1 relay: Add global mode support for buffer-only channels
From: Akash Goel <[email protected]>
The following patch added support to use channels with no associated files.
commit 20d8b67c06fa5e74f44e80b0a0fd68c8327f7c6a Author: Eduard - Gabriel Munteanu <[email protected]> Date: Fri Jul 25 19:45:12 2008 -0700 relay: add buffer-only channels; useful for early logging
This is useful when the exact location of relay file is not known or the the parent directory of relay file is not available, while creating the channel and the logging has to start right from the boot.
But there was no provision to use global mode with buffer-only channels, which is added by this patch, without modifying the interface where initially there will be a dummy invocation of create_buf_file callback through which kernel client can convey the need of a global buffer.
For the use case where drivers/kernel clients want a simple interface for the userspace, which enables them to capture data/logs from relay file inorder & without any post processing, support of Global buffer mode is warranted.
Modules, like i915, using relay_open() in early init would have to later register their buffer-only relays, once debugfs is available, by calling relay_late_setup_files(). Hence relay_late_setup_files() symbol also needs to be exported.
v2: Minor refactoring of code & rephrase the comment to be succinct. (Chris)
v3:
- Update the documentation & changelog to clarify about the need for exporting of relay_late_setup_files() symbol. (Chris)
- Elaborate the description of the parent patch. (Andrew)
--- kernel/relay.c | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-)
kernel/relay.c +32 -2
@@ -451,6 +451,13 @@ static struct rchan_buf *relay_open_buf(struct rchan *chan, unsigned int cpu)if (!dentry) goto free_buf;relay_set_buf_dentry (buf, dentry); + }else { +/* Only retrieve global info, nothing more, nothing less */ + dentry = chan->cb->create_buf_file (NULL ,NULL , +S_IRUSR , buf, + &chan->is_global); +if (WARN_ON (dentry)) + goto free_buf; } buf->cpu = cpu;
@@ -562,6 +569,10 @@ static int relay_hotcpu_callback(struct notifier_block *nb,* attributes specified. The created channel buffer files * will be named base_filename0...base_filenameN-1. File * permissions will be %S_IRUSR. + +* If opening a buffer (@parent = NULL) that you later wish to register +* in a filesystem, call relay_late_setup_files() once the @parent dentry +* is available. */ struct rchan *relay_open(const char *base_filename, struct dentry *parent,
@@ -640,8 +651,12 @@ static void __relay_set_buf_dentry(void *info)* * Returns 0 if successful, non-zero otherwise. * -* Use to setup files for a previously buffer-only channel. -* Useful to do early tracing in kernel, before VFS is up, for example. +* Use to setup files for a previously buffer-only channel created +* by relay_open() with a NULL parent dentry. +* +* For example, this is useful for perfomring early tracing in kernel, +* before VFS is up and then exposing the early results once the dentry +* is available. */ int relay_late_setup_files(struct rchan *chan, const char *base_filename,
@@ -666,6 +681,20 @@ int relay_late_setup_files(struct rchan *chan, } chan->has_base_filename =1 ; chan->parent = parent; + +if (chan->is_global) { + err = -EINVAL ; +if (!WARN_ON_ONCE (!chan->buf[0 ])) { + dentry =relay_create_buf_file (chan, chan->buf[0 ],0 ); +if (dentry && !WARN_ON_ONCE (!chan->is_global)) { +relay_set_buf_dentry (chan->buf[0 ], dentry); + err =0 ; + } + } +mutex_unlock (&relay_channels_mutex); +return err; + } + curr_cpu =get_cpu ();/* * The CPU hotplug notifier ran before us and created buffers with
@@ -706,6 +735,7 @@ int relay_late_setup_files(struct rchan *chan,return err; } +EXPORT_SYMBOL_GPL (relay_late_setup_files);/** * relay_switch_subbuf - switch to a new sub-buffer
Signature · 1 line
1.9.2
kbuild test robot
build boturl: https://github.com/0day-ci/linux/commits/akash-goel-intel-com/relay-Add-global-mode-support-for-buffer-only-channels/20160713-153432 reproduce: make htmldocs
Hi,
[auto build test WARNING on v4.7-rc7]
[also build test WARNING on next-20160712]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/akash-goel-intel-com/relay-Add-global-mode-support-for-buffer-only-channels/20160713-153432
reproduce: make htmldocs
All warnings (new ones prefixed by >>):
lib/crc32.c:148: warning: No description found for parameter 'tab)[256]' lib/crc32.c:148: warning: Excess function parameter 'tab' description in 'crc32_le_generic' lib/crc32.c:293: warning: No description found for parameter 'tab)[256]' lib/crc32.c:293: warning: Excess function parameter 'tab' description in 'crc32_be_generic' lib/crc32.c:1: warning: no structured comments found
>> kernel/relay.c:572: warning: bad line: >> kernel/relay.c:572: warning: bad line:
vim +572 kernel/relay.c
556
557 /**
558 * relay_open - create a new relay channel
559 * @base_filename: base name of files to create, %NULL for buffering only
560 * @parent: dentry of parent directory, %NULL for root directory or buffer
561 * @subbuf_size: size of sub-buffers
562 * @n_subbufs: number of sub-buffers
563 * @cb: client callback functions
564 * @private_data: user-defined data
565 *
566 * Returns channel pointer if successful, %NULL otherwise.
567 *
568 * Creates a channel buffer for each cpu using the sizes and
569 * attributes specified. The created channel buffer files
570 * will be named base_filename0...base_filenameN-1. File
571 * permissions will be %S_IRUSR.
> 572
573 * If opening a buffer (@parent = NULL) that you later wish to register
574 * in a filesystem, call relay_late_setup_files() once the @parent dentry
575 * is available.
576 */
577 struct rchan *relay_open(const char *base_filename,
578 struct dentry *parent,
579 size_t subbuf_size,
580 size_t n_subbufs,
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
PATCH v4 1/1 relay: Add global mode support for buffer-only channels
From: Akash Goel <[email protected]>
The following patch added support to use channels with no associated files.
commit 20d8b67c06fa5e74f44e80b0a0fd68c8327f7c6a Author: Eduard - Gabriel Munteanu <[email protected]> Date: Fri Jul 25 19:45:12 2008 -0700 relay: add buffer-only channels; useful for early logging
This is useful when the exact location of relay file is not known or the the parent directory of relay file is not available, while creating the channel and the logging has to start right from the boot.
But there was no provision to use global mode with buffer-only channels, which is added by this patch, without modifying the interface where initially there will be a dummy invocation of create_buf_file callback through which kernel client can convey the need of a global buffer.
For the use case where drivers/kernel clients want a simple interface for the userspace, which enables them to capture data/logs from relay file inorder & without any post processing, support of Global buffer mode is warranted.
Modules, like i915, using relay_open() in early init would have to later register their buffer-only relays, once debugfs is available, by calling relay_late_setup_files(). Hence relay_late_setup_files() symbol also needs to be exported.
v2: Minor refactoring of code & rephrase the comment to be succinct. (Chris)
v3:
- Update the documentation & changelog to clarify about the need for exporting of relay_late_setup_files() symbol. (Chris)
- Elaborate the description of the parent patch. (Andrew)
v4: Fix the bad line warning issue with multi line comments.
--- kernel/relay.c | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-)
kernel/relay.c +32 -2
@@ -451,6 +451,13 @@ static struct rchan_buf *relay_open_buf(struct rchan *chan, unsigned int cpu)if (!dentry) goto free_buf;relay_set_buf_dentry (buf, dentry); + }else { +/* Only retrieve global info, nothing more, nothing less */ + dentry = chan->cb->create_buf_file (NULL ,NULL , +S_IRUSR , buf, + &chan->is_global); +if (WARN_ON (dentry)) + goto free_buf; } buf->cpu = cpu;
@@ -562,6 +569,10 @@ static int relay_hotcpu_callback(struct notifier_block *nb,* attributes specified. The created channel buffer files * will be named base_filename0...base_filenameN-1. File * permissions will be %S_IRUSR. +* +* If opening a buffer (@parent = NULL) that you later wish to register +* in a filesystem, call relay_late_setup_files() once the @parent dentry +* is available. */ struct rchan *relay_open(const char *base_filename, struct dentry *parent,
@@ -640,8 +651,12 @@ static void __relay_set_buf_dentry(void *info)* * Returns 0 if successful, non-zero otherwise. * -* Use to setup files for a previously buffer-only channel. -* Useful to do early tracing in kernel, before VFS is up, for example. +* Use to setup files for a previously buffer-only channel created +* by relay_open() with a NULL parent dentry. +* +* For example, this is useful for perfomring early tracing in kernel, +* before VFS is up and then exposing the early results once the dentry +* is available. */ int relay_late_setup_files(struct rchan *chan, const char *base_filename,
@@ -666,6 +681,20 @@ int relay_late_setup_files(struct rchan *chan, } chan->has_base_filename =1 ; chan->parent = parent; + +if (chan->is_global) { + err = -EINVAL ; +if (!WARN_ON_ONCE (!chan->buf[0 ])) { + dentry =relay_create_buf_file (chan, chan->buf[0 ],0 ); +if (dentry && !WARN_ON_ONCE (!chan->is_global)) { +relay_set_buf_dentry (chan->buf[0 ], dentry); + err =0 ; + } + } +mutex_unlock (&relay_channels_mutex); +return err; + } + curr_cpu =get_cpu ();/* * The CPU hotplug notifier ran before us and created buffers with
@@ -706,6 +735,7 @@ int relay_late_setup_files(struct rchan *chan,return err; } +EXPORT_SYMBOL_GPL (relay_late_setup_files);/** * relay_switch_subbuf - switch to a new sub-buffer
Signature · 1 line
1.9.2