* remap_file_pages doesn't like MAP_ANONYMOUS (but used to?)
@ 2011-03-17 5:54 Kenny Simpson
2011-03-19 22:52 ` Hugh Dickins
0 siblings, 1 reply; 4+ messages in thread
From: Kenny Simpson @ 2011-03-17 5:54 UTC (permalink / raw)
To: linux-kernel
Hello,
In older kernels (2.6.15-2.6.18?) I was able to make an anonymous mapping and remap part of it back over itself to create a circular buffer:
p = mmap(0, sz, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, -1, 0)
remap_file_pages(p + sz/2, sz/2, 0/*prot*/, 0/*offset*/, 0/*flags*/)
I find the same method fails with EINVAL on the remap_file_pages call in 2.6.35/38. Making a dummy file or shared memory object works, but seems a bit more messy.
Why drop support for ANONYMOUS? Is there another way to get the same effect?
thanks,
-Kenny
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: remap_file_pages doesn't like MAP_ANONYMOUS (but used to?)
2011-03-17 5:54 remap_file_pages doesn't like MAP_ANONYMOUS (but used to?) Kenny Simpson
@ 2011-03-19 22:52 ` Hugh Dickins
2011-03-20 17:51 ` Kenny Simpson
0 siblings, 1 reply; 4+ messages in thread
From: Hugh Dickins @ 2011-03-19 22:52 UTC (permalink / raw)
To: Kenny Simpson; +Cc: linux-kernel
[-- Attachment #1: Type: TEXT/PLAIN, Size: 1654 bytes --]
On Wed, 16 Mar 2011, Kenny Simpson wrote:
> Hello,
> In older kernels (2.6.15-2.6.18?) I was able to make an anonymous mapping and remap part of it back over itself to create a circular buffer:
> p = mmap(0, sz, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, -1, 0)
> remap_file_pages(p + sz/2, sz/2, 0/*prot*/, 0/*offset*/, 0/*flags*/)
>
> I find the same method fails with EINVAL on the remap_file_pages call in 2.6.35/38. Making a dummy file or shared memory object works, but seems a bit more messy.
>
> Why drop support for ANONYMOUS? Is there another way to get the same effect?
Thanks for reporting. It was a simple oversight: and until you came
along, nobody noticed. Here's the patch, I'll pass it upstream shortly.
[PATCH] shmem: let shared anonymous be nonlinear again
Up to 2.6.22, you could use remap_file_pages(2) on a tmpfs file or a
shared mapping of /dev/zero or a shared anonymous mapping. In 2.6.23
we disabled it by default, but set VM_CAN_NONLINEAR to enable it on
safe mappings. We made sure to set it in shmem_mmap() for tmpfs files,
but missed it in shmem_zero_setup() for the others. Fix that at last.
Reported-by: Kenny Simpson <theonetruekenny@yahoo.com>
Signed-off-by: Hugh Dickins <hughd@google.com>
---
mm/shmem.c | 1 +
1 file changed, 1 insertion(+)
--- 2.6.38/mm/shmem.c 2011-03-14 18:20:32.000000000 -0700
+++ linux/mm/shmem.c 2011-03-19 15:09:26.000000000 -0700
@@ -2791,5 +2791,6 @@ int shmem_zero_setup(struct vm_area_stru
fput(vma->vm_file);
vma->vm_file = file;
vma->vm_ops = &shmem_vm_ops;
+ vma->vm_flags |= VM_CAN_NONLINEAR;
return 0;
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: remap_file_pages doesn't like MAP_ANONYMOUS (but used to?)
2011-03-19 22:52 ` Hugh Dickins
@ 2011-03-20 17:51 ` Kenny Simpson
2011-03-21 1:57 ` Hugh Dickins
0 siblings, 1 reply; 4+ messages in thread
From: Kenny Simpson @ 2011-03-20 17:51 UTC (permalink / raw)
To: Hugh Dickins; +Cc: linux-kernel
--- On Sat, 3/19/11, Hugh Dickins <hughd@google.com> wrote:
> Thanks for reporting. It was a simple oversight: and
> until you came
> along, nobody noticed. Here's the patch, I'll pass it
> upstream shortly.
Since this bug has existed for a while, could it be pushed back to the various stable/longterm branches as well? (as they all are affected)
Many thanks on the quick response! Glad it was a simple oversight with an easy and obvious fix.
thanks again!
-Kenny
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: remap_file_pages doesn't like MAP_ANONYMOUS (but used to?)
2011-03-20 17:51 ` Kenny Simpson
@ 2011-03-21 1:57 ` Hugh Dickins
0 siblings, 0 replies; 4+ messages in thread
From: Hugh Dickins @ 2011-03-21 1:57 UTC (permalink / raw)
To: Kenny Simpson; +Cc: Andrew Morton, linux-kernel
[-- Attachment #1: Type: TEXT/PLAIN, Size: 1040 bytes --]
On Sun, 20 Mar 2011, Kenny Simpson wrote:
> --- On Sat, 3/19/11, Hugh Dickins <hughd@google.com> wrote:
> > Thanks for reporting. It was a simple oversight: and
> > until you came
> > along, nobody noticed. Here's the patch, I'll pass it
> > upstream shortly.
>
> Since this bug has existed for a while, could it be pushed back to the various stable/longterm branches as well? (as they all are affected)
>
> Many thanks on the quick response! Glad it was a simple oversight with an easy and obvious fix.
>
> thanks again!
> -Kenny
It's a rare pleasure to be presented with such a straightforward bug!
stable/longterm: well, I don't mind asking akpm to add a Cc: stable,
but don't be surprised if he prefers not: although it was a regression
back in 2.6.23, it's not a security issue, and the lack of interest
between then and now doesn't make a strong argument for it.
Andrew, if you're so inclined, please add a Cc: stable@kernel.org
to [PATCH] shmem: let shared anonymous be nonlinear again
Thanks,
Hugh
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-03-21 1:57 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-17 5:54 remap_file_pages doesn't like MAP_ANONYMOUS (but used to?) Kenny Simpson
2011-03-19 22:52 ` Hugh Dickins
2011-03-20 17:51 ` Kenny Simpson
2011-03-21 1:57 ` Hugh Dickins
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®