netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Grover <andy.grover@oracle.com>
To: netdev@vger.kernel.org
Cc: rds-devel@oss.oracle.com
Subject: [PATCH 12/13] RDS: Do not call set_page_dirty() with irqs off
Date: Thu, 11 Mar 2010 15:50:06 -0800	[thread overview]
Message-ID: <1268351407-7394-13-git-send-email-andy.grover@oracle.com> (raw)
In-Reply-To: <1268351407-7394-1-git-send-email-andy.grover@oracle.com>

set_page_dirty() unconditionally re-enables interrupts, so
if we call it with irqs off, they will be on after the call,
and that's bad. This patch moves the call after we've re-enabled
interrupts in send_drop_to(), so it's safe.

Also, add BUG_ONs to let us know if we ever do call set_page_dirty
with interrupts off.

Signed-off-by: Andy Grover <andy.grover@oracle.com>
---
 net/rds/ib_rdma.c |    1 +
 net/rds/rdma.c    |    4 +++-
 net/rds/send.c    |   14 ++++++++------
 3 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/net/rds/ib_rdma.c b/net/rds/ib_rdma.c
index 65e668d..cfb1d90 100644
--- a/net/rds/ib_rdma.c
+++ b/net/rds/ib_rdma.c
@@ -440,6 +440,7 @@ static void __rds_ib_teardown_mr(struct rds_ib_mr *ibmr)
 
 			/* FIXME we need a way to tell a r/w MR
 			 * from a r/o MR */
+			BUG_ON(in_interrupt());
 			set_page_dirty(page);
 			put_page(page);
 		}
diff --git a/net/rds/rdma.c b/net/rds/rdma.c
index 4c64daa..61b359d 100644
--- a/net/rds/rdma.c
+++ b/net/rds/rdma.c
@@ -438,8 +438,10 @@ void rds_rdma_free_op(struct rds_rdma_op *ro)
 		/* Mark page dirty if it was possibly modified, which
 		 * is the case for a RDMA_READ which copies from remote
 		 * to local memory */
-		if (!ro->r_write)
+		if (!ro->r_write) {
+			BUG_ON(in_interrupt());
 			set_page_dirty(page);
+		}
 		put_page(page);
 	}
 
diff --git a/net/rds/send.c b/net/rds/send.c
index 51e2def..4629a0b 100644
--- a/net/rds/send.c
+++ b/net/rds/send.c
@@ -507,12 +507,13 @@ EXPORT_SYMBOL_GPL(rds_send_get_message);
  */
 void rds_send_remove_from_sock(struct list_head *messages, int status)
 {
-	unsigned long flags = 0; /* silence gcc :P */
+	unsigned long flags;
 	struct rds_sock *rs = NULL;
 	struct rds_message *rm;
 
-	local_irq_save(flags);
 	while (!list_empty(messages)) {
+		int was_on_sock = 0;
+
 		rm = list_entry(messages->next, struct rds_message,
 				m_conn_item);
 		list_del_init(&rm->m_conn_item);
@@ -527,7 +528,7 @@ void rds_send_remove_from_sock(struct list_head *messages, int status)
 		 * while we're messing with it. It does not prevent the
 		 * message from being removed from the socket, though.
 		 */
-		spin_lock(&rm->m_rs_lock);
+		spin_lock_irqsave(&rm->m_rs_lock, flags);
 		if (!test_bit(RDS_MSG_ON_SOCK, &rm->m_flags))
 			goto unlock_and_drop;
 
@@ -556,21 +557,22 @@ void rds_send_remove_from_sock(struct list_head *messages, int status)
 					notifier->n_status = status;
 				rm->m_rdma_op->r_notifier = NULL;
 			}
-			rds_message_put(rm);
+			was_on_sock = 1;
 			rm->m_rs = NULL;
 		}
 		spin_unlock(&rs->rs_lock);
 
 unlock_and_drop:
-		spin_unlock(&rm->m_rs_lock);
+		spin_unlock_irqrestore(&rm->m_rs_lock, flags);
 		rds_message_put(rm);
+		if (was_on_sock)
+			rds_message_put(rm);
 	}
 
 	if (rs) {
 		rds_wake_sk_sleep(rs);
 		sock_put(rds_rs_to_sk(rs));
 	}
-	local_irq_restore(flags);
 }
 
 /*
-- 
1.6.3.3


  parent reply	other threads:[~2010-03-11 23:52 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-11 23:49 [PATCH net-next 00/13] RDS bugfixes and cleanups Andy Grover
2010-03-11 23:49 ` [PATCH 01/13] RDS: Do not BUG() on error returned from ib_post_send Andy Grover
2010-03-11 23:49 ` [PATCH 02/13] RDS: sendmsg() should check sndtimeo, not rcvtimeo Andy Grover
2010-03-11 23:49 ` [PATCH 03/13] RDS: update copy_to_user state in tcp transport Andy Grover
2010-03-11 23:49 ` [PATCH 04/13] RDS/TCP: Wait to wake thread when write space available Andy Grover
2010-03-11 23:49 ` [PATCH 05/13] RDS: Fix congestion issues for loopback Andy Grover
2010-03-11 23:50 ` [PATCH 06/13] RDS: Fix send locking issue Andy Grover
2010-03-11 23:50 ` [PATCH 07/13] RDS: Workaround for in-use MRs on close causing crash Andy Grover
2010-03-11 23:50 ` [PATCH 08/13] RDS: Turn down alarming reconnect messages Andy Grover
2010-03-11 23:50 ` [PATCH 09/13] RDS: Fix locking in rds_send_drop_to() Andy Grover
2010-03-11 23:50 ` [PATCH 10/13] RDS: only put sockets that have seen congestion on the poll_waitq Andy Grover
2010-03-11 23:50 ` [PATCH 11/13] RDS: Properly unmap when getting a remote access error Andy Grover
2010-03-11 23:50 ` Andy Grover [this message]
2010-03-11 23:50 ` [PATCH 13/13] RDS: Enable per-cpu workqueue threads Andy Grover
2010-03-17  4:18 ` [PATCH net-next 00/13] RDS bugfixes and cleanups David Miller

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=1268351407-7394-13-git-send-email-andy.grover@oracle.com \
    --to=andy.grover@oracle.com \
    --cc=netdev@vger.kernel.org \
    --cc=rds-devel@oss.oracle.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).