Re: process creation time increases linearly with shmem

2005-08-29 Thread Linus Torvalds
On Tue, 30 Aug 2005, Nick Piggin wrote: > > Andrew, did you pick up the patch or should I resend to someone? I picked it up. If it causes performance regressions, we can fix them, and if it causes other problems then that will be interesting in itself. Linus - To unsubscribe

Re: process creation time increases linearly with shmem

2005-08-29 Thread Nick Piggin
Ray Fucillo wrote: Nick Piggin wrote: How does the following look? (I changed the comment a bit). Andrew, please apply if nobody objects. Nick, I applied this latest patch to a 2.6.12 kernel and found that it does resolve the problem. Prior to the patch on this machine, I was seeing

Re: process creation time increases linearly with shmem

2005-08-29 Thread Linus Torvalds
On Mon, 29 Aug 2005, Ray Fucillo wrote: > > FWIW, an interesting side effect of this occurs when I run the database > with this patch internally on a Linux server that uses NIS. Its an > unrelated problem and not a kernel problem. Its due to the children > calling initgroups()...

Re: process creation time increases linearly with shmem

2005-08-29 Thread Ray Fucillo
Nick Piggin wrote: How does the following look? (I changed the comment a bit). Andrew, please apply if nobody objects. Nick, I applied this latest patch to a 2.6.12 kernel and found that it does resolve the problem. Prior to the patch on this machine, I was seeing about 23ms spent in fork

Re: process creation time increases linearly with shmem

2005-08-29 Thread Ray Fucillo
Nick Piggin wrote: How does the following look? (I changed the comment a bit). Andrew, please apply if nobody objects. Nick, I applied this latest patch to a 2.6.12 kernel and found that it does resolve the problem. Prior to the patch on this machine, I was seeing about 23ms spent in fork

Re: process creation time increases linearly with shmem

2005-08-29 Thread Linus Torvalds
On Mon, 29 Aug 2005, Ray Fucillo wrote: FWIW, an interesting side effect of this occurs when I run the database with this patch internally on a Linux server that uses NIS. Its an unrelated problem and not a kernel problem. Its due to the children calling initgroups()... apparently

Re: process creation time increases linearly with shmem

2005-08-29 Thread Nick Piggin
Ray Fucillo wrote: Nick Piggin wrote: How does the following look? (I changed the comment a bit). Andrew, please apply if nobody objects. Nick, I applied this latest patch to a 2.6.12 kernel and found that it does resolve the problem. Prior to the patch on this machine, I was seeing

Re: process creation time increases linearly with shmem

2005-08-29 Thread Linus Torvalds
On Tue, 30 Aug 2005, Nick Piggin wrote: Andrew, did you pick up the patch or should I resend to someone? I picked it up. If it causes performance regressions, we can fix them, and if it causes other problems then that will be interesting in itself. Linus - To unsubscribe

Re: process creation time increases linearly with shmem

2005-08-28 Thread Nick Piggin
Hugh Dickins wrote: On Sun, 28 Aug 2005, Nick Piggin wrote: This is the condition I ended up with. Any good? if (!(vma->vm_flags & (VM_HUGETLB|VM_NONLINEAR|VM_RESERVED))) { if (vma->vm_flags & VM_MAYSHARE) return 0; if (vma->vm_file && !vma->anon_vma) return 0; } It's not bad, and

Re: process creation time increases linearly with shmem

2005-08-28 Thread Nick Piggin
Hugh Dickins wrote: On Sun, 28 Aug 2005, Nick Piggin wrote: This is the condition I ended up with. Any good? if (!(vma-vm_flags (VM_HUGETLB|VM_NONLINEAR|VM_RESERVED))) { if (vma-vm_flags VM_MAYSHARE) return 0; if (vma-vm_file !vma-anon_vma) return 0; } It's not bad, and practical

Re: process creation time increases linearly with shmem

2005-08-27 Thread Hugh Dickins
On Sun, 28 Aug 2005, Nick Piggin wrote: > > This is the condition I ended up with. Any good? > > if (!(vma->vm_flags & (VM_HUGETLB|VM_NONLINEAR|VM_RESERVED))) { > if (vma->vm_flags & VM_MAYSHARE) > return 0; > if (vma->vm_file && !vma->anon_vma) >return 0; > } It's not bad, and practical

