At 2011-03-28 10:00:27,"David Gibson" <[email protected]> wrote:

>On Sun, Mar 27, 2011 at 10:25:23PM +0800, rocky wrote:
>> Hey :)
>> 
>> I am using libhugetlbfs to test ARM hugetlb support , I am a bit of
>> confused of some test cases in libhugetlbfs.
>
>> take alloc-instantiate-race for exmapple,
>> for shared mapping, why does we employ fork to produce 2 process do the 
>> racing?
>> while for private mapping, we actually use pthread do it .
>> I don't get it the reason of this testing theme,
>
>alloc-instantiate-race is designed to test for a specific kernel bug
>we had at one point.  This bug occurred when two processes or threads
>raced to instantiate the last available huge page in the system.  The
>buggy case only occurred when the two threads/processes were
>attempting to instantiate the *same* huge page - that is, that if the
>two faults did not race, but occurred sequentially the second fault
>would simply use the hugepage already instantiated by the first
>fault.  The bug was that the second fault when racing would fail to
>allocate a new page (because none were available) and fail the fault,
>even though if it waited the necessary page would be supplied by the
>first fault.
>
>There are two situations where this can occur.  The first is in a
>MAP_SHARED mapping, shared between two processes.  Here the race it to
>instantiate the same page in the shared mapping's radix tree.  We
>could theoretically test this with threads instead of processes, but
>in that case we wouldn't really be testing the proper synchronization
>between different processes that share a mapping.
>
>The second case is a MAP_PRIVATE mapping, with the race being between
>two threads sharing that private mapping (since a private mapping is
>not shared between processes).  In this case the race is to
>instantiate the same page in the mm's page tables which are shared
>between the threads.
>
>-- 
>David Gibson                   | I'll have my music baroque, and my code
>david AT gibson.dropbear.id.au | minimalist, thank you.  NOT _the_ _other_
>                               | _way_ _around_!
>http://www.ozlabs.org/~dgibson

You are the guy who wrote libhugetlbfs, nice to reach you in mail.
Yes, I understand now, thanks for your help:)

And a couple of question if you don't mind, I do the homework and I'm 
struggling to make it clear.
platform : ARM(32bit) cortex A9 SMP platform with 16MB hugepage, linux-2.6.34

1:mremap-expand-slice-collision
   this test FAIL both on X86_64/ARM , it's about mremap on normal 4K page,not 
hugepage
   mmap     SLICE_BOUNDARY-0x400 ~ SLICE_BOUNDARY              OK
   mremap  SLICE_BOUNDARY-0x400 ~ SLICE_BOUNDARY+0x400  OK
   readback SLICE_BOUNDARY-0x400 ~ SLICE_BOUNDARY             OK
   readback SLICE_BOUNDARY            ~ SLICE_BOUNDARY+0X400  BUS ERROR
   attachment is mremap test code.

2: icache-hygiene
    test rationale says:
    'This test will never trigger (obviously) on machines with coherent icache 
and dcache (including x86 and POWER5). '
   Is this test case applicable to arm ?

3:slbpacaflush
  Is this test case applicable to arm ?

4:truncate_above_4GB
   This test failed on mmap64, I dig the code, it fails here: 
    fs/hugetlbfs/inode.c/hugetlbfs_file_mmap:
        if (vma->vm_pgoff & ~(huge_page_mask(h) >> PAGE_SHIFT))
                return -EINVAL;

   I don't know the FOURGIG number is OK for 32bit arm?
   

thanks for you time.

rocky

   














   





















/*
 * libhugetlbfs - Easy use of Linux hugepages
 * Copyright (C) 2009 David Gibson, IBM Corporation.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 */

#define _GNU_SOURCE

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/mman.h>
#include <errno.h>

#define RANDOM_CONSTANT 0x1234ABCD

#ifdef __LP64__
#define SLICE_BOUNDARY 0x20000000000
#else
//#define SLICE_BOUNDARY 0xe0000000
#define SLICE_BOUNDARY 0x80000000
#endif

long hpage_size, page_size;

void do_readback(void *p, size_t size, const char *stage)
{
        unsigned int *q = p;
        int i;

        printf("do_readback(%p, 0x%lx, \"%s\")\n", p,
                       (unsigned long)size, stage);

        for (i = 0; i < (size / sizeof(*q)); i++) {
                q[i] = RANDOM_CONSTANT ^ i;
        }

        for (i = 0; i < (size / sizeof(*q)); i++) {
                if (q[i] != (RANDOM_CONSTANT ^ i))
                        printf("Stage \"%s\": Mismatch at offset 0x%x: 0x%x 
instead of 0x%x",
                             stage, i, q[i], RANDOM_CONSTANT ^ i);
        }
}


int main(int argc, char *argv[])
{
        int fd, rc;
        void *p, *q, *r;


        page_size = getpagesize();


        q = mmap((void *)(SLICE_BOUNDARY - page_size), page_size,
                 PROT_READ | PROT_WRITE,
                 MAP_SHARED | MAP_ANONYMOUS | MAP_FIXED, -1, 0);
        if (q == MAP_FAILED)
                printf("mmap(normal below): %s", strerror(errno));

        do_readback(q, page_size, "normal below");

        printf("Attempting to remap...");

        r = mremap(q, page_size, 2*page_size, 0);
        if (r == MAP_FAILED) {
                printf("disallowed\n");
                rc = munmap(q, page_size);
                if (rc != 0)
                        printf("munmap(normal below): %s", strerror(errno));
        } else {
                if (r != q)
                        printf("mremap() moved without MREMAP_MAYMOVE!?");

                printf("testing...");
                do_readback(q, 2*page_size, "normal below expanded");
                rc = munmap(q, 2*page_size);
                if (rc != 0)
                        printf("munmap(normal below expanded): %s", 
strerror(errno));
        }

}

------------------------------------------------------------------------------
Enable your software for Intel(R) Active Management Technology to meet the
growing manageability and security demands of your customers. Businesses
are taking advantage of Intel(R) vPro (TM) technology - will your software 
be a part of the solution? Download the Intel(R) Manageability Checker 
today! http://p.sf.net/sfu/intel-dev2devmar
_______________________________________________
Libhugetlbfs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel

Reply via email to