Skip to content

Commit 90ad525

Browse files
jognesspmladek
authored andcommitted
printk: Use prb_first_seq() as base for 32bit seq macros
Note: This change only applies to 32bit architectures. On 64bit architectures the macros are NOPs. Currently prb_next_seq() is used as the base for the 32bit seq macros __u64seq_to_ulseq() and __ulseq_to_u64seq(). However, in a follow-up commit, prb_next_seq() will need to make use of the 32bit seq macros. Use prb_first_seq() as the base for the 32bit seq macros instead because it is guaranteed to return 64bit sequence numbers without relying on any 32bit seq macros. Signed-off-by: John Ogness <[email protected]> Reviewed-by: Petr Mladek <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Petr Mladek <[email protected]>
1 parent 418ec19 commit 90ad525

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

kernel/printk/printk_ringbuffer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1832,7 +1832,7 @@ static int prb_read(struct printk_ringbuffer *rb, u64 seq,
18321832
}
18331833

18341834
/* Get the sequence number of the tail descriptor. */
1835-
static u64 prb_first_seq(struct printk_ringbuffer *rb)
1835+
u64 prb_first_seq(struct printk_ringbuffer *rb)
18361836
{
18371837
struct prb_desc_ring *desc_ring = &rb->desc_ring;
18381838
enum desc_state d_state;

kernel/printk/printk_ringbuffer.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ bool prb_read_valid(struct printk_ringbuffer *rb, u64 seq,
378378
bool prb_read_valid_info(struct printk_ringbuffer *rb, u64 seq,
379379
struct printk_info *info, unsigned int *line_count);
380380

381+
u64 prb_first_seq(struct printk_ringbuffer *rb);
381382
u64 prb_first_valid_seq(struct printk_ringbuffer *rb);
382383
u64 prb_next_seq(struct printk_ringbuffer *rb);
383384

@@ -392,12 +393,12 @@ u64 prb_next_seq(struct printk_ringbuffer *rb);
392393

393394
static inline u64 __ulseq_to_u64seq(struct printk_ringbuffer *rb, u32 ulseq)
394395
{
396+
u64 rb_first_seq = prb_first_seq(rb);
395397
u64 seq;
396-
u64 rb_next_seq;
397398

398399
/*
399400
* The provided sequence is only the lower 32 bits of the ringbuffer
400-
* sequence. It needs to be expanded to 64bit. Get the next sequence
401+
* sequence. It needs to be expanded to 64bit. Get the first sequence
401402
* number from the ringbuffer and fold it.
402403
*
403404
* Having a 32bit representation in the console is sufficient.
@@ -406,8 +407,7 @@ static inline u64 __ulseq_to_u64seq(struct printk_ringbuffer *rb, u32 ulseq)
406407
*
407408
* Also the access to the ring buffer is always safe.
408409
*/
409-
rb_next_seq = prb_next_seq(rb);
410-
seq = rb_next_seq - (s32)((u32)rb_next_seq - ulseq);
410+
seq = rb_first_seq - (s32)((u32)rb_first_seq - ulseq);
411411

412412
return seq;
413413
}

0 commit comments

Comments
 (0)