From: David Daney <ddaney@caviumnetworks.com>
To: Jian Peng <jipeng@broadcom.com>
Cc: "linux-mips@linux-mips.org" <linux-mips@linux-mips.org>,
Ralf Baechle <ralf@linux-mips.org>
Subject: Re: patch to support topdown mmap allocation in MIPS
Date: Mon, 16 May 2011 17:12:34 -0700 [thread overview]
Message-ID: <4DD1BD72.2000408@caviumnetworks.com> (raw)
In-Reply-To: <E18F441196CA634DB8E1F1C56A50A8743242B54C8A@IRVEXCHCCR01.corp.ad.broadcom.com>
On 05/16/2011 02:09 PM, Jian Peng wrote:
>> From cda3f14f0201342db9649376e9124167b42bbeba Mon Sep 17 00:00:00 2001
> From: Jian Peng<jipeng2005@gmail.com>
> Date: Mon, 16 May 2011 12:07:37 -0700
> Subject: [PATCH 1/1] MIPS: topdown mmap support
>
> This patch introduced topdown mmap support in user process address
> space allocation policy.
>
> Recently, we ran some large applications that use mmap heavily and
> lead to OOM due to inflexible mmap allocation policy on MIPS32.
>
> Since most other major archs supported it for years, it is reasonable
> to follow the trend and reduce the pain of porting applications.
>
> Due to cache aliasing concern, arch_get_unmapped_area_topdown() and
> other helper functions are implemented in arch/mips/kernel/syscall.c.
>
> Signed-off-by: Jian Peng<jipeng2005@gmail.com>
[...]
> +
> +/* add COLOUR_ALIGN_DOWN */
That is not a good comment. We know you are adding it by all the '+'
characters in the patch.
> +static inline unsigned long COLOUR_ALIGN_DOWN(unsigned long addr,
> + unsigned long pgoff)
> +{
> + unsigned long base = addr& ~shm_align_mask;
> + unsigned long off = (pgoff<< PAGE_SHIFT)& shm_align_mask;
> +
> + if (base + off<= addr)
> + return base + off;
> +
> + return base - off;
> +}
> +
> #define COLOUR_ALIGN(addr,pgoff) \
> ((((addr) + shm_align_mask)& ~shm_align_mask) + \
> (((pgoff)<< PAGE_SHIFT)& shm_align_mask))
> @@ -136,6 +185,125 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
> }
> }
>
> +/* add arch_get_unmapped_area_topdown */
Another bad comment.
> +unsigned long
> +arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
> + const unsigned long len, const unsigned long pgoff,
> + const unsigned long flags)
> +{
> + struct vm_area_struct *vma;
> + struct mm_struct *mm = current->mm;
> + unsigned long addr = addr0;
> + int do_colour_align;
> + unsigned long task_size;
> +
> +#ifdef CONFIG_32BIT
> + task_size = TASK_SIZE;
> +#else /* Must be CONFIG_64BIT*/
> + task_size = test_thread_flag(TIF_32BIT_ADDR) ? TASK_SIZE32 : TASK_SIZE;
> +#endif
> +
> + if (flags& MAP_FIXED) {
> + /* We do not accept a shared mapping if it would violate
> + * cache aliasing constraints.
> + */
> + if ((flags& MAP_SHARED)&&
> + ((addr - (pgoff<< PAGE_SHIFT))& shm_align_mask))
> + return -EINVAL;
> + return addr;
> + }
> +
> + if (unlikely(len> task_size))
> + return -ENOMEM;
> +
All this code you are duplicating from arch_get_unmapped_area(), but you
introduce subtle bugs by removing some needed checks.
Why duplicate the code?
Why remove the checks?
David Daney
next prev parent reply other threads:[~2011-05-17 0:12 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-16 21:09 patch to support topdown mmap allocation in MIPS Jian Peng
2011-05-16 23:37 ` Jian Peng
2011-05-17 0:12 ` David Daney [this message]
2011-05-17 1:06 ` Jian Peng
2011-05-17 16:49 ` David Daney
2011-05-17 19:37 ` Jian Peng
2011-05-25 17:47 ` Jian Peng
2011-05-25 17:58 ` David Daney
2011-05-25 18:06 ` Jian Peng
2011-06-13 23:43 ` Jian Peng
2011-06-14 0:21 ` Jian Peng
2011-11-09 17:45 ` Ralf Baechle
2011-05-17 1:27 ` Kevin Cernekee
2011-05-17 4:04 ` Jian Peng
2011-05-17 15:18 ` [PATCH] MIPS: Cleanup arch_get_unmapped_area Ralf Baechle
2011-05-17 16:52 ` patch to support topdown mmap allocation in MIPS Ralf Baechle
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=4DD1BD72.2000408@caviumnetworks.com \
--to=ddaney@caviumnetworks.com \
--cc=jipeng@broadcom.com \
--cc=linux-mips@linux-mips.org \
--cc=ralf@linux-mips.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.