Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1318105 > unrolled thread

fork on processes with lots of memory

Started byFelix von Leitner <felix-linuxkernel@fefe.de>
First post2016-01-26 17:20 +0100
Last post2016-01-26 21:30 +0100
Articles 4 — 3 participants

Back to article view | Back to linux.kernel


Contents

  fork on processes with lots of memory Felix von Leitner <felix-linuxkernel@fefe.de> - 2016-01-26 17:20 +0100
    Re: fork on processes with lots of memory Felix von Leitner <felix-linuxkernel@fefe.de> - 2016-01-26 17:30 +0100
      Re: fork on processes with lots of memory Borislav Petkov <bp@alien8.de> - 2016-01-26 17:40 +0100
      Re: fork on processes with lots of memory Mikael Pettersson <mikpelinux@gmail.com> - 2016-01-26 21:30 +0100

#1318105 — fork on processes with lots of memory

FromFelix von Leitner <felix-linuxkernel@fefe.de>
Date2016-01-26 17:20 +0100
Subjectfork on processes with lots of memory
Message-ID<qVevx-6B0-19@gated-at.bofh.it>
Dear Linux kernel devs,

I talked to someone who uses large Linux based hardware to run a
process with huge memory requirements (think 4 GB), and he told me that
if they do a fork() syscall on that process, the whole system comes to
standstill. And not just for a second or two. He said they measured a 45
minute (!) delay before the system became responsive again.

Their working theory is that all the pages need to be marked copy-on-write
in both processes, and if you touch one page, a copy needs to be made,
and than just takes a while if you have a billion pages.

I was wondering if there is any advice for such situations from the
memory management people on this list.

In this case the fork was for an execve afterwards, but I was going to
recommend fork to them for something else that can not be tricked around
with vfork.

Can anyone comment on whether the 45 minute number sounds like it could
be real? When I heard it, I was flabberghasted. But the other person
swore it was real. Can a fork cause this much of a delay? Is there a way
to work around it?

I was going to recommend the fork to create a boundary between the
processes, so that you can recover from memory corruption in one
process. In fact, after the fork I would want to munmap almost all of
the shared pages anyway, but there is no way to tell fork that.

Thanks,

Felix

PS: Please put me on Cc if you reply, I'm not subscribed to this mailing
list.

[toc] | [next] | [standalone]


#1318118

FromFelix von Leitner <felix-linuxkernel@fefe.de>
Date2016-01-26 17:30 +0100
Message-ID<qVeFd-6F7-23@gated-at.bofh.it>
In reply to#1318105
> Dear Linux kernel devs,

> I talked to someone who uses large Linux based hardware to run a
> process with huge memory requirements (think 4 GB), and he told me that
> if they do a fork() syscall on that process, the whole system comes to
> standstill. And not just for a second or two. He said they measured a 45
> minute (!) delay before the system became responsive again.

I'm sorry, I meant 4 TB not 4 GB.
I'm not used to working with that kind of memory sizes.

> Their working theory is that all the pages need to be marked copy-on-write
> in both processes, and if you touch one page, a copy needs to be made,
> and than just takes a while if you have a billion pages.

> I was wondering if there is any advice for such situations from the
> memory management people on this list.

> In this case the fork was for an execve afterwards, but I was going to
> recommend fork to them for something else that can not be tricked around
> with vfork.

> Can anyone comment on whether the 45 minute number sounds like it could
> be real? When I heard it, I was flabberghasted. But the other person
> swore it was real. Can a fork cause this much of a delay? Is there a way
> to work around it?

> I was going to recommend the fork to create a boundary between the
> processes, so that you can recover from memory corruption in one
> process. In fact, after the fork I would want to munmap almost all of
> the shared pages anyway, but there is no way to tell fork that.

> Thanks,

> Felix

> PS: Please put me on Cc if you reply, I'm not subscribed to this mailing
> list.

[toc] | [prev] | [next] | [standalone]


#1318122

FromBorislav Petkov <bp@alien8.de>
Date2016-01-26 17:40 +0100
Message-ID<qVeOS-6K1-3@gated-at.bofh.it>
In reply to#1318118
+ linux-mm

