Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

rcu: Update docs to include kfree_rcu()

Mention kfree_rcu() in the call_rcu() section. Additionally fix the
example code for list replacement that used the wrong structure element.

Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>

authored by

Kees Cook and committed by
Paul E. McKenney
57d34a6c 0f9574d8

+12 -3
+1 -1
Documentation/RCU/listRCU.txt
··· 205 205 audit_copy_rule(&ne->rule, &e->rule); 206 206 ne->rule.action = newaction; 207 207 ne->rule.file_count = newfield_count; 208 - list_replace_rcu(e, ne); 208 + list_replace_rcu(&e->list, &ne->list); 209 209 call_rcu(&e->rcu, audit_free_rule); 210 210 return 0; 211 211 }
+11 -2
Documentation/RCU/whatisRCU.txt
··· 499 499 { 500 500 struct foo *fp = container_of(rp, struct foo, rcu); 501 501 502 + foo_cleanup(fp->a); 503 + 502 504 kfree(fp); 503 505 } 504 506 ··· 522 520 function that will be invoked after the completion of all RCU 523 521 read-side critical sections that might be referencing that 524 522 data item. 523 + 524 + If the callback for call_rcu() is not doing anything more than calling 525 + kfree() on the structure, you can use kfree_rcu() instead of call_rcu() 526 + to avoid having to write your own callback: 527 + 528 + kfree_rcu(old_fp, rcu); 525 529 526 530 Again, see checklist.txt for additional rules governing the use of RCU. 527 531 ··· 781 773 782 774 Also, the presence of synchronize_rcu() means that the RCU version of 783 775 delete() can now block. If this is a problem, there is a callback-based 784 - mechanism that never blocks, namely call_rcu(), that can be used in 785 - place of synchronize_rcu(). 776 + mechanism that never blocks, namely call_rcu() or kfree_rcu(), that can 777 + be used in place of synchronize_rcu(). 786 778 787 779 788 780 7. FULL LIST OF RCU APIs ··· 821 813 rcu_read_unlock synchronize_rcu 822 814 rcu_dereference synchronize_rcu_expedited 823 815 call_rcu 816 + kfree_rcu 824 817 825 818 826 819 bh: Critical sections Grace period Barrier