Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1440306 > unrolled thread

[PATCH v2] relay: Add global mode support for buffer-only channels

Started byakash.goel@intel.com
First post2016-07-11 09:10 +0200
Last post2016-07-13 12:00 +0200
Articles 10 — 5 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v2] relay: Add global mode support for buffer-only channels akash.goel@intel.com - 2016-07-11 09:10 +0200
    Re: [PATCH v2] relay: Add global mode support for buffer-only  channels Andrew Morton <akpm@linux-foundation.org> - 2016-07-11 22:20 +0200
      Re: [PATCH v2] relay: Add global mode support for buffer-only  channels Chris Wilson <chris@chris-wilson.co.uk> - 2016-07-12 11:50 +0200
        Re: [PATCH v2] relay: Add global mode support for buffer-only  channels "Goel, Akash" <akash.goel@intel.com> - 2016-07-12 15:00 +0200
          Re: [PATCH v2] relay: Add global mode support for buffer-only  channels Chris Wilson <chris@chris-wilson.co.uk> - 2016-07-12 15:10 +0200
            Re: [PATCH v2] relay: Add global mode support for buffer-only  channels "Goel, Akash" <akash.goel@intel.com> - 2016-07-12 15:30 +0200
              Re: [PATCH v2] relay: Add global mode support for buffer-only  channels Andrew Morton <akpm@linux-foundation.org> - 2016-07-12 22:00 +0200
                [PATCH v3] relay: Add global mode support for buffer-only channels akash.goel@intel.com - 2016-07-13 09:30 +0200
                  Re: [PATCH v3] relay: Add global mode support for buffer-only  channels kbuild test robot <lkp@intel.com> - 2016-07-13 10:40 +0200
                    [PATCH v4] relay: Add global mode support for buffer-only channels akash.goel@intel.com - 2016-07-13 12:00 +0200

#1440306 — [PATCH v2] relay: Add global mode support for buffer-only channels

Fromakash.goel@intel.com
Date2016-07-11 09:10 +0200
Subject[PATCH v2] relay: Add global mode support for buffer-only channels
Message-ID<rTDvQ-3N4-27@gated-at.bofh.it>
From: Akash Goel <akash.goel@intel.com>

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)

Cc: Eduard - Gabriel Munteanu <eduard.munteanu@linux360.ro>
Cc: Tom Zanussi <tzanussi@gmail.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Akash Goel <akash.goel@intel.com>
---
 kernel/relay.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/kernel/relay.c b/kernel/relay.c
index 04d7cf3..92db973 100644
--- a/kernel/relay.c
+++ b/kernel/relay.c
@@ -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
-- 
1.9.2

[toc] | [next] | [standalone]


#1440857 — Re: [PATCH v2] relay: Add global mode support for buffer-only channels

FromAndrew Morton <akpm@linux-foundation.org>
Date2016-07-11 22:20 +0200
SubjectRe: [PATCH v2] relay: Add global mode support for buffer-only channels
Message-ID<rTPQm-3pU-15@gated-at.bofh.it>
In reply to#1440306
On Mon, 11 Jul 2016 12:47:36 +0530 akash.goel@intel.com wrote:

> From: Akash Goel <akash.goel@intel.com>
> 
> 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 <eduard.munteanu@linux360.ro>
Date:   Fri Jul 25 19:45:12 2008 -0700

    relay: add buffer-only channels; useful for early logging

would be better.

> 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.
>
> ...
>
> @@ -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.

[toc] | [prev] | [next] | [standalone]


#1441186 — Re: [PATCH v2] relay: Add global mode support for buffer-only channels

FromChris Wilson <chris@chris-wilson.co.uk>
Date2016-07-12 11:50 +0200
SubjectRe: [PATCH v2] relay: Add global mode support for buffer-only channels
Message-ID<rU2ue-37M-13@gated-at.bofh.it>
In reply to#1440857
On Mon, Jul 11, 2016 at 01:17:09PM -0700, Andrew Morton wrote:
> On Mon, 11 Jul 2016 12:47:36 +0530 akash.goel@intel.com wrote:
> 
> > From: Akash Goel <akash.goel@intel.com>
> > 
> > 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 <eduard.munteanu@linux360.ro>
> Date:   Fri Jul 25 19:45:12 2008 -0700
> 
>     relay: add buffer-only channels; useful for early logging
> 
> would be better.
> 
> > 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.
> >
> > ...
> >
> > @@ -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:

diff --git a/kernel/relay.c b/kernel/relay.c
index 04d7cf3ef8cf..fd86f01de4b2 100644
--- a/kernel/relay.c
+++ b/kernel/relay.c
@@ -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

-- 
Chris Wilson, Intel Open Source Technology Centre

[toc] | [prev] | [next] | [standalone]


#1441332 — Re: [PATCH v2] relay: Add global mode support for buffer-only channels

From"Goel, Akash" <akash.goel@intel.com>
Date2016-07-12 15:00 +0200
SubjectRe: [PATCH v2] relay: Add global mode support for buffer-only channels
Message-ID<rU5s6-51i-37@gated-at.bofh.it>
In reply to#1441186

