linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Konstantin Khlebnikov <koct9i@gmail.com>
To: "Kirill A. Shutemov" <kirill@shutemov.name>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
	Armin Rigo <arigo@tunes.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	linux-mm <linux-mm@kvack.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@kernel.org>
Subject: Re: [PATCHv2 0/2] remap_file_pages() decommission
Date: Mon, 12 May 2014 18:59:15 +0400	[thread overview]
Message-ID: <CALYGNiMY=f0M2gAJWgUSxa5z61PS3H8nXvJsiXp3XPbsJE+jyQ@mail.gmail.com> (raw)
In-Reply-To: <20140512124344.GA26865@node.dhcp.inet.fi>

On Mon, May 12, 2014 at 4:43 PM, Kirill A. Shutemov
<kirill@shutemov.name> wrote:
> On Fri, May 09, 2014 at 08:14:08AM -0700, Linus Torvalds wrote:
>> On Fri, May 9, 2014 at 7:05 AM, Kirill A. Shutemov
>> <kirill.shutemov@linux.intel.com> wrote:
>> >
>> > Hm. I'm confused here. Do we have any limit forced per-user?
>>
>> Sure we do. See "struct user_struct". We limit max number of
>> processes, open files, signals etc.
>>
>> > I only see things like rlimits which are copied from parrent.
>> > Is it what you want?
>>
>> No, rlimits are per process (although in some cases what they limit
>> are counted per user despite the _limits_ of those resources then
>> being settable per thread).
>>
>> So I was just thinking that if we raise the per-mm default limits,
>> maybe we should add a global per-user limit to make it harder for a
>> user to use tons and toms of vma's.
>
> Here's the first attempt.
>
> I'm not completely happy about current_user(). It means we rely on that
> user of mm owner task is always equal to user of current. Not sure if it's
> always the case.
>
> Other option is to make MM_OWNER is always on and lookup proper user
> through task_cred_xxx(rcu_dereference(mm->owner), user).
>
> From 5ee6f6dd721ada8eb66c84a91003ac1e3eb2970a Mon Sep 17 00:00:00 2001
> From: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
> Date: Mon, 12 May 2014 15:13:12 +0300
> Subject: [PATCH] mm: add per-user limit on mapping count
>
> We're going to increase per-mm map_count. To avoid non-obvious memory
> abuse by creating a lot of VMA's, let's introduce per-user limit.
>
> The limit is implemented as sysctl. For now value of limit is pretty
> arbitrary -- 2^20.
>
> sizeof(vm_area_struct) with my kernel config (DEBUG_KERNEL=n) is 184
> bytes. It means with the limit user can use up to 184 MiB of RAM in
> VMAs.
>
> The limit is not applicable for root (INIT_USER).

I don't like this.

Maybe we could just account VMAs into OOM-badness points and let
OOM-killer do its job?

--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -170,7 +170,9 @@ unsigned long oom_badness(struct task_struct *p,
struct mem_cgroup *memcg,
         * task's rss, pagetable and swap space use.
         */
        points = get_mm_rss(p->mm) + atomic_long_read(&p->mm->nr_ptes) +
-                get_mm_counter(p->mm, MM_SWAPENTS);
+                get_mm_counter(p->mm, MM_SWAPENTS) +
+                (long)p->mm->map_count *
+                       sizeof(struct vm_area_struct) / PAGE_SIZE;
        task_unlock(p);

        /*

  reply	other threads:[~2014-05-12 14:59 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-08 12:41 [PATCHv2 0/2] remap_file_pages() decommission Kirill A. Shutemov
2014-05-08 12:41 ` [PATCH 1/2] mm: mark remap_file_pages() syscall as deprecated Kirill A. Shutemov
2014-06-12  5:48   ` Michael Kerrisk
2014-06-12  9:40     ` Kirill A. Shutemov
2014-06-12  9:44       ` Michael Kerrisk (man-pages)
2014-05-08 12:41 ` [PATCH 2/2] mm: replace remap_file_pages() syscall with emulation Kirill A. Shutemov
2014-05-08 21:57   ` Andrew Morton
2014-05-12 15:11     ` Sasha Levin
2014-05-12 17:05       ` Kirill A. Shutemov
2014-05-14 20:52         ` Sasha Levin
2014-05-14 21:17           ` Kirill A. Shutemov
2014-05-14 21:40             ` Andrew Morton
2014-05-13  7:32       ` Armin Rigo
2014-05-13 12:57         ` Sasha Levin
2014-05-08 15:35 ` [PATCHv2 0/2] remap_file_pages() decommission Linus Torvalds
2014-05-08 15:44 ` Armin Rigo
2014-05-08 16:02   ` Kirill A. Shutemov
2014-05-08 16:08     ` Linus Torvalds
2014-05-09 14:05       ` Kirill A. Shutemov
2014-05-09 15:14         ` Linus Torvalds
2014-05-09 18:19           ` Kirill A. Shutemov
2014-05-12 12:43           ` Kirill A. Shutemov
2014-05-12 14:59             ` Konstantin Khlebnikov [this message]
2014-05-12  3:36   ` Andi Kleen
2014-05-12  5:16     ` Konstantin Khlebnikov
2014-05-12  7:50     ` Armin Rigo

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='CALYGNiMY=f0M2gAJWgUSxa5z61PS3H8nXvJsiXp3XPbsJE+jyQ@mail.gmail.com' \
    --to=koct9i@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=arigo@tunes.org \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=kirill@shutemov.name \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=torvalds@linux-foundation.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;
as well as URLs for NNTP newsgroup(s).