File tree 1 file changed +15
-1
lines changed
sdb/commands/spl/internal 1 file changed +15
-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,25 @@ 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
+ 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
100
114
return int (cache .skc_obj_alloc .value_ ())
101
115
102
116
You can’t perform that action at this time.
0 commit comments