Skip to content

Commit 2489e95

Browse files
JasonXingakpm00
authored andcommitted
relayfs: abolish prev_padding
Patch series "relayfs: misc changes", v5. The series mostly focuses on the error counters which helps every user debug their own kernel module. This patch (of 5): prev_padding represents the unused space of certain subbuffer. If the content of a call of relay_write() exceeds the limit of the remainder of this subbuffer, it will skip storing in the rest space and record the start point as buf->prev_padding in relay_switch_subbuf(). Since the buf is a per-cpu big buffer, the point of prev_padding as a global value for the whole buffer instead of a single subbuffer (whose padding info is stored in buf->padding[]) seems meaningless from the real use cases, so we don't bother to record it any more. Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Jason Xing <[email protected]> Reviewed-by: Yushan Zhou <[email protected]> Reviewed-by: Masami Hiramatsu (Google) <[email protected]> Cc: Jens Axboe <[email protected]> Cc: Mathieu Desnoyers <[email protected]> Cc: Steven Rostedt <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent c9e3fb0 commit 2489e95

File tree

6 files changed

+13
-16
lines changed

6 files changed

+13
-16
lines changed

drivers/gpu/drm/i915/gt/uc/intel_guc_log.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,7 @@ static int guc_action_control_log(struct intel_guc *guc, bool enable,
220220
*/
221221
static int subbuf_start_callback(struct rchan_buf *buf,
222222
void *subbuf,
223-
void *prev_subbuf,
224-
size_t prev_padding)
223+
void *prev_subbuf)
225224
{
226225
/*
227226
* Use no-overwrite mode by default, where relay will stop accepting

drivers/net/wwan/iosm/iosm_ipc_trace.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ static int ipc_trace_remove_buf_file_handler(struct dentry *dentry)
5151
}
5252

5353
static int ipc_trace_subbuf_start_handler(struct rchan_buf *buf, void *subbuf,
54-
void *prev_subbuf,
55-
size_t prev_padding)
54+
void *prev_subbuf)
5655
{
5756
if (relay_buf_full(buf)) {
5857
pr_err_ratelimited("Relay_buf full dropping traces");

drivers/net/wwan/t7xx/t7xx_port_trace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ static int t7xx_trace_remove_buf_file_handler(struct dentry *dentry)
3333
}
3434

3535
static int t7xx_trace_subbuf_start_handler(struct rchan_buf *buf, void *subbuf,
36-
void *prev_subbuf, size_t prev_padding)
36+
void *prev_subbuf)
3737
{
3838
if (relay_buf_full(buf)) {
3939
pr_err_ratelimited("Relay_buf full dropping traces");

include/linux/relay.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ struct rchan_buf
4747
unsigned int page_count; /* number of current buffer pages */
4848
unsigned int finalized; /* buffer has been finalized */
4949
size_t *padding; /* padding counts per sub-buffer */
50-
size_t prev_padding; /* temporary variable */
5150
size_t bytes_consumed; /* bytes consumed in cur read subbuf */
5251
size_t early_bytes; /* bytes consumed before VFS inited */
5352
unsigned int cpu; /* this buf's cpu */
@@ -84,7 +83,6 @@ struct rchan_callbacks
8483
* @buf: the channel buffer containing the new sub-buffer
8584
* @subbuf: the start of the new sub-buffer
8685
* @prev_subbuf: the start of the previous sub-buffer
87-
* @prev_padding: unused space at the end of previous sub-buffer
8886
*
8987
* The client should return 1 to continue logging, 0 to stop
9088
* logging.
@@ -100,8 +98,7 @@ struct rchan_callbacks
10098
*/
10199
int (*subbuf_start) (struct rchan_buf *buf,
102100
void *subbuf,
103-
void *prev_subbuf,
104-
size_t prev_padding);
101+
void *prev_subbuf);
105102

106103
/*
107104
* create_buf_file - create file to represent a relay channel buffer

kernel/relay.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -249,13 +249,13 @@ EXPORT_SYMBOL_GPL(relay_buf_full);
249249
*/
250250

251251
static int relay_subbuf_start(struct rchan_buf *buf, void *subbuf,
252-
void *prev_subbuf, size_t prev_padding)
252+
void *prev_subbuf)
253253
{
254254
if (!buf->chan->cb->subbuf_start)
255255
return !relay_buf_full(buf);
256256

257257
return buf->chan->cb->subbuf_start(buf, subbuf,
258-
prev_subbuf, prev_padding);
258+
prev_subbuf);
259259
}
260260

261261
/**
@@ -301,7 +301,7 @@ static void __relay_reset(struct rchan_buf *buf, unsigned int init)
301301
for (i = 0; i < buf->chan->n_subbufs; i++)
302302
buf->padding[i] = 0;
303303

304-
relay_subbuf_start(buf, buf->data, NULL, 0);
304+
relay_subbuf_start(buf, buf->data, NULL);
305305
}
306306

307307
/**
@@ -554,9 +554,11 @@ size_t relay_switch_subbuf(struct rchan_buf *buf, size_t length)
554554
goto toobig;
555555

556556
if (buf->offset != buf->chan->subbuf_size + 1) {
557-
buf->prev_padding = buf->chan->subbuf_size - buf->offset;
557+
size_t prev_padding;
558+
559+
prev_padding = buf->chan->subbuf_size - buf->offset;
558560
old_subbuf = buf->subbufs_produced % buf->chan->n_subbufs;
559-
buf->padding[old_subbuf] = buf->prev_padding;
561+
buf->padding[old_subbuf] = prev_padding;
560562
buf->subbufs_produced++;
561563
if (buf->dentry)
562564
d_inode(buf->dentry)->i_size +=
@@ -581,7 +583,7 @@ size_t relay_switch_subbuf(struct rchan_buf *buf, size_t length)
581583
new_subbuf = buf->subbufs_produced % buf->chan->n_subbufs;
582584
new = buf->start + new_subbuf * buf->chan->subbuf_size;
583585
buf->offset = 0;
584-
if (!relay_subbuf_start(buf, new, old, buf->prev_padding)) {
586+
if (!relay_subbuf_start(buf, new, old)) {
585587
buf->offset = buf->chan->subbuf_size + 1;
586588
return 0;
587589
}

kernel/trace/blktrace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ static const struct file_operations blk_msg_fops = {
461461
* the user space app in telling how many lost events there were.
462462
*/
463463
static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
464-
void *prev_subbuf, size_t prev_padding)
464+
void *prev_subbuf)
465465
{
466466
struct blk_trace *bt;
467467

0 commit comments

Comments
 (0)