Skip to content

Commit 2a1c615

Browse files
Dr. David Alan Gilbertakpm00
authored andcommitted
relay: remove unused relay_late_setup_files
The last use of relay_late_setup_files() was removed in 2018 by commit 2b47733 ("drm/i915/guc: Merge log relay file and channel creation") Remove it and the helper it used. relay_late_setup_files() was used for eventually registering 'buffer only' channels. With it gone, delete the docs that explain how to do that. Which suggests it should be possible to lose the 'has_base_filename' flags. (Are there any other uses??) Link: https://lkml.kernel.org/r/20250418234932.490863-1-linux@treblig.org Signed-off-by: Dr. David Alan Gilbert <linux@treblig.org> Reviewed-by: Jens Axboe <axboe@kernel.dk> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Andriy Shevchenko <andriy.shevchenko@linux.intel.com> Cc: Jonathan Corbet <corbet@lwn.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent ba8182d commit 2a1c615

File tree

3 files changed

+1
-123
lines changed

3 files changed

+1
-123
lines changed

Documentation/filesystems/relay.rst

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -301,16 +301,6 @@ user-defined data with a channel, and is immediately available
301301
(including in create_buf_file()) via chan->private_data or
302302
buf->chan->private_data.
303303

304-
Buffer-only channels
305-
--------------------
306-
307-
These channels have no files associated and can be created with
308-
relay_open(NULL, NULL, ...). Such channels are useful in scenarios such
309-
as when doing early tracing in the kernel, before the VFS is up. In these
310-
cases, one may open a buffer-only channel and then call
311-
relay_late_setup_files() when the kernel is ready to handle files,
312-
to expose the buffered data to the userspace.
313-
314304
Channel 'modes'
315305
---------------
316306

include/linux/relay.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,6 @@ struct rchan *relay_open(const char *base_filename,
159159
size_t n_subbufs,
160160
const struct rchan_callbacks *cb,
161161
void *private_data);
162-
extern int relay_late_setup_files(struct rchan *chan,
163-
const char *base_filename,
164-
struct dentry *parent);
165162
extern void relay_close(struct rchan *chan);
166163
extern void relay_flush(struct rchan *chan);
167164
extern void relay_subbufs_consumed(struct rchan *chan,

kernel/relay.c

Lines changed: 1 addition & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ int relay_prepare_cpu(unsigned int cpu)
452452

453453
/**
454454
* relay_open - create a new relay channel
455-
* @base_filename: base name of files to create, %NULL for buffering only
455+
* @base_filename: base name of files to create
456456
* @parent: dentry of parent directory, %NULL for root directory or buffer
457457
* @subbuf_size: size of sub-buffers
458458
* @n_subbufs: number of sub-buffers
@@ -465,10 +465,6 @@ int relay_prepare_cpu(unsigned int cpu)
465465
* attributes specified. The created channel buffer files
466466
* will be named base_filename0...base_filenameN-1. File
467467
* permissions will be %S_IRUSR.
468-
*
469-
* If opening a buffer (@parent = NULL) that you later wish to register
470-
* in a filesystem, call relay_late_setup_files() once the @parent dentry
471-
* is available.
472468
*/
473469
struct rchan *relay_open(const char *base_filename,
474470
struct dentry *parent,
@@ -540,111 +536,6 @@ struct rchan_percpu_buf_dispatcher {
540536
struct dentry *dentry;
541537
};
542538

543-
/* Called in atomic context. */
544-
static void __relay_set_buf_dentry(void *info)
545-
{
546-
struct rchan_percpu_buf_dispatcher *p = info;
547-
548-
relay_set_buf_dentry(p->buf, p->dentry);
549-
}
550-
551-
/**
552-
* relay_late_setup_files - triggers file creation
553-
* @chan: channel to operate on
554-
* @base_filename: base name of files to create
555-
* @parent: dentry of parent directory, %NULL for root directory
556-
*
557-
* Returns 0 if successful, non-zero otherwise.
558-
*
559-
* Use to setup files for a previously buffer-only channel created
560-
* by relay_open() with a NULL parent dentry.
561-
*
562-
* For example, this is useful for perfomring early tracing in kernel,
563-
* before VFS is up and then exposing the early results once the dentry
564-
* is available.
565-
*/
566-
int relay_late_setup_files(struct rchan *chan,
567-
const char *base_filename,
568-
struct dentry *parent)
569-
{
570-
int err = 0;
571-
unsigned int i, curr_cpu;
572-
unsigned long flags;
573-
struct dentry *dentry;
574-
struct rchan_buf *buf;
575-
struct rchan_percpu_buf_dispatcher disp;
576-
577-
if (!chan || !base_filename)
578-
return -EINVAL;
579-
580-
strscpy(chan->base_filename, base_filename, NAME_MAX);
581-
582-
mutex_lock(&relay_channels_mutex);
583-
/* Is chan already set up? */
584-
if (unlikely(chan->has_base_filename)) {
585-
mutex_unlock(&relay_channels_mutex);
586-
return -EEXIST;
587-
}
588-
chan->has_base_filename = 1;
589-
chan->parent = parent;
590-
591-
if (chan->is_global) {
592-
err = -EINVAL;
593-
buf = *per_cpu_ptr(chan->buf, 0);
594-
if (!WARN_ON_ONCE(!buf)) {
595-
dentry = relay_create_buf_file(chan, buf, 0);
596-
if (dentry && !WARN_ON_ONCE(!chan->is_global)) {
597-
relay_set_buf_dentry(buf, dentry);
598-
err = 0;
599-
}
600-
}
601-
mutex_unlock(&relay_channels_mutex);
602-
return err;
603-
}
604-
605-
curr_cpu = get_cpu();
606-
/*
607-
* The CPU hotplug notifier ran before us and created buffers with
608-
* no files associated. So it's safe to call relay_setup_buf_file()
609-
* on all currently online CPUs.
610-
*/
611-
for_each_online_cpu(i) {
612-
buf = *per_cpu_ptr(chan->buf, i);
613-
if (unlikely(!buf)) {
614-
WARN_ONCE(1, KERN_ERR "CPU has no buffer!\n");
615-
err = -EINVAL;
616-
break;
617-
}
618-
619-
dentry = relay_create_buf_file(chan, buf, i);
620-
if (unlikely(!dentry)) {
621-
err = -EINVAL;
622-
break;
623-
}
624-
625-
if (curr_cpu == i) {
626-
local_irq_save(flags);
627-
relay_set_buf_dentry(buf, dentry);
628-
local_irq_restore(flags);
629-
} else {
630-
disp.buf = buf;
631-
disp.dentry = dentry;
632-
smp_mb();
633-
/* relay_channels_mutex must be held, so wait. */
634-
err = smp_call_function_single(i,
635-
__relay_set_buf_dentry,
636-
&disp, 1);
637-
}
638-
if (unlikely(err))
639-
break;
640-
}
641-
put_cpu();
642-
mutex_unlock(&relay_channels_mutex);
643-
644-
return err;
645-
}
646-
EXPORT_SYMBOL_GPL(relay_late_setup_files);
647-
648539
/**
649540
* relay_switch_subbuf - switch to a new sub-buffer
650541
* @buf: channel buffer

0 commit comments

Comments
 (0)