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