From mboxrd@z Thu Jan 1 00:00:00 1970 From: Helge Deller Subject: Re: parisc: fix mmap(MAP_FIXED|MAP_SHARED) to already mmapped address - optimized patches Date: Sun, 22 Feb 2015 19:28:26 +0100 Message-ID: <54EA1FCA.1050609@gmx.de> References: <20131219191750.GC2881@blackmetal.musicnaut.iki.fi> <201312191619.05005.vapier@gentoo.org> <5313A12E.7010307@gmx.de> <20140401182627.GA3285@drone.musicnaut.iki.fi> <533B0A57.2060700@gmx.de> <533C7C9A.5080703@gmx.de> <533DB961.9010607@gmx.de> <533DC3E8.5010701@gmx.de> <1424560158.2146.22.camel@HansenPartnership.com> <54E9141B.4050009@gmx.de> <1424563046.2146.41.camel@HansenPartnership.com> <1424625475.2146.88.camel@HansenPartnership.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Cc: Carlos O'Donell , Aaro Koskinen , Mike Frysinger , linux-parisc To: John David Anglin , James Bottomley Return-path: In-Reply-To: List-ID: List-Id: linux-parisc.vger.kernel.org On 22.02.2015 18:54, John David Anglin wrote: > At one time, we thought this value needed to be 4 MB. > Helge was working on improving the mmap allocation scheme but this > work stalled after some improvement. The patches are still available: http://git.kernel.org/cgit/linux/kernel/git/deller/parisc-linux.git/commit/?h=parisc-mmap&id=34ae0a4620b50d27ce2f1314322275cbea7f2055 and http://git.kernel.org/cgit/linux/kernel/git/deller/parisc-linux.git/commit/?h=parisc-mmap&id=7a6e51ddfd3ab3b11a4ebdd995e26672e69a8efa Basically the idea is: - Currently we have a static calculation where the mapping should happen inside the 4MB range: see: arch/parisc/kernel/sys_parisc.c: (filp ? ((unsigned long) filp->f_mapping) >> 8 : 0UL) - Replace that by a dynamic mapping, which searches best fit address in free mem area *if* the file hasn't been mapped yet, and save this mapping in the struct address_space. If another process then maps the same file again, then just reuse the last calculated "dynamic" mapping (offset). This helps a lot to prevent userspace memory fragmentation, but Linus didn't liked this approach and proposed instead: https://lkml.org/lkml/2014/5/1/368 Sadly his patch didn't worked out of the box. I did tried various ways (I'm sure it can work somehow), but I couldn't solve it yet. Maybe some Linux mm expert could help here? Helge