lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20131105155105.41c9a624689c3262f5141e41@linux-foundation.org>
Date:	Tue, 5 Nov 2013 15:51:05 -0800
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	Jerome Marchand <jmarchan@...hat.com>
Cc:	linux-mm@...ck.org, linux-kernel@...r.kernel.org,
	dave.hansen@...el.com
Subject: Re: [PATCH v4 1/2] mm: factor commit limit calculation

On Fri, 18 Oct 2013 14:56:58 +0200 Jerome Marchand <jmarchan@...hat.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@...ux-foundation.org>
Subject: mm-factor-commit-limit-calculation-fix

Cc: Dave Hansen <dave.hansen@...ux.intel.com>
Cc: Jerome Marchand <jmarchan@...hat.com>
Signed-off-by: Andrew Morton <akpm@...ux-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 from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