Blame SOURCES/0013-sbitmapq-Fix-for-sbitmap_queue-without-ws_active-mem.patch

aefe19
From 9ce31a14d1083cbb2beb4a8e6eb7b88234b79a99 Mon Sep 17 00:00:00 2001
aefe19
From: Kazuhito Hagio <k-hagio-ab@nec.com>
aefe19
Date: Fri, 10 Jun 2022 11:49:47 +0900
aefe19
Subject: [PATCH 13/18] sbitmapq: Fix for sbitmap_queue without ws_active
aefe19
 member
aefe19
aefe19
The sbitmap_queue.ws_active member was added by kernel commit 5d2ee7122c73
aefe19
("sbitmap: optimize wakeup check") at Linux 5.0.  Without the patch, on
aefe19
earlier kernels the "sbitmapq" command fails with the following error:
aefe19
aefe19
  crash> sbitmapq ffff8f1a3611cf10
aefe19
aefe19
  sbitmapq: invalid structure member offset: sbitmap_queue_ws_active
aefe19
            FILE: sbitmap.c  LINE: 393  FUNCTION: sbitmap_queue_context_load()
aefe19
aefe19
Signed-off-by: Kazuhito Hagio <k-hagio-ab@nec.com>
aefe19
Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
aefe19
---
aefe19
 sbitmap.c | 6 ++++--
aefe19
 1 file changed, 4 insertions(+), 2 deletions(-)
aefe19
aefe19
diff --git a/sbitmap.c b/sbitmap.c
aefe19
index e8ebd62fe01c..152c28e6875f 100644
aefe19
--- a/sbitmap.c
aefe19
+++ b/sbitmap.c
aefe19
@@ -325,7 +325,8 @@ static void sbitmap_queue_show(const struct sbitmap_queue_context *sqc,
aefe19
 
aefe19
 	fprintf(fp, "wake_batch = %u\n", sqc->wake_batch);
aefe19
 	fprintf(fp, "wake_index = %d\n", sqc->wake_index);
aefe19
-	fprintf(fp, "ws_active = %d\n", sqc->ws_active);
aefe19
+	if (VALID_MEMBER(sbitmap_queue_ws_active)) /* 5.0 and later */
aefe19
+		fprintf(fp, "ws_active = %d\n", sqc->ws_active);
aefe19
 
aefe19
 	sbq_wait_state_size = SIZE(sbq_wait_state);
aefe19
 	wait_cnt_off = OFFSET(sbq_wait_state_wait_cnt);
aefe19
@@ -380,7 +381,8 @@ static void sbitmap_queue_context_load(ulong addr, struct sbitmap_queue_context
aefe19
 	sqc->wake_batch = UINT(sbitmap_queue_buf + OFFSET(sbitmap_queue_wake_batch));
aefe19
 	sqc->wake_index = INT(sbitmap_queue_buf + OFFSET(sbitmap_queue_wake_index));
aefe19
 	sqc->ws_addr = ULONG(sbitmap_queue_buf + OFFSET(sbitmap_queue_ws));
aefe19
-	sqc->ws_active = INT(sbitmap_queue_buf + OFFSET(sbitmap_queue_ws_active));
aefe19
+	if (VALID_MEMBER(sbitmap_queue_ws_active))
aefe19
+		sqc->ws_active = INT(sbitmap_queue_buf + OFFSET(sbitmap_queue_ws_active));
aefe19
 	if (VALID_MEMBER(sbitmap_queue_round_robin))
aefe19
 		sqc->round_robin = BOOL(sbitmap_queue_buf + OFFSET(sbitmap_queue_round_robin));
aefe19
 	sqc->min_shallow_depth = UINT(sbitmap_queue_buf + OFFSET(sbitmap_queue_min_shallow_depth));
aefe19
-- 
aefe19
2.30.2
aefe19