login
Header Space

 
 

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

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Frank Mayhar <fmayhar@...>
Cc: <parag.warudkar@...>, Alejandro Riveira <ariveira@...>, Andrew Morton <akpm@...>, <linux-kernel@...>, Ingo Molnar <mingo@...>, Thomas Gleixner <tglx@...>, Jakub Jelinek <jakub@...>
Date: Wednesday, March 5, 2008 - 12:08 am

> My first patch did essentially what you outlined above, incrementing

There is a 1:1 correspondence between "shares signal_struct" and "member of
same thread group".  signal_struct is the right place for such new fields.
Don't be confused by the existing fields utime, stime, gtime, and
sum_sched_runtime.  All of those are accumulators only touched when a
non-leader thread dies (in __exit_signal), and governed by the siglock.
Their only purpose now is to represent the threads that are dead and gone
when calculating the cumulative total for the whole thread group.  If you
were to provide cumulative totals that are updated on every tick, then
these old fields would not be needed.


The task_struct.group_leader field is never NULL.  Every thread is a member
of some thread group.  The degenerate case is that it's the only member of
the group; then p->group_leader == p.


It sounds like you sped up only one of the sampling loops.  Having a
cumulative total already on hand means cpu_clock_sample_group can also
become simple and cheap, as can the analogues in do_getitimer and
k_getrusage.  These are what's used in clock_gettime and in the timer
manipulation calls, and in getitimer and getrusage.  That's all just gravy.

The real benefit of having a cumulative total is for the basic logic of
run_posix_cpu_timers (check_process_timers) and the timer expiry setup.  
It sounds like you didn't take advantage of the new fields for that.

When a cumulative total is on hand in the tick handler, then there is no
need at all to derive per-thread expiry times from group-wide CPU timers
("rebalance") either there or when arming the timer in the first place.
All of that complexity can just disappear from the implementation.

check_process_timers can look just like check_thread_timers, but
consulting the shared fields instead of the per-thread ones for both the
clock accumulators and the timers' expiry times.  Likewise, arm_timer
only has to set signal->it_*_expires; process_timer_rebalance goes away.

If you do all that then the time spent in run_posix_cpu_timers should
not be affected at all by the number of threads.  The only "walking the
timer lists" that happens is popping the expired timers off the head of
the lists that are kept in ascending order of expiry time.  For each
flavor of timer, there are n+1 steps in the "walk" for n timers that
have expired.  So already no costs here should scale with the number of
timers, just the with the number of timers that all expire at the same time.

Back for a moment to the status quo and your second patch.


What I would expect is that there be at most one item in the queue for
each process (thread group).  If you have 200000 threads in one process,
you still only need one iteration of check_process_timers to run.  If it
hasn't run by the time more threads in the same group get more ticks,
then all that matters is that it indeed runs once reasonably soon (for
an overall effect of not much less often than once per tick interval).


I can help you with all of that.  What I'll need from you is careful
performance analysis of all the effects of any changes we consider.

The simplifications I described above will obviously greatly improve
your test case (many threads and with some process timers expiring
pretty frequently).  We need to consider and analyze the other kinds of
cases too.  That is, cases with a few threads (not many more than the
number of CPUs); cases where no timer is close to expiring very often.
The most common cases, from one-thread cases to one-million thread
cases, are when no timers are going off before next Tuesday (if any are
set at all).  Then run_posix_cpu_timers always bails out early, and none
of the costs you've seen become relevant at all.  Any change to what the
timer interrupt handler does on every tick affects those cases too.

As I mentioned in my last message, my concern about this originally was
with the SMP cache/lock effects of multiple CPUs touching the same
memory in signal_struct on every tick (which presumably all tend to
happen simultaneously on all the CPUs).  I'd insist that we have
measurements and analysis as thorough as possible of the effects of
introducing that frequent/synchronized sharing, before endorsing such
changes.  I have a couple of guesses as to what might be reasonable ways
to mitigate that.  But it needs a lot of measurement and wise opinion on
the low-level performance effects of each proposal.


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