Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1289893

Re: [RFC] mm: Account anon mappings as RLIMIT_DATA

Path csiph.com!eternal-september.org!feeder.eternal-september.org!aioe.org!bofh.it!news.nic.it!robomod
From Linus Torvalds <torvalds@linux-foundation.org>
Newsgroups linux.kernel
Subject Re: [RFC] mm: Account anon mappings as RLIMIT_DATA
Date Fri, 11 Dec 2015 22:00:01 +0100
Message-ID <qECXf-10Z-7@gated-at.bofh.it> (permalink)
References <qECXf-10Z-5@gated-at.bofh.it>
X-Original-To Cyrill Gorcunov <gorcunov@gmail.com>
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=I0Itp2lY2GK1UKtvNEK6cEa01sx+Cq/t/JKag6rWKJQ=; b=gimzAMCFzEh3jIvOrtfUBsc2+ppljAZP3PbIt4HaLgGeAeyzKG82wd4DxJ+rS7vdnQ Ete3lZpHPfWUzSfVe6xc9av+s2DKnd9TxwfNvB/WEwaW/5SEhZ8nbEYZjUxMEiMdDrpi gJNWogoHL0b80ANya6UMIi2NV+gex1rl+SeDNKMiZYgKK0cEd0AW5M4AV4ON0iElqcPS h+StVtIgBV5QcMpRhssMr7XrnOBfLPW+W76Ff2dx8S7Vt8hVGrmc94EkbmzKT4Koz1rd WFu4RQHHIjhaJNqXwYqjDlpLB/0MGSajxTBYfZ1+Rr3K6XIxSj+dnDfTAQUpzmtQVKE2 fOoQ==
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=I0Itp2lY2GK1UKtvNEK6cEa01sx+Cq/t/JKag6rWKJQ=; b=EcYWvzQYYwTXexMe1UWAOa/e7LgZ0ZmJLs9lGAJzdGzsyL1MJeaax6SmiF8sKQ+cjx GfPQq2n3JOCeA/wn4h6mYRE1EJmWSFh9z1enRq7dYG2wTkSweoG7ebcJLSW9+Ugdl+/f +lTeCF9CpcJbpfzsHUEooh01qFg1MZuIalHL8=
MIME-Version 1.0
X-Received by 10.50.50.133 with SMTP id c5mr6312672igo.25.1449867351427; Fri, 11 Dec 2015 12:55:51 -0800 (PST)
X-Google-Sender-Auth hp97O6jgUqu-_cb0QQ5OWMrfNWA
Content-Type text/plain; charset=UTF-8
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 54
Organization linux.* mail to news gateway
X-Original-Cc LKML <linux-kernel@vger.kernel.org>, Linux MM <linux-mm@kvack.org>, Quentin Casasnovas <quentin.casasnovas@oracle.com>, Vegard Nossum <vegard.nossum@oracle.com>, Willy Tarreau <w@1wt.eu>, Andy Lutomirski <luto@amacapital.net>, Kees Cook <keescook@google.com>, Vladimir Davydov <vdavydov@virtuozzo.com>, Konstantin Khlebnikov <koct9i@gmail.com>, Pavel Emelyanov <xemul@virtuozzo.com>, Peter Zijlstra <a.p.zijlstra@chello.nl>
X-Original-Date Fri, 11 Dec 2015 12:55:51 -0800
X-Original-Message-ID <CA+55aFzbBQp-QzWj2k7twuZ7+ESFpzoRPGZVKWkDv04zHCZ3Sg@mail.gmail.com>
X-Original-References <20151211204939.GA2604@uranus>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1289893

Show key headers only | View raw


On Fri, Dec 11, 2015 at 12:49 PM, Cyrill Gorcunov <gorcunov@gmail.com> wrote:
>
> This should give a way to control the amount of anonymous
> memory allocated.

This looks good to me, assuming it gets testing. I think we could add
the hugetlb stuff later, I think it's a separate improvement.

Small nit:

> @@ -1214,6 +1214,8 @@ void vm_stat_account(struct mm_struct *m
>  {
>         const unsigned long stack_flags
>                 = VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
> +       const unsigned long not_anon_acc
> +               = VM_GROWSUP | VM_GROWSDOWN | VM_SHARED | VM_MAYSHARE;
>
>         mm->total_vm += pages;
>
> @@ -1223,6 +1225,9 @@ void vm_stat_account(struct mm_struct *m
>                         mm->exec_vm += pages;
>         } else if (flags & stack_flags)
>                 mm->stack_vm += pages;
> +
> +       if (!file && (flags & not_anon_acc) == 0)
> +               mm->anon_vm += pages;
>  }
>  #endif /* CONFIG_PROC_FS */
>
> @@ -1534,6 +1539,13 @@ static inline int accountable_mapping(st
>         return (vm_flags & (VM_NORESERVE | VM_SHARED | VM_WRITE)) == VM_WRITE;
>  }
>
> +static inline int anon_accountable_mapping(struct file *file, vm_flags_t vm_flags)
> +{
> +       return !file &&
> +               (vm_flags & (VM_GROWSDOWN | VM_GROWSUP |
> +                            VM_SHARED | VM_MAYSHARE)) == 0;
> +}

You're duplicating that "is it an anon accountable mapping" logic. I
think you should move the inline helper function up, and use it in
vm_stat_account().

Other than that, I think the patch certainly looks clean and obvious
enough. But I didn't actually try to *run* it, maybe it ends up not
working due to something I don't see.

               Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[RFC] mm: Account anon mappings as RLIMIT_DATA Cyrill Gorcunov <gorcunov@gmail.com> - 2015-12-11 22:00 +0100
  Re: [RFC] mm: Account anon mappings as RLIMIT_DATA Linus Torvalds <torvalds@linux-foundation.org> - 2015-12-11 22:00 +0100
    Re: [RFC] mm: Account anon mappings as RLIMIT_DATA Cyrill Gorcunov <gorcunov@gmail.com> - 2015-12-11 22:10 +0100

csiph-web