linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* how to unmap pages in an anonymous mmap?
       [not found]       ` <85a41492-8aba-b752-c180-ec25f43d2a1a@cmss.chinamobile.com>
@ 2017-02-27 19:32         ` Andy Grover
  2017-03-10  1:45           ` Xiubo Li
  0 siblings, 1 reply; 2+ messages in thread
From: Andy Grover @ 2017-02-27 19:32 UTC (permalink / raw)
  To: Xiubo Li, nab, mchristi, shli
  Cc: hch, sheng, namei.unix, bart.vanassche, linux-scsi, target-devel,
	linux-kernel, Jianfei Hu, linux-mm

On 02/26/2017 09:59 PM, Xiubo Li wrote:
>> But, We likely don't want to release memory from the data area anyways
>> while active, in any case. How about if we set a timer when active
>> commands go to zero, and then reduce data area to some minimum if no new
>> cmds come in before timer expires?
> 
> If I understand correctly: for example, we have 1G(as the minimum)
> data area and all blocks have been allocated and mapped to runner's
> vma, then we extern it to 1G + 256M as needed. When there have no
> active cmds and after the timer expires, will it reduce the data area
> back to 1G ? And then should it release the reduced 256M data area's
> memories ?
> 
> If so, after kfree()ed the blocks' memories, it should also try to remove
> all the ptes which are mapping this page(like using the try_to_umap()),
> but something like try_to_umap() doesn't export for the modules.
> 
> Without ummaping the kfree()ed pages' ptes mentioned above, then
> the reduced 256M vma space couldn't be reused again for the runner
> process, because the runner has already do the mapping for the reduced
> vma space to some old physical pages(won't trigger new page fault
> again). Then there will be a hole, and the hole will be bigger and bigger.
> 
> Without ummaping the kfree()ed pages' ptes mentioned above, the
> pages' reference count (page_ref_dec(), which _inc()ed in page fault)
> couldn't be reduced back too.

Let's ask people who will know...

Hi linux-mm,

TCM-User (drivers/target/target_core_user.c) currently uses vmalloc()ed
memory to back a ring buffer that is mmaped by userspace.

We want to move to dynamically mapping pages into this region, and also
we'd like to unmap/free pages when idle. What's the right way to unmap?
I see unmap_mapping_range() but that mentions an underlying file, which
TCMU doesn't have. Or maybe zap_page_range()? But it's not exported.

Any advice?

Thanks in advance -- Regards -- Andy

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: how to unmap pages in an anonymous mmap?
  2017-02-27 19:32         ` how to unmap pages in an anonymous mmap? Andy Grover
@ 2017-03-10  1:45           ` Xiubo Li
  0 siblings, 0 replies; 2+ messages in thread
From: Xiubo Li @ 2017-03-10  1:45 UTC (permalink / raw)
  To: linux-mm
  Cc: Andy Grover, nab, mchristi, shli, hch, sheng, namei.unix,
	bart.vanassche, linux-scsi, target-devel, linux-kernel,
	Jianfei Hu



On 2017a1'02ae??28ae?JPY 03:32, Andy Grover wrote:
> On 02/26/2017 09:59 PM, Xiubo Li wrote:
>>> But, We likely don't want to release memory from the data area anyways
>>> while active, in any case. How about if we set a timer when active
>>> commands go to zero, and then reduce data area to some minimum if no new
>>> cmds come in before timer expires?
>> If I understand correctly: for example, we have 1G(as the minimum)
>> data area and all blocks have been allocated and mapped to runner's
>> vma, then we extern it to 1G + 256M as needed. When there have no
>> active cmds and after the timer expires, will it reduce the data area
>> back to 1G ? And then should it release the reduced 256M data area's
>> memories ?
>>
>> If so, after kfree()ed the blocks' memories, it should also try to remove
>> all the ptes which are mapping this page(like using the try_to_umap()),
>> but something like try_to_umap() doesn't export for the modules.
>>
>> Without ummaping the kfree()ed pages' ptes mentioned above, then
>> the reduced 256M vma space couldn't be reused again for the runner
>> process, because the runner has already do the mapping for the reduced
>> vma space to some old physical pages(won't trigger new page fault
>> again). Then there will be a hole, and the hole will be bigger and bigger.
>>
>> Without ummaping the kfree()ed pages' ptes mentioned above, the
>> pages' reference count (page_ref_dec(), which _inc()ed in page fault)
>> couldn't be reduced back too.
> Let's ask people who will know...
>
> Hi linux-mm,
>
> TCM-User (drivers/target/target_core_user.c) currently uses vmalloc()ed
> memory to back a ring buffer that is mmaped by userspace.
>
> We want to move to dynamically mapping pages into this region, and also
> we'd like to unmap/free pages when idle. What's the right way to unmap?
> I see unmap_mapping_range() but that mentions an underlying file, which
> TCMU doesn't have. Or maybe zap_page_range()? But it's not exported.
Hi linux-mm

For the TCMU case, the vm is not anonymous mapping. And still has
device file desc:

mmap(NULL, len, PROT_READ|PROT_WRITE, MAP_SHARED, dev->fd, 0);

If using the unmap_mapping_range() to do the dynamically maping,
is it okay ? Any other potential risks ?

Or the mentioned 'underlying file' is must one desk file ?

Thanks very much,

BRs
Xiubo



> Any advice?
>
> Thanks in advance -- Regards -- Andy



--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-03-10  1:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1487323472-20481-1-git-send-email-lixiubo@cmss.chinamobile.com>
     [not found] ` <09891673-0d95-8b66-ddce-0ace7aea43d1@redhat.com>
     [not found]   ` <48b49493-4c82-3ed5-126f-2ea18c701242@cmss.chinamobile.com>
     [not found]     ` <21d93bec-a717-5157-8dcf-cc629611572f@redhat.com>
     [not found]       ` <85a41492-8aba-b752-c180-ec25f43d2a1a@cmss.chinamobile.com>
2017-02-27 19:32         ` how to unmap pages in an anonymous mmap? Andy Grover
2017-03-10  1:45           ` Xiubo Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox