Skip to content

Commit

Permalink
Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/…
Browse files Browse the repository at this point in the history
…git/vbabka/slab.git
  • Loading branch information
Mark Brown committed Feb 23, 2022
2 parents 5e0ec34 + d3d5993 commit 9b45d9a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 19 deletions.
3 changes: 1 addition & 2 deletions include/linux/slab.h
Original file line number Diff line number Diff line change
Expand Up @@ -660,8 +660,7 @@ static inline __alloc_size(1, 2) void *kcalloc(size_t n, size_t size, gfp_t flag
* allocator where we care about the real place the memory allocation
* request comes from.
*/
extern void *__kmalloc_track_caller(size_t size, gfp_t flags, unsigned long caller)
__alloc_size(1);
extern void *__kmalloc_track_caller(size_t size, gfp_t flags, unsigned long caller);
#define kmalloc_track_caller(size, flags) \
__kmalloc_track_caller(size, flags, _RET_IP_)

Expand Down
2 changes: 1 addition & 1 deletion mm/slab_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ void __init setup_kmalloc_cache_index_table(void)
unsigned int i;

BUILD_BUG_ON(KMALLOC_MIN_SIZE > 256 ||
(KMALLOC_MIN_SIZE & (KMALLOC_MIN_SIZE - 1)));
!is_power_of_2(KMALLOC_MIN_SIZE));

for (i = 8; i < KMALLOC_MIN_SIZE; i += 8) {
unsigned int elem = size_index_elem(i);
Expand Down
2 changes: 1 addition & 1 deletion mm/slob.c
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ int __kmem_cache_shrink(struct kmem_cache *d)
return 0;
}

struct kmem_cache kmem_cache_boot = {
static struct kmem_cache kmem_cache_boot = {
.name = "kmem_cache",
.size = sizeof(struct kmem_cache),
.flags = SLAB_PANIC,
Expand Down
30 changes: 15 additions & 15 deletions tools/cgroup/memcg_slabinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from drgn.helpers.linux import for_each_page
from drgn.helpers.linux.cpumask import for_each_online_cpu
from drgn.helpers.linux.percpu import per_cpu_ptr
from drgn import container_of, FaultError, Object
from drgn import container_of, FaultError, Object, cast


DESC = """
Expand Down Expand Up @@ -69,15 +69,15 @@ def oo_objects(s):


def count_partial(n, fn):
nr_pages = 0
for page in list_for_each_entry('struct page', n.partial.address_of_(),
'lru'):
nr_pages += fn(page)
return nr_pages
nr_objs = 0
for slab in list_for_each_entry('struct slab', n.partial.address_of_(),
'slab_list'):
nr_objs += fn(slab)
return nr_objs


def count_free(page):
return page.objects - page.inuse
def count_free(slab):
return slab.objects - slab.inuse


def slub_get_slabinfo(s, cfg):
Expand Down Expand Up @@ -145,14 +145,14 @@ def detect_kernel_config():
return cfg


def for_each_slab_page(prog):
def for_each_slab(prog):
PGSlab = 1 << prog.constant('PG_slab')
PGHead = 1 << prog.constant('PG_head')

for page in for_each_page(prog):
try:
if page.flags.value_() & PGSlab:
yield page
yield cast('struct slab *', page)
except FaultError:
pass

Expand Down Expand Up @@ -190,13 +190,13 @@ def main():
'list'):
obj_cgroups.add(ptr.value_())

# look over all slab pages, belonging to non-root memcgs
# and look for objects belonging to the given memory cgroup
for page in for_each_slab_page(prog):
objcg_vec_raw = page.memcg_data.value_()
# look over all slab folios and look for objects belonging
# to the given memory cgroup
for slab in for_each_slab(prog):
objcg_vec_raw = slab.memcg_data.value_()
if objcg_vec_raw == 0:
continue
cache = page.slab_cache
cache = slab.slab_cache
if not cache:
continue
addr = cache.value_()
Expand Down

0 comments on commit 9b45d9a

Please sign in to comment.