Thread (25 messages) 25 messages, 7 authors, 2022-01-03

Re: [PATCH v2 22/33] mm: Convert struct page to struct slab in functions used by other subsystems

From: Johannes Weiner <hidden>
Date: 2021-12-14 14:31:50
Also in: linux-mm, linux-patches

On Wed, Dec 01, 2021 at 07:14:59PM +0100, Vlastimil Babka wrote:
KASAN, KFENCE and memcg interact with SLAB or SLUB internals through functions
nearest_obj(), obj_to_index() and objs_per_slab() that use struct page as
parameter. This patch converts it to struct slab including all callers, through
a coccinelle semantic patch.

// Options: --include-headers --no-includes --smpl-spacing include/linux/slab_def.h include/linux/slub_def.h mm/slab.h mm/kasan/*.c mm/kfence/kfence_test.c mm/memcontrol.c mm/slab.c mm/slub.c
// Note: needs coccinelle 1.1.1 to avoid breaking whitespace

@@
@@

-objs_per_slab_page(
+objs_per_slab(
 ...
 )
 { ... }

@@
@@

-objs_per_slab_page(
+objs_per_slab(
 ...
 )

@@
identifier fn =~ "obj_to_index|objs_per_slab";
@@

 fn(...,
-   const struct page *page
+   const struct slab *slab
    ,...)
 {
<...
(
- page_address(page)
+ slab_address(slab)
|
- page
+ slab
)
...>
 }

@@
identifier fn =~ "nearest_obj";
@@

 fn(...,
-   struct page *page
+   const struct slab *slab
    ,...)
 {
<...
(
- page_address(page)
+ slab_address(slab)
|
- page
+ slab
)
...>
 }

@@
identifier fn =~ "nearest_obj|obj_to_index|objs_per_slab";
expression E;
@@

 fn(...,
(
- slab_page(E)
+ E
|
- virt_to_page(E)
+ virt_to_slab(E)
|
- virt_to_head_page(E)
+ virt_to_slab(E)
|
- page
+ page_slab(page)
)
  ,...)

Signed-off-by: Vlastimil Babka <redacted>
Cc: Julia Lawall <redacted>
Cc: Luis Chamberlain <redacted>
Cc: Andrey Ryabinin <redacted>
Cc: Alexander Potapenko <redacted>
Cc: Andrey Konovalov <redacted>
Cc: Dmitry Vyukov <redacted>
Cc: Marco Elver <redacted>
Cc: Johannes Weiner <redacted>
Cc: Michal Hocko <redacted>
Cc: Vladimir Davydov <redacted>
Cc: <kasan-dev-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
Cc: <redacted>
LGTM.

Acked-by: Johannes Weiner <redacted>
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help