Skip to content

Commit 31100eb

Browse files
committed
Merge remote-tracking branch 'origin/6.0/stage' into 6.0/release
2 parents 9957fde + 0d4599f commit 31100eb

File tree

7 files changed

+42
-9
lines changed

7 files changed

+42
-9
lines changed

sdb/commands/linux/internal/slub_helpers.py

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,18 @@ def for_each_child_cache(root_cache: drgn.Object) -> Iterable[drgn.Object]:
4444
"memcg_params.children_node")
4545

4646

47+
def for_each_node(cache: drgn.Object) -> Iterable[drgn.Object]:
48+
assert sdb.type_canonical_name(cache.type_) == 'struct kmem_cache *'
49+
node_num = sdb.get_object('nr_node_ids')
50+
for i in range(node_num):
51+
yield cache.node[i]
52+
53+
4754
def nr_slabs(cache: drgn.Object) -> int:
4855
assert sdb.type_canonical_name(cache.type_) == 'struct kmem_cache *'
49-
nslabs: int = cache.node[0].nr_slabs.counter.value_()
56+
nslabs = 0
57+
for node in for_each_node(cache):
58+
nslabs += node.nr_slabs.counter.value_()
5059
if is_root_cache(cache):
5160
for child in for_each_child_cache(cache):
5261
nslabs += nr_slabs(child)
@@ -78,7 +87,9 @@ def total_memory(cache: drgn.Object) -> int:
7887

7988
def objs(cache: drgn.Object) -> int:
8089
assert sdb.type_canonical_name(cache.type_) == 'struct kmem_cache *'
81-
count: int = cache.node[0].total_objects.counter.value_()
90+
count = 0
91+
for node in for_each_node(cache):
92+
count += node.total_objects.counter.value_()
8293
if is_root_cache(cache):
8394
for child in for_each_child_cache(cache):
8495
count += objs(child)
@@ -87,10 +98,12 @@ def objs(cache: drgn.Object) -> int:
8798

8899
def inactive_objs(cache: drgn.Object) -> int:
89100
assert sdb.type_canonical_name(cache.type_) == 'struct kmem_cache *'
90-
node = cache.node[0].partial # assumption nr_node_ids == 0
91101
free = 0
92-
for page in list_for_each_entry("struct page", node.address_of_(), "lru"):
93-
free += page.objects.value_() - page.inuse.value_()
102+
for node in for_each_node(cache):
103+
node_partial = node.partial
104+
for page in list_for_each_entry("struct page",
105+
node_partial.address_of_(), "lru"):
106+
free += page.objects.value_() - page.inuse.value_()
94107
if is_root_cache(cache):
95108
for child in for_each_child_cache(cache):
96109
free += inactive_objs(child)
@@ -178,9 +191,10 @@ def for_each_freeobj_in_slab(cache: drgn.Object,
178191

179192
def for_each_partial_slab_in_cache(cache: drgn.Object) -> Iterable[drgn.Object]:
180193
assert sdb.type_canonical_name(cache.type_) == 'struct kmem_cache *'
181-
182-
node = cache.node[0].partial # assumption nr_node_ids == 0
183-
yield from list_for_each_entry("struct page", node.address_of_(), "lru")
194+
for node in for_each_node(cache):
195+
node_partial = node.partial
196+
yield from list_for_each_entry("struct page",
197+
node_partial.address_of_(), "lru")
184198

185199
if is_root_cache(cache):
186200
for child in for_each_child_cache(cache):

sdb/commands/spl/internal/kmem_helpers.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import drgn
2222
import drgn.helpers.linux.list as drgn_list
23+
import drgn.helpers.linux.percpu as drgn_percpu
2324

2425
import sdb
2526
from sdb.commands.internal import p2
@@ -91,12 +92,25 @@ def object_size(cache: drgn.Object) -> int:
9192
def nr_objects(cache: drgn.Object) -> int:
9293
assert sdb.type_canonical_name(cache.type_) == 'struct spl_kmem_cache *'
9394
if backed_by_linux_cache(cache):
94-
return int(cache.skc_obj_alloc.value_())
95+
return obj_alloc(cache)
9596
return int(cache.skc_obj_total.value_())
9697

9798

9899
def obj_alloc(cache: drgn.Object) -> int:
99100
assert sdb.type_canonical_name(cache.type_) == 'struct spl_kmem_cache *'
101+
if backed_by_linux_cache(cache):
102+
try:
103+
return int(drgn_percpu.percpu_counter_sum(cache.skc_linux_alloc))
104+
except AttributeError:
105+
#
106+
# The percpu_counter referenced above wasn't in ZoL until the
107+
# following commit: ec1fea4516ac2f0c08d31d6308929298d1b281d0
108+
#
109+
# Fall back to the old-mechanism of using skc_obj_alloc if that
110+
# percpu_counter member doesn't exist (an AttributeError will
111+
# be thrown).
112+
#
113+
pass
100114
return int(cache.skc_obj_alloc.value_())
101115

102116

tests/integration/test_core_generic.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
# pylint: disable=missing-module-docstring
1818
# pylint: disable=missing-function-docstring
19+
# pylint: disable=not-callable
1920

2021
from typing import Any
2122

tests/integration/test_linux_generic.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
# pylint: disable=missing-module-docstring
1818
# pylint: disable=missing-function-docstring
1919
# pylint: disable=line-too-long
20+
# pylint: disable=not-callable
2021

2122
from typing import Any
2223

tests/integration/test_spl_generic.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
# pylint: disable=missing-module-docstring
1818
# pylint: disable=missing-function-docstring
1919
# pylint: disable=line-too-long
20+
# pylint: disable=not-callable
2021

2122
from typing import Any
2223

tests/integration/test_zfs_generic.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
# pylint: disable=missing-module-docstring
1818
# pylint: disable=missing-function-docstring
1919
# pylint: disable=line-too-long
20+
# pylint: disable=not-callable
2021

2122
from typing import Any
2223

tests/unit/test_parser.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#
1616

1717
# pylint: disable=missing-docstring
18+
# pylint: disable=not-callable
1819

1920
from typing import List, Tuple
2021

0 commit comments

Comments
 (0)