[RFC] upmfs - page-unaligned mmap() for Linux

Dan Aloni da-x at colinux.org
Sat May 21 07:08:08 CDT 2005

Hello All,

I'd like to bring this to your attention and review, hopefully to spawn 
some constructive discussions. The code was a result of experiments I've 
been doing lately concering some new idea not especially related to 

To quote myself from http://wiki.winehq.org/UnalignedMmap:

Large majority of PE executables have sections that are page-aligned in 
memory but not in the PE file image. Linux's mmap() doesn't support 
mappings that are not aligned to page boundries with regard to file 
offsets. Currently it forces wineserver to fake mmap() by allocating 
anonymous pages and using read() to load the sections.

In dlls/ntdll/virtual.c, comment above map_file_into_view() says: 
"Linux kernels before 2.4.x can support non page-aligned offsets, as 
long as the offset is aligned to the filesystem block size. This is a 
big performance gain so we want to take advantage of it."

These days are long gone, we are now using Linux 2.6, and it doesn't 
support unaligned mmap().

Enter upmfs. This simple kernel module exports this function to 
userspace using '/proc':

    * int mmap_offset(int fd, unsigned long offset);

Given an fd and an offset, a new fd is returned. Using mmap() on that new 
fd, the mapping will be aligned with the given offset, which can be smaller 

A wineserver implementation can check the existance of that module in the 
kernel (i.e "/proc/upmfs/interface" exists) and use its functionality.

The code for the upmfs source package is attached to this post.

Dan Aloni
da-x at colinux.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: upmfs.tar.gz
Type: application/octet-stream
Size: 14162 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-devel/attachments/20050521/79c733f7/upmfs.tar.obj

More information about the wine-devel mailing list