From patchwork Mon Apr 23 16:42:26 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: 8051 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 B26A523E22 for ; Mon, 23 Apr 2012 16:42:37 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id 7A34FA181B8 for ; Mon, 23 Apr 2012 16:42:37 +0000 (UTC) Received: by mail-iy0-f180.google.com with SMTP id e36so23096175iag.11 for ; Mon, 23 Apr 2012 09:42:37 -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-gm-message-state; bh=IPuCOcVmMYoPQ7V69wGBnruJJJHuZP9OvZ2LwzTvXIw=; b=IHEQRC951chPyfB56ao2DtGGMXNCBBQsFP36jk5Hf5QZq4acjSi7ChGNU6VGJhQc4a MWHDaxlM6ZJFZiZzjgGYEpNwPZnXTKa8gTYHl1eyH/43FtVstwCgitXTqZvzJzmY4Ppm v7lBfXxuTtcl8AUOkCBB7i7OFpRtOvYJXXS6NvzDua/p7+Znya4gM1EPhApk1uXbg3Zr ZQLxESfb0jzDDeWLEfEQYCWs+0LrSe90pTwftSiGeWgF16nHZ9BCVtf08ea6Nwu3LCfM B+ex7Rkk+BNdYR1qtJMZ/mciONNhfQSIZVDI57BwIKi2P4yX9j5/UbY14tds3DTDbvHI hXjg== Received: by 10.50.194.163 with SMTP id hx3mr7002040igc.49.1335199357242; Mon, 23 Apr 2012 09:42:37 -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.231.137.198 with SMTP id x6csp125332ibt; Mon, 23 Apr 2012 09:42:36 -0700 (PDT) Received: by 10.50.155.168 with SMTP id vx8mr7154379igb.11.1335199356815; Mon, 23 Apr 2012 09:42:36 -0700 (PDT) Received: from e8.ny.us.ibm.com (e8.ny.us.ibm.com. [32.97.182.138]) by mx.google.com with ESMTPS id xf6si9252253igb.9.2012.04.23.09.42.36 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 23 Apr 2012 09:42:36 -0700 (PDT) Received-SPF: pass (google.com: domain of paulmck@linux.vnet.ibm.com designates 32.97.182.138 as permitted sender) client-ip=32.97.182.138; Authentication-Results: mx.google.com; spf=pass (google.com: domain of paulmck@linux.vnet.ibm.com designates 32.97.182.138 as permitted sender) smtp.mail=paulmck@linux.vnet.ibm.com Received: from /spool/local by e8.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 23 Apr 2012 12:42:36 -0400 Received: from d01dlp01.pok.ibm.com (9.56.224.56) by e8.ny.us.ibm.com (192.168.1.108) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 23 Apr 2012 12:42:35 -0400 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by d01dlp01.pok.ibm.com (Postfix) with ESMTP id AC99C38C8071 for ; Mon, 23 Apr 2012 12:42:33 -0400 (EDT) Received: from d03av01.boulder.ibm.com (d03av01.boulder.ibm.com [9.17.195.167]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q3NGgWQA065162 for ; Mon, 23 Apr 2012 12:42:32 -0400 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 q3NGgUen018648 for ; Mon, 23 Apr 2012 10:42:31 -0600 Received: from paulmck-ThinkPad-W500 ([9.47.24.152]) by d03av01.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q3NGgTOW018619; Mon, 23 Apr 2012 10:42:29 -0600 Received: by paulmck-ThinkPad-W500 (Postfix, from userid 1000) id 96132E5279; Mon, 23 Apr 2012 09:42:29 -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, patches@linaro.org, Jan Engelhardt , "Paul E. McKenney" Subject: [PATCH RFC tip/core/rcu 5/6] rcu: Make __kfree_rcu() less dependent on compiler choices Date: Mon, 23 Apr 2012 09:42:26 -0700 Message-Id: <1335199347-13926-5-git-send-email-paulmck@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.8 In-Reply-To: <1335199347-13926-1-git-send-email-paulmck@linux.vnet.ibm.com> References: <20120423164159.GA13819@linux.vnet.ibm.com> <1335199347-13926-1-git-send-email-paulmck@linux.vnet.ibm.com> X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12042316-9360-0000-0000-000005ABAB0D X-Gm-Message-State: ALoCoQmqWi5W090f7v5YMLBJ3V6UjnbpfHWeOQwtPg9D58fkKFPqVgGeDAuSd2/Y0cz9KyML/nq3 From: Jan Engelhardt Currently, __kfree_rcu() is implemented as an inline function, and contains a BUILD_BUG_ON() that malfunctions if __kfree_rcu() is compiled as an out-of-line function. Unfortunately, there are compiler settings (e.g., -O0) that can result in __kfree_rcu() being compiled out of line, resulting in annoying build breakage. This commit therefore converts both __kfree_rcu() and __is_kfree_rcu_offset() from inline functions to macros to prevent such misbehavior on the part of the compiler. Signed-off-by: Jan Engelhardt Signed-off-by: Paul E. McKenney Reviewed-by: Josh Triplett --- include/linux/rcupdate.h | 18 ++++++++++++++++++ 1 files changed, 18 insertions(+), 0 deletions(-) diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h index 20fb776..d5dfb10 100644 --- a/include/linux/rcupdate.h +++ b/include/linux/rcupdate.h @@ -922,6 +922,21 @@ void __kfree_rcu(struct rcu_head *head, unsigned long offset) kfree_call_rcu(head, (rcu_callback)offset); } +/* + * Does the specified offset indicate that the corresponding rcu_head + * structure can be handled by kfree_rcu()? + */ +#define __is_kfree_rcu_offset(offset) ((offset) < 4096) + +/* + * Helper macro for kfree_rcu() to prevent argument-expansion eyestrain. + */ +#define __kfree_rcu(head, offset) \ + do { \ + BUILD_BUG_ON(!__is_kfree_rcu_offset(offset)); \ + call_rcu(head, (void (*)(struct rcu_head *))(unsigned long)(offset)); \ + } while (0) + /** * kfree_rcu() - kfree an object after a grace period. * @ptr: pointer to kfree @@ -944,6 +959,9 @@ void __kfree_rcu(struct rcu_head *head, unsigned long offset) * * Note that the allowable offset might decrease in the future, for example, * to allow something like kmem_cache_free_rcu(). + * + * The BUILD_BUG_ON check must not involve any function calls, hence the + * checks are done in macros here. */ #define kfree_rcu(ptr, rcu_head) \ __kfree_rcu(&((ptr)->rcu_head), offsetof(typeof(*(ptr)), rcu_head))