OSDN Git Service

Copy the kernel module data from user space in chunks
authorLinus Torvalds <torvalds@linux-foundation.org>
Tue, 7 Apr 2015 17:33:49 +0000 (10:33 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 8 Apr 2015 21:35:48 +0000 (14:35 -0700)
commit3afe9f849600645723246baa95e7559caeca6ce9
tree6de4adcc568a7df591f3b73f36ecb8736eb9168d
parentcae2a173fe94ab3a437416af6f092fae2e65837e
Copy the kernel module data from user space in chunks

Unlike most (all?) other copies from user space, kernel module loading
is almost unlimited in size.  So we do a potentially huge
"copy_from_user()" when we copy the module data from user space to the
kernel buffer, which can be a latency concern when preemption is
disabled (or voluntary).

Also, because 'copy_from_user()' clears the tail of the kernel buffer on
failures, even a *failed* copy can end up wasting a lot of time.

Normally neither of these are concerns in real life, but they do trigger
when doing stress-testing with trinity.  Running in a VM seems to add
its own overheadm causing trinity module load testing to even trigger
the watchdog.

The simple fix is to just chunk up the module loading, so that it never
tries to copy insanely big areas in one go.  That bounds the latency,
and also the amount of (unnecessarily, in this case) cleared memory for
the failure case.

Reported-by: Sasha Levin <sasha.levin@oracle.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
kernel/module.c