linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [RFC] non-preemptible kernel socket for RAMster
@ 2011-07-05 15:54 Dan Magenheimer
  2011-07-05 16:30 ` Eric Dumazet
  2011-07-05 16:36 ` Loke, Chetan
  0 siblings, 2 replies; 13+ messages in thread
From: Dan Magenheimer @ 2011-07-05 15:54 UTC (permalink / raw)
  To: netdev; +Cc: Konrad Wilk, linux-mm

In working on a kernel project called RAMster* (where RAM on a
remote system may be used for clean page cache pages and for swap
pages), I found I have need for a kernel socket to be used when
in non-preemptible state.  I admit to being a networking idiot,
but I have been successfully using the following small patch.
I'm not sure whether I am lucky so far... perhaps more
sockets or larger/different loads will require a lot more
changes (or maybe even make my objective impossible).
So I thought I'd post it for comment.  I'd appreciate
any thoughts or suggestions.

Thanks,
Dan

* http://events.linuxfoundation.org/events/linuxcon/magenheimer 

diff -Napur linux-2.6.37/net/core/sock.c linux-2.6.37-ramster/net/core/sock.c
--- linux-2.6.37/net/core/sock.c	2011-07-03 19:14:52.267853088 -0600
+++ linux-2.6.37-ramster/net/core/sock.c	2011-07-03 19:10:04.340980799 -0600
@@ -1587,6 +1587,14 @@ static void __lock_sock(struct sock *sk)
 	__acquires(&sk->sk_lock.slock)
 {
 	DEFINE_WAIT(wait);
+	if (!preemptible()) {
+		while (sock_owned_by_user(sk)) {
+			spin_unlock_bh(&sk->sk_lock.slock);
+			cpu_relax();
+			spin_lock_bh(&sk->sk_lock.slock);
+		}
+		return;
+	}
 
 	for (;;) {
 		prepare_to_wait_exclusive(&sk->sk_lock.wq, &wait,
@@ -1623,7 +1631,8 @@ static void __release_sock(struct sock *
 			 * This is safe to do because we've taken the backlog
 			 * queue private:
 			 */
-			cond_resched_softirq();
+			if (preemptible())
+				cond_resched_softirq();
 			skb = next;
 		} while (skb != NULL);

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2011-07-07 15:34 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-05 15:54 [RFC] non-preemptible kernel socket for RAMster Dan Magenheimer
2011-07-05 16:30 ` Eric Dumazet
2011-07-05 17:25   ` Dan Magenheimer
2011-07-05 18:23     ` Eric Dumazet
2011-07-05 19:07       ` Dan Magenheimer
2011-07-05 16:36 ` Loke, Chetan
2011-07-05 17:25   ` Dan Magenheimer
2011-07-05 17:52     ` Loke, Chetan
2011-07-05 19:18       ` Dan Magenheimer
2011-07-05 22:27         ` Loke, Chetan
2011-07-06  1:05           ` Dan Magenheimer
2011-07-06 18:12             ` Loke, Chetan
2011-07-07 15:34               ` Dan Magenheimer

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).