From: Tejun Heo <tj@kernel.org>
To: Wanlong Gao <gaowanlong@cn.fujitsu.com>
Cc: josh@kernel.org, linux-sparse@vger.kernel.org,
Wu Fengguang <fengguang.wu@intel.com>,
kbuild-all@01.org, Rusty Russell <rusty@rustcorp.com.au>,
Christoph Lameter <cl@linux-foundation.org>
Subject: [PATCH] percpu: fix spurious sparse warnings from DEFINE_PER_CPU()
Date: Thu, 5 Dec 2013 13:01:17 -0500 [thread overview]
Message-ID: <20131205180117.GA25939@mtj.dyndns.org> (raw)
In-Reply-To: <529FC670.2080308@cn.fujitsu.com>
Applied the following to percpu/for-3.13-fixes.
Thanks!
------ 8< ------
From b1a0fbfdde65dffd83c84c006f84fa12041907c5 Mon Sep 17 00:00:00 2001
From: Tejun Heo <tj@kernel.org>
Date: Wed, 4 Dec 2013 10:12:40 -0500
When CONFIG_DEBUG_FORCE_WEAK_PER_CPU or CONFIG_ARCH_NEEDS_WEAK_PER_CPU
is set, DEFINE_PER_CPU() explodes into cryptic series of definitions
to still allow using "static" for percpu variables while keeping all
per-cpu symbols unique in the kernel image which is required for weak
symbols. This ultimately converts the actual symbol to global whether
DEFINE_PER_CPU() is prefixed with static or not.
Unfortunately, the macro forgot to add explicit extern declartion of
the actual symbol ending up defining global symbol without preceding
declaration for static definitions which naturally don't have matching
DECLARE_PER_CPU(). The only ill effect is triggering of the following
warnings.
fs/inode.c:74:8: warning: symbol 'nr_inodes' was not declared. Should it be static?
fs/inode.c:75:8: warning: symbol 'nr_unused' was not declared. Should it be static?
Fix it by adding extern declaration in the DEFINE_PER_CPU() macro.
Signed-off-by: Tejun Heo <tj@kernel.org>
Reported-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
Tested-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
---
include/linux/percpu-defs.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/include/linux/percpu-defs.h b/include/linux/percpu-defs.h
index 57e890a..a5fc7d0 100644
--- a/include/linux/percpu-defs.h
+++ b/include/linux/percpu-defs.h
@@ -69,6 +69,7 @@
__PCPU_DUMMY_ATTRS char __pcpu_scope_##name; \
extern __PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \
__PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \
+ extern __PCPU_ATTRS(sec) __typeof__(type) name; \
__PCPU_ATTRS(sec) PER_CPU_DEF_ATTRIBUTES __weak \
__typeof__(type) name
#else
--
1.8.4.2
prev parent reply other threads:[~2013-12-05 18:01 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-26 3:37 [BUG report]sparse warnings on DEFINE_PER_CPU() symbols non-static Wanlong Gao
2013-12-03 22:25 ` Tejun Heo
2013-12-03 23:43 ` Josh Triplett
2013-12-04 15:10 ` Tejun Heo
2013-12-04 3:26 ` Wanlong Gao
2013-12-04 15:12 ` Tejun Heo
2013-12-05 0:18 ` Wanlong Gao
2013-12-05 18:01 ` Tejun Heo [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20131205180117.GA25939@mtj.dyndns.org \
--to=tj@kernel.org \
--cc=cl@linux-foundation.org \
--cc=fengguang.wu@intel.com \
--cc=gaowanlong@cn.fujitsu.com \
--cc=josh@kernel.org \
--cc=kbuild-all@01.org \
--cc=linux-sparse@vger.kernel.org \
--cc=rusty@rustcorp.com.au \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).