printk: ringbuffer: change representation of states
Rather than deriving the state by evaluating bits within the flags area of the state variable, assign the states explicit values and set those values in the flags area. Introduce macros to make it simple to read and write state values for the state variable. Although the functionality is preserved, the binary representation for the states is changed. 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/20200914123354.832-5-john.ogness@linutronix.de
This commit is contained in:

committed by
Petr Mladek

vanhempi
cc5c7041c6
commit
10dcb06d40
@@ -78,10 +78,10 @@ class LxDmesg(gdb.Command):
|
||||
len_off = off + printk_info_type.get_type()['text_len'].bitpos // 8
|
||||
|
||||
# definitions from kernel/printk/printk_ringbuffer.h
|
||||
desc_committed = 1
|
||||
desc_sv_bits = utils.get_long_type().sizeof * 8
|
||||
desc_committed_mask = 1 << (desc_sv_bits - 1)
|
||||
desc_reuse_mask = 1 << (desc_sv_bits - 2)
|
||||
desc_flags_mask = desc_committed_mask | desc_reuse_mask
|
||||
desc_flags_shift = desc_sv_bits - 2
|
||||
desc_flags_mask = 3 << desc_flags_shift
|
||||
desc_id_mask = ~desc_flags_mask
|
||||
|
||||
# read in tail and head descriptor ids
|
||||
@@ -96,8 +96,9 @@ class LxDmesg(gdb.Command):
|
||||
desc_off = desc_sz * ind
|
||||
|
||||
# skip non-committed record
|
||||
state = utils.read_u64(descs, desc_off + sv_off + counter_off) & desc_flags_mask
|
||||
if state != desc_committed_mask:
|
||||
state = 3 & (utils.read_u64(descs, desc_off + sv_off +
|
||||
counter_off) >> desc_flags_shift)
|
||||
if state != desc_committed:
|
||||
if did == head_id:
|
||||
break
|
||||
did = (did + 1) & desc_id_mask
|
||||
|
Viittaa uudesa ongelmassa
Block a user