public inbox for linux-doc@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/3] Documentation: adopt new coding style of type-aware kmalloc-family
@ 2026-04-24 17:47 Manuel Ebner
  2026-04-24 17:51 ` [PATCH v3 1/3] " Manuel Ebner
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Manuel Ebner @ 2026-04-24 17:47 UTC (permalink / raw)
  To: Jonathan Corbet, Shuah Khan, linux-doc, Kees Cook
  Cc: linux-kernel, workflows, linux-sound, rcu, linux-media, linux-mm,
	Manuel Ebner

Update the documentation to reflect new type-aware kmalloc-family as
suggested in commit 2932ba8d9c99 ("slab: Introduce kmalloc_obj()
and family")

On Tue, 2026-04-21 at 19:55 +0200, Manuel Ebner wrote:
> I have also thought about adding a few cases to checkpatch.pl, but this
> will take me more time, and i want to get this series finished.
I can't do it, i don't have the knowledge in Perl and Regex.

 [v2] -> [v3]:
remove obvious wrong replacements in [1/3]
add Acked-by: Paul E. McKenney in [2/3]
change how to mark the optional argument in [3/3]
add recipants
 --cc="linux-mm@kvack.org"
 --to="Kees Cook"
 --cc="Geert Uytterhoeven"

 [v1] -> [v2]:
put RCU/* in a seperate patch [Patch 2/3]
Omit optional argument (GFP_KERNEL) as suggested by https://lwn.net/Articles/1062856/
deprecated.rst: change the argument gfp to optional [Patch 3/3]

Signed-off-by: Manuel Ebner <manuelebner@mailbox.org>

^ permalink raw reply	[flat|nested] 7+ messages in thread
* Re: [PATCH v2 2/3] Documentation: RCU: adopt new coding style of type-aware kmalloc-family
@ 2026-04-21 18:41 Paul E. McKenney
  2026-04-25  5:39 ` [PATCH v3 " Manuel Ebner
  0 siblings, 1 reply; 7+ messages in thread
From: Paul E. McKenney @ 2026-04-21 18:41 UTC (permalink / raw)
  To: Manuel Ebner; +Cc: Jonathan Corbet, Shuah Khan, linux-doc, rcu, Kees Cook

On Tue, Apr 21, 2026 at 08:06:53PM +0200, Manuel Ebner wrote:
> Update Documentation/RCU/* to reflect new type-aware kmalloc-family as
> suggested in commit 2932ba8d9c99 ("slab: Introduce kmalloc_obj() and family")
> 
> ptr = kmalloc(sizeof(*ptr), gfp);
>  -> ptr = kmalloc_obj(*ptr);
> 
> Signed-off-by: Manuel Ebner <manuelebner@mailbox.org>

Acked-by: Paul E. McKenney <paulmck@kernel.org>

> ---
>  Documentation/RCU/Design/Requirements/Requirements.rst | 6 +++---
>  Documentation/RCU/listRCU.rst                          | 2 +-
>  Documentation/RCU/whatisRCU.rst                        | 4 ++--
>  3 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/Documentation/RCU/Design/Requirements/Requirements.rst b/Documentation/RCU/Design/Requirements/Requirements.rst
> index b5cdbba3ec2e..faca5a9c8c12 100644
> --- a/Documentation/RCU/Design/Requirements/Requirements.rst
> +++ b/Documentation/RCU/Design/Requirements/Requirements.rst
> @@ -206,7 +206,7 @@ non-\ ``NULL``, locklessly accessing the ``->a`` and ``->b`` fields.
>  
>         1 bool add_gp_buggy(int a, int b)
>         2 {
> -       3   p = kmalloc(sizeof(*p), GFP_KERNEL);
> +       3   p = kmalloc_obj(*p);
>         4   if (!p)
>         5     return -ENOMEM;
>         6   spin_lock(&gp_lock);
> @@ -228,7 +228,7 @@ their rights to reorder this code as follows:
>  
>         1 bool add_gp_buggy_optimized(int a, int b)
>         2 {
> -       3   p = kmalloc(sizeof(*p), GFP_KERNEL);
> +       3   p = kmalloc_obj(*p);
>         4   if (!p)
>         5     return -ENOMEM;
>         6   spin_lock(&gp_lock);
> @@ -264,7 +264,7 @@ shows an example of insertion:
>  
>         1 bool add_gp(int a, int b)
>         2 {
> -       3   p = kmalloc(sizeof(*p), GFP_KERNEL);
> +       3   p = kmalloc_obj(*p);
>         4   if (!p)
>         5     return -ENOMEM;
>         6   spin_lock(&gp_lock);
> diff --git a/Documentation/RCU/listRCU.rst b/Documentation/RCU/listRCU.rst
> index d8bb98623c12..48c7272a4ccc 100644
> --- a/Documentation/RCU/listRCU.rst
> +++ b/Documentation/RCU/listRCU.rst
> @@ -276,7 +276,7 @@ The RCU version of audit_upd_rule() is as follows::
>  
>  		list_for_each_entry(e, list, list) {
>  			if (!audit_compare_rule(rule, &e->rule)) {
> -				ne = kmalloc(sizeof(*entry), GFP_ATOMIC);
> +				ne = kmalloc_obj(*entry, GFP_ATOMIC);
>  				if (ne == NULL)
>  					return -ENOMEM;
>  				audit_copy_rule(&ne->rule, &e->rule);
> diff --git a/Documentation/RCU/whatisRCU.rst b/Documentation/RCU/whatisRCU.rst
> index a1582bd653d1..770aab8ea36a 100644
> --- a/Documentation/RCU/whatisRCU.rst
> +++ b/Documentation/RCU/whatisRCU.rst
> @@ -468,7 +468,7 @@ uses of RCU may be found in listRCU.rst and NMI-RCU.rst.
>  		struct foo *new_fp;
>  		struct foo *old_fp;
>  
> -		new_fp = kmalloc(sizeof(*new_fp), GFP_KERNEL);
> +		new_fp = kmalloc_obj(*new_fp);
>  		spin_lock(&foo_mutex);
>  		old_fp = rcu_dereference_protected(gbl_foo, lockdep_is_held(&foo_mutex));
>  		*new_fp = *old_fp;
> @@ -570,7 +570,7 @@ The foo_update_a() function might then be written as follows::
>  		struct foo *new_fp;
>  		struct foo *old_fp;
>  
> -		new_fp = kmalloc(sizeof(*new_fp), GFP_KERNEL);
> +		new_fp = kmalloc_obj(*new_fp);
>  		spin_lock(&foo_mutex);
>  		old_fp = rcu_dereference_protected(gbl_foo, lockdep_is_held(&foo_mutex));
>  		*new_fp = *old_fp;
> -- 
> 2.53.0
> 
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-04-27  9:51 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-24 17:47 [PATCH v3 0/3] Documentation: adopt new coding style of type-aware kmalloc-family Manuel Ebner
2026-04-24 17:51 ` [PATCH v3 1/3] " Manuel Ebner
2026-04-24 17:55 ` [PATCH v3 2/3] Documentation: RCU: " Manuel Ebner
2026-04-25  5:46   ` Manuel Ebner
2026-04-24 17:57 ` [PATCH v3 3/3] Documentation: deprecated.rst: kmalloc-family: mark argument as optional Manuel Ebner
2026-04-27  9:51   ` Jonathan Corbet
  -- strict thread matches above, loose matches on Subject: below --
2026-04-21 18:41 [PATCH v2 2/3] Documentation: RCU: adopt new coding style of type-aware kmalloc-family Paul E. McKenney
2026-04-25  5:39 ` [PATCH v3 " Manuel Ebner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox