cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: Vlastimil Babka <vbabka@suse.cz>
Cc: cocci@inria.fr
Subject: Re: [cocci] mm/slab: mass conversion of struct page to struct slab by spatch
Date: Sat, 6 Nov 2021 16:36:58 +0100	[thread overview]
Message-ID: <ab280f62-1069-bdb6-00a1-68bdb843e227@web.de> (raw)
In-Reply-To: <17a7a40f-b736-e0ea-02ae-1b03ef4483bf@suse.cz>

> Thanks in advance for any hints!

I have also taken another look at the proposed SmPL script file.
https://git.kernel.org/pub/scm/linux/kernel/git/vbabka/linux.git/diff/slab.cocci?h=slab-struct_slab-v1r8&id=ccd7da3f3888df4acd82448f861445d4593a9fcb

I have noticed then a few opportunities for a bit of fine-tuning
for the presented code according to the semantic patch language.


@convert_callers@
@@
(
(
-account_slab_page
+account_slab
|
-unaccount_slab_page
+unaccount_slab
)
  (
- page
+ slab
  , ...)
|
(
-PageSlabPfmemalloc
+slab_test_pfmemalloc
|
-ClearPageSlabPfmemalloc
+slab_clear_pfmemalloc
)
  (
- page
+ slab
  )
)

@convert_list_entry@
identifier fn =~ "^list_\w*entry(?:_or_null)?";
@@
-page
+slab
       = fn(...,
-          struct page
+          struct slab
            , ...)

@convert_param_struct_page_ptr@
identifier fn;
expression E;
@@
  fn(...,
-   struct page *page
+   struct slab *slab
     , ...)
  {
  <...
(
-page_node
+slab_node
|
-page_slab(page)
+slab
|
(
-page_address
+slab_address
|
-page_size
+slab_size
|
-page_to_nid
+slab_nid
)
  (
- page
+ slab
  )
|
-virt_to_head_page
+virt_to_slab
  (E)
|
-page
+slab
)
  ...>
  }

@convert_param_page_node@
identifier fn;
expression E;
@@
  fn(...,
     int
-       page_node
+       slab_node
     , ...)
  {
  <...
-page_node
+slab_node
  ...>
  }

@remove_slab_page_wrappers@
expression E;
@@
  index_to_obj(...,
-             slab_page(
                         E
-                      )
+             , ...)

@rename_called_function_parameter@
@@
  TODO(...,
-     page
+     slab
       , ...)

@convert_return_struct_page@
identifier fn =~ "^(?:cache_grow_begin|get_(?:valid_)?first_slab)";
expression E;
@@
  static
-struct page *
+struct slab *
  fn(...)
  {
  <...
-slab_page(
            E
-         )
  ...>
  }

@convert_local_struct_page@
identifier fn !~ "^kmem_(?:get|free)pages", tmp;
expression E;
@@
  fn(...)
  {
  <...
(
-struct page *page
+struct slab *slab
  ;
|
-struct page *
+struct slab *
  tmp;
|
-page_slab(page)
+slab
|
  kasan_poison_slab(
-                  page
+                  slab_page(slab)
                   )
|
(
-page_address
+slab_address
|
-page_size
+slab_size
|
-page_to_nid
+slab_nid
)
  (
- page
+ slab
  )
|
-page->pages
+slab->slabs
|
-page = virt_to_head_page
+slab = virt_to_slab
  (E)
|
-page
+slab
)
  ...>
  }


Regards,
Markus

  parent reply	other threads:[~2021-11-06 15:37 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-05 16:12 [cocci] Need some help with spatch Vlastimil Babka
2021-11-05 16:20 ` Luis Chamberlain
2021-11-06  6:44   ` Julia Lawall
2021-11-07 23:08   ` Vlastimil Babka
2021-11-08 14:35     ` Vlastimil Babka
2021-11-08 14:45       ` Julia Lawall
2021-11-08 16:53         ` Vlastimil Babka
2021-11-08 17:01           ` Julia Lawall
2021-11-05 20:56 ` Julia Lawall
2021-11-05 21:13 ` Julia Lawall
2021-11-05 21:24   ` Vlastimil Babka
2021-11-05 21:27     ` Julia Lawall
2021-11-05 21:31 ` Julia Lawall
2021-11-05 21:32   ` Vlastimil Babka
2021-11-05 21:43 ` Julia Lawall
2021-11-05 21:59 ` Julia Lawall
2021-11-06 15:36 ` Markus Elfring [this message]
2021-11-07 12:10 ` [cocci] mm/slab: prepare for struct patch conversion by spatch Markus Elfring
2021-11-07 12:22   ` Julia Lawall
2021-11-07 12:50     ` [cocci] mm/slab: prepare for struct page " Markus Elfring
2021-11-07 13:18       ` Julia Lawall
2021-11-07 13:40         ` Markus Elfring
2021-11-07 17:50       ` Vlastimil Babka
2021-11-07 18:09         ` Julia Lawall
2021-11-08 17:35           ` Markus Elfring
2021-11-08 17:40             ` Julia Lawall
2021-11-08 23:35             ` Vlastimil Babka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ab280f62-1069-bdb6-00a1-68bdb843e227@web.de \
    --to=markus.elfring@web.de \
    --cc=cocci@inria.fr \
    --cc=vbabka@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).