Skip to contentSkip to conversation

printk: ringbuffer: fix error in comment

PATCH In review Loïc Grégoire 3 participants 5 messages Mar 28 – Mar 31 Printk

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 printk: ringbuffer: fix error in comment

The printk ringbuffer implementation is described in the comment as using three ringbuffers, but the current implementation uses two (desc and data). Update the comment so it matches the code.

---
 kernel/printk/printk_ringbuffer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/printk/printk_ringbuffer.c +1 -1
index 56c8e3d031f4..11dae8229103 100644
@@ -14,7 +14,7 @@
  *
  * Data Structure
  * --------------
- * The printk_ringbuffer is made up of 3 internal ringbuffers:
+ * The printk_ringbuffer is made up of 2 internal ringbuffers:
  *
  *   desc_ring
  *     A ring of descriptors and their meta data (such as sequence number,
Signature · 1 line
2.53.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Loïc Grégoire

The printk ringbuffer implementation is described in the comment as using three ringbuffers, but the current implementation uses two (desc and data). Update the comment so it matches the code.

However, this is only a single fixup when there are other documentation errors that need fixing as well. Does it make sense to commit such tiny fixups separately? For example, below are needed fixes that I am aware of.

Perhaps we should fold these into a single doc-fixup patch?

John

kernel/printk/printk_ringbuffer.c +5 -5
index 56c8e3d031f49..3f019207d2688 100644
@@ -224,7 +224,7 @@
  *
  *	prb_rec_init_rd(&r, &info, &text_buf[0], sizeof(text_buf));
  *
- *	prb_for_each_record(0, &test_rb, &seq, &r) {
+ *	prb_for_each_record(0, &test_rb, seq, &r) {
  *		if (info.seq != seq)
  *			pr_warn("lost %llu records\n", info.seq - seq);
  *
@@ -1365,7 +1365,7 @@ static struct prb_desc *desc_reopen_last(struct prb_desc_ring *desc_ring,
 	 *
 	 * WMB from _prb_commit:A to _prb_commit:B
 	 *    matching
-	 * MB If desc_reopen_last:A to prb_reserve_in_last:A
+	 * MB from desc_reopen_last:A to prb_reserve_in_last:A
 	 */
 	if (!atomic_long_try_cmpxchg(&d->state_var, &prev_state_val,
 			DESC_SV(id, desc_reserved))) { /* LMM(desc_reopen_last:A) */
@@ -1770,9 +1770,9 @@ static void _prb_commit(struct prb_reserved_entry *e, unsigned long state_val)
 	 *
 	 *    Relies on:
 	 *
-	 *    MB _prb_commit:B to prb_commit:A
+	 *    MB from _prb_commit:B to prb_commit:A
 	 *       matching
-	 *    MB desc_reserve:D to desc_make_final:A
+	 *    MB from desc_reserve:D to desc_make_final:A
 	 */
 	if (!atomic_long_try_cmpxchg(&d->state_var, &prev_state_val,
 			DESC_SV(e->id, state_val))) { /* LMM(_prb_commit:B) */
@@ -2035,7 +2035,7 @@ u64 prb_first_seq(struct printk_ringbuffer *rb)
 		 *
 		 * MB from desc_push_tail:B to desc_reserve:F
 		 *    matching
-		 * RMB prb_first_seq:B to prb_first_seq:A
+		 * RMB from prb_first_seq:B to prb_first_seq:A
 		 */
 		smp_rmb(); /* LMM(prb_first_seq:C) */
 	}
kernel/printk/printk_ringbuffer.h +1 -1
index 1651b53ece34f..fb7d2ee29af23 100644
@@ -388,7 +388,7 @@ for ((s) = from; prb_read_valid(rb, s, r); (s) = (r)->info->seq + 1)
  *
  * This is a macro for conveniently iterating over a ringbuffer.
  * Note that @s may not be the sequence number of the record on each
- * iteration. For the sequence number, @r->info->seq should be checked.
+ * iteration. For the sequence number, @i->seq should be checked.
  *
  * Context: Any context.
  */
maintainer Reviewed-by Reviewed-by
#2 lore raw
Quoted 8 lines · John Ogness
Quoted 5 lines · Loïc Grégoire

The printk ringbuffer implementation is described in the comment as using three ringbuffers, but the current implementation uses two (desc and data). Update the comment so it matches the code.

Quoted 55 lines

However, this is only a single fixup when there are other documentation errors that need fixing as well. Does it make sense to commit such tiny fixups separately? For example, below are needed fixes that I am aware of.

Perhaps we should fold these into a single doc-fixup patch?

kernel/printk/printk_ringbuffer.c +5 -5
index 56c8e3d031f49..3f019207d2688 100644
@@ -224,7 +224,7 @@
  *
  *	prb_rec_init_rd(&r, &info, &text_buf[0], sizeof(text_buf));
  *
- *	prb_for_each_record(0, &test_rb, &seq, &r) {
+ *	prb_for_each_record(0, &test_rb, seq, &r) {
  *		if (info.seq != seq)
  *			pr_warn("lost %llu records\n", info.seq - seq);
  *
@@ -1365,7 +1365,7 @@ static struct prb_desc *desc_reopen_last(struct prb_desc_ring *desc_ring,
 	 *
 	 * WMB from _prb_commit:A to _prb_commit:B
 	 *    matching
-	 * MB If desc_reopen_last:A to prb_reserve_in_last:A
+	 * MB from desc_reopen_last:A to prb_reserve_in_last:A
 	 */
 	if (!atomic_long_try_cmpxchg(&d->state_var, &prev_state_val,
 			DESC_SV(id, desc_reserved))) { /* LMM(desc_reopen_last:A) */
@@ -1770,9 +1770,9 @@ static void _prb_commit(struct prb_reserved_entry *e, unsigned long state_val)
 	 *
 	 *    Relies on:
 	 *
-	 *    MB _prb_commit:B to prb_commit:A
+	 *    MB from _prb_commit:B to prb_commit:A
 	 *       matching
-	 *    MB desc_reserve:D to desc_make_final:A
+	 *    MB from desc_reserve:D to desc_make_final:A
 	 */
 	if (!atomic_long_try_cmpxchg(&d->state_var, &prev_state_val,
 			DESC_SV(e->id, state_val))) { /* LMM(_prb_commit:B) */
@@ -2035,7 +2035,7 @@ u64 prb_first_seq(struct printk_ringbuffer *rb)
 		 *
 		 * MB from desc_push_tail:B to desc_reserve:F
 		 *    matching
-		 * RMB prb_first_seq:B to prb_first_seq:A
+		 * RMB from prb_first_seq:B to prb_first_seq:A
 		 */
 		smp_rmb(); /* LMM(prb_first_seq:C) */
 	}
kernel/printk/printk_ringbuffer.h +0 -0
index 1651b53ece34f..fb7d2ee29af23 100644

kernel/printk/printk_ringbuffer.h for ((s) = from; prb_read_valid(rb, s, r); (s) = (r)->info->seq + 1) · line 394

Quoted 8 lines
kernel/printk/printk_ringbuffer.h +1 -1
@@ -388,7 +388,7 @@ for ((s) = from; prb_read_valid(rb, s, r); (s) = (r)->info->seq + 1)
  *
  * This is a macro for conveniently iterating over a ringbuffer.
  * Note that @s may not be the sequence number of the record on each
- * iteration. For the sequence number, @r->info->seq should be checked.
+ * iteration. For the sequence number, @i->seq should be checked.
  *
  * Context: Any context.
  */

All these changes look correct as well:

I could squash these changes into the original patch when comitting into printk/linux.git.

John, could I use your Signed-off-by to mark you as a co-author and keep Loïc as the author of the patch?

Best Regards,
Petr

maintainer
#3 lore raw
Quoted 78 lines · Petr Mladek
Quoted 8 lines · John Ogness
Quoted 5 lines · Loïc Grégoire

The printk ringbuffer implementation is described in the comment as using three ringbuffers, but the current implementation uses two (desc and data). Update the comment so it matches the code.

Quoted 55 lines

However, this is only a single fixup when there are other documentation errors that need fixing as well. Does it make sense to commit such tiny fixups separately? For example, below are needed fixes that I am aware of.

Perhaps we should fold these into a single doc-fixup patch?

kernel/printk/printk_ringbuffer.c +5 -5
index 56c8e3d031f49..3f019207d2688 100644
@@ -224,7 +224,7 @@
  *
  *	prb_rec_init_rd(&r, &info, &text_buf[0], sizeof(text_buf));
  *
- *	prb_for_each_record(0, &test_rb, &seq, &r) {
+ *	prb_for_each_record(0, &test_rb, seq, &r) {
  *		if (info.seq != seq)
  *			pr_warn("lost %llu records\n", info.seq - seq);
  *
@@ -1365,7 +1365,7 @@ static struct prb_desc *desc_reopen_last(struct prb_desc_ring *desc_ring,
 	 *
 	 * WMB from _prb_commit:A to _prb_commit:B
 	 *    matching
-	 * MB If desc_reopen_last:A to prb_reserve_in_last:A
+	 * MB from desc_reopen_last:A to prb_reserve_in_last:A
 	 */
 	if (!atomic_long_try_cmpxchg(&d->state_var, &prev_state_val,
 			DESC_SV(id, desc_reserved))) { /* LMM(desc_reopen_last:A) */
@@ -1770,9 +1770,9 @@ static void _prb_commit(struct prb_reserved_entry *e, unsigned long state_val)
 	 *
 	 *    Relies on:
 	 *
-	 *    MB _prb_commit:B to prb_commit:A
+	 *    MB from _prb_commit:B to prb_commit:A
 	 *       matching
-	 *    MB desc_reserve:D to desc_make_final:A
+	 *    MB from desc_reserve:D to desc_make_final:A
 	 */
 	if (!atomic_long_try_cmpxchg(&d->state_var, &prev_state_val,
 			DESC_SV(e->id, state_val))) { /* LMM(_prb_commit:B) */
@@ -2035,7 +2035,7 @@ u64 prb_first_seq(struct printk_ringbuffer *rb)
 		 *
 		 * MB from desc_push_tail:B to desc_reserve:F
 		 *    matching
-		 * RMB prb_first_seq:B to prb_first_seq:A
+		 * RMB from prb_first_seq:B to prb_first_seq:A
 		 */
 		smp_rmb(); /* LMM(prb_first_seq:C) */
 	}
kernel/printk/printk_ringbuffer.h +0 -0
index 1651b53ece34f..fb7d2ee29af23 100644

kernel/printk/printk_ringbuffer.h for ((s) = from; prb_read_valid(rb, s, r); (s) = (r)->info->seq + 1) · line 394

Quoted 8 lines
kernel/printk/printk_ringbuffer.h +1 -1
@@ -388,7 +388,7 @@ for ((s) = from; prb_read_valid(rb, s, r); (s) = (r)->info->seq + 1)
  *
  * This is a macro for conveniently iterating over a ringbuffer.
  * Note that @s may not be the sequence number of the record on each
- * iteration. For the sequence number, @r->info->seq should be checked.
+ * iteration. For the sequence number, @i->seq should be checked.
  *
  * Context: Any context.
  */

All these changes look correct as well:

Quoted 7 lines

I could squash these changes into the original patch when comitting into printk/linux.git.

John, could I use your Signed-off-by to mark you as a co-author and keep Loïc as the author of the patch?

Sure.

maintainer
#4 lore raw
Quoted 81 lines · John Ogness
Quoted 80 lines · Petr Mladek
Quoted 8 lines · John Ogness
Quoted 5 lines · Loïc Grégoire

The printk ringbuffer implementation is described in the comment as using three ringbuffers, but the current implementation uses two (desc and data). Update the comment so it matches the code.

Quoted 55 lines

However, this is only a single fixup when there are other documentation errors that need fixing as well. Does it make sense to commit such tiny fixups separately? For example, below are needed fixes that I am aware of.

Perhaps we should fold these into a single doc-fixup patch?

kernel/printk/printk_ringbuffer.c +5 -5
index 56c8e3d031f49..3f019207d2688 100644
@@ -224,7 +224,7 @@
  *
  *	prb_rec_init_rd(&r, &info, &text_buf[0], sizeof(text_buf));
  *
- *	prb_for_each_record(0, &test_rb, &seq, &r) {
+ *	prb_for_each_record(0, &test_rb, seq, &r) {
  *		if (info.seq != seq)
  *			pr_warn("lost %llu records\n", info.seq - seq);
  *
@@ -1365,7 +1365,7 @@ static struct prb_desc *desc_reopen_last(struct prb_desc_ring *desc_ring,
 	 *
 	 * WMB from _prb_commit:A to _prb_commit:B
 	 *    matching
-	 * MB If desc_reopen_last:A to prb_reserve_in_last:A
+	 * MB from desc_reopen_last:A to prb_reserve_in_last:A
 	 */
 	if (!atomic_long_try_cmpxchg(&d->state_var, &prev_state_val,
 			DESC_SV(id, desc_reserved))) { /* LMM(desc_reopen_last:A) */
@@ -1770,9 +1770,9 @@ static void _prb_commit(struct prb_reserved_entry *e, unsigned long state_val)
 	 *
 	 *    Relies on:
 	 *
-	 *    MB _prb_commit:B to prb_commit:A
+	 *    MB from _prb_commit:B to prb_commit:A
 	 *       matching
-	 *    MB desc_reserve:D to desc_make_final:A
+	 *    MB from desc_reserve:D to desc_make_final:A
 	 */
 	if (!atomic_long_try_cmpxchg(&d->state_var, &prev_state_val,
 			DESC_SV(e->id, state_val))) { /* LMM(_prb_commit:B) */
@@ -2035,7 +2035,7 @@ u64 prb_first_seq(struct printk_ringbuffer *rb)
 		 *
 		 * MB from desc_push_tail:B to desc_reserve:F
 		 *    matching
-		 * RMB prb_first_seq:B to prb_first_seq:A
+		 * RMB from prb_first_seq:B to prb_first_seq:A
 		 */
 		smp_rmb(); /* LMM(prb_first_seq:C) */
 	}
kernel/printk/printk_ringbuffer.h +0 -0
index 1651b53ece34f..fb7d2ee29af23 100644

kernel/printk/printk_ringbuffer.h for ((s) = from; prb_read_valid(rb, s, r); (s) = (r)->info->seq + 1) · line 394

Quoted 8 lines
kernel/printk/printk_ringbuffer.h +1 -1
@@ -388,7 +388,7 @@ for ((s) = from; prb_read_valid(rb, s, r); (s) = (r)->info->seq + 1)
  *
  * This is a macro for conveniently iterating over a ringbuffer.
  * Note that @s may not be the sequence number of the record on each
- * iteration. For the sequence number, @r->info->seq should be checked.
+ * iteration. For the sequence number, @i->seq should be checked.
  *
  * Context: Any context.
  */

All these changes look correct as well:

Quoted 7 lines
Quoted 5 lines

I could squash these changes into the original patch when comitting into printk/linux.git.

John, could I use your Signed-off-by to mark you as a co-author and keep Loïc as the author of the patch?

JFYI, the patch has been comitted into printk/linux.git, branch rework/prb-fixes.

I have merged the extra fixes proposed by John, see
https://git.kernel.org/pub/scm/linux/kernel/git/printk/linux.git/commit/?h=rework/prb-fixes&id=bf56987c111372a54ae877934a42f7fb0953a6ca

Best Regards,
Petr