|
|
aefe19 |
From 0d3e86fee5eead93b521a0e20a0e099ede4ab72b 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 14/18] sbitmapq: Fix for sbitmap_word without cleared member
|
|
|
aefe19 |
|
|
|
aefe19 |
The sbitmap_word.cleared member was added by kernel commit ea86ea2cdced
|
|
|
aefe19 |
("sbitmap: ammortize cost of clearing bits") at Linux 5.0. Without the
|
|
|
aefe19 |
patch, on earlier kernels the "sbitmapq" command fails with the
|
|
|
aefe19 |
following error:
|
|
|
aefe19 |
|
|
|
aefe19 |
crash> sbitmapq ffff8f1a3611cf10
|
|
|
aefe19 |
|
|
|
aefe19 |
sbitmapq: invalid structure member offset: sbitmap_word_cleared
|
|
|
aefe19 |
FILE: sbitmap.c LINE: 92 FUNCTION: __sbitmap_weight()
|
|
|
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 | 26 ++++++++++++++++++--------
|
|
|
aefe19 |
1 file changed, 18 insertions(+), 8 deletions(-)
|
|
|
aefe19 |
|
|
|
aefe19 |
diff --git a/sbitmap.c b/sbitmap.c
|
|
|
aefe19 |
index 152c28e6875f..c9f7209f9e3e 100644
|
|
|
aefe19 |
--- a/sbitmap.c
|
|
|
aefe19 |
+++ b/sbitmap.c
|
|
|
aefe19 |
@@ -89,7 +89,6 @@ static unsigned int __sbitmap_weight(const struct sbitmap_context *sc, bool set)
|
|
|
aefe19 |
{
|
|
|
aefe19 |
const ulong sbitmap_word_size = SIZE(sbitmap_word);
|
|
|
aefe19 |
const ulong w_word_off = OFFSET(sbitmap_word_word);
|
|
|
aefe19 |
- const ulong w_cleared_off = OFFSET(sbitmap_word_cleared);
|
|
|
aefe19 |
|
|
|
aefe19 |
unsigned int weight = 0;
|
|
|
aefe19 |
ulong addr = sc->map_addr;
|
|
|
aefe19 |
@@ -111,7 +110,10 @@ static unsigned int __sbitmap_weight(const struct sbitmap_context *sc, bool set)
|
|
|
aefe19 |
word = ULONG(sbitmap_word_buf + w_word_off);
|
|
|
aefe19 |
weight += bitmap_weight(word, depth);
|
|
|
aefe19 |
} else {
|
|
|
aefe19 |
- cleared = ULONG(sbitmap_word_buf + w_cleared_off);
|
|
|
aefe19 |
+ if (VALID_MEMBER(sbitmap_word_cleared))
|
|
|
aefe19 |
+ cleared = ULONG(sbitmap_word_buf + OFFSET(sbitmap_word_cleared));
|
|
|
aefe19 |
+ else
|
|
|
aefe19 |
+ cleared = 0;
|
|
|
aefe19 |
weight += bitmap_weight(cleared, depth);
|
|
|
aefe19 |
}
|
|
|
aefe19 |
|
|
|
aefe19 |
@@ -130,7 +132,10 @@ static unsigned int sbitmap_weight(const struct sbitmap_context *sc)
|
|
|
aefe19 |
|
|
|
aefe19 |
static unsigned int sbitmap_cleared(const struct sbitmap_context *sc)
|
|
|
aefe19 |
{
|
|
|
aefe19 |
- return __sbitmap_weight(sc, false);
|
|
|
aefe19 |
+ if (VALID_MEMBER(sbitmap_word_cleared)) /* 5.0 and later */
|
|
|
aefe19 |
+ return __sbitmap_weight(sc, false);
|
|
|
aefe19 |
+
|
|
|
aefe19 |
+ return 0;
|
|
|
aefe19 |
}
|
|
|
aefe19 |
|
|
|
aefe19 |
static void sbitmap_emit_byte(unsigned int offset, uint8_t byte)
|
|
|
aefe19 |
@@ -149,7 +154,6 @@ static void sbitmap_bitmap_show(const struct sbitmap_context *sc)
|
|
|
aefe19 |
{
|
|
|
aefe19 |
const ulong sbitmap_word_size = SIZE(sbitmap_word);
|
|
|
aefe19 |
const ulong w_word_off = OFFSET(sbitmap_word_word);
|
|
|
aefe19 |
- const ulong w_cleared_off = OFFSET(sbitmap_word_cleared);
|
|
|
aefe19 |
|
|
|
aefe19 |
uint8_t byte = 0;
|
|
|
aefe19 |
unsigned int byte_bits = 0;
|
|
|
aefe19 |
@@ -169,7 +173,10 @@ static void sbitmap_bitmap_show(const struct sbitmap_context *sc)
|
|
|
aefe19 |
}
|
|
|
aefe19 |
|
|
|
aefe19 |
word = ULONG(sbitmap_word_buf + w_word_off);
|
|
|
aefe19 |
- cleared = ULONG(sbitmap_word_buf + w_cleared_off);
|
|
|
aefe19 |
+ if (VALID_MEMBER(sbitmap_word_cleared))
|
|
|
aefe19 |
+ cleared = ULONG(sbitmap_word_buf + OFFSET(sbitmap_word_cleared));
|
|
|
aefe19 |
+ else
|
|
|
aefe19 |
+ cleared = 0;
|
|
|
aefe19 |
word_bits = __map_depth(sc, i);
|
|
|
aefe19 |
|
|
|
aefe19 |
word &= ~cleared;
|
|
|
aefe19 |
@@ -219,7 +226,6 @@ static void __sbitmap_for_each_set(const struct sbitmap_context *sc,
|
|
|
aefe19 |
{
|
|
|
aefe19 |
const ulong sbitmap_word_size = SIZE(sbitmap_word);
|
|
|
aefe19 |
const ulong w_word_off = OFFSET(sbitmap_word_word);
|
|
|
aefe19 |
- const ulong w_cleared_off = OFFSET(sbitmap_word_cleared);
|
|
|
aefe19 |
|
|
|
aefe19 |
unsigned int index;
|
|
|
aefe19 |
unsigned int nr;
|
|
|
aefe19 |
@@ -245,7 +251,10 @@ static void __sbitmap_for_each_set(const struct sbitmap_context *sc,
|
|
|
aefe19 |
}
|
|
|
aefe19 |
|
|
|
aefe19 |
w_word = ULONG(sbitmap_word_buf + w_word_off);
|
|
|
aefe19 |
- w_cleared = ULONG(sbitmap_word_buf + w_cleared_off);
|
|
|
aefe19 |
+ if (VALID_MEMBER(sbitmap_word_cleared))
|
|
|
aefe19 |
+ w_cleared = ULONG(sbitmap_word_buf + OFFSET(sbitmap_word_cleared));
|
|
|
aefe19 |
+ else
|
|
|
aefe19 |
+ w_cleared = 0;
|
|
|
aefe19 |
|
|
|
aefe19 |
depth = min(__map_depth(sc, index) - nr, sc->depth - scanned);
|
|
|
aefe19 |
|
|
|
aefe19 |
@@ -297,7 +306,8 @@ static void sbitmap_queue_show(const struct sbitmap_queue_context *sqc,
|
|
|
aefe19 |
|
|
|
aefe19 |
fprintf(fp, "depth = %u\n", sc->depth);
|
|
|
aefe19 |
fprintf(fp, "busy = %u\n", sbitmap_weight(sc) - sbitmap_cleared(sc));
|
|
|
aefe19 |
- fprintf(fp, "cleared = %u\n", sbitmap_cleared(sc));
|
|
|
aefe19 |
+ if (VALID_MEMBER(sbitmap_word_cleared)) /* 5.0 and later */
|
|
|
aefe19 |
+ fprintf(fp, "cleared = %u\n", sbitmap_cleared(sc));
|
|
|
aefe19 |
fprintf(fp, "bits_per_word = %u\n", 1U << sc->shift);
|
|
|
aefe19 |
fprintf(fp, "map_nr = %u\n", sc->map_nr);
|
|
|
aefe19 |
|
|
|
aefe19 |
--
|
|
|
aefe19 |
2.30.2
|
|
|
aefe19 |
|