RE: [RFC] non-preemptible kernel socket for RAMster
From: Dan Magenheimer <hidden>
Date: 2011-07-05 17:25:35
Also in:
linux-mm
From: Eric Dumazet [mailto:eric.dumazet@gmail.com] Sent: Tuesday, July 05, 2011 10:31 AM To: Dan Magenheimer Cc: netdev@vger.kernel.org; Konrad Wilk; linux-mm Subject: Re: [RFC] non-preemptible kernel socket for RAMster Le mardi 05 juillet 2011 à 08:54 -0700, Dan Magenheimer a écrit :quoted
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; + }Hmm, was this tested on UP machine ?
Hi Eric -- Thanks for the reply! I hadn't tested UP in awhile so am testing now, and it seems to work OK so far. However, I am just testing my socket, *not* testing sockets in general. Are you implying that this patch will break (kernel) sockets in general on a UP machine? If so, could you be more specific as to why? (Again, I said I am a networking idiot. ;-) I played a bit with adding a new SOCK_ flag and triggering off of that, but this version of the patch seemed much simpler. Thanks, Dan -- 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>