----- Original Message -----
> From: "Jan Stancek" <jstan...@redhat.com>
> To: libhugetlbfs-devel@lists.sourceforge.net
> Cc: n-horigu...@ah.jp.nec.com, an...@redhat.com
> Sent: Tuesday, 28 May, 2013 1:02:20 PM
> Subject: [Libhugetlbfs-devel] [PATCH] misalign: misaligned length allowed on  
> kernels >= 3.10-rc1
> 
> Starting with 3.10-rc1, length passed in mmap() doesn't need
> to be aligned because commit af73e4d9506d3b797509f3c030e7dcd554f7d9c4
> added ALIGN() to kernel side, in mmap_pgoff(), when mapping huge
> page files.
> 
> This patch treats successful mmap() with misaligned length on
> kernels >= 3.10 as PASS.
> 
> See also:
> Bug 56881 - MAP_HUGETLB mmap fails for certain sizes
> https://bugzilla.kernel.org/show_bug.cgi?id=56881
> 
> Signed-off-by: Jan Stancek <jstan...@redhat.com>

Any thoughts about this patch?

Regards,
Jan

> ---
>  tests/misalign.c |   36 ++++++++++++++++++++++++++++++------
>  1 files changed, 30 insertions(+), 6 deletions(-)
> 
> diff --git a/tests/misalign.c b/tests/misalign.c
> index de85be6..de1bf98 100644
> --- a/tests/misalign.c
> +++ b/tests/misalign.c
> @@ -23,6 +23,7 @@
>  #include <errno.h>
>  #include <signal.h>
>  #include <sys/mman.h>
> +#include <sys/utsname.h>
>  
>  #include <hugetlbfs.h>
>  
> @@ -40,6 +41,11 @@
>   * necessary checks for the hugepage paths.  This testcase ensures
>   * that attempted hugepage mappings with parameters which are not
>   * correctly hugepage aligned are rejected.
> + *
> + * However starting with 3.10-rc1, length passed in mmap() doesn't need
> + * to be aligned because commit af73e4d9506d3b797509f3c030e7dcd554f7d9c4
> + * added ALIGN() to kernel side, in mmap_pgoff(), when mapping huge page
> + * files.
>   */
>  int main(int argc, char *argv[])
>  {
> @@ -47,9 +53,13 @@ int main(int argc, char *argv[])
>       int fd;
>       void *p, *q;
>       int err;
> +     struct utsname buf;
>  
>       test_init(argc, argv);
>  
> +     if (uname(&buf) != 0)
> +             FAIL("uname failed %s", strerror(errno));
> +
>       page_size = getpagesize();
>       hpage_size = check_hugepagesize();
>  
> @@ -92,16 +102,30 @@ int main(int argc, char *argv[])
>  
>       /* 3) Try a misaligned length */
>       q = mmap(NULL, page_size, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);
> -     if (q != MAP_FAILED)
> -             FAIL("mmap() with misaligned length 0x%lx succeeded",
> -                  page_size);
> +
> +     if (test_compare_kver(buf.release, "3.10.0") < 0) {
> +             if (q != MAP_FAILED)
> +                     FAIL("mmap() with misaligned length 0x%lx succeeded",
> +                             page_size);
> +     } else {
> +             if (q == MAP_FAILED)
> +                     FAIL("mmap() with misaligned length 0x%lx failed",
> +                             page_size);
> +     }
>  
>       /* 4) Try a misaligned length with MAP_FIXED */
>       q = mmap(p, page_size, PROT_READ|PROT_WRITE,
>                MAP_PRIVATE|MAP_FIXED, fd, 0);
> -     if (q != MAP_FAILED)
> -             FAIL("mmap() MAP_FIXED with misaligned length 0x%lx succeeded",
> -                  page_size);
> +
> +     if (test_compare_kver(buf.release, "3.10.0") < 0) {
> +             if (q != MAP_FAILED)
> +                     FAIL("mmap() MAP_FIXED with misaligned length 0x%lx "
> +                             "succeeded", page_size);
> +     } else {
> +             if (q == MAP_FAILED)
> +                     FAIL("mmap() MAP_FIXED with misaligned length 0x%lx "
> +                             "failed", page_size);
> +     }
>  
>       /* 5) Try a misaligned offset */
>       q = mmap(NULL, hpage_size, PROT_READ|PROT_WRITE,
> --
> 1.7.1
> 
> 
> ------------------------------------------------------------------------------
> Try New Relic Now & We'll Send You this Cool Shirt
> New Relic is the only SaaS-based application performance monitoring service
> that delivers powerful full stack analytics. Optimize and monitor your
> browser, app, & servers with just a few lines of code. Try New Relic
> and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
> _______________________________________________
> Libhugetlbfs-devel mailing list
> Libhugetlbfs-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel
> 

------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
_______________________________________________
Libhugetlbfs-devel mailing list
Libhugetlbfs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel

Reply via email to