Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion sdb/commands/spl/internal/kmem_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import drgn
import drgn.helpers.linux.list as drgn_list
import drgn.helpers.linux.percpu as drgn_percpu

import sdb
from sdb.commands.internal import p2
Expand Down Expand Up @@ -91,12 +92,25 @@ def object_size(cache: drgn.Object) -> int:
def nr_objects(cache: drgn.Object) -> int:
assert sdb.type_canonical_name(cache.type_) == 'struct spl_kmem_cache *'
if backed_by_linux_cache(cache):
return int(cache.skc_obj_alloc.value_())
return obj_alloc(cache)
return int(cache.skc_obj_total.value_())


def obj_alloc(cache: drgn.Object) -> int:
assert sdb.type_canonical_name(cache.type_) == 'struct spl_kmem_cache *'
if backed_by_linux_cache(cache):
try:
return int(drgn_percpu.percpu_counter_sum(cache.skc_linux_alloc))
except AttributeError:
#
# The percpu_counter referenced above wasn't in ZoL until the
# following commit: ec1fea4516ac2f0c08d31d6308929298d1b281d0
#
# Fall back to the old-mechanism of using skc_obj_alloc if that
# percpu_counter member doesn't exist (an AttributeError will
# be thrown).
#
pass
return int(cache.skc_obj_alloc.value_())


Expand Down
1 change: 1 addition & 0 deletions tests/integration/test_core_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

# pylint: disable=missing-module-docstring
# pylint: disable=missing-function-docstring
# pylint: disable=not-callable

from typing import Any

Expand Down
1 change: 1 addition & 0 deletions tests/integration/test_linux_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# pylint: disable=missing-module-docstring
# pylint: disable=missing-function-docstring
# pylint: disable=line-too-long
# pylint: disable=not-callable

from typing import Any

Expand Down
1 change: 1 addition & 0 deletions tests/integration/test_spl_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# pylint: disable=missing-module-docstring
# pylint: disable=missing-function-docstring
# pylint: disable=line-too-long
# pylint: disable=not-callable

from typing import Any

Expand Down
1 change: 1 addition & 0 deletions tests/integration/test_zfs_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# pylint: disable=missing-module-docstring
# pylint: disable=missing-function-docstring
# pylint: disable=line-too-long
# pylint: disable=not-callable

from typing import Any

Expand Down
1 change: 1 addition & 0 deletions tests/unit/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#

# pylint: disable=missing-docstring
# pylint: disable=not-callable

from typing import List, Tuple

Expand Down