]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
Documentation: RCU: adopt new coding style of type-aware kmalloc-family
authorManuel Ebner <manuelebner@mailbox.org>
Wed, 29 Apr 2026 07:23:21 +0000 (09:23 +0200)
committerJonathan Corbet <corbet@lwn.net>
Sun, 3 May 2026 14:55:13 +0000 (08:55 -0600)
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, gfp);

Signed-off-by: Manuel Ebner <manuelebner@mailbox.org>
Acked-by: Paul E. McKenney <paulmck@kernel.org>
Acked-by: SeongJae Park <sj@kernel.org>
Acked-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Message-ID: <20260429072320.310817-2-manuelebner@mailbox.org>

Documentation/RCU/Design/Requirements/Requirements.rst
Documentation/RCU/listRCU.rst
Documentation/RCU/whatisRCU.rst

index 4d886e7c7a9564c088e61696aa4125c6a6098152..8a216e4a46a7dff1f38f5f6859306d6df1e878bf 100644 (file)
@@ -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);
index d8bb98623c124e23f868d0ed8a2c23f135ff4ca2..48c7272a4cccb07ecff914138126e54311d1d51f 100644 (file)
@@ -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);
index a1582bd653d115bad3a1002e6d2d25b779367b84..e6767baff2d34d8448f3d8bed7574b6e4eb896d5 100644 (file)
@@ -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;