qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] mmap-alloc: use same backend for all mappings


From: Michael S. Tsirkin
Subject: Re: [Qemu-devel] [PATCH] mmap-alloc: use same backend for all mappings
Date: Tue, 1 Dec 2015 16:25:03 +0200

On Tue, Dec 01, 2015 at 05:45:27PM +0530, Aneesh Kumar K.V wrote:
> "Michael S. Tsirkin" <address@hidden> writes:
> 
> > On Tue, Dec 01, 2015 at 04:23:11PM +0530, Aneesh Kumar K.V wrote:
> >> "Michael S. Tsirkin" <address@hidden> writes:
> >> 
> >> > On Mon, Nov 30, 2015 at 02:46:31PM +0100, Greg Kurz wrote:
> >> >> On Mon, 30 Nov 2015 15:06:33 +0200
> >> >> "Michael S. Tsirkin" <address@hidden> wrote:
> >> >> 
> >> 
> >> 
> >> ....
> >> >> 
> >> >> On ppc64, the address space is divided in 256MB-sized segments where 
> >> >> all pages
> >> >> have the same size. This is a hw limitation IIUC. I don't know if it 
> >> >> can be
> >> >> fixed and I'll let Ben comment on it.
> >> >
> >> > But it's anonymous memory with PROT_NONE.  There should be no pages 
> >> > there:
> >> > just a chunk of virtual memory reserved.
> >> >
> >> 
> >> ppc64 use page size (called as base page size) to find the hash slot in
> >> which we find the virtual address to real address translation. All the
> >> pages in a segment should have same base page size. Hugetlb pages have a
> >> base page size of 16M whereas a regular linux page have 64K. mmap will
> >> fail to map a hugetlb mapping in a segment that already have regular
> >> pages mapped.
> >> 
> >> -aneesh
> >
> >
> > I see this in kernel:
> >
> >        } else if (flags & MAP_HUGETLB) {
> >                 struct user_struct *user = NULL;
> >                 struct hstate *hs;
> >
> >                 hs = hstate_sizelog((flags >> MAP_HUGE_SHIFT) & 
> > SHM_HUGE_MASK);
> >                 if (!hs)
> >                         return -EINVAL;
> >
> >                 len = ALIGN(len, huge_page_size(hs));
> >                 /*
> >                  * VM_NORESERVE is used because the reservations will be
> >                  * taken when vm_ops->mmap() is called
> >                  * A dummy user value is used because we are not locking
> >                  * memory so no accounting is necessary
> >                  */
> >                 file = hugetlb_file_setup(HUGETLB_ANON_FILE, len,
> >                                 VM_NORESERVE,
> >                                 &user, HUGETLB_ANONHUGE_INODE,
> >                                 (flags >> MAP_HUGE_SHIFT) & MAP_HUGE_MASK);
> >                 if (IS_ERR(file))
> >                         return PTR_ERR(file);
> >         }
> >
> > So maybe it's a question of passing in MAP_HUGETLB and the
> > correct size mask.
> >
> 
> Can you explain this more ?
> 
> If the question is do we need to pass fd and remove MAP_ANONYMOUS to map
> hugetlb, we don't. A good example is
> tools/testing/selftest/vm/map_hugetlb.c
> 
> If the question is whether we will loose hugepages on mmap even if the
> mapping is PROT_NONE, then the answer is we do in the form of hugetlb
> reservation.
> 
> -aneesh

The question is whether passing MAP_HUGETLB to the PROT_NONE
mapping with fd == -1 will get a mapping in the correct slice on ppc.

-- 
MST



reply via email to

[Prev in Thread] Current Thread [Next in Thread]