linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Jerome Marchand <jmarchan@redhat.com>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, dave.hansen@intel.com
Subject: Re: [PATCH v4 1/2] mm: factor commit limit calculation
Date: Tue, 5 Nov 2013 15:51:05 -0800	[thread overview]
Message-ID: <20131105155105.41c9a624689c3262f5141e41@linux-foundation.org> (raw)
In-Reply-To: <1382101019-23563-1-git-send-email-jmarchan@redhat.com>

On Fri, 18 Oct 2013 14:56:58 +0200 Jerome Marchand <jmarchan@redhat.com> wrote:

> Change since v3:
>  - rebase on 3.12-rc5
> 
> The same calculation is currently done in three differents places.
> Factor that code so future changes has to be made at only one place.
> 

lgtm.

> --- a/include/linux/mman.h
> +++ b/include/linux/mman.h
> @@ -7,6 +7,9 @@
>  #include <linux/atomic.h>
>  #include <uapi/linux/mman.h>
>  
> +#include <linux/hugetlb.h>
> +#include <linux/swap.h>
> +
>  extern int sysctl_overcommit_memory;
>  extern int sysctl_overcommit_ratio;
>  extern struct percpu_counter vm_committed_as;
> @@ -87,4 +90,13 @@ calc_vm_flag_bits(unsigned long flags)
>  	       _calc_vm_trans(flags, MAP_DENYWRITE,  VM_DENYWRITE ) |
>  	       _calc_vm_trans(flags, MAP_LOCKED,     VM_LOCKED    );
>  }
> +
> +/*
> + * Commited memory limit enforced when OVERCOMMIT_NEVER policy is used
> + */
> +static inline unsigned long vm_commit_limit()
> +{
> +	return ((totalram_pages - hugetlb_total_pages())
> +		* sysctl_overcommit_ratio / 100) + total_swap_pages;
> +}

Not sure I like this part much.  This function is large and slow and
doesn't merit inlining, plus it requires worsening our nested-include
mess.  This?

Also, it should be vm_commit_limit(void).



From: Andrew Morton <akpm@linux-foundation.org>
Subject: mm-factor-commit-limit-calculation-fix

Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Jerome Marchand <jmarchan@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 include/linux/mman.h |   12 +-----------
 mm/mmap.c            |    9 +++++++++
 2 files changed, 10 insertions(+), 11 deletions(-)

diff -puN fs/proc/meminfo.c~mm-factor-commit-limit-calculation-fix fs/proc/meminfo.c
diff -puN include/linux/mman.h~mm-factor-commit-limit-calculation-fix include/linux/mman.h
--- a/include/linux/mman.h~mm-factor-commit-limit-calculation-fix
+++ a/include/linux/mman.h
@@ -7,9 +7,6 @@
 #include <linux/atomic.h>
 #include <uapi/linux/mman.h>
 
-#include <linux/hugetlb.h>
-#include <linux/swap.h>
-
 extern int sysctl_overcommit_memory;
 extern int sysctl_overcommit_ratio;
 extern struct percpu_counter vm_committed_as;
@@ -91,12 +88,5 @@ calc_vm_flag_bits(unsigned long flags)
 	       _calc_vm_trans(flags, MAP_LOCKED,     VM_LOCKED    );
 }
 
-/*
- * Commited memory limit enforced when OVERCOMMIT_NEVER policy is used
- */
-static inline unsigned long vm_commit_limit()
-{
-	return ((totalram_pages - hugetlb_total_pages())
-		* sysctl_overcommit_ratio / 100) + total_swap_pages;
-}
+unsigned long vm_commit_limit(void);
 #endif /* _LINUX_MMAN_H */
diff -puN mm/mmap.c~mm-factor-commit-limit-calculation-fix mm/mmap.c
--- a/mm/mmap.c~mm-factor-commit-limit-calculation-fix
+++ a/mm/mmap.c
@@ -110,6 +110,15 @@ unsigned long vm_memory_committed(void)
 EXPORT_SYMBOL_GPL(vm_memory_committed);
 
 /*
+ * Commited memory limit enforced when OVERCOMMIT_NEVER policy is used
+ */
+unsigned long vm_commit_limit(void)
+{
+	return ((totalram_pages - hugetlb_total_pages())
+		* sysctl_overcommit_ratio / 100) + total_swap_pages;
+}
+
+/*
  * Check that a process has enough memory to allocate a new virtual
  * mapping. 0 means there is enough memory for the allocation to
  * succeed and -ENOMEM implies there is not.
diff -puN mm/nommu.c~mm-factor-commit-limit-calculation-fix mm/nommu.c
diff -puN mm/util.c~mm-factor-commit-limit-calculation-fix mm/util.c
diff -puN include/linux/mm.h~mm-factor-commit-limit-calculation-fix include/linux/mm.h
_

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

      parent reply	other threads:[~2013-11-05 23:51 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-18 12:56 Jerome Marchand
2013-10-18 12:56 ` [PATCH v4 2/2] mm: allow to set overcommit ratio more precisely Jerome Marchand
2013-11-05 23:53   ` Andrew Morton
2013-11-06  8:42     ` Jerome Marchand
2013-11-06 22:33       ` Andrew Morton
2013-11-06 23:49         ` Dave Hansen
2013-11-07 10:43           ` Jerome Marchand
2013-12-03 13:33   ` [PATCH v5] mm: add overcommit_kbytes sysctl variable Jerome Marchand
2013-12-03 22:14     ` Andrew Morton
2013-12-19  7:36     ` Olof Johansson
2013-11-05 23:51 ` Andrew Morton [this message]

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=20131105155105.41c9a624689c3262f5141e41@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=dave.hansen@intel.com \
    --cc=jmarchan@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.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