summaryrefslogtreecommitdiff
path: root/kernel/printk/printk_ringbuffer.h
diff options
context:
space:
mode:
authorJohn Ogness <john.ogness@linutronix.de>2020-09-19 00:40:19 +0206
committerPetr Mladek <pmladek@suse.com>2020-09-22 11:09:42 +0200
commitcfe2790b163acdc9c058a63bff310923e84a16b4 (patch)
tree6c54003be5c53de5a84358669ebb1dc3a71a4430 /kernel/printk/printk_ringbuffer.h
parentf5f022e53b874f978dda23847173cbf2589b07f5 (diff)
printk: move printk_info into separate array
The majority of the size of a descriptor is taken up by meta data, which is often not of interest to the ringbuffer (for example, when performing state checks). Since descriptors are often temporarily stored on the stack, keeping their size minimal will help reduce stack pressure. Rather than embedding the printk_info into the descriptor, create a separate printk_info array. The index of a descriptor in the descriptor array corresponds to the printk_info with the same index in the printk_info array. The rules for validity of a printk_info match the existing rules for the data blocks: the descriptor must be in a consistent state. 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-2-john.ogness@linutronix.de
Diffstat (limited to 'kernel/printk/printk_ringbuffer.h')
-rw-r--r--kernel/printk/printk_ringbuffer.h29
1 files changed, 16 insertions, 13 deletions
diff --git a/kernel/printk/printk_ringbuffer.h b/kernel/printk/printk_ringbuffer.h
index 853ea62dc5f2..97c8561e74e0 100644
--- a/kernel/printk/printk_ringbuffer.h
+++ b/kernel/printk/printk_ringbuffer.h
@@ -58,7 +58,6 @@ struct prb_data_blk_lpos {
* @state_var: A bitwise combination of descriptor ID and descriptor state.
*/
struct prb_desc {
- struct printk_info info;
atomic_long_t state_var;
struct prb_data_blk_lpos text_blk_lpos;
struct prb_data_blk_lpos dict_blk_lpos;
@@ -76,6 +75,7 @@ struct prb_data_ring {
struct prb_desc_ring {
unsigned int count_bits;
struct prb_desc *descs;
+ struct printk_info *infos;
atomic_long_t head_id;
atomic_long_t tail_id;
};
@@ -237,19 +237,8 @@ enum desc_state {
static char _##name##_dict[1U << ((avgdictbits) + (descbits))] \
__aligned(__alignof__(unsigned long)); \
static struct prb_desc _##name##_descs[_DESCS_COUNT(descbits)] = { \
- /* this will be the first record reserved by a writer */ \
- [0] = { \
- .info = { \
- /* will be incremented to 0 on the first reservation */ \
- .seq = -(u64)_DESCS_COUNT(descbits), \
- }, \
- }, \
/* the initial head and tail */ \
[_DESCS_COUNT(descbits) - 1] = { \
- .info = { \
- /* reports the first seq value during the bootstrap phase */ \
- .seq = 0, \
- }, \
/* reusable */ \
.state_var = ATOMIC_INIT(DESC0_SV(descbits)), \
/* no associated data block */ \
@@ -257,10 +246,23 @@ static struct prb_desc _##name##_descs[_DESCS_COUNT(descbits)] = { \
.dict_blk_lpos = FAILED_BLK_LPOS, \
}, \
}; \
+static struct printk_info _##name##_infos[_DESCS_COUNT(descbits)] = { \
+ /* this will be the first record reserved by a writer */ \
+ [0] = { \
+ /* will be incremented to 0 on the first reservation */ \
+ .seq = -(u64)_DESCS_COUNT(descbits), \
+ }, \
+ /* the initial head and tail */ \
+ [_DESCS_COUNT(descbits) - 1] = { \
+ /* reports the first seq value during the bootstrap phase */ \
+ .seq = 0, \
+ }, \
+}; \
static struct printk_ringbuffer name = { \
.desc_ring = { \
.count_bits = descbits, \
.descs = &_##name##_descs[0], \
+ .infos = &_##name##_infos[0], \
.head_id = ATOMIC_INIT(DESC0_ID(descbits)), \
.tail_id = ATOMIC_INIT(DESC0_ID(descbits)), \
}, \
@@ -336,7 +338,8 @@ void prb_final_commit(struct prb_reserved_entry *e);
void prb_init(struct printk_ringbuffer *rb,
char *text_buf, unsigned int text_buf_size,
char *dict_buf, unsigned int dict_buf_size,
- struct prb_desc *descs, unsigned int descs_count_bits);
+ struct prb_desc *descs, unsigned int descs_count_bits,
+ struct printk_info *infos);
unsigned int prb_record_text_space(struct prb_reserved_entry *e);
/* Reader Interface */