[PATCH] Add a counter and debug printf to change the latency inside tlb_sync

Chao-ying Fu icebergfu at gmail.com
Thu Jan 9 16:03:01 PST 2025


The tlb_sync loop is slowed down by variable latency to avoid
livelock on some platforms.
---
 lib/sbi/sbi_tlb.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lib/sbi/sbi_tlb.c b/lib/sbi/sbi_tlb.c
index 01b31f4..d46b95c 100644
--- a/lib/sbi/sbi_tlb.c
+++ b/lib/sbi/sbi_tlb.c
@@ -247,6 +247,7 @@ static void tlb_process(struct sbi_scratch *scratch)
 
 static void tlb_sync(struct sbi_scratch *scratch)
 {
+	int count = 0;
 	atomic_t *tlb_sync =
 			sbi_scratch_offset_ptr(scratch, tlb_sync_off);
 
@@ -256,6 +257,11 @@ static void tlb_sync(struct sbi_scratch *scratch)
 		 * consume fifo requests to avoid deadlock.
 		 */
 		tlb_process_once(scratch);
+		count++;
+		if ((count % 20) == 0) {
+			sbi_dprintf("tlb_sync loop count = %d value = %ld\n",
+				    count, atomic_read(tlb_sync));
+		}
 	}
 
 	return;
-- 
2.47.1




More information about the opensbi mailing list