Skip to content

Commit be40bba

Browse files
JasonXingkawasaki
authored andcommitted
relayfs: abolish prev_padding
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. Reviewed-by: Yushan Zhou <[email protected]> Signed-off-by: Jason Xing <[email protected]>
1 parent 3d460ec commit be40bba

6 files changed

Lines changed: 13 additions & 16 deletions

File tree

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
@@ -250,13 +250,13 @@ EXPORT_SYMBOL_GPL(relay_buf_full);
250250
*/
251251

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

258258
return buf->chan->cb->subbuf_start(buf, subbuf,
259-
prev_subbuf, prev_padding);
259+
prev_subbuf);
260260
}
261261

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

305-
relay_subbuf_start(buf, buf->data, NULL, 0);
305+
relay_subbuf_start(buf, buf->data, NULL);
306306
}
307307

308308
/**
@@ -555,9 +555,11 @@ size_t relay_switch_subbuf(struct rchan_buf *buf, size_t length)
555555
goto toobig;
556556

557557
if (buf->offset != buf->chan->subbuf_size + 1) {
558-
buf->prev_padding = buf->chan->subbuf_size - buf->offset;
558+
size_t prev_padding;
559+
560+
prev_padding = buf->chan->subbuf_size - buf->offset;
559561
old_subbuf = buf->subbufs_produced % buf->chan->n_subbufs;
560-
buf->padding[old_subbuf] = buf->prev_padding;
562+
buf->padding[old_subbuf] = prev_padding;
561563
buf->subbufs_produced++;
562564
if (buf->dentry)
563565
d_inode(buf->dentry)->i_size +=
@@ -582,7 +584,7 @@ size_t relay_switch_subbuf(struct rchan_buf *buf, size_t length)
582584
new_subbuf = buf->subbufs_produced % buf->chan->n_subbufs;
583585
new = buf->start + new_subbuf * buf->chan->subbuf_size;
584586
buf->offset = 0;
585-
if (!relay_subbuf_start(buf, new, old, buf->prev_padding)) {
587+
if (!relay_subbuf_start(buf, new, old)) {
586588
buf->offset = buf->chan->subbuf_size + 1;
587589
return 0;
588590
}

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)