Re: [PATCH] mmap: Fix and tidy up overcommit page arithmetic

From: Minchan Kim
Date: Sun Jul 10 2011 - 19:08:50 EST


On Sun, Jul 10, 2011 at 5:55 AM, Dmitry Fink <dmitry.fink@xxxxxxxx> wrote:
> - shmem pages are not immediately available, but they are not
> potentially available either, even if we swap them out, they will
> just relocate from memory into swap, total amount of immediate and
> potentially available memory is not going to be affected, so we
> shouldn't count them as potentially free in the first place.
>
> - nr_free_pages() is not an expensive operation anymore, there is
> no need to split the decision making in two halves and repeat code.
>
> Signed-off-by: Dmitry Fink <dmitry.fink@xxxxxxxx>
> Reviewed-by: Minchan Kim <minchan.kim@xxxxxxxxx>
> Acked-by: Hugh Dickins <hughd@xxxxxxxxxx>
> ---
> Âmm/mmap.c Â| Â 33 ++++++++++++---------------------
> Âmm/nommu.c | Â 33 ++++++++++++---------------------
> Â2 files changed, 24 insertions(+), 42 deletions(-)
>
> diff --git a/mm/mmap.c b/mm/mmap.c
> index d49736f..b6ed22e 100644
> --- a/mm/mmap.c
> +++ b/mm/mmap.c
> @@ -122,9 +122,16 @@ int __vm_enough_memory(struct mm_struct *mm, long pages, int cap_sys_admin)
> Â Â Â Â Â Â Â Âreturn 0;
>
> Â Â Â Âif (sysctl_overcommit_memory == OVERCOMMIT_GUESS) {
> - Â Â Â Â Â Â Â unsigned long n;
> + Â Â Â Â Â Â Â free = global_page_state(NR_FREE_PAGES);
> + Â Â Â Â Â Â Â free += global_page_state(NR_FILE_PAGES);
> +
> + Â Â Â Â Â Â Â /* shmem pages shouldn't be counted as free in this

Nitpick.
You didn't correct comment style. It's not a linux kernel coding style.

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