Re: process creation time increases linearly with shmem

2005-08-27 Thread Nick Piggin
Linus Torvalds wrote: On Fri, 26 Aug 2005, Rik van Riel wrote: On Fri, 26 Aug 2005, Hugh Dickins wrote: Well, I still don't think we need to test vm_file. We can add an anon_vma test if you like, if we really want to minimize the fork overhead, in favour of later faults. Do we? When

Re: process creation time increases linearly with shmem

2005-08-27 Thread Nick Piggin
Linus Torvalds wrote: On Fri, 26 Aug 2005, Rik van Riel wrote: On Fri, 26 Aug 2005, Hugh Dickins wrote: Well, I still don't think we need to test vm_file. We can add an anon_vma test if you like, if we really want to minimize the fork overhead, in favour of later faults. Do we? When

Re: process creation time increases linearly with shmem

2005-08-27 Thread Hugh Dickins
On Sun, 28 Aug 2005, Nick Piggin wrote: This is the condition I ended up with. Any good? if (!(vma-vm_flags (VM_HUGETLB|VM_NONLINEAR|VM_RESERVED))) { if (vma-vm_flags VM_MAYSHARE) return 0; if (vma-vm_file !vma-anon_vma) return 0; } It's not bad, and practical timings are

Re: process creation time increases linearly with shmem

2005-08-26 Thread Linus Torvalds
On Fri, 26 Aug 2005, Rik van Riel wrote: > On Fri, 26 Aug 2005, Hugh Dickins wrote: > > > Well, I still don't think we need to test vm_file. We can add an > > anon_vma test if you like, if we really want to minimize the fork > > overhead, in favour of later faults. Do we? > > When you

Re: process creation time increases linearly with shmem

2005-08-26 Thread Rik van Riel
On Fri, 26 Aug 2005, Hugh Dickins wrote: > Well, I still don't think we need to test vm_file. We can add an > anon_vma test if you like, if we really want to minimize the fork > overhead, in favour of later faults. Do we? When you consider NUMA placement (the child process may end up running

Re: process creation time increases linearly with shmem

2005-08-26 Thread Linus Torvalds
On Fri, 26 Aug 2005, Hugh Dickins wrote: > > Well, I still don't think we need to test vm_file. We can add an > anon_vma test if you like, if we really want to minimize the fork > overhead, in favour of later faults. Do we? I think we might want to do it in -mm for testing. Because quite

Re: process creation time increases linearly with shmem

2005-08-26 Thread Hugh Dickins
On Fri, 26 Aug 2005, Ross Biro wrote: > On 8/26/05, Rik van Riel <[EMAIL PROTECTED]> wrote: > > > > Filling in all the page table entries at the first fault to > > a VMA doesn't make much sense, IMHO. > > > > I suspect we would be better off without that extra complexity, > > unless there is a

Re: process creation time increases linearly with shmem

2005-08-26 Thread Hugh Dickins
On Fri, 26 Aug 2005, Linus Torvalds wrote: > On Fri, 26 Aug 2005, Hugh Dickins wrote: > > > > I see some flaws in the various patches posted, including Rik's. > > Here's another version - doing it inside copy_page_range, so this > > kind of vma special-casing is over in mm/ rather than kernel/. >

Re: process creation time increases linearly with shmem

2005-08-26 Thread Ross Biro
On 8/26/05, Rik van Riel <[EMAIL PROTECTED]> wrote: > > Filling in all the page table entries at the first fault to > a VMA doesn't make much sense, IMHO. > > > I suspect we would be better off without that extra complexity, > unless there is a demonstrated benefit to it. You are probably

Re: process creation time increases linearly with shmem

2005-08-26 Thread Linus Torvalds
On Fri, 26 Aug 2005, Hugh Dickins wrote: > > I see some flaws in the various patches posted, including Rik's. > Here's another version - doing it inside copy_page_range, so this > kind of vma special-casing is over in mm/ rather than kernel/. I like this approach better, but I don't understand

Re: process creation time increases linearly with shmem

