slab fixes for 5.17-rc6

-----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCAAdFiEEjUuTAak14xi+SF7M4CHKc/GJqRAFAmIV/fQACgkQ4CHKc/GJ
 qRBhaAgAoz81fjhlkcCaHdgxVTEx6L93iJQJiZWoE3gTKk2jruun3sIYmPSOiY+b
 bWR1datDnvaS/Xv04rZ6pm6XPjCT+LmrOQCOlZMjptc6HKoKuDZTvcQ0u5CYOfQS
 I9ZRtPaHjSmhntS8BErxGes5+PF1hz/q2rGuODt4/DQCNPZNdHXMdym9w4Z4xHXm
 TuH2VXzv5JXhYlUEDz2HP8LXmbvxA9rGaMgngpX92pCL8uTLqANoZCT+zHEj3cKw
 db6/A8S7Y4PsfF0JphNup+wcsWj+yfIrfAQwnTgNXR4hlhbUxOHTJqXlQGK/NW7C
 tg2nXxQQn14MwPlkatdxFYzg1TbMYg==
 =U6Fu
 -----END PGP SIGNATURE-----

Merge tag 'slab-for-5.17-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/vbabka/slab

Pull slab fixes from Vlastimil Babka:

 - Build fix (workaround) for clang.

 - Fix a /proc/kcore based slabinfo script broken by struct slab changes
   in 5.17-rc1.

* tag 'slab-for-5.17-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/vbabka/slab:
  tools/cgroup/slabinfo: update to work with struct slab
  slab: remove __alloc_size attribute from __kmalloc_track_caller
This commit is contained in:
Linus Torvalds 2022-02-23 11:33:12 -08:00
commit 4eb0a7c8e1
2 changed files with 16 additions and 17 deletions

View File

@ -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_)

View File

@ -11,7 +11,7 @@ from drgn.helpers.linux import list_for_each_entry, list_empty
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 = """
@ -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):
@ -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
@ -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_()