Re: [Bugme-new] [Bug 9906] New: Weird hang with NPTL and SIGPROF.

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Roland McGrath
Date: Tuesday, March 4, 2008 - 12:00 am

Thanks for the detailed explanation and for bringing this to my attention.

This is a problem we knew about when I first implemented posix-cpu-timers
and process-wide SIGPROF/SIGVTALRM.  I'm a little surprised it took this
long to become a problem in practice.  I originally expected to have to
revisit it sooner than this, but I certainly haven't thought about it for
quite some time.  I'd guess that HZ=1000 becoming common is what did it.

The obvious implementation for the process-wide clocks is to have the
tick interrupt increment shared utime/stime/sched_time fields in
signal_struct as well as the private task_struct fields.  The all-threads
totals accumulate in the signal_struct fields, which would be atomic_t.
It's then trivial for the timer expiry checks to compare against those
totals.

The concern I had about this was multiple CPUs competing for the
signal_struct fields.  (That is, several CPUs all running threads in the
same process.)  If the ticks on each CPU are even close to synchronized,
then every single time all those CPUs will do an atomic_add on the same
word.  I'm not any kind of expert on SMP and cache effects, but I know
this is bad.  However bad it is, it's that bad all the time and however
few threads (down to 2) it's that bad for that many CPUs.

The implementation we have instead is obviously dismal for large numbers
of threads.  I always figured we'd replace that with something based on
more sophisticated thinking about the CPU-clash issue.  

I don't entirely follow your description of your patch.  It sounds like it
should be two patches, though.  The second of those patches (workqueue)
sounds like it could be an appropriate generic cleanup, or like it could
be a complication that might be unnecessary if we get a really good
solution to main issue.  

The first patch I'm not sure whether I understand what you said or not.
Can you elaborate?  Or just post the unfinished patch as illustration,
marking it as not for submission until you've finished.


Thanks,
Roland
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [Bugme-new] [Bug 9906] New: Weird hang with NPTL and S ..., Alejandro Riveira , (Thu Feb 7, 8:22 am)
Re: [Bugme-new] [Bug 9906] New: Weird hang with NPTL and S ..., Alejandro Riveira , (Thu Feb 7, 8:54 am)
Re: [Bugme-new] [Bug 9906] New: Weird hang with NPTL and S ..., Roland McGrath, (Tue Mar 4, 12:00 am)
posix-cpu-timers revamp, Roland McGrath, (Tue Mar 11, 12:50 am)
Re: posix-cpu-timers revamp, Frank Mayhar, (Tue Mar 11, 2:05 pm)
Re: posix-cpu-timers revamp, Roland McGrath, (Tue Mar 11, 2:35 pm)
Re: posix-cpu-timers revamp, Frank Mayhar, (Thu Mar 13, 5:37 pm)
Re: posix-cpu-timers revamp, Roland McGrath, (Fri Mar 21, 12:18 am)
Re: posix-cpu-timers revamp, Frank Mayhar, (Fri Mar 21, 10:57 am)
Re: posix-cpu-timers revamp, Frank Mayhar, (Fri Mar 21, 1:40 pm)
Re: posix-cpu-timers revamp, Roland McGrath, (Sat Mar 22, 2:58 pm)
Re: posix-cpu-timers revamp, Frank Mayhar, (Mon Mar 24, 10:34 am)
Re: posix-cpu-timers revamp, Frank Mayhar, (Mon Mar 24, 3:43 pm)
[PATCH 2.6.25-rc6] Fix itimer/many thread hang., Frank Mayhar, (Thu Mar 27, 5:52 pm)
Re: [PATCH 2.6.25-rc6] Fix itimer/many thread hang., Ingo Molnar, (Fri Mar 28, 3:28 am)
Re: posix-cpu-timers revamp, Roland McGrath, (Sun Mar 30, 10:44 pm)
Re: posix-cpu-timers revamp, Frank Mayhar, (Mon Mar 31, 1:24 pm)
Re: posix-cpu-timers revamp, Roland McGrath, (Tue Apr 1, 7:07 pm)
Re: posix-cpu-timers revamp, Frank Mayhar, (Wed Apr 2, 9:34 am)
Re: posix-cpu-timers revamp, Frank Mayhar, (Wed Apr 2, 10:42 am)
Re: posix-cpu-timers revamp, Frank Mayhar, (Wed Apr 2, 11:42 am)
Re: posix-cpu-timers revamp, Roland McGrath, (Wed Apr 2, 12:48 pm)
Re: posix-cpu-timers revamp, Frank Mayhar, (Wed Apr 2, 1:34 pm)
Re: posix-cpu-timers revamp, Frank Mayhar, (Wed Apr 2, 2:42 pm)
Re: posix-cpu-timers revamp, Frank Mayhar, (Thu Apr 3, 5:53 pm)
Re: posix-cpu-timers revamp, Roland McGrath, (Fri Apr 4, 4:17 pm)
Re: posix-cpu-timers revamp, Frank Mayhar, (Sat Apr 5, 10:26 pm)
Re: posix-cpu-timers revamp, Roland McGrath, (Mon Apr 7, 1:08 pm)
Re: posix-cpu-timers revamp, Frank Mayhar, (Mon Apr 7, 2:31 pm)
Re: posix-cpu-timers revamp, Roland McGrath, (Mon Apr 7, 3:02 pm)
Re: posix-cpu-timers revamp, Frank Mayhar, (Tue Apr 8, 2:27 pm)
Re: posix-cpu-timers revamp, Frank Mayhar, (Tue Apr 8, 2:52 pm)
Re: posix-cpu-timers revamp, Roland McGrath, (Tue Apr 8, 3:49 pm)
Re: posix-cpu-timers revamp, Frank Mayhar, (Wed Apr 9, 9:29 am)