Konstantin Khlebnikov 8463833590 mm: rework virtual memory accounting
When inspecting a vague code inside prctl(PR_SET_MM_MEM) call (which
testing the RLIMIT_DATA value to figure out if we're allowed to assign
new @start_brk, @brk, @start_data, @end_data from mm_struct) it's been
commited that RLIMIT_DATA in a form it's implemented now doesn't do
anything useful because most of user-space libraries use mmap() syscall
for dynamic memory allocations.

Linus suggested to convert RLIMIT_DATA rlimit into something suitable
for anonymous memory accounting.  But in this patch we go further, and
the changes are bundled together as:

 * keep vma counting if CONFIG_PROC_FS=n, will be used for limits
 * replace mm->shared_vm with better defined mm->data_vm
 * account anonymous executable areas as executable
 * account file-backed growsdown/up areas as stack
 * drop struct file* argument from vm_stat_account
 * enforce RLIMIT_DATA for size of data areas

This way code looks cleaner: now code/stack/data classification depends
only on vm_flags state:

 VM_EXEC & ~VM_WRITE            -> code  (VmExe + VmLib in proc)
 VM_GROWSUP | VM_GROWSDOWN      -> stack (VmStk)
 VM_WRITE & ~VM_SHARED & !stack -> data  (VmData)

The rest (VmSize - VmData - VmStk - VmExe - VmLib) could be called
"shared", but that might be strange beast like readonly-private or VM_IO
area.

 - RLIMIT_AS            limits whole address space "VmSize"
 - RLIMIT_STACK         limits stack "VmStk" (but each vma individually)
 - RLIMIT_DATA          now limits "VmData"

Signed-off-by: Konstantin Khlebnikov <koct9i@gmail.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Cc: Quentin Casasnovas <quentin.casasnovas@oracle.com>
Cc: Vegard Nossum <vegard.nossum@oracle.com>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Willy Tarreau <w@1wt.eu>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Kees Cook <keescook@google.com>
Cc: Vladimir Davydov <vdavydov@virtuozzo.com>
Cc: Pavel Emelyanov <xemul@virtuozzo.com>
Cc: 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>
2016-01-14 16:00:49 -08:00
..
2015-10-01 12:48:11 -07:00
2015-06-25 11:49:31 +03:00
2015-10-17 21:22:08 -07:00
2015-10-07 18:08:15 +01:00
2016-01-13 10:13:36 -08:00
2016-01-11 17:48:53 -05:00
2016-01-05 18:04:58 +01:00
2015-11-16 15:41:49 +00:00
2016-01-13 11:38:27 -08:00
2015-05-13 12:04:55 -05:00
2016-01-13 09:26:40 -08:00
2015-08-03 12:01:54 -04:00
2015-11-07 10:40:47 -07:00
2015-12-28 13:07:07 -07:00
2015-12-06 12:46:31 +01:00
2015-10-07 16:02:49 -07:00
2015-09-04 16:54:41 -07:00
2015-09-08 15:35:28 -07:00
2015-10-18 10:14:39 -07:00
2015-10-31 19:05:59 -04:00
2015-10-30 01:47:27 -04:00
2015-06-24 17:49:45 -07:00
2016-01-13 19:15:14 -08:00
2015-05-12 10:46:53 +02:00
2015-06-19 15:18:28 +02:00
2015-09-08 15:35:28 -07:00
2015-05-05 13:40:42 -06:00
2015-10-23 05:44:28 -07:00
2015-08-27 19:40:58 -04:00
2015-10-01 15:06:43 +02:00
2015-12-14 10:03:46 +01:00
2015-06-25 12:06:45 +02:00
2015-07-28 08:50:42 +01:00
2015-04-29 17:17:17 -05:00
2015-11-23 09:44:58 +01:00
2015-04-14 16:49:05 -07:00
2015-10-27 18:55:31 -07:00
2015-06-24 17:49:41 -07:00
2016-01-14 16:00:49 -08:00
2015-10-20 22:10:45 +08:00
2015-07-21 10:39:05 -07:00
2015-06-25 04:20:04 -04:00
2015-07-01 19:40:18 -07:00
2015-09-10 13:29:01 -07:00
2015-09-10 13:29:01 -07:00
2015-11-06 17:50:42 -08:00
2015-04-12 21:03:31 +02:00
2016-01-07 14:31:27 -05:00
2015-10-09 17:00:32 -04:00
2015-10-06 17:08:19 +02:00
2015-10-22 08:59:18 -07:00
2015-05-26 15:23:23 +02:00
2015-06-25 01:13:43 +02:00
2016-01-10 22:13:15 -05:00
2015-12-13 19:59:48 -08:00
2016-01-04 16:11:11 -05:00
2016-01-14 16:00:49 -08:00
2015-04-11 15:53:35 -04:00
2016-01-04 10:20:19 -05:00
2015-11-13 21:53:18 -08:00
2015-06-25 17:00:39 -07:00
2015-11-05 14:36:09 -05:00
2015-08-17 11:25:28 -07:00
2015-10-01 09:57:59 -07:00
2015-10-19 01:01:21 +02:00
2015-11-23 09:44:58 +01:00
2015-12-04 08:38:42 -07:00
2016-01-14 16:00:49 -08:00
2015-09-08 15:35:28 -07:00