From patchwork Tue Oct 30 16:04:35 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 12580 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 0BF3523FB0 for ; Tue, 30 Oct 2012 16:06:23 +0000 (UTC) Received: from mail-ia0-f180.google.com (mail-ia0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id 8EE53A18F12 for ; Tue, 30 Oct 2012 16:06:22 +0000 (UTC) Received: by mail-ia0-f180.google.com with SMTP id f6so284628iag.11 for ; Tue, 30 Oct 2012 09:06:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-content-scanned:x-cbid:x-ibm-iss-spamdetectors :x-ibm-iss-detailinfo:x-gm-message-state; bh=hn/lSDhdaV6qedHWFhbYXntTFG/hFgcjNZX7JF8/4Hk=; b=SGAu59ovwUgkCGCsP1OEn5OeSxd6jWTQwC2diPvf7lvbwGGkHaZrOP7NOgFoocVA2A 30S0LdarLcXQZuTzs3VyuK60DHzWkE5Hu5yTzfSXiDAFfCDanod5d91xLfCzSJf/I82S JTvKTX4ntnnK/59srK/HsrMZx0JMDC6zApXwrCZGPuyiCx5LBNTowL2NEPPG0uspU4FU LQ33IqleofBF5ShlqodAkvNhiGZf6662dX2D7d0ZlpgKhpiTtgq1TGjT8rhpNuJ8BKN3 qLBGNov+DbOlVz++wSXmOVHiShMjIFBzmVSVnqcT/zuLS8GqGMbtAsBisXWmbY8YEntG eGSA== Received: by 10.42.57.10 with SMTP id b10mr29087585ich.54.1351613181902; Tue, 30 Oct 2012 09:06:21 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.67.148 with SMTP id n20csp439919igt; Tue, 30 Oct 2012 09:06:21 -0700 (PDT) Received: by 10.50.179.33 with SMTP id dd1mr1987980igc.31.1351613181583; Tue, 30 Oct 2012 09:06:21 -0700 (PDT) Received: from e33.co.us.ibm.com (e33.co.us.ibm.com. [32.97.110.151]) by mx.google.com with ESMTPS id qp3si9799703igc.13.2012.10.30.09.06.21 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 30 Oct 2012 09:06:21 -0700 (PDT) Received-SPF: pass (google.com: domain of paulmck@linux.vnet.ibm.com designates 32.97.110.151 as permitted sender) client-ip=32.97.110.151; Authentication-Results: mx.google.com; spf=pass (google.com: domain of paulmck@linux.vnet.ibm.com designates 32.97.110.151 as permitted sender) smtp.mail=paulmck@linux.vnet.ibm.com Received: from /spool/local by e33.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 30 Oct 2012 10:06:19 -0600 Received: from d03dlp01.boulder.ibm.com (9.17.202.177) by e33.co.us.ibm.com (192.168.1.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 30 Oct 2012 10:04:50 -0600 Received: from d03relay04.boulder.ibm.com (d03relay04.boulder.ibm.com [9.17.195.106]) by d03dlp01.boulder.ibm.com (Postfix) with ESMTP id 9800EC4000F for ; Tue, 30 Oct 2012 10:04:47 -0600 (MDT) Received: from d03av01.boulder.ibm.com (d03av01.boulder.ibm.com [9.17.195.167]) by d03relay04.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q9UG4ikt126562 for ; Tue, 30 Oct 2012 10:04:44 -0600 Received: from d03av01.boulder.ibm.com (loopback [127.0.0.1]) by d03av01.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q9UG4g6I016392 for ; Tue, 30 Oct 2012 10:04:44 -0600 Received: from paulmck-ThinkPad-W500 (sig-9-77-143-103.mts.ibm.com [9.77.143.103]) by d03av01.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q9UG4dDs016047; Tue, 30 Oct 2012 10:04:40 -0600 Received: by paulmck-ThinkPad-W500 (Postfix, from userid 1000) id CA1F5EBE99; Tue, 30 Oct 2012 09:04:38 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: mingo@elte.hu, laijs@cn.fujitsu.com, dipankar@in.ibm.com, akpm@linux-foundation.org, mathieu.desnoyers@polymtl.ca, josh@joshtriplett.org, niv@us.ibm.com, tglx@linutronix.de, peterz@infradead.org, rostedt@goodmis.org, Valdis.Kletnieks@vt.edu, dhowells@redhat.com, eric.dumazet@gmail.com, darren@dvhart.com, fweisbec@gmail.com, sbw@mit.edu, patches@linaro.org, Kees Cook , "Paul E. McKenney" Subject: [PATCH tip/core/rcu 3/4] RCU: Update docs to include kfree_rcu() Date: Tue, 30 Oct 2012 09:04:35 -0700 Message-Id: <1351613076-22022-3-git-send-email-paulmck@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.8 In-Reply-To: <1351613076-22022-1-git-send-email-paulmck@linux.vnet.ibm.com> References: <20121030160350.GA21837@linux.vnet.ibm.com> <1351613076-22022-1-git-send-email-paulmck@linux.vnet.ibm.com> X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12103016-2398-0000-0000-00000D0E0028 X-IBM-ISS-SpamDetectors: X-IBM-ISS-DetailInfo: BY=3.00000294; HX=3.00000198; KW=3.00000007; PH=3.00000001; SC=3.00000008; SDB=6.00186989; UDB=6.00042358; UTC=2012-10-30 16:06:17 X-Gm-Message-State: ALoCoQlu7Etb3GvoI271lU9I/oNlPOARQ9gGOLoW4Q4HeRiJSv0MGfyJcfcLgkR14lE8E0dFKfMp From: Kees Cook 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 Signed-off-by: Paul E. McKenney --- Documentation/RCU/listRCU.txt | 2 +- Documentation/RCU/whatisRCU.txt | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Documentation/RCU/listRCU.txt b/Documentation/RCU/listRCU.txt index 4349c14..adb5a37 100644 --- a/Documentation/RCU/listRCU.txt +++ b/Documentation/RCU/listRCU.txt @@ -205,7 +205,7 @@ RCU ("read-copy update") its name. The RCU code is as follows: audit_copy_rule(&ne->rule, &e->rule); ne->rule.action = newaction; ne->rule.file_count = newfield_count; - list_replace_rcu(e, ne); + list_replace_rcu(&e->list, &ne->list); call_rcu(&e->rcu, audit_free_rule); return 0; } diff --git a/Documentation/RCU/whatisRCU.txt b/Documentation/RCU/whatisRCU.txt index bf0f6de..160ac55 100644 --- a/Documentation/RCU/whatisRCU.txt +++ b/Documentation/RCU/whatisRCU.txt @@ -499,6 +499,8 @@ The foo_reclaim() function might appear as follows: { struct foo *fp = container_of(rp, struct foo, rcu); + foo_cleanup(fp->a); + kfree(fp); } @@ -521,6 +523,12 @@ o Use call_rcu() -after- removing a data element from an read-side critical sections that might be referencing that data item. +If the callback for call_rcu() is not doing anything more than calling +kfree() on the structure, you can use kfree_rcu() instead of call_rcu() +to avoid having to write your own callback: + + kfree_rcu(old_fp, rcu); + Again, see checklist.txt for additional rules governing the use of RCU. @@ -773,8 +781,8 @@ a single atomic update, converting to RCU will require special care. Also, the presence of synchronize_rcu() means that the RCU version of delete() can now block. If this is a problem, there is a callback-based -mechanism that never blocks, namely call_rcu(), that can be used in -place of synchronize_rcu(). +mechanism that never blocks, namely call_rcu() or kfree_rcu(), that can +be used in place of synchronize_rcu(). 7. FULL LIST OF RCU APIs @@ -813,6 +821,7 @@ RCU: Critical sections Grace period Barrier rcu_read_unlock synchronize_rcu rcu_dereference synchronize_rcu_expedited call_rcu + kfree_rcu bh: Critical sections Grace period Barrier