From: Michal Sabala <lkml@saahbs.net>
To: linux-kernel@vger.kernel.org
Subject: 2.6.18 mmap hangs unrelated apps
Date: Thu, 14 Dec 2006 20:30:14 -0600 [thread overview]
Message-ID: <20061215023014.GC2721@prosiaczek> (raw)
Hello LKML,
I am observing processes entering uninterruptible sleep apparently due
to an unrelated application using mmap over nfs. Applications in
"uninterruptible sleep" hang indefinitely while other applications
continue working properly.
The code causing the mmap nfs hangs does the following:
(as replicated by the included test-mmap.c file)
1. create file on nfs (file_A, descr_A)
2. make file_A a sparse 200MB file
3. mmap descr_A
4. close descr_A
5. unlink file_A
6. memcpy 200MB to mmaped buffer
7. create a second file on nfs (file_B, descr_B)
8. write() 200MB from mmaped buffer to descr_B
9. close descr_B
10. munmap first file
This code may need to be ran tens to hundred runs to trigger the condition.
During the execution of the above code, unrelated applications enter
uninterruptible sleep (D) - usually firefox2.0, Xorg/XFree86, gimp2.2, gconfd
or bash; probably the most active processes.
`dmesg` shows nothing of interest.
`free` shows anywhere between 1MB and 80MB of memory still remaining
free when the problem occurs.
`cat /proc/*PID*/wchan` for all hanging processes contains page_sync.
* Client Setups:
Linux 2.6.18 debian kernel (not tainted)
Intel P3/800
512MB ram
0 swap
NFS root (rw,noatime,rsize=8192,wsize=8192,nfsvers=3,hard,lock,udp)
NIC: 100mbit tulip Cardbus
NFS server is Linux 2.6.8 (debian)
Gnome running with ooffice, gimp2.2 and firefox2 open
and
Linux 2.6.18 debian kernel (not tainted)
Intel P4/2.8
mem=192M boot option
0 swap
NFS home (rw,nosuid,rsize=8192,wsize=8192,hard)
NIC: 100mbit e100 PCI
NFS server is Apple OSX 10.3
Gnome running with ooffice, gimp2.2 and firefox2 open
This happens with NFS servers based on Linux 2.6.8 and OSX 10.3.x. There
is nothing unusual in the server log files. Other than large nfs mmaps
on limited ram clients, NFS clients are 100% stable (file locking, performance,
6 month uptimes, etc..)
NOTE:
I also ran the same code on the P4 machine in /tmp (local disk)
and it too caused some applications to enter uninterruptible sleep
(dozens of consecutive runs were needed). As such this looks not to
be directly related to nfs.
I would like to assist in any way I can in tracking this bug. I am open
to running patched kernels, etc...
Thank You,
Sincerely,
Michal Sabala
PS. thank you for all the hard work on the Linux kernel.
----------- test-mmap.c: --------------------------------
#include <unistd.h>
#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <sys/mman.h>
int main (int argc, char * argv[] ){
char * data = 0;
int blocks = 12800;
int bSize = 16384;
char mmapFileName[] = "temp-XXXXXX";
int mmapFileDes = mkstemp( mmapFileName );
if ( mmapFileDes == -1 ){
printf( "cannot make temporary file %s !\n", mmapFileName );
exit( -1 );
}
printf( "using desc %d tempfile %s\n", mmapFileDes, mmapFileName );
errno = 0;
if ( lseek( mmapFileDes, (blocks*bSize)-1, SEEK_SET ) == -1 ){
if ( errno != 0 ){
perror ( "lseek error: " );
}
printf( "cannot lseek tempfile %s !\n", mmapFileName);
close( mmapFileDes );
unlink( mmapFileName );
exit( -1 );
}
if ( write( mmapFileDes, "X", 1 ) != 1 ){
printf( "cannot sparse write tempfile %s !\n", mmapFileName);
close( mmapFileDes );
unlink( mmapFileName );
exit( -1 );
}
data = mmap ( NULL, (blocks*bSize), PROT_READ | PROT_WRITE, MAP_SHARED, mmapFileDes, 0 );
if ( data == (void *) -1 ){
printf( "mmap of %s failed!\n", mmapFileName );
close( mmapFileDes );
unlink( mmapFileName );
exit( -1 );
}
printf( "block size: %d, blocks num: %d\n", bSize, blocks);
close( mmapFileDes );
unlink( mmapFileName );
int i;
char * ptr = data;
for ( i = 1; i <= blocks; i++ ){
printf( "wrote %d of %d blocks to %s\n", i, blocks, mmapFileName );
memset( ptr, 0, bSize );
ptr += bSize;
}
// msync( data, blocks*bSize, MS_SYNC );
char destFile[] = "destination-XXXXXX";
int destDes = mkstemp( destFile );
if ( destDes == -1 ){
printf( "cannot make destination file %s !\n", destFile );
exit( -1 );
}
printf( "using desc %d destfile %s\n", destDes, destFile);
ptr = data;
for ( i = 1; i <= blocks; i++ ){
int wLen = write( destDes, ptr, bSize );
printf( "wrote %d of %d blocks to %s\n", i, blocks, destFile );
if ( wLen != bSize ){
printf( "debug: short write to %s at %d bytes\n", destFile, wLen );
}
ptr += bSize;
}
close( destDes );
munmap( data, blocks*bSize );
exit( 0 );
}
--
Michal "Saahbs" Sabala
next reply other threads:[~2006-12-15 2:36 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-12-15 2:30 Michal Sabala [this message]
2006-12-15 16:24 ` 2.6.18 mmap hangs unrelated apps Trond Myklebust
2006-12-15 17:50 ` Michal Sabala
2006-12-15 19:44 ` Trond Myklebust
2006-12-15 21:06 ` Michal Sabala
2006-12-15 21:12 ` Arjan van de Ven
2006-12-15 21:43 ` Michal Sabala
2006-12-15 21:44 ` Trond Myklebust
2006-12-15 22:05 ` Michal Sabala
2006-12-19 22:26 ` Andrew Morton
2006-12-19 23:19 ` Trond Myklebust
2006-12-20 0:03 ` Andrew Morton
2006-12-20 0:17 ` Trond Myklebust
2006-12-20 0:22 ` Andrew Morton
2006-12-20 1:21 ` Trond Myklebust
2007-01-08 14:48 ` [PATCH] NFS: Fix race in nfs_release_page() Peter Zijlstra
2006-12-20 14:51 ` 2.6.18 mmap hangs unrelated apps Michal Sabala
2006-12-15 20:42 ` Andrew Morton
2006-12-15 21:35 ` Michal Sabala
2006-12-15 21:41 ` Andrew Morton
2006-12-16 12:59 ` Christian Kuhn
2006-12-16 18:45 ` Christian Kuhn
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=20061215023014.GC2721@prosiaczek \
--to=lkml@saahbs.net \
--cc=linux-kernel@vger.kernel.org \
/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