Messages in this thread | | | Date | Fri, 23 Jul 1999 22:10:24 +0200 | From | Kurt Garloff <> | Subject | Re: Strangest bug |
| |
On Fri, Jul 23, 1999 at 03:36:56PM -0400, Stanislav Krasilovskiy wrote: > Description of the problem: A process passes a pointer allocated in the > user space to the kernel through a custom system call. This pointer is > then saved for future reference. > > Upon an interrupt, a kernel routine uses this saved pointer with > copy_from_user() to obtain a copy of that structure. The problem is, > every now and then the values in the structure are bogus! > > This is not due to memory corruption (in the user process, I > continuously print out the values, and they are fine). When I use > mlock() on the structure, then the problem no longer occurs (the copy > reflects accurate values). So the problem has something to do with > virtual addressing and paging...
You are very close to an explanation with your observation that no porblems occur with mlock(). mlock() does prevent paging out of the memory. When the page is paged out and you want to write to it in interrupt context, it won't work: You are not able to page it in. mlock() is the right solution to prevent it.
-- Kurt Garloff <garloff@suse.de> SuSE GmbH, Nürnberg, FRG Linux kernel development; SCSI drivers: tmscsim(DC390), DC395 [unhandled content-type:application/pgp-signature] | |