File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
sdb/commands/spl/internal Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change 20
20
21
21
import drgn
22
22
import drgn .helpers .linux .list as drgn_list
23
+ import drgn .helpers .linux .percpu as drgn_percpu
23
24
24
25
import sdb
25
26
from sdb .commands .internal import p2
@@ -91,12 +92,23 @@ def object_size(cache: drgn.Object) -> int:
91
92
def nr_objects (cache : drgn .Object ) -> int :
92
93
assert sdb .type_canonical_name (cache .type_ ) == 'struct spl_kmem_cache *'
93
94
if backed_by_linux_cache (cache ):
94
- return int (cache . skc_obj_alloc . value_ () )
95
+ return obj_alloc (cache )
95
96
return int (cache .skc_obj_total .value_ ())
96
97
97
98
98
99
def obj_alloc (cache : drgn .Object ) -> int :
99
100
assert sdb .type_canonical_name (cache .type_ ) == 'struct spl_kmem_cache *'
101
+ try :
102
+ return int (drgn_percpu .percpu_counter_sum (cache .skc_linux_alloc ))
103
+ except AttributeError :
104
+ #
105
+ # The percpu_counter referenced above wasn't in ZoL until the
106
+ # following commit: ec1fea4516ac2f0c08d31d6308929298d1b281d0
107
+ #
108
+ # Fall back to the old-mechanism if that percpu_counter member
109
+ # doesn't exist (an AttributeError will be thrown).
110
+ #
111
+ return int (cache .skc_obj_alloc .value_ ())
100
112
return int (cache .skc_obj_alloc .value_ ())
101
113
102
114
You can’t perform that action at this time.
0 commit comments