2005-08-26 Thread Rik van Riel
On Fri, 26 Aug 2005, Ray Fucillo wrote: > However, there is still a need that the child, once successfully forked, is > operational reasonably quickly. I suspect that Ross's idea of paging in > everything after the first fault would not be optimal for us, because we'd > still be talking about

Re: process creation time increases linearly with shmem

2005-08-26 Thread Ray Fucillo
Nick Piggin wrote: OK let's see how Ray goes, and try it when 2.6.14 opens... Working on that now - I'll let you know. Yeah I guess that's a good idea. Patch looks pretty good. Just a minor issue with the comment, it is not strictly just assuming the child will exec... IMO it is worthwhile

Re: process creation time increases linearly with shmem

2005-08-26 Thread Ross Biro
On 8/26/05, Hugh Dickins <[EMAIL PROTECTED]> wrote: > On Fri, 26 Aug 2005, Ross Biro wrote: > > On 8/26/05, Hugh Dickins <[EMAIL PROTECTED]> wrote: > > > > > > The refaulting will hurt the performance of something: let's > > > just hope that something doesn't turn out to be a show-stopper. > > > >

Re: process creation time increases linearly with shmem

2005-08-26 Thread Hugh Dickins
On Fri, 26 Aug 2005, Ross Biro wrote: > On 8/26/05, Hugh Dickins <[EMAIL PROTECTED]> wrote: > > > > The refaulting will hurt the performance of something: let's > > just hope that something doesn't turn out to be a show-stopper. > > Why not just fault in all the pages on the first fault. Then

Re: process creation time increases linearly with shmem

