[Patch] Do not copy from remote while in_atomic()

Ansgar Esztermann <[email protected]>
Newsgroups gmane.linux.cluster.openmosix.devel
Message-ID <[email protected]>
Here is a patch for CONFIG_HIGHMEM enabled kernels. 

Some kernel functions use kmap_atomic() rather than kmap() to map a
page before copying data from user space. While this is faster, atomic
maps pose a problem with OpenMosix: deputy_copy_from_user() has to
get the data over the network; the network code in turn might
reschedule, which will lead to a "scheduling while atomic" error
message. Worse, the copied data may be corrupted.
One of the functions affected is the write() system call.

The following patch makes deputy_copy_*_user() fail gracefully in this
case. The calling function then has the opportunity to retry the
operation using non-atomic maps instead.


A.



diff -ruNp linux-2.6-om/hpc/copyuser.c linux-2.6-om-work/hpc/copyuser.c
--- linux-2.6-om/hpc/copyuser.c	2006-02-07 16:51:58.000000000 +0100
+++ linux-2.6-om-work/hpc/copyuser.c	2006-03-22 15:43:52.000000000 +0100
@@ -27,6 +27,9 @@ unsigned long deputy_copy_from_user(void
 {
 	struct omp_usercopy_req u;
 	int error;
+
+	if (in_atomic())
+		return n;
 	
 	u.addr = (unsigned long) from;
 	u.len = n;
@@ -82,6 +85,9 @@ unsigned long deputy_copy_to_user(void _
 {
 	struct omp_usercopy_req u;
 	int error;
+
+	if (in_atomic())
+		return n;
 	
 	OMDEBUG_CPYUSER(1, "copy [0x%p]->user[0x%p][%ld]\n", from, to, n);
 	u.addr = (unsigned long) to;


-- 
Ansgar Esztermann
Researcher & Sysadmin
http://www2.thphy.uni-duesseldorf.de/~ansgar
signature.asc (application/pgp-signature, 191 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)

iD8DBQFEInp4wAkt8h1/xRgRAkgEAJ9ucrECbGCuFw9S+NPSDtat3IobMACcDyRz
dZ7HYDSA17JJ4x+ZPTwEqZ0=
=X0NN
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.