On 7/12/2016 2:54 PM, Chris Wilson wrote:
> On Mon, Jul 11, 2016 at 01:17:09PM -0700, Andrew Morton wrote:
>> On Mon, 11 Jul 2016 12:47:36 +0530 akash.goel@intel.com wrote:
>>
>>> From: Akash Goel <akash.goel@intel.com>
>>>
>>> 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 <eduard.munteanu@linux360.ro>
>> Date:   Fri Jul 25 19:45:12 2008 -0700
>>
>>     relay: add buffer-only channels; useful for early logging
>>
>> would be better.
>>
>>> 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.
>>>
>>> ...
>>>
>>> @@ -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:
>
> diff --git a/kernel/relay.c b/kernel/relay.c
> index 04d7cf3ef8cf..fd86f01de4b2 100644
> --- a/kernel/relay.c
> +++ b/kernel/relay.c
> @@ -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.

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


> -Chris
>

[toc] | [prev] | [next] | [standalone]


#1441335 — Re: [PATCH v2] relay: Add global mode support for buffer-only channels

FromChris Wilson <chris@chris-wilson.co.uk>
Date2016-07-12 15:10 +0200
SubjectRe: [PATCH v2] relay: Add global mode support for buffer-only channels
Message-ID<rU5BM-5k0-49@gated-at.bofh.it>
In reply to#1441332
On Tue, Jul 12, 2016 at 06:20:06PM +0530, Goel, Akash wrote:
> 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 ?

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

-- 
Chris Wilson, Intel Open Source Technology Centre

[toc] | [prev] | [next] | [standalone]


#1441346 — Re: [PATCH v2] relay: Add global mode support for buffer-only channels

From"Goel, Akash" <akash.goel@intel.com>
Date2016-07-12 15:30 +0200
SubjectRe: [PATCH v2] relay: Add global mode support for buffer-only channels
Message-ID<rU5V7-5rJ-19@gated-at.bofh.it>
In reply to#1441335

On 7/12/2016 6:31 PM, Chris Wilson wrote:
> On Tue, Jul 12, 2016 at 06:20:06PM +0530, Goel, Akash wrote:
>> 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 ?
>
> 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

> -Chris
>

[toc] | [prev] | [next] | [standalone]


#1441694 — Re: [PATCH v2] relay: Add global mode support for buffer-only channels

FromAndrew Morton <akpm@linux-foundation.org>
Date2016-07-12 22:00 +0200
SubjectRe: [PATCH v2] relay: Add global mode support for buffer-only channels
Message-ID<rUc0x-10J-1@gated-at.bofh.it>
In reply to#1441346
On Tue, 12 Jul 2016 18:54:49 +0530 "Goel, Akash" <akash.goel@intel.com> wrote:

> 
> 
> On 7/12/2016 6:31 PM, Chris Wilson wrote:
> > On Tue, Jul 12, 2016 at 06:20:06PM +0530, Goel, Akash wrote:
> >> 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 ?
> >
> > 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() ?

No, as long as i915 people promise to use the export, a note in the
changelog is sufficient.

[toc] | [prev] | [next] | [standalone]


#1442095 — [PATCH v3] relay: Add global mode support for buffer-only channels

Fromakash.goel@intel.com
Date2016-07-13 09:30 +0200
Subject[PATCH v3] relay: Add global mode support for buffer-only channels
Message-ID<rUmMi-8ia-21@gated-at.bofh.it>
In reply to#1441694
From: Akash Goel <akash.goel@intel.com>

The following patch added support to use channels with no associated files.
	commit 20d8b67c06fa5e74f44e80b0a0fd68c8327f7c6a
	Author: Eduard - Gabriel Munteanu <eduard.munteanu@linux360.ro>
	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)

Cc: Eduard - Gabriel Munteanu <eduard.munteanu@linux360.ro>
Cc: Tom Zanussi <tzanussi@gmail.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Akash Goel <akash.goel@intel.com>
---
 kernel/relay.c | 34 ++++++++++++++++++++++++++++++++--
 1 file changed, 32 insertions(+), 2 deletions(-)

diff --git a/kernel/relay.c b/kernel/relay.c
index 04d7cf3..000c7bc 100644
--- a/kernel/relay.c
+++ b/kernel/relay.c
@@ -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
-- 
1.9.2

[toc] | [prev] | [next] | [standalone]


#1442174 — Re: [PATCH v3] relay: Add global mode support for buffer-only channels

Fromkbuild test robot <lkp@intel.com>
Date2016-07-13 10:40 +0200
SubjectRe: [PATCH v3] relay: Add global mode support for buffer-only channels
Message-ID<rUnS2-vb-9@gated-at.bofh.it>
In reply to#1442095

[Multipart message — attachments visible in raw view] — view raw

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

[toc] | [prev] | [next] | [standalone]


#1442279 — [PATCH v4] relay: Add global mode support for buffer-only channels

Fromakash.goel@intel.com
Date2016-07-13 12:00 +0200
Subject[PATCH v4] relay: Add global mode support for buffer-only channels
Message-ID<rUp7s-1hq-15@gated-at.bofh.it>
In reply to#1442174
From: Akash Goel <akash.goel@intel.com>

The following patch added support to use channels with no associated files.
	commit 20d8b67c06fa5e74f44e80b0a0fd68c8327f7c6a
	Author: Eduard - Gabriel Munteanu <eduard.munteanu@linux360.ro>
	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.

Cc: Eduard - Gabriel Munteanu <eduard.munteanu@linux360.ro>
Cc: Tom Zanussi <tzanussi@gmail.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Akash Goel <akash.goel@intel.com>
---
 kernel/relay.c | 34 ++++++++++++++++++++++++++++++++--
 1 file changed, 32 insertions(+), 2 deletions(-)

diff --git a/kernel/relay.c b/kernel/relay.c
index 04d7cf3..d797502 100644
--- a/kernel/relay.c
+++ b/kernel/relay.c
@@ -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
-- 
1.9.2

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web