2005-08-26 Thread Nick Piggin
Hugh Dickins wrote: On Thu, 25 Aug 2005, Linus Torvalds wrote: That said, I think it's a valid optimization. Especially as the child _probably_ doesn't need it (ie there's at least some likelihood of an execve() or similar). I agree, seems a great idea to me (sulking because I was too

Re: process creation time increases linearly with shmem

2005-08-26 Thread Hugh Dickins
On Thu, 25 Aug 2005, Linus Torvalds wrote: > On Fri, 26 Aug 2005, Nick Piggin wrote: > > > > > Skipping MAP_SHARED in fork() sounds like a good idea to me... > > > > Indeed. Linus, can you remember why we haven't done this before? > > Hmm. Historical reasons. Also, if the child ends up needing

Re: process creation time increases linearly with shmem

2005-08-26 Thread Hugh Dickins
On Thu, 25 Aug 2005, Linus Torvalds wrote: On Fri, 26 Aug 2005, Nick Piggin wrote: Skipping MAP_SHARED in fork() sounds like a good idea to me... Indeed. Linus, can you remember why we haven't done this before? Hmm. Historical reasons. Also, if the child ends up needing it, it will

Re: process creation time increases linearly with shmem

2005-08-26 Thread Nick Piggin
Hugh Dickins wrote: On Thu, 25 Aug 2005, Linus Torvalds wrote: That said, I think it's a valid optimization. Especially as the child _probably_ doesn't need it (ie there's at least some likelihood of an execve() or similar). I agree, seems a great idea to me (sulking because I was too

Re: process creation time increases linearly with shmem

2005-08-26 Thread Hugh Dickins
On Fri, 26 Aug 2005, Ross Biro wrote: On 8/26/05, Hugh Dickins [EMAIL PROTECTED] wrote: The refaulting will hurt the performance of something: let's just hope that something doesn't turn out to be a show-stopper. Why not just fault in all the pages on the first fault. Then the

Re: process creation time increases linearly with shmem

2005-08-26 Thread Ross Biro
On 8/26/05, Hugh Dickins [EMAIL PROTECTED] wrote: On Fri, 26 Aug 2005, Ross Biro wrote: On 8/26/05, Hugh Dickins [EMAIL PROTECTED] wrote: The refaulting will hurt the performance of something: let's just hope that something doesn't turn out to be a show-stopper. Why not just fault

Re: process creation time increases linearly with shmem

2005-08-26 Thread Ray Fucillo
Nick Piggin wrote: OK let's see how Ray goes, and try it when 2.6.14 opens... Working on that now - I'll let you know. Yeah I guess that's a good idea. Patch looks pretty good. Just a minor issue with the comment, it is not strictly just assuming the child will exec... IMO it is worthwhile

Re: process creation time increases linearly with shmem

2005-08-26 Thread Rik van Riel
On Fri, 26 Aug 2005, Ray Fucillo wrote: However, there is still a need that the child, once successfully forked, is operational reasonably quickly. I suspect that Ross's idea of paging in everything after the first fault would not be optimal for us, because we'd still be talking about

Re: process creation time increases linearly with shmem

2005-08-26 Thread Linus Torvalds
On Fri, 26 Aug 2005, Hugh Dickins wrote: I see some flaws in the various patches posted, including Rik's. Here's another version - doing it inside copy_page_range, so this kind of vma special-casing is over in mm/ rather than kernel/. I like this approach better, but I don't understand

Re: process creation time increases linearly with shmem

2005-08-26 Thread Ross Biro
On 8/26/05, Rik van Riel [EMAIL PROTECTED] wrote: Filling in all the page table entries at the first fault to a VMA doesn't make much sense, IMHO. I suspect we would be better off without that extra complexity, unless there is a demonstrated benefit to it. You are probably right, but do

Re: process creation time increases linearly with shmem

2005-08-26 Thread Hugh Dickins
On Fri, 26 Aug 2005, Linus Torvalds wrote: On Fri, 26 Aug 2005, Hugh Dickins wrote: I see some flaws in the various patches posted, including Rik's. Here's another version - doing it inside copy_page_range, so this kind of vma special-casing is over in mm/ rather than kernel/. I like

Re: process creation time increases linearly with shmem

2005-08-26 Thread Hugh Dickins
On Fri, 26 Aug 2005, Ross Biro wrote: On 8/26/05, Rik van Riel [EMAIL PROTECTED] wrote: Filling in all the page table entries at the first fault to a VMA doesn't make much sense, IMHO. I suspect we would be better off without that extra complexity, unless there is a demonstrated

Re: process creation time increases linearly with shmem

2005-08-26 Thread Linus Torvalds
On Fri, 26 Aug 2005, Hugh Dickins wrote: Well, I still don't think we need to test vm_file. We can add an anon_vma test if you like, if we really want to minimize the fork overhead, in favour of later faults. Do we? I think we might want to do it in -mm for testing. Because quite frankly,

Re: process creation time increases linearly with shmem

2005-08-26 Thread Rik van Riel
On Fri, 26 Aug 2005, Hugh Dickins wrote: Well, I still don't think we need to test vm_file. We can add an anon_vma test if you like, if we really want to minimize the fork overhead, in favour of later faults. Do we? When you consider NUMA placement (the child process may end up running

Re: process creation time increases linearly with shmem

2005-08-26 Thread Linus Torvalds
On Fri, 26 Aug 2005, Rik van Riel wrote: On Fri, 26 Aug 2005, Hugh Dickins wrote: Well, I still don't think we need to test vm_file. We can add an anon_vma test if you like, if we really want to minimize the fork overhead, in favour of later faults. Do we? When you consider NUMA

Re: process creation time increases linearly with shmem

2005-08-25 Thread Linus Torvalds
On Fri, 26 Aug 2005, Nick Piggin wrote: > > > Skipping MAP_SHARED in fork() sounds like a good idea to me... > > > > Indeed. Linus, can you remember why we haven't done this before? Hmm. Historical reasons. Also, if the child ends up needing it, it will now have to fault them in. That

Re: process creation time increases linearly with shmem

2005-08-25 Thread Rik van Riel
On Fri, 26 Aug 2005, Nick Piggin wrote: > > Skipping MAP_SHARED in fork() sounds like a good idea to me... > > Indeed. Linus, can you remember why we haven't done this before? Where "this" looks something like the patch below, shamelessly merging Nick's and Andy's patches and adding the

Re: process creation time increases linearly with shmem

2005-08-25 Thread Nick Piggin
Rik van Riel wrote: On Thu, 25 Aug 2005, Nick Piggin wrote: fork() can be changed so as not to set up page tables for MAP_SHARED mappings. I think that has other tradeoffs like initially causing several unavoidable faults reading libraries and program text. Actually, libraries and program

Re: process creation time increases linearly with shmem

2005-08-25 Thread Rik van Riel
On Thu, 25 Aug 2005, Nick Piggin wrote: > fork() can be changed so as not to set up page tables for > MAP_SHARED mappings. I think that has other tradeoffs like > initially causing several unavoidable faults reading > libraries and program text. Actually, libraries and program text are usually

Re: process creation time increases linearly with shmem

2005-08-25 Thread Andi Kleen
On Thursday 25 August 2005 16:47, Parag Warudkar wrote: > Exactly - one problem is that this forces all of the hugetlb users to go > the lazy faulting way. Actually I disabled it for hugetlbfs (... !is_huge...vma). The reason is that lazy faulting for huge pages is still not in mainline. -Andi

Re: process creation time increases linearly with shmem

2005-08-25 Thread Parag Warudkar
On Thu, 2005-08-25 at 16:22 +0200, Andi Kleen wrote: > But I'm not sure it's a good idea in all cases. Would need a lot of > benchmarking at least. > > -Andi > Exactly - one problem is that this forces all of the hugetlb users to go the lazy faulting way. This is more or less similar to the

Re: process creation time increases linearly with shmem

2005-08-25 Thread Nick Piggin
Andi Kleen wrote: Would it be worth trying to do something like this? Maybe. Shouldn't be very hard though - you just need to check if the VMA is backed by an object and if yes don't call copy_page_range for it. I think it just needs (untested) I think you need to check for MAP_SHARED

Re: process creation time increases linearly with shmem

2005-08-25 Thread Nick Piggin
Ray Fucillo wrote: Nick Piggin wrote: fork() can be changed so as not to set up page tables for MAP_SHARED mappings. I think that has other tradeoffs like initially causing several unavoidable faults reading libraries and program text. What kind of application are you using? The

Re: process creation time increases linearly with shmem

2005-08-25 Thread Andi Kleen
> Would it be worth trying to do something like this? Maybe. Shouldn't be very hard though - you just need to check if the VMA is backed by an object and if yes don't call copy_page_range for it. I think it just needs (untested) Index: linux-2.6.13-rc5-misc/kernel/fork.c

Re: process creation time increases linearly with shmem

2005-08-25 Thread Parag Warudkar
> Ray Fucillo <[EMAIL PROTECTED]> writes: > > > > The application is a database system called Caché. We allocate a > > large shared memory segment for database cache, which in a large > > production environment may realistically be 1+GB on 32-bit platforms > > and much larger on 64-bit. At

Re: process creation time increases linearly with shmem

2005-08-25 Thread Andi Kleen
Ray Fucillo <[EMAIL PROTECTED]> writes: > > The application is a database system called Caché. We allocate a > large shared memory segment for database cache, which in a large > production environment may realistically be 1+GB on 32-bit platforms > and much larger on 64-bit. At these sizes

Re: process creation time increases linearly with shmem

2005-08-25 Thread Ray Fucillo
Nick Piggin wrote: fork() can be changed so as not to set up page tables for MAP_SHARED mappings. I think that has other tradeoffs like initially causing several unavoidable faults reading libraries and program text. What kind of application are you using? The application is a database system

Re: process creation time increases linearly with shmem

2005-08-25 Thread Ray Fucillo
Nick Piggin wrote: fork() can be changed so as not to set up page tables for MAP_SHARED mappings. I think that has other tradeoffs like initially causing several unavoidable faults reading libraries and program text. What kind of application are you using? The application is a database system

Re: process creation time increases linearly with shmem

2005-08-25 Thread Andi Kleen
Ray Fucillo [EMAIL PROTECTED] writes: The application is a database system called Caché. We allocate a large shared memory segment for database cache, which in a large production environment may realistically be 1+GB on 32-bit platforms and much larger on 64-bit. At these sizes fork() is

Re: process creation time increases linearly with shmem

2005-08-25 Thread Parag Warudkar
Ray Fucillo [EMAIL PROTECTED] writes: The application is a database system called Caché. We allocate a large shared memory segment for database cache, which in a large production environment may realistically be 1+GB on 32-bit platforms and much larger on 64-bit. At these sizes

Re: process creation time increases linearly with shmem

2005-08-25 Thread Andi Kleen
Would it be worth trying to do something like this? Maybe. Shouldn't be very hard though - you just need to check if the VMA is backed by an object and if yes don't call copy_page_range for it. I think it just needs (untested) Index: linux-2.6.13-rc5-misc/kernel/fork.c

Re: process creation time increases linearly with shmem

2005-08-25 Thread Nick Piggin
Ray Fucillo wrote: Nick Piggin wrote: fork() can be changed so as not to set up page tables for MAP_SHARED mappings. I think that has other tradeoffs like initially causing several unavoidable faults reading libraries and program text. What kind of application are you using? The

Re: process creation time increases linearly with shmem

2005-08-25 Thread Nick Piggin
Andi Kleen wrote: Would it be worth trying to do something like this? Maybe. Shouldn't be very hard though - you just need to check if the VMA is backed by an object and if yes don't call copy_page_range for it. I think it just needs (untested) I think you need to check for MAP_SHARED

Re: process creation time increases linearly with shmem

2005-08-25 Thread Parag Warudkar
On Thu, 2005-08-25 at 16:22 +0200, Andi Kleen wrote: But I'm not sure it's a good idea in all cases. Would need a lot of benchmarking at least. -Andi Exactly - one problem is that this forces all of the hugetlb users to go the lazy faulting way. This is more or less similar to the

Re: process creation time increases linearly with shmem

2005-08-25 Thread Rik van Riel
On Thu, 25 Aug 2005, Nick Piggin wrote: fork() can be changed so as not to set up page tables for MAP_SHARED mappings. I think that has other tradeoffs like initially causing several unavoidable faults reading libraries and program text. Actually, libraries and program text are usually

Re: process creation time increases linearly with shmem

2005-08-25 Thread Nick Piggin
Rik van Riel wrote: On Thu, 25 Aug 2005, Nick Piggin wrote: fork() can be changed so as not to set up page tables for MAP_SHARED mappings. I think that has other tradeoffs like initially causing several unavoidable faults reading libraries and program text. Actually, libraries and program

Re: process creation time increases linearly with shmem

2005-08-25 Thread Rik van Riel
On Fri, 26 Aug 2005, Nick Piggin wrote: Skipping MAP_SHARED in fork() sounds like a good idea to me... Indeed. Linus, can you remember why we haven't done this before? Where this looks something like the patch below, shamelessly merging Nick's and Andy's patches and adding the

Re: process creation time increases linearly with shmem

2005-08-25 Thread Linus Torvalds
On Fri, 26 Aug 2005, Nick Piggin wrote: Skipping MAP_SHARED in fork() sounds like a good idea to me... Indeed. Linus, can you remember why we haven't done this before? Hmm. Historical reasons. Also, if the child ends up needing it, it will now have to fault them in. That said, I

Re: process creation time increases linearly with shmem

2005-08-24 Thread Nick Piggin
Ray Fucillo wrote: I am seeing process creation time increase linearly with the size of the shared memory segment that the parent touches. The attached forktest.c is a very simple user program that illustrates this behavior, which I have tested on various kernel versions from 2.4 through 2.6.

process creation time increases linearly with shmem

2005-08-24 Thread Ray Fucillo
I am seeing process creation time increase linearly with the size of the shared memory segment that the parent touches. The attached forktest.c is a very simple user program that illustrates this behavior, which I have tested on various kernel versions from 2.4 through 2.6. Is this a known

process creation time increases linearly with shmem

2005-08-24 Thread Ray Fucillo
I am seeing process creation time increase linearly with the size of the shared memory segment that the parent touches. The attached forktest.c is a very simple user program that illustrates this behavior, which I have tested on various kernel versions from 2.4 through 2.6. Is this a known

Re: process creation time increases linearly with shmem

2005-08-24 Thread Nick Piggin
Ray Fucillo wrote: I am seeing process creation time increase linearly with the size of the shared memory segment that the parent touches. The attached forktest.c is a very simple user program that illustrates this behavior, which I have tested on various kernel versions from 2.4 through 2.6.