add MAP_UNLOCKED mmap flag
Subsystems (10)
PATCH v5 1/1 add MAP_UNLOCKED mmap flag
If application does mlockall(MCL_FUTURE) it is no longer possible to mmap file bigger than main memory or allocate big area of anonymous memory in a thread safe manner. Sometimes it is desirable to lock everything related to program execution into memory, but still be able to mmap big file or allocate huge amount of memory and allow OS to swap them on demand. MAP_UNLOCKED allows to do that.
---
I get reports that people find this useful, so resending.
v1->v2
- adding new flag to all archs
- fixing typo
v2->v3
- one more typo fix
v3->v4
- return error if MAP_LOCKED | MAP_UNLOCKED is specified
v4->v5
- rebase to latest head
arch/alpha/include/asm/mman.h +1 -0
@@ -30,6 +30,7 @@#define MAP_NONBLOCK 0x40000/* do not block on IO */ #define MAP_STACK 0x80000/* give out an address that is best suited for process/thread stacks */ #define MAP_HUGETLB 0x100000/* create a huge page mapping */ +#define MAP_UNLOCKED 0x200000/* force page unlocking */ #define MS_ASYNC 1/* sync memory asynchronously */ #define MS_SYNC 2/* synchronous memory sync */
arch/mips/include/asm/mman.h +1 -0
@@ -48,6 +48,7 @@#define MAP_NONBLOCK 0x20000/* do not block on IO */ #define MAP_STACK 0x40000/* give out an address that is best suited for process/thread stacks */ #define MAP_HUGETLB 0x80000/* create a huge page mapping */ +#define MAP_UNLOCKED 0x100000/* force page unlocking */ /* * Flags for msync
arch/parisc/include/asm/mman.h +1 -0
@@ -24,6 +24,7 @@#define MAP_NONBLOCK 0x20000/* do not block on IO */ #define MAP_STACK 0x40000/* give out an address that is best suited for process/thread stacks */ #define MAP_HUGETLB 0x80000/* create a huge page mapping */ +#define MAP_UNLOCKED 0x100000/* force page unlocking */ #define MS_SYNC 1/* synchronous memory sync */ #define MS_ASYNC 2/* sync memory asynchronously */
arch/powerpc/include/asm/mman.h +1 -0
@@ -27,6 +27,7 @@#define MAP_NONBLOCK 0x10000/* do not block on IO */ #define MAP_STACK 0x20000/* give out an address that is best suited for process/thread stacks */ #define MAP_HUGETLB 0x40000/* create a huge page mapping */ +#define MAP_UNLOCKED 0x80000/* force page unlocking */ #ifdef __KERNEL__#ifdef CONFIG_PPC64
arch/sparc/include/asm/mman.h +1 -0
@@ -22,6 +22,7 @@#define MAP_NONBLOCK 0x10000/* do not block on IO */ #define MAP_STACK 0x20000/* give out an address that is best suited for process/thread stacks */ #define MAP_HUGETLB 0x40000/* create a huge page mapping */ +#define MAP_UNLOCKED 0x80000/* force page unlocking */ #ifdef __KERNEL__#ifndef __ASSEMBLY__
arch/xtensa/include/asm/mman.h +1 -0
@@ -55,6 +55,7 @@#define MAP_NONBLOCK 0x20000/* do not block on IO */ #define MAP_STACK 0x40000/* give out an address that is best suited for process/thread stacks */ #define MAP_HUGETLB 0x80000/* create a huge page mapping */ +#define MAP_UNLOCKED 0x100000/* force page unlocking */ /* * Flags for msync
include/asm-generic/mman.h +1 -0
@@ -12,6 +12,7 @@#define MAP_NONBLOCK 0x10000/* do not block on IO */ #define MAP_STACK 0x20000/* give out an address that is best suited for process/thread stacks */ #define MAP_HUGETLB 0x40000/* create a huge page mapping */ +#define MAP_UNLOCKED 0x80000/* force page unlocking */ #define MCL_CURRENT 1/* lock all current mappings */ #define MCL_FUTURE 2/* lock all future mappings */
mm/mmap.c +7 -1
@@ -962,6 +962,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,if (!can_do_mlock ())return -EPERM ; +if (flags &MAP_UNLOCKED ) + vm_flags &= ~VM_LOCKED ; +/* mlock MCL_FUTURE? */ if (vm_flags &VM_LOCKED ) {unsigned long locked, lock_limit;
@@ -1050,7 +1053,10 @@ SYSCALL_DEFINE6(mmap_pgoff, unsigned long, addr, unsigned long, len,struct file *file =NULL ;unsigned long retval = -EBADF ; -if (!(flags &MAP_ANONYMOUS )) { +if (unlikely ((flags & (MAP_LOCKED |MAP_UNLOCKED )) == + (MAP_LOCKED |MAP_UNLOCKED ))) { +return -EINVAL ; + }else if (!(flags &MAP_ANONYMOUS )) {if (unlikely (flags &MAP_HUGETLB ))return -EINVAL ; file =fget (fd);
--
Gleb.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 8 lines · Gleb Natapov
If application does
mlockall(MCL_FUTURE)it is no longer possible to mmap file bigger than main memory or allocate big area of anonymous memory in a thread safe manner. Sometimes it is desirable to lock everything related to program execution into memory, but still be able to mmap big file or allocate huge amount of memory and allow OS to swap them on demand.MAP_UNLOCKEDallows to do that.Signed-off-by Gleb Natapov <[email protected]>
Thanks for keeping working on it.
This version looks fine for me.
Quoted 131 lines
---
I get reports that people find this useful, so resending.
v1->v2
- adding new flag to all archs
- fixing typov2->v3
- one more typo fixv3->v4
- return error ifMAP_LOCKED|MAP_UNLOCKEDis specifiedv4->v5
- rebase to latest headarch/alpha/include/asm/mman.h +1
-0@@ -30,6 +30,7 @@#define MAP_NONBLOCK 0x40000/* do not block on IO */ #define MAP_STACK 0x80000/* give out an address that is best suited for process/thread stacks */ #define MAP_HUGETLB 0x100000/* create a huge page mapping */ +#define MAP_UNLOCKED 0x200000/* force page unlocking */ #define MS_ASYNC 1/* sync memory asynchronously */ #define MS_SYNC 2/* synchronous memory sync */ arch/mips/include/asm/mman.h +1
-0@@ -48,6 +48,7 @@#define MAP_NONBLOCK 0x20000/* do not block on IO */ #define MAP_STACK 0x40000/* give out an address that is best suited for process/thread stacks */ #define MAP_HUGETLB 0x80000/* create a huge page mapping */ +#define MAP_UNLOCKED 0x100000/* force page unlocking */ /* * Flags for msync arch/parisc/include/asm/mman.h +1
-0@@ -24,6 +24,7 @@#define MAP_NONBLOCK 0x20000/* do not block on IO */ #define MAP_STACK 0x40000/* give out an address that is best suited for process/thread stacks */ #define MAP_HUGETLB 0x80000/* create a huge page mapping */ +#define MAP_UNLOCKED 0x100000/* force page unlocking */ #define MS_SYNC 1/* synchronous memory sync */ #define MS_ASYNC 2/* sync memory asynchronously */ arch/powerpc/include/asm/mman.h +1
-0@@ -27,6 +27,7 @@#define MAP_NONBLOCK 0x10000/* do not block on IO */ #define MAP_STACK 0x20000/* give out an address that is best suited for process/thread stacks */ #define MAP_HUGETLB 0x40000/* create a huge page mapping */ +#define MAP_UNLOCKED 0x80000/* force page unlocking */ #ifdef __KERNEL__#ifdef CONFIG_PPC64 arch/sparc/include/asm/mman.h +1
-0@@ -22,6 +22,7 @@#define MAP_NONBLOCK 0x10000/* do not block on IO */ #define MAP_STACK 0x20000/* give out an address that is best suited for process/thread stacks */ #define MAP_HUGETLB 0x40000/* create a huge page mapping */ +#define MAP_UNLOCKED 0x80000/* force page unlocking */ #ifdef __KERNEL__#ifndef __ASSEMBLY__arch/xtensa/include/asm/mman.h +1
-0@@ -55,6 +55,7 @@#define MAP_NONBLOCK 0x20000/* do not block on IO */ #define MAP_STACK 0x40000/* give out an address that is best suited for process/thread stacks */ #define MAP_HUGETLB 0x80000/* create a huge page mapping */ +#define MAP_UNLOCKED 0x100000/* force page unlocking */ /* * Flags for msync include/asm-generic/mman.h +1
-0@@ -12,6 +12,7 @@#define MAP_NONBLOCK 0x10000/* do not block on IO */ #define MAP_STACK 0x20000/* give out an address that is best suited for process/thread stacks */ #define MAP_HUGETLB 0x40000/* create a huge page mapping */ +#define MAP_UNLOCKED 0x80000/* force page unlocking */ #define MCL_CURRENT 1/* lock all current mappings */ #define MCL_FUTURE 2/* lock all future mappings */ mm/mmap.c +7
-2@@ -962,6 +962,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,if (!can_do_mlock ())return -EPERM ; +if (flags &MAP_UNLOCKED ) + vm_flags &= ~VM_LOCKED ; +/* mlock MCL_FUTURE? */ if (vm_flags &VM_LOCKED ) {unsigned long locked, lock_limit;@@ -1050,7 +1053,10 @@ SYSCALL_DEFINE6(mmap_pgoff, unsigned long, addr, unsigned long, len,struct file *file =NULL ;unsigned long retval = -EBADF ; -if (!(flags &MAP_ANONYMOUS )) { +if (unlikely ((flags & (MAP_LOCKED |MAP_UNLOCKED )) == + (MAP_LOCKED |MAP_UNLOCKED ))) { +return -EINVAL ; + }else if (!(flags &MAP_ANONYMOUS )) {if (unlikely (flags &MAP_HUGETLB ))return -EINVAL ; file =fget (fd); --Gleb.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Signature · 8 lines
Live like a child, think like the god. -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 8 lines · * Gleb Natapov ([email protected]) wrote:
If application does
mlockall(MCL_FUTURE)it is no longer possible to mmap file bigger than main memory or allocate big area of anonymous memory in a thread safe manner. Sometimes it is desirable to lock everything related to program execution into memory, but still be able to mmap big file or allocate huge amount of memory and allow OS to swap them on demand.MAP_UNLOCKEDallows to do that.Signed-off-by Gleb Natapov <[email protected]>
Looks good to me.
thanks,
-chris
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 11 lines
If application does
mlockall(MCL_FUTURE)it is no longer possible to mmap file bigger than main memory or allocate big area of anonymous memory in a thread safe manner. Sometimes it is desirable to lock everything related to program execution into memory, but still be able to mmap big file or allocate huge amount of memory and allow OS to swap them on demand.MAP_UNLOCKEDallows to do that.Signed-off-by Gleb Natapov <[email protected]>---
I get reports that people find this useful, so resending.
This description is still wrong. It doesn't describe why this patch is useful.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 7 lines · KOSAKI Motohiro
Quoted 7 lines
If application does
mlockall(MCL_FUTURE)it is no longer possible to mmap file bigger than main memory or allocate big area of anonymous memory in a thread safe manner. Sometimes it is desirable to lock everything related to program execution into memory, but still be able to mmap big file or allocate huge amount of memory and allow OS to swap them on demand.MAP_UNLOCKEDallows to do that.
Quoted 7 lines
Quoted 4 lines
Signed-off-by Gleb Natapov <[email protected]>---
I get reports that people find this useful, so resending.
This description is still wrong. It doesn't describe why this patch is useful.
I think the text above describes the feature it adds and its use case quite well. Can you elaborate what is missing in your opinion, or suggest alternative text please?
--
Gleb.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 11 lines · KOSAKI Motohiro
Quoted 10 lines
Quoted 10 lines
If application does
mlockall(MCL_FUTURE)it is no longer possible to mmap file bigger than main memory or allocate big area of anonymous memory in a thread safe manner. Sometimes it is desirable to lock everything related to program execution into memory, but still be able to mmap big file or allocate huge amount of memory and allow OS to swap them on demand.MAP_UNLOCKEDallows to do that.Signed-off-by Gleb Natapov <[email protected]>---
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
I get reports that people find this useful, so resending.
This description is still wrong. It doesn't describe why this patch is useful.
I think the text above describes the feature it adds and its use case quite well. Can you elaborate what is missing in your opinion, or suggest alternative text please?
My point is, introducing mmap new flags need strong and clearly use-case. All patch should have good benefit/cost balance. the code can describe the cost, but the benefit can be only explained by the patch description.
I don't think this poor description explained bit benefit rather than cost. you should explain why this patch is useful and not just pretty toy.
Quoted 19 lines · KOSAKI Motohiro
Quoted 11 lines · KOSAKI Motohiro
Quoted 10 lines
Quoted 10 lines
If application does
mlockall(MCL_FUTURE)it is no longer possible to mmap file bigger than main memory or allocate big area of anonymous memory in a thread safe manner. Sometimes it is desirable to lock everything related to program execution into memory, but still be able to mmap big file or allocate huge amount of memory and allow OS to swap them on demand.MAP_UNLOCKEDallows to do that.Signed-off-by Gleb Natapov <[email protected]>---
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
I get reports that people find this useful, so resending.
This description is still wrong. It doesn't describe why this patch is useful.
I think the text above describes the feature it adds and its use case quite well. Can you elaborate what is missing in your opinion, or suggest alternative text please?
Quoted 7 lines
My point is, introducing mmap new flags need strong and clearly use-case. All patch should have good benefit/cost balance. the code can describe the cost, but the benefit can be only explained by the patch description.
I don't think this poor description explained bit benefit rather than cost. you should explain why this patch is useful and not just pretty toy.
The benefit is that with this patch I can lock all of my application in memory except some very big memory areas. My use case is that I want to run virtual machine in such a way that everything related to machine emulator is locked into the memory, but guest address space can be swapped out at will. Guest address space is so huge that it is not possible to allocated it locked and then unlock. I was very surprised that current Linux API has no way to do it hence this patch. It may look like a pretty toy to you until some day you need this and has no way to do it.
--
Gleb.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 27 lines · KOSAKI Motohiro
Quoted 19 lines
Quoted 11 lines · KOSAKI Motohiro
Quoted 10 lines
Quoted 10 lines
If application does
mlockall(MCL_FUTURE)it is no longer possible to mmap file bigger than main memory or allocate big area of anonymous memory in a thread safe manner. Sometimes it is desirable to lock everything related to program execution into memory, but still be able to mmap big file or allocate huge amount of memory and allow OS to swap them on demand.MAP_UNLOCKEDallows to do that.Signed-off-by Gleb Natapov <[email protected]>---
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
I get reports that people find this useful, so resending.
This description is still wrong. It doesn't describe why this patch is useful.
I think the text above describes the feature it adds and its use case quite well. Can you elaborate what is missing in your opinion, or suggest alternative text please?
Quoted 7 lines
My point is, introducing mmap new flags need strong and clearly use-case. All patch should have good benefit/cost balance. the code can describe the cost, but the benefit can be only explained by the patch description.
I don't think this poor description explained bit benefit rather than cost. you should explain why this patch is useful and not just pretty toy.
Quoted 9 lines
The benefit is that with this patch I can lock all of my application in memory except some very big memory areas. My use case is that I want to run virtual machine in such a way that everything related to machine emulator is locked into the memory, but guest address space can be swapped out at will. Guest address space is so huge that it is not possible to allocated it locked and then unlock. I was very surprised that current Linux API has no way to do it hence this patch. It may look like a pretty toy to you until some day you need this and has no way to do it.
Hmm..
Your answer didn't match I wanted.
few additional questions.
- Why don't you change your application? It seems natural way than kernel change.
- Why do you want your virtual machine have mlockall? AFAIK, current majority virtual machine doesn't.
- If this feature added, average distro user can get any benefit?
I mean, many application developrs want to add their specific feature into kernel. but if we allow it unlimitedly, major syscall become the trushbox of pretty toy feature soon.
Quoted 37 lines · KOSAKI Motohiro
Quoted 27 lines · KOSAKI Motohiro
Quoted 19 lines
Quoted 11 lines · KOSAKI Motohiro
Quoted 10 lines
Quoted 10 lines
If application does
mlockall(MCL_FUTURE)it is no longer possible to mmap file bigger than main memory or allocate big area of anonymous memory in a thread safe manner. Sometimes it is desirable to lock everything related to program execution into memory, but still be able to mmap big file or allocate huge amount of memory and allow OS to swap them on demand.MAP_UNLOCKEDallows to do that.Signed-off-by Gleb Natapov <[email protected]>---
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
I get reports that people find this useful, so resending.
This description is still wrong. It doesn't describe why this patch is useful.
I think the text above describes the feature it adds and its use case quite well. Can you elaborate what is missing in your opinion, or suggest alternative text please?
Quoted 7 lines
My point is, introducing mmap new flags need strong and clearly use-case. All patch should have good benefit/cost balance. the code can describe the cost, but the benefit can be only explained by the patch description.
I don't think this poor description explained bit benefit rather than cost. you should explain why this patch is useful and not just pretty toy.
Quoted 9 lines
The benefit is that with this patch I can lock all of my application in memory except some very big memory areas. My use case is that I want to run virtual machine in such a way that everything related to machine emulator is locked into the memory, but guest address space can be swapped out at will. Guest address space is so huge that it is not possible to allocated it locked and then unlock. I was very surprised that current Linux API has no way to do it hence this patch. It may look like a pretty toy to you until some day you need this and has no way to do it.
Quoted 2 lines
Hmm..
Your answer didn't match I wanted.
Then I don't get what you want.
Quoted 3 lines
few additional questions.
- Why don't you change your application? It seems natural way than kernel change.
There is no way to change my application and achieve what I've described in a multithreaded app.
Quoted 2 lines
- Why do you want your virtual machine have mlockall? AFAIK, current majority virtual machine doesn't.
It is absolutely irrelevant for that patch, but just because you ask I want to measure the cost of swapping out of a guest memory.
Quoted 2 lines
- If this feature added, average distro user can get any benefit?
?! Is this some kind of new measure? There are plenty of much more invasive features that don't bring benefits to an average distro user. This feature can bring benefit to embedded/RT developers.
Quoted 4 lines
I mean, many application developrs want to add their specific feature into kernel. but if we allow it unlimitedly, major syscall become the trushbox of pretty toy feature soon.
And if application developer wants to extend kernel in a way that it will be possible to do something that was not possible before why is this a bad thing? I would agree with you if for my problem was userspace solution, but there is none. The mmap interface is asymmetric in regards to mlock currently. There is MAP_LOCKED, but no MAP_UNLOCKED. Why MAP_LOCKED is useful then?
--
Gleb.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 3 lines
Quoted 2 lines
Hmm..
Your answer didn't match I wanted.Then I don't get what you want.
I want to know the benefit of the patch for patch reviewing.
Quoted 5 lines
Quoted 3 lines
few additional questions.
- Why don't you change your application? It seems natural way than kernel change.
There is no way to change my application and achieve what I've described in a multithreaded app.
Then, we don't recommend to use mlockall(). I don't hope to hear your conclusion, it is not objectivization. I hope to hear why you reached such conclusion.
Quoted 4 lines
Quoted 2 lines
- Why do you want your virtual machine have mlockall? AFAIK, current majority virtual machine doesn't.
It is absolutely irrelevant for that patch, but just because you ask I want to measure the cost of swapping out of a guest memory.
No. if you stop to use mlockall, the issue is vanished.
Quoted 5 lines
Quoted 2 lines
- If this feature added, average distro user can get any benefit?
?! Is this some kind of new measure? There are plenty of much more invasive features that don't bring benefits to an average distro user. This feature can bring benefit to embedded/RT developers.
I mean who get benifit?
Quoted 10 lines
Quoted 4 lines
I mean, many application developrs want to add their specific feature into kernel. but if we allow it unlimitedly, major syscall become the trushbox of pretty toy feature soon.
And if application developer wants to extend kernel in a way that it will be possible to do something that was not possible before why is this a bad thing? I would agree with you if for my problem was userspace solution, but there is none. The mmap interface is asymmetric in regards to mlock currently. There is
MAP_LOCKED, but noMAP_UNLOCKED. WhyMAP_LOCKEDis useful then?
Why? Because this is formal LKML reviewing process. I'm reviewing your patch for YOU.
If there is no objective reason, I don't want to continue reviewing.
Quoted 7 lines · KOSAKI Motohiro
Quoted 3 lines
Quoted 2 lines
Hmm..
Your answer didn't match I wanted.Then I don't get what you want.
I want to know the benefit of the patch for patch reviewing.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
few additional questions.
- Why don't you change your application? It seems natural way than kernel change.
There is no way to change my application and achieve what I've described in a multithreaded app.
Then, we don't recommend to use
mlockall(). I don't hope to hear your conclusion, it is not objectivization. I hope to hear why you reached such conclusion.
So what do you recommend? Don't just wave hand on me saying "These aren't the droids you're looking for". I explained you what I need to achieve you seems to be trying to convince me I don't really need it without proposing any alternatives. This is not constructive discussion.
Quoted 9 lines
Quoted 6 lines
Quoted 4 lines
- Why do you want your virtual machine have mlockall? AFAIK, current majority virtual machine doesn't.
It is absolutely irrelevant for that patch, but just because you ask I want to measure the cost of swapping out of a guest memory.
No. if you stop to use mlockall, the issue is vanished.
And emulator parts will be swapped out too which is not what I want.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
- If this feature added, average distro user can get any benefit?
?! Is this some kind of new measure? There are plenty of much more invasive features that don't bring benefits to an average distro user. This feature can bring benefit to embedded/RT developers.
I mean who get benifit?
Someone who wants to mlock all application memory, but wants to be able to mmap big file for reading and understand that access to that file can cause major fault.
Quoted 13 lines
Quoted 6 lines
Quoted 6 lines
I mean, many application developrs want to add their specific feature into kernel. but if we allow it unlimitedly, major syscall become the trushbox of pretty toy feature soon.
Quoted 6 lines
And if application developer wants to extend kernel in a way that it will be possible to do something that was not possible before why is this a bad thing? I would agree with you if for my problem was userspace solution, but there is none. The mmap interface is asymmetric in regards to mlock currently. There is
MAP_LOCKED, but noMAP_UNLOCKED. WhyMAP_LOCKEDis useful then?
Quoted 3 lines
Why? Because this is formal LKML reviewing process. I'm reviewing your patch for YOU.
I appreciate that, but unfortunately it seems that you are trying to dismiss my arguments on the basis that _you_ don't find that useful.
Quoted 2 lines
If there is no objective reason, I don't want to continue reviewing.
--
Gleb.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 6 lines · KOSAKI Motohiro
Quoted 3 lines
Quoted 2 lines
Hmm..
Your answer didn't match I wanted.Then I don't get what you want.
I want to know the benefit of the patch for patch reviewing.
The benefit of the patch is that it makes it possible for an application which has previously called mlockall(MCL_FUTURE) to selectively exempt new memory mappings from memory locking, on a per-mmap-call basis. As was pointed out earlier, there is currently no thread-safe way for an application to do this. The earlier proposed workaround of toggling MCL_FUTURE around calls to mmap is racy in a multi-threaded context. Other threads may manipulate the address space during the window where MCL_FUTURE is off, subverting the programmers intended memory locking semantics.
The ability to exempt specific memory mappings from memory locking is necessary when the region to be mapped is larger than physical memory. In such cases a call to mmap the region cannot succeed, unless MAP_UNLOCKED is available.
Quoted 10 lines
Quoted 6 lines
Quoted 4 lines
few additional questions.
- Why don't you change your application? It seems natural way than kernel change.
There is no way to change my application and achieve what I've described in a multithreaded app.
Then, we don't recommend to use
mlockall(). I don't hope to hear your conclusion, it is not objectivization. I hope to hear why you reached such conclusion.
I agree that mlockall is a big hammer and should be avoided in most cases, but there are situations where it is exactly what is needed. In Gleb's instance, it sounds like he is doing some finicky performance measurement and major page faults skew his results. In my case, I have a realtime process where the measured latency impact of major page faults is unacceptable. In both of these cases, mlockall is a reasonable approach to eliminating major faults.
However, Gleb and I have independently found ourselves unable to use mlockall because we also need to create a very large memory mapping (for which we don't care about major faults). The proposed MAP_UNLOCKED flag would allow us to override MCL_FUTURE for that one mapping.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
- Why do you want your virtual machine have mlockall? AFAIK, current majority virtual machine doesn't.
It is absolutely irrelevant for that patch, but just because you ask I want to measure the cost of swapping out of a guest memory.
No. if you stop to use mlockall, the issue is vanished.
And other issues arise. Gleb described a situation where the use of mlockall is justified, identified an issue which prevents its use, and provided a patch which resolves that issue. Why are you focusing on the validity of using mlockall?
Quoted 21 lines
Quoted 6 lines
Quoted 3 lines
- If this feature added, average distro user can get any benefit?
?! Is this some kind of new measure? There are plenty of much more invasive features that don't bring benefits to an average distro user. This feature can bring benefit to embedded/RT developers.
I mean who get benifit?
Quoted 10 lines
Quoted 4 lines
I mean, many application developrs want to add their specific feature into kernel. but if we allow it unlimitedly, major syscall become the trushbox of pretty toy feature soon.
And if application developer wants to extend kernel in a way that it will be possible to do something that was not possible before why is this a bad thing? I would agree with you if for my problem was userspace solution, but there is none. The mmap interface is asymmetric in regards to mlock currently. There is
MAP_LOCKED, but noMAP_UNLOCKED. WhyMAP_LOCKEDis useful then?
Quoted 5 lines
Why? Because this is formal LKML reviewing process. I'm reviewing your patch for YOU.
If there is no objective reason, I don't want to continue reviewing.
There is an objective reason: the current interaction between mlockall(MCL_FUTURE) and mmap has a deficiency. In 'normal' mode, without MCL_FUTURE in force, the default is that new memory mappings are not locked, but mmap provides MAP_LOCKED specifically to override that default. However, with MCL_FUTURE toggled to on, there is no analogous way to tell mmap to override the default. The proposed MAP_UNLOCKED flag would resolve this deficiency.
Andrew
Quoted 91 lines
Quoted 6 lines · KOSAKI Motohiro
Quoted 3 lines
Quoted 2 lines
Hmm..
Your answer didn't match I wanted.Then I don't get what you want.
I want to know the benefit of the patch for patch reviewing.
The benefit of the patch is that it makes it possible for an application which has previously called
mlockall(MCL_FUTURE)to selectively exempt new memory mappings from memory locking, on a per-mmap-call basis. As was pointed out earlier, there is currently no thread-safe way for an application to do this. The earlier proposed workaround of togglingMCL_FUTUREaround calls to mmap is racy in a multi-threaded context. Other threads may manipulate the address space during the window whereMCL_FUTUREis off, subverting the programmers intended memory locking semantics.The ability to exempt specific memory mappings from memory locking is necessary when the region to be mapped is larger than physical memory. In such cases a call to mmap the region cannot succeed, unless
MAP_UNLOCKEDis available.Quoted 10 lines
Quoted 6 lines
Quoted 4 lines
few additional questions.
- Why don't you change your application? It seems natural way than kernel change.
There is no way to change my application and achieve what I've described in a multithreaded app.
Then, we don't recommend to use
mlockall(). I don't hope to hear your conclusion, it is not objectivization. I hope to hear why you reached such conclusion.I agree that mlockall is a big hammer and should be avoided in most cases, but there are situations where it is exactly what is needed. In Gleb's instance, it sounds like he is doing some finicky performance measurement and major page faults skew his results. In my case, I have a realtime process where the measured latency impact of major page faults is unacceptable. In both of these cases, mlockall is a reasonable approach to eliminating major faults.
However, Gleb and I have independently found ourselves unable to use mlockall because we also need to create a very large memory mapping (for which we don't care about major faults). The proposed
MAP_UNLOCKEDflag would allow us to overrideMCL_FUTUREfor that one mapping.Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
- Why do you want your virtual machine have mlockall? AFAIK, current majority virtual machine doesn't.
It is absolutely irrelevant for that patch, but just because you ask I want to measure the cost of swapping out of a guest memory.
No. if you stop to use mlockall, the issue is vanished.
And other issues arise. Gleb described a situation where the use of mlockall is justified, identified an issue which prevents its use, and provided a patch which resolves that issue. Why are you focusing on the validity of using mlockall?
Quoted 21 lines
Quoted 6 lines
Quoted 3 lines
- If this feature added, average distro user can get any benefit?
?! Is this some kind of new measure? There are plenty of much more invasive features that don't bring benefits to an average distro user. This feature can bring benefit to embedded/RT developers.
I mean who get benifit?
Quoted 10 lines
Quoted 4 lines
I mean, many application developrs want to add their specific feature into kernel. but if we allow it unlimitedly, major syscall become the trushbox of pretty toy feature soon.
And if application developer wants to extend kernel in a way that it will be possible to do something that was not possible before why is this a bad thing? I would agree with you if for my problem was userspace solution, but there is none. The mmap interface is asymmetric in regards to mlock currently. There is
MAP_LOCKED, but noMAP_UNLOCKED. WhyMAP_LOCKEDis useful then?Quoted 5 lines
Why? Because this is formal LKML reviewing process. I'm reviewing your patch for YOU.
If there is no objective reason, I don't want to continue reviewing.
Quoted 7 lines
There is an objective reason: the current interaction between
mlockall(MCL_FUTURE)and mmap has a deficiency. In 'normal' mode, withoutMCL_FUTUREin force, the default is that new memory mappings are not locked, but mmap providesMAP_LOCKEDspecifically to override that default. However, withMCL_FUTUREtoggled to on, there is no analogous way to tell mmap to override the default. The proposedMAP_UNLOCKEDflag would resolve this deficiency.
Very thank you, Andrew!
Your explanation help me lots rather than original patch description. OK, At least MAP_UNLOCED have two users (you and gleb) and your explanation seems makes sense.
So, if gleb resend this patch with rewrited description, I might take my reviewed-by tag to it, probagly.
Thanks.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 99 lines · KOSAKI Motohiro
Quoted 91 lines
Quoted 6 lines · KOSAKI Motohiro
Quoted 3 lines
Quoted 2 lines
Hmm..
Your answer didn't match I wanted.Then I don't get what you want.
I want to know the benefit of the patch for patch reviewing.
The benefit of the patch is that it makes it possible for an application which has previously called
mlockall(MCL_FUTURE)to selectively exempt new memory mappings from memory locking, on a per-mmap-call basis. As was pointed out earlier, there is currently no thread-safe way for an application to do this. The earlier proposed workaround of togglingMCL_FUTUREaround calls to mmap is racy in a multi-threaded context. Other threads may manipulate the address space during the window whereMCL_FUTUREis off, subverting the programmers intended memory locking semantics.The ability to exempt specific memory mappings from memory locking is necessary when the region to be mapped is larger than physical memory. In such cases a call to mmap the region cannot succeed, unless
MAP_UNLOCKEDis available.Quoted 10 lines
Quoted 6 lines
Quoted 4 lines
few additional questions.
- Why don't you change your application? It seems natural way than kernel change.
There is no way to change my application and achieve what I've described in a multithreaded app.
Then, we don't recommend to use
mlockall(). I don't hope to hear your conclusion, it is not objectivization. I hope to hear why you reached such conclusion.I agree that mlockall is a big hammer and should be avoided in most cases, but there are situations where it is exactly what is needed. In Gleb's instance, it sounds like he is doing some finicky performance measurement and major page faults skew his results. In my case, I have a realtime process where the measured latency impact of major page faults is unacceptable. In both of these cases, mlockall is a reasonable approach to eliminating major faults.
However, Gleb and I have independently found ourselves unable to use mlockall because we also need to create a very large memory mapping (for which we don't care about major faults). The proposed
MAP_UNLOCKEDflag would allow us to overrideMCL_FUTUREfor that one mapping.Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
- Why do you want your virtual machine have mlockall? AFAIK, current majority virtual machine doesn't.
It is absolutely irrelevant for that patch, but just because you ask I want to measure the cost of swapping out of a guest memory.
No. if you stop to use mlockall, the issue is vanished.
And other issues arise. Gleb described a situation where the use of mlockall is justified, identified an issue which prevents its use, and provided a patch which resolves that issue. Why are you focusing on the validity of using mlockall?
Quoted 21 lines
Quoted 6 lines
Quoted 3 lines
- If this feature added, average distro user can get any benefit?
?! Is this some kind of new measure? There are plenty of much more invasive features that don't bring benefits to an average distro user. This feature can bring benefit to embedded/RT developers.
I mean who get benifit?
Quoted 10 lines
Quoted 4 lines
I mean, many application developrs want to add their specific feature into kernel. but if we allow it unlimitedly, major syscall become the trushbox of pretty toy feature soon.
And if application developer wants to extend kernel in a way that it will be possible to do something that was not possible before why is this a bad thing? I would agree with you if for my problem was userspace solution, but there is none. The mmap interface is asymmetric in regards to mlock currently. There is
MAP_LOCKED, but noMAP_UNLOCKED. WhyMAP_LOCKEDis useful then?Quoted 5 lines
Why? Because this is formal LKML reviewing process. I'm reviewing your patch for YOU.
If there is no objective reason, I don't want to continue reviewing.
Quoted 7 lines
There is an objective reason: the current interaction between
mlockall(MCL_FUTURE)and mmap has a deficiency. In 'normal' mode, withoutMCL_FUTUREin force, the default is that new memory mappings are not locked, but mmap providesMAP_LOCKEDspecifically to override that default. However, withMCL_FUTUREtoggled to on, there is no analogous way to tell mmap to override the default. The proposedMAP_UNLOCKEDflag would resolve this deficiency.
Quoted 8 lines
Very thank you, Andrew!
Your explanation help me lots rather than original patch description. OK, At least
MAP_UNLOCEDhave two users (you and gleb) and your explanation seems makes sense.So, if gleb resend this patch with rewrited description, I might take my reviewed-by tag to it, probagly.
Just did it. I hope the commit message is OK with you now. Its text is taken from this Andrew's mail. Thanks.
--
Gleb.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>