Re: remap_file_pages() use

From: Kenny Simpson
Date: Tue May 20 2014 - 23:56:44 EST


I might need a gentle nudge with a clue stick...
checking against latest git tree it looks as though most common
filesystem types do support remap_file_pages.

I just wrote a simple test case and it worked on my 3.13-based ubuntu
14.04 system on an ext4 filesystem.

thanks,
-Kenny

Here was my simple test case: (it doesn't have error handling, but the
case passed, and running under strace shows all system calls as
passing as well)

#include <unistd.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>

// make a 16-page file, map page 17 over the first page, write to the
aliasing page, assert that it is seen on the first page

int main()
{
unlink("foo");
int fd = open("foo", O_CREAT | O_RDWR, 0755);
ftruncate(fd, 16*4096);
void* ptr = mmap(0, 17*4096, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
char* cptr = (char*) ptr;

// remap the last page over the first
remap_file_pages(cptr + 16*4096/*addr*/, 4096/*size*/,
0/*prot*/, 0/*pgoff*/, 0/*flags*/);

cptr[16*4096] = 'a';
return cptr[0] != 'a'; // if this aliases, this will be 'a'
}


On Tue, May 20, 2014 at 9:53 PM, Kenny Simpson
<theonetruekenny@xxxxxxxxx> wrote:
> ouch... hope they don't try to run that code on anything newer then :(
> Will let them know.
>
> -Kenny
>
>
> On Mon, May 19, 2014 at 5:24 PM, Kirill A. Shutemov
> <kirill@xxxxxxxxxxxxx> wrote:
>> On Mon, May 19, 2014 at 01:34:05PM -0400, Kenny Simpson wrote:
>>> For the other cases I had used the remapping to have more of a sliding
>>> window over a disk-backed file where I also was using aliasing to
>>> eliminate the corner cases of hitting the end of a window and needing
>>> to split records due to crossing boundaries, etc..
>>
>> Disk backed files are not supported by remap_file_pages() since 2007.
>> See commit 3ee6dafc677a.
>>
>> --
>> Kirill A. Shutemov
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/