linux-rt-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Luis Claudio R. Goncalves" <lclaudio@uudg.org>
To: linux-rt-users@vger.kernel.org
Cc: Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@elte.hu>,
	Clark Williams <williams@redhat.com>
Subject: [PATCH] net: iptables: rework the fix of xt_info locking
Date: Wed, 2 Mar 2011 17:14:14 -0300	[thread overview]
Message-ID: <20110302201414.GE8384@uudg.org> (raw)

Thomas,

Maybe PREEMPT_NONE is not really what we want to check against, maybe it is 
RT_MUTEXES... anyway, this patch works fine as is in kernels with
PREEMPT_NONE, PREEMPT_DESKTOP, PREEMPT_VOLUNTARY and PREEMPT_RT set.

---

net: iptables: rework the fix of xt_info locking

Commit 5bbbedc from tip/rt/2.6.33 fixed an annoying locking issue on
PREEMPT_RT enabled kernels. I have observed a similar issue when testing a
kernel with PREEMPT_DESKTOP enabled. My test kernels would boot fine and as
soon as I tried to ssh into the test box I would see messages like this one:

	BUG: %Ps exited with wrong preemption count!
	=> enter: 00000101, exit: 00000100.
	BUG: %Ps exited with wrong preemption count!
	=> enter: 00000101, exit: 00000100.
	BUG: %Ps exited with wrong preemption count!
	=> enter: 00000102, exit: 00000101.

And soon after a flood of backtraces such as:

	WARNING: at kernel/sched.c:5571 sub_preempt_count+0x68/0x87()

This patch extends the changes made to the PREEMPT_RT case to all of the cases
where PREEMPT_NONE is not enabled.

Signed-off-by: Luis Claudio R. Gonçalves <lgoncalv@redhat.com>

diff --git a/include/linux/netfilter/x_tables.h b/include/linux/netfilter/x_tables.h
index f85b72b..0b61a0f 100644
--- a/include/linux/netfilter/x_tables.h
+++ b/include/linux/netfilter/x_tables.h
@@ -439,7 +439,7 @@ extern void xt_free_table_info(struct xt_table_info *info);
  *  necessary for reading the counters.
  */
 struct xt_info_lock {
-#ifndef CONFIG_PREEMPT_RT
+#ifdef CONFIG_PREEMPT_NONE
 	spinlock_t lock;
 #else
 	rwlock_t lock;
@@ -471,7 +471,7 @@ static inline int xt_info_rdlock_bh(void)
 	cpu = smp_processor_id();
 	lock = &per_cpu(xt_info_locks, cpu);
 
-#ifndef CONFIG_PREEMPT_RT
+#ifdef CONFIG_PREEMPT_NONE
 	if (likely(!--lock->readers))
 		spin_unlock(&lock->lock);
 #else
@@ -485,7 +485,7 @@ static inline void xt_info_rdunlock_bh(int cpu)
 {
 	struct xt_info_lock *lock = &per_cpu(xt_info_locks, cpu);
 
-#ifndef CONFIG_PREEMPT_RT
+#ifdef CONFIG_PREEMPT_NONE
 	if (likely(!--lock->readers)) {
 		preempt_enable_rt();
 		spin_unlock(&lock->lock);
@@ -504,7 +504,7 @@ static inline void xt_info_rdunlock_bh(int cpu)
  */
 static inline void xt_info_wrlock(unsigned int cpu)
 {
-#ifndef CONFIG_PREEMPT_RT
+#ifdef CONFIG_PREEMPT_NONE
 	spin_lock(&per_cpu(xt_info_locks, cpu).lock);
 #else
 	write_lock(&per_cpu(xt_info_locks, cpu).lock);
@@ -513,7 +513,7 @@ static inline void xt_info_wrlock(unsigned int cpu)
 
 static inline void xt_info_wrunlock(unsigned int cpu)
 {
-#ifndef CONFIG_PREEMPT_RT
+#ifdef CONFIG_PREEMPT_NONE
 	spin_unlock(&per_cpu(xt_info_locks, cpu).lock);
 #else
 	write_unlock(&per_cpu(xt_info_locks, cpu).lock);
diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c
index 3eae9d9..546e6a1 100644
--- a/net/netfilter/x_tables.c
+++ b/net/netfilter/x_tables.c
@@ -1184,7 +1184,7 @@ static int __init xt_init(void)
 	for_each_possible_cpu(i) {
 		struct xt_info_lock *lock = &per_cpu(xt_info_locks, i);
 
-#ifndef CONFIG_PREEMPT_RT
+#ifdef CONFIG_PREEMPT_NONE
 		spin_lock_init(&lock->lock);
 #else
 		rwlock_init(&lock->lock);

-- 
[ Luis Claudio R. Goncalves                    Bass - Gospel - RT ]
[ Fingerprint: 4FDD B8C4 3C59 34BD 8BE9  2696 7203 D980 A448 C8F8 ]

--
To unsubscribe from this list: send the line "unsubscribe linux-rt-users" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

             reply	other threads:[~2011-03-02 20:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-02 20:14 Luis Claudio R. Goncalves [this message]
2011-03-02 20:58 ` [PATCH] net: iptables: rework the fix of xt_info locking Uwe Kleine-König

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=20110302201414.GE8384@uudg.org \
    --to=lclaudio@uudg.org \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=tglx@linutronix.de \
    --cc=williams@redhat.com \
    /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).