On Tue, Jan 26, 2016 at 05:28:53PM +0100, Felix von Leitner wrote:
> > Dear Linux kernel devs,
> 
> > I talked to someone who uses large Linux based hardware to run a
> > process with huge memory requirements (think 4 GB), and he told me that
> > if they do a fork() syscall on that process, the whole system comes to
> > standstill. And not just for a second or two. He said they measured a 45
> > minute (!) delay before the system became responsive again.
> 
> I'm sorry, I meant 4 TB not 4 GB.
> I'm not used to working with that kind of memory sizes.
> 
> > Their working theory is that all the pages need to be marked copy-on-write
> > in both processes, and if you touch one page, a copy needs to be made,
> > and than just takes a while if you have a billion pages.
> 
> > I was wondering if there is any advice for such situations from the
> > memory management people on this list.
> 
> > In this case the fork was for an execve afterwards, but I was going to
> > recommend fork to them for something else that can not be tricked around
> > with vfork.
> 
> > Can anyone comment on whether the 45 minute number sounds like it could
> > be real? When I heard it, I was flabberghasted. But the other person
> > swore it was real. Can a fork cause this much of a delay? Is there a way
> > to work around it?
> 
> > I was going to recommend the fork to create a boundary between the
> > processes, so that you can recover from memory corruption in one
> > process. In fact, after the fork I would want to munmap almost all of
> > the shared pages anyway, but there is no way to tell fork that.
> 
> > Thanks,
> 
> > Felix
> 
> > PS: Please put me on Cc if you reply, I'm not subscribed to this mailing
> > list.
> 

-- 
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.

[toc] | [prev] | [next] | [standalone]


#1318338

FromMikael Pettersson <mikpelinux@gmail.com>
Date2016-01-26 21:30 +0100
Message-ID<qVips-Vs-19@gated-at.bofh.it>
In reply to#1318118
Felix von Leitner writes:
 > > Dear Linux kernel devs,
 > 
 > > I talked to someone who uses large Linux based hardware to run a
 > > process with huge memory requirements (think 4 GB), and he told me that
 > > if they do a fork() syscall on that process, the whole system comes to
 > > standstill. And not just for a second or two. He said they measured a 45
 > > minute (!) delay before the system became responsive again.
 > 
 > I'm sorry, I meant 4 TB not 4 GB.
 > I'm not used to working with that kind of memory sizes.

Make sure you have >>4TB physical if you're going to fork from a process
with a 4TB virtual address space.  (I'm assuming it's not sparse, but all
actually being used.)

Disable transparent hugepages (THP).  The internal book-keeping mechanisms
have been known to run amok with large RAM sizes causing severe performance
issues.  Maybe 4.x kernels are better, I haven't checked.

If you're using explicit hugepages and these kinds of RAM sizes, don't
bother with RHEL 6 or 7 kernels -- they're broken.  Vanilla 4.x kernels work.

We're also in the TB range, though not quite 4TB, and fork()ing from inside
such processes definitely works for us.  We do disable THP since it kills us
otherwise.

 > 
 > > Their working theory is that all the pages need to be marked copy-on-write
 > > in both processes, and if you touch one page, a copy needs to be made,
 > > and than just takes a while if you have a billion pages.
 > 
 > > I was wondering if there is any advice for such situations from the
 > > memory management people on this list.
 > 
 > > In this case the fork was for an execve afterwards, but I was going to
 > > recommend fork to them for something else that can not be tricked around
 > > with vfork.
 > 
 > > Can anyone comment on whether the 45 minute number sounds like it could
 > > be real? When I heard it, I was flabberghasted. But the other person
 > > swore it was real. Can a fork cause this much of a delay? Is there a way
 > > to work around it?
 > 
 > > I was going to recommend the fork to create a boundary between the
 > > processes, so that you can recover from memory corruption in one
 > > process. In fact, after the fork I would want to munmap almost all of
 > > the shared pages anyway, but there is no way to tell fork that.
 > 
 > > Thanks,
 > 
 > > Felix
 > 
 > > PS: Please put me on Cc if you reply, I'm not subscribed to this mailing
 > > list.

-- 

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web