Skip to content

Commit f35efc7

Browse files
jognesspmladek
authored andcommitted
printk: remove dict ring
Since there is no code that will ever store anything into the dict ring, remove it. If any future dictionary properties are to be added, these should be added to the struct printk_info. Signed-off-by: John Ogness <john.ogness@linutronix.de> Reviewed-by: Petr Mladek <pmladek@suse.com> Signed-off-by: Petr Mladek <pmladek@suse.com> Link: https://lore.kernel.org/r/20200918223421.21621-4-john.ogness@linutronix.de
1 parent 74caba7 commit f35efc7

3 files changed

Lines changed: 64 additions & 200 deletions

File tree

kernel/printk/printk.c

Lines changed: 14 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -427,15 +427,14 @@ static u32 log_buf_len = __LOG_BUF_LEN;
427427
* Define the average message size. This only affects the number of
428428
* descriptors that will be available. Underestimating is better than
429429
* overestimating (too many available descriptors is better than not enough).
430-
* The dictionary buffer will be the same size as the text buffer.
431430
*/
432431
#define PRB_AVGBITS 5 /* 32 character average length */
433432

434433
#if CONFIG_LOG_BUF_SHIFT <= PRB_AVGBITS
435434
#error CONFIG_LOG_BUF_SHIFT value too small.
436435
#endif
437436
_DEFINE_PRINTKRB(printk_rb_static, CONFIG_LOG_BUF_SHIFT - PRB_AVGBITS,
438-
PRB_AVGBITS, PRB_AVGBITS, &__log_buf[0]);
437+
PRB_AVGBITS, &__log_buf[0]);
439438

440439
static struct printk_ringbuffer printk_rb_dynamic;
441440

@@ -502,12 +501,12 @@ static int log_store(u32 caller_id, int facility, int level,
502501
struct printk_record r;
503502
u16 trunc_msg_len = 0;
504503

505-
prb_rec_init_wr(&r, text_len, 0);
504+
prb_rec_init_wr(&r, text_len);
506505

507506
if (!prb_reserve(&e, prb, &r)) {
508507
/* truncate the message if it is too long for empty buffer */
509508
truncate_msg(&text_len, &trunc_msg_len);
510-
prb_rec_init_wr(&r, text_len + trunc_msg_len, 0);
509+
prb_rec_init_wr(&r, text_len + trunc_msg_len);
511510
/* survive when the log buffer is too small for trunc_msg */
512511
if (!prb_reserve(&e, prb, &r))
513512
return 0;
@@ -898,8 +897,7 @@ static int devkmsg_open(struct inode *inode, struct file *file)
898897
mutex_init(&user->lock);
899898

900899
prb_rec_init_rd(&user->record, &user->info,
901-
&user->text_buf[0], sizeof(user->text_buf),
902-
NULL, 0);
900+
&user->text_buf[0], sizeof(user->text_buf));
903901

904902
logbuf_lock_irq();
905903
user->seq = prb_first_valid_seq(prb);
@@ -957,7 +955,6 @@ void log_buf_vmcoreinfo_setup(void)
957955
VMCOREINFO_STRUCT_SIZE(printk_ringbuffer);
958956
VMCOREINFO_OFFSET(printk_ringbuffer, desc_ring);
959957
VMCOREINFO_OFFSET(printk_ringbuffer, text_data_ring);
960-
VMCOREINFO_OFFSET(printk_ringbuffer, dict_data_ring);
961958
VMCOREINFO_OFFSET(printk_ringbuffer, fail);
962959

963960
VMCOREINFO_STRUCT_SIZE(prb_desc_ring);
@@ -970,7 +967,6 @@ void log_buf_vmcoreinfo_setup(void)
970967
VMCOREINFO_STRUCT_SIZE(prb_desc);
971968
VMCOREINFO_OFFSET(prb_desc, state_var);
972969
VMCOREINFO_OFFSET(prb_desc, text_blk_lpos);
973-
VMCOREINFO_OFFSET(prb_desc, dict_blk_lpos);
974970

975971
VMCOREINFO_STRUCT_SIZE(prb_data_blk_lpos);
976972
VMCOREINFO_OFFSET(prb_data_blk_lpos, begin);
@@ -980,7 +976,6 @@ void log_buf_vmcoreinfo_setup(void)
980976
VMCOREINFO_OFFSET(printk_info, seq);
981977
VMCOREINFO_OFFSET(printk_info, ts_nsec);
982978
VMCOREINFO_OFFSET(printk_info, text_len);
983-
VMCOREINFO_OFFSET(printk_info, dict_len);
984979
VMCOREINFO_OFFSET(printk_info, caller_id);
985980
VMCOREINFO_OFFSET(printk_info, dev_info);
986981

@@ -1081,7 +1076,7 @@ static unsigned int __init add_to_rb(struct printk_ringbuffer *rb,
10811076
struct prb_reserved_entry e;
10821077
struct printk_record dest_r;
10831078

1084-
prb_rec_init_wr(&dest_r, r->info->text_len, 0);
1079+
prb_rec_init_wr(&dest_r, r->info->text_len);
10851080

10861081
if (!prb_reserve(&e, rb, &dest_r))
10871082
return 0;
@@ -1112,7 +1107,6 @@ void __init setup_log_buf(int early)
11121107
size_t new_descs_size;
11131108
size_t new_infos_size;
11141109
unsigned long flags;
1115-
char *new_dict_buf;
11161110
char *new_log_buf;
11171111
unsigned int free;
11181112
u64 seq;
@@ -1147,19 +1141,12 @@ void __init setup_log_buf(int early)
11471141
return;
11481142
}
11491143

1150-
new_dict_buf = memblock_alloc(new_log_buf_len, LOG_ALIGN);
1151-
if (unlikely(!new_dict_buf)) {
1152-
pr_err("log_buf_len: %lu dict bytes not available\n",
1153-
new_log_buf_len);
1154-
goto err_free_log_buf;
1155-
}
1156-
11571144
new_descs_size = new_descs_count * sizeof(struct prb_desc);
11581145
new_descs = memblock_alloc(new_descs_size, LOG_ALIGN);
11591146
if (unlikely(!new_descs)) {
11601147
pr_err("log_buf_len: %zu desc bytes not available\n",
11611148
new_descs_size);
1162-
goto err_free_dict_buf;
1149+
goto err_free_log_buf;
11631150
}
11641151

11651152
new_infos_size = new_descs_count * sizeof(struct printk_info);
@@ -1170,13 +1157,10 @@ void __init setup_log_buf(int early)
11701157
goto err_free_descs;
11711158
}
11721159

1173-
prb_rec_init_rd(&r, &info,
1174-
&setup_text_buf[0], sizeof(setup_text_buf),
1175-
NULL, 0);
1160+
prb_rec_init_rd(&r, &info, &setup_text_buf[0], sizeof(setup_text_buf));
11761161

11771162
prb_init(&printk_rb_dynamic,
11781163
new_log_buf, ilog2(new_log_buf_len),
1179-
new_dict_buf, ilog2(new_log_buf_len),
11801164
new_descs, ilog2(new_descs_count),
11811165
new_infos);
11821166

@@ -1211,8 +1195,6 @@ void __init setup_log_buf(int early)
12111195

12121196
err_free_descs:
12131197
memblock_free(__pa(new_descs), new_descs_size);
1214-
err_free_dict_buf:
1215-
memblock_free(__pa(new_dict_buf), new_log_buf_len);
12161198
err_free_log_buf:
12171199
memblock_free(__pa(new_log_buf), new_log_buf_len);
12181200
}
@@ -1463,7 +1445,7 @@ static int syslog_print(char __user *buf, int size)
14631445
if (!text)
14641446
return -ENOMEM;
14651447

1466-
prb_rec_init_rd(&r, &info, text, LOG_LINE_MAX + PREFIX_MAX, NULL, 0);
1448+
prb_rec_init_rd(&r, &info, text, LOG_LINE_MAX + PREFIX_MAX);
14671449

14681450
while (size > 0) {
14691451
size_t n;
@@ -1550,7 +1532,7 @@ static int syslog_print_all(char __user *buf, int size, bool clear)
15501532
len -= get_record_print_text_size(&info, line_count, true, time);
15511533
}
15521534

1553-
prb_rec_init_rd(&r, &info, text, LOG_LINE_MAX + PREFIX_MAX, NULL, 0);
1535+
prb_rec_init_rd(&r, &info, text, LOG_LINE_MAX + PREFIX_MAX);
15541536

15551537
len = 0;
15561538
prb_for_each_record(seq, prb, seq, &r) {
@@ -1920,7 +1902,7 @@ static size_t log_output(int facility, int level, enum log_flags lflags,
19201902
struct prb_reserved_entry e;
19211903
struct printk_record r;
19221904

1923-
prb_rec_init_wr(&r, text_len, 0);
1905+
prb_rec_init_wr(&r, text_len);
19241906
if (prb_reserve_in_last(&e, prb, &r, caller_id)) {
19251907
memcpy(&r.text_buf[r.info->text_len], text, text_len);
19261908
r.info->text_len += text_len;
@@ -2408,7 +2390,7 @@ void console_unlock(void)
24082390
return;
24092391
}
24102392

2411-
prb_rec_init_rd(&r, &info, text, sizeof(text), NULL, 0);
2393+
prb_rec_init_rd(&r, &info, text, sizeof(text));
24122394

24132395
/*
24142396
* Console drivers are called with interrupts disabled, so
@@ -3266,7 +3248,7 @@ bool kmsg_dump_get_line_nolock(struct kmsg_dumper *dumper, bool syslog,
32663248
size_t l = 0;
32673249
bool ret = false;
32683250

3269-
prb_rec_init_rd(&r, &info, line, size, NULL, 0);
3251+
prb_rec_init_rd(&r, &info, line, size);
32703252

32713253
if (!dumper->active)
32723254
goto out;
@@ -3357,7 +3339,7 @@ bool kmsg_dump_get_buffer(struct kmsg_dumper *dumper, bool syslog,
33573339
bool ret = false;
33583340
bool time = printk_time;
33593341

3360-
prb_rec_init_rd(&r, &info, buf, size, NULL, 0);
3342+
prb_rec_init_rd(&r, &info, buf, size);
33613343

33623344
if (!dumper->active || !buf || !size)
33633345
goto out;
@@ -3405,7 +3387,7 @@ bool kmsg_dump_get_buffer(struct kmsg_dumper *dumper, bool syslog,
34053387
l += record_print_text(&r, syslog, time);
34063388

34073389
/* adjust record to store to remaining buffer space */
3408-
prb_rec_init_rd(&r, &info, buf + l, size - l, NULL, 0);
3390+
prb_rec_init_rd(&r, &info, buf + l, size - l);
34093391

34103392
seq = r.info->seq + 1;
34113393
}

0 commit comments

Comments
 (0)