This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [libc/string] State of PAGE_COPY_FWD / PAGE_COPY_THRESHOLD
> On Nov 1, 2016, at 5:59 PM, Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:
>
...
> $ cat sysdeps/x86/pagecopy.h
>
> #define PAGE_SIZE 4096
> #define PAGE_COPY_THRESHOLD PAGE_SIZE
>
> #define PAGE_COPY_FWD(dstp, srcp, nbytes_left, nbytes) /* Implement it */
>
> It should work on any other architecture as well. Now the question
> is whether this actually does make sense for Linux. Hurd/mach provided
> a syscall (?) to actually copy the pages (vm_copy) which seems to apply
> some tricks to avoid full copy pages. By 'linux zero page sharing' are
> you referring to KSM (Kernel Samepage Merging)?
>
> If so, on a system without a provided kernel interface to work directed
> with underlying memory mapping (such as for mach), mem{cpy,set} will
> actually need to touch the pages and it will be up to kernel page fault
> mechanism to actually handle it (by identifying common pages and adjusting
> vma mapping accordingly). And AFAIK this are only enabled on KSM if you
> actually madavise the page explicit. So I am not grasping the need to
> actually implement page copying on Linux.
Linux kernel has a reserved page filled with zeroes, so it there /were/ a syscall to tell kernel to map N consecutive pages starting at address PTR to that zero page, we could use that in GLIBC for really big memset(0).
A quick investigation shows that there is no such syscall provided by the Linux kernel. Doesn't mean we can't ask for / implement one.
--
Maxim Kuvyrkov
www.linaro.org