2008-10-22 22:26:29 -07:00
|
|
|
|
|
|
|
|
|
2008-06-13 14:39:25 -03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-09-21 12:43:12 -07:00
|
|
|
|
2008-06-13 14:39:25 -03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
x86, 64-bit: Clean up user address masking
The discussion about using "access_ok()" in get_user_pages_fast() (see
commit 7f8189068726492950bf1a2dcfd9b51314560abf: "x86: don't use
'access_ok()' as a range check in get_user_pages_fast()" for details and
end result), made us notice that x86-64 was really being very sloppy
about virtual address checking.
So be way more careful and straightforward about masking x86-64 virtual
addresses:
- All the VIRTUAL_MASK* variants now cover half of the address
space, it's not like we can use the full mask on a signed
integer, and the larger mask just invites mistakes when
applying it to either half of the 48-bit address space.
- /proc/kcore's kc_offset_to_vaddr() becomes a lot more
obvious when it transforms a file offset into a
(kernel-half) virtual address.
- Unify/simplify the 32-bit and 64-bit USER_DS definition to
be based on TASK_SIZE_MAX.
This cleanup and more careful/obvious user virtual address checking also
uncovered a buglet in the x86-64 implementation of strnlen_user(): it
would do an "access_ok()" check on the whole potential area, even if the
string itself was much shorter, and thus return an error even for valid
strings. Our sloppy checking had hidden this.
So this fixes 'strnlen_user()' to do this properly, the same way we
already handled user strings in 'strncpy_from_user()'. Namely by just
checking the first byte, and then relying on fault handling for the
rest. That always works, since we impose a guard page that cannot be
mapped at the end of the user space address space (and even if we
didn't, we'd have the address space hole).
Acked-by: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Nick Piggin <npiggin@suse.de>
Cc: Hugh Dickins <hugh.dickins@tiscali.co.uk>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-06-20 15:40:00 -07:00
|
|
|
|
2008-06-13 14:39:25 -03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-05-26 10:14:39 -07:00
|
|
|
|
2012-04-20 15:41:35 -07:00
|
|
|
|
|
|
|
|
|
2008-06-25 11:08:51 -03:00
|
|
|
|
2008-06-13 14:39:25 -03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-12-27 16:52:47 -08:00
|
|
|
|
2013-12-27 15:30:58 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-12-27 16:52:47 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-12-27 15:30:58 -08:00
|
|
|
|
2008-06-13 14:39:25 -03:00
|
|
|
|
2012-04-20 15:41:35 -07:00
|
|
|
|
2008-06-13 14:39:25 -03:00
|
|
|
|
|
|
|
|
|
2013-12-27 15:30:58 -08:00
|
|
|
|
2008-06-13 14:39:25 -03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-04-20 15:41:35 -07:00
|
|
|
|
2013-12-27 16:52:47 -08:00
|
|
|
|
2008-06-13 14:39:25 -03:00
|
|
|
|
|
|
|
|
|
2012-04-20 17:12:48 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-06-13 14:39:25 -03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-04-20 17:12:48 -07:00
|
|
|
|
2008-06-13 14:39:25 -03:00
|
|
|
|
2012-04-20 17:12:48 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-06-13 14:39:25 -03:00
|
|
|
|
|
|
|
|
|
2012-04-20 17:12:48 -07:00
|
|
|
|
2008-06-13 14:39:25 -03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-02-12 11:47:31 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-06-25 11:05:11 -03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-02-12 15:37:02 -08:00
|
|
|
|
|
|
|
|
|
2013-02-12 11:47:31 -08:00
|
|
|
|
|
|
|
|
|
2013-02-12 15:37:02 -08:00
|
|
|
|
2013-08-29 13:34:50 -07:00
|
|
|
|
2013-02-12 15:37:02 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-08-29 13:34:50 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-06-25 11:05:11 -03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-08-29 21:13:05 +02:00
|
|
|
|
2008-06-25 11:05:11 -03:00
|
|
|
|
2008-09-10 13:37:17 +02:00
|
|
|
|
2013-02-12 11:47:31 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-12-12 01:56:04 +02:00
|
|
|
|
2008-06-25 11:05:11 -03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-06-25 13:17:43 -03:00
|
|
|
|
|
|
|
|
|
2009-01-19 16:34:26 -08:00
|
|
|
|
2008-06-25 13:17:43 -03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-06-25 11:48:29 -03:00
|
|
|
|
2009-01-30 18:16:46 -08:00
|
|
|
|
2012-09-21 12:43:12 -07:00
|
|
|
|
|
|
|
|
|
2008-06-25 11:48:29 -03:00
|
|
|
|
2012-09-21 12:43:12 -07:00
|
|
|
|
2008-06-25 11:48:29 -03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-01-30 18:16:46 -08:00
|
|
|
|
2008-06-25 13:17:43 -03:00
|
|
|
|
2009-01-23 15:49:41 -08:00
|
|
|
|
2012-09-21 12:43:12 -07:00
|
|
|
|
|
|
|
|
|
2009-01-23 15:49:41 -08:00
|
|
|
|
2012-09-21 12:43:12 -07:00
|
|
|
|
2012-04-20 16:57:35 -07:00
|
|
|
|
|
|
|
|
|
2009-01-23 15:49:41 -08:00
|
|
|
|
|
|
|
|
|
2008-06-25 13:17:43 -03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-06-25 11:48:29 -03:00
|
|
|
|
2009-01-30 18:16:46 -08:00
|
|
|
|
2009-07-20 23:27:39 -07:00
|
|
|
|
2009-01-23 15:49:41 -08:00
|
|
|
|
2009-07-20 23:27:39 -07:00
|
|
|
|
2008-06-25 13:17:43 -03:00
|
|
|
|
2008-06-25 11:48:29 -03:00
|
|
|
|
|
|
|
|
|
2008-06-25 13:17:43 -03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-09-10 13:37:17 +02:00
|
|
|
|
2008-06-25 13:17:43 -03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-06-25 11:48:29 -03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-01-19 16:34:26 -08:00
|
|
|
|
2008-06-25 11:48:29 -03:00
|
|
|
|
|
|
|
|
|
2009-01-30 18:16:46 -08:00
|
|
|
|
|
|
|
|
|
2008-06-25 11:48:29 -03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-01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-21 12:43:15 -07:00
|
|
|
|
|
|
|
|
|
2012-04-20 16:57:35 -07:00
|
|
|
|
2009-01-23 15:49:41 -08:00
|
|
|
|
|
|
|
|
|
2008-06-25 11:48:29 -03:00
|
|
|
|
|
|
|
|
|
2008-12-08 19:18:38 -08:00
|
|
|
|
2008-06-25 11:48:29 -03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-06-25 12:48:47 -03:00
|
|
|
|
|
|
|
|
|
2008-12-08 19:18:38 -08:00
|
|
|
|
2008-06-25 12:48:47 -03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-06-25 11:48:29 -03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-09-21 12:43:12 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-06-25 11:48:29 -03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-01-23 15:49:41 -08:00
|
|
|
|
|
|
|
|
|
2012-09-21 12:43:15 -07:00
|
|
|
|
|
|
|
|
|
2012-04-20 16:57:35 -07:00
|
|
|
|
2009-01-23 15:49:41 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-09-21 12:43:15 -07:00
|
|
|
|
2009-01-23 15:49:41 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-09-21 12:43:15 -07:00
|
|
|
|
2011-11-07 16:33:40 -08:00
|
|
|
|
2009-01-23 15:49:41 -08:00
|
|
|
|
|
|
|
|
|
2008-06-25 14:43:30 -03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-06-25 11:48:29 -03:00
|
|
|
|
2008-06-25 14:43:30 -03:00
|
|
|
|
|
|
|
|
|
2009-01-23 15:49:41 -08:00
|
|
|
|
2008-06-25 14:43:30 -03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-06-25 11:05:11 -03:00
|
|
|
|
2009-01-23 15:49:41 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-01-29 11:49:18 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-01-23 15:49:41 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-06-07 11:49:55 +02:00
|
|
|
|
|
|
|
|
|
2012-04-06 14:32:32 -07:00
|
|
|
|
|
|
|
|
|
2011-06-07 11:49:55 +02:00
|
|
|
|
2012-05-26 11:09:53 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-09-21 12:43:11 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-12-14 14:25:02 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
2007-10-11 11:20:03 +02:00
|
|
|
|
2012-10-02 18:01:25 +01:00
|
|
|
|
2007-10-11 11:20:03 +02:00
|
|
|
|
2012-10-02 18:01:25 +01:00
|
|
|
|
2007-10-11 11:20:03 +02:00
|
|
|
|
2008-06-13 14:39:25 -03:00
|
|
|
|
2013-10-21 09:43:57 +01:00
|
|
|
|
|
|
|
|
|
2013-10-21 09:44:37 +01:00
|
|
|
|
|
|
|
|
|
2013-10-21 09:43:57 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-10-21 09:44:37 +01:00
|
|
|
|
|
|
|
|
|
2013-10-21 09:43:57 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-10-21 09:44:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-10-21 09:43:57 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-10-21 09:44:37 +01:00
|
|
|
|
|
|
|
|
|
2013-10-21 09:43:57 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-10-21 09:44:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-10-21 09:43:57 +01:00
|
|
|
|
2013-10-21 09:44:37 +01:00
|
|
|
|
2013-10-21 09:43:57 +01:00
|
|
|
|
2008-10-22 22:26:29 -07:00
|
|
|
|
x86: lockless get_user_pages_fast()
Implement get_user_pages_fast without locking in the fastpath on x86.
Do an optimistic lockless pagetable walk, without taking mmap_sem or any
page table locks or even mmap_sem. Page table existence is guaranteed by
turning interrupts off (combined with the fact that we're always looking
up the current mm, means we can do the lockless page table walk within the
constraints of the TLB shootdown design). Basically we can do this
lockless pagetable walk in a similar manner to the way the CPU's pagetable
walker does not have to take any locks to find present ptes.
This patch (combined with the subsequent ones to convert direct IO to use
it) was found to give about 10% performance improvement on a 2 socket 8
core Intel Xeon system running an OLTP workload on DB2 v9.5
"To test the effects of the patch, an OLTP workload was run on an IBM
x3850 M2 server with 2 processors (quad-core Intel Xeon processors at
2.93 GHz) using IBM DB2 v9.5 running Linux 2.6.24rc7 kernel. Comparing
runs with and without the patch resulted in an overall performance
benefit of ~9.8%. Correspondingly, oprofiles showed that samples from
__up_read and __down_read routines that is seen during thread contention
for system resources was reduced from 2.8% down to .05%. Monitoring the
/proc/vmstat output from the patched run showed that the counter for
fast_gup contained a very high number while the fast_gup_slow value was
zero."
(fast_gup is the old name for get_user_pages_fast, fast_gup_slow is a
counter we had for the number of times the slowpath was invoked).
The main reason for the improvement is that DB2 has multiple threads each
issuing direct-IO. Direct-IO uses get_user_pages, and thus the threads
contend the mmap_sem cacheline, and can also contend on page table locks.
I would anticipate larger performance gains on larger systems, however I
think DB2 uses an adaptive mix of threads and processes, so it could be
that thread contention remains pretty constant as machine size increases.
In which case, we stuck with "only" a 10% gain.
The downside of using get_user_pages_fast is that if there is not a pte
with the correct permissions for the access, we end up falling back to
get_user_pages and so the get_user_pages_fast is a bit of extra work.
However this should not be the common case in most performance critical
code.
[akpm@linux-foundation.org: coding-style fixes]
[akpm@linux-foundation.org: build fix]
[akpm@linux-foundation.org: Kconfig fix]
[akpm@linux-foundation.org: Makefile fix/cleanup]
[akpm@linux-foundation.org: warning fix]
Signed-off-by: Nick Piggin <npiggin@suse.de>
Cc: Dave Kleikamp <shaggy@austin.ibm.com>
Cc: Andy Whitcroft <apw@shadowen.org>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Dave Kleikamp <shaggy@austin.ibm.com>
Cc: Badari Pulavarty <pbadari@us.ibm.com>
Cc: Zach Brown <zach.brown@oracle.com>
Cc: Jens Axboe <jens.axboe@oracle.com>
Reviewed-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-07-25 19:45:24 -07:00
|
|
|
|