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: Roland McGrath <roland@...>
Cc: <parag.warudkar@...>, Alejandro Riveira <ariveira@...>, Andrew Morton <akpm@...>, <linux-kernel@...>, Ingo Molnar <mingo@...>, Thomas Gleixner <tglx@...>, Jakub Jelinek <jakub@...>
Date: Friday, March 7, 2008 - 7:26 pm

Based on Roland's comments and from reading the source, I have a
possible fix.  I'm posting the attached patch _not_ for submission but
_only_ for comment.  For one thing it's based on 2.6.18.5 and for
another it hasn't had much testing yet.  I wanted to get it out here for
comment, though, in case anyone can see where I might have gone wrong.
Comments, criticism and (especially!) testing enthusiastically
requested.


	Replaces the utime, stime and sched_time fields in signal_struct with
	shared_utime, shared_stime and shared_schedtime, respectively.  It
	also adds it_sched_expires to the signal struct.

	Each place that loops through all threads in a thread group to sum
	task->utime and/or task->stime now loads the value from
	task->signal->shared_[us]time.  This includes compat_sys_times(),
	do_task_stat(), do_getitimer(), sys_times() and k_getrusage().

	Certain routines that used task->signal->[us]time now use the shared
	fields instead, which may change their semantics slightly.  These
	include fill_prstatus() (in fs/binfmt_elf.c), do_task_stat() (in
	fs/proc/array.c), wait_task_zombie() and do_notify_parent().

	The shared fields are updated at each tick, in update_cpu_clock()
	(shared_schedtime), account_user_time() (shared_utime) and
	account_system_time() (shared_stime).  Each of these functions updates
	the task-private field followed by the shared version in the signal
	structure if one is present.  Note that if different threads of the
	same process are being run by different CPUs at the tick, there may
	be serious cache contention here.

	Finally, kernel/posix-cpu-timers.c has changed quite dramatically.
	First, run_posix_cpu_timers() decides whether a timer has expired by
	consulting the it_*_expires and shared_* fields in the signal struct.
	The check_process_timers() routine bases its computations on the new
	shared fields, removing two loops through the threads.  "Rebalancing"
	is no longer required, the process_timer_rebalance() routine as
	disappeared entirely and the arm_timer() routine merely fills
	p->signal->it_*_expires from timer->it.cpu.expires.*.  The
	cpu_clock_sample_group_locked() loses its summing loops, consulting
	the shared fields instead.  Finally, set_process_cpu_timer() sets
	tsk->signal->it_*_expires directly rather than calling the deleted
	rebalance routine.

	There are still a few open questions.  In particular, it's possible
	that cache contention on the tick update of the shared fields could
	mean that the current scheme is not entirely sufficient.  Further,
	the semantics of the status-returning routines fill_prstatus(),
	do_task_stat(), wait_task_zombie() and do_notify_parent() may no longer
	follow standards.  For that matter, ITIMER_PROF handling may be broken
	entirely, although a brief test seems to show that it's working fine.

Stats:
 fs/binfmt_elf.c           |   18 +--
 fs/proc/array.c           |    6 -
 include/linux/sched.h     |   10 +-
 kernel/exit.c             |   13 --
 kernel/fork.c             |   25 +----
 kernel/itimer.c           |   18 ---
 kernel/posix-cpu-timers.c |  224 ++++++++++------------------------------------
 kernel/sched.c            |   16 +++
 kernel/signal.c           |    6 -
 kernel/sys.c              |   17 ---
 10 files changed, 105 insertions(+), 248 deletions(-)
-- 
Frank Mayhar <fmayhar@google.com>
Google, Inc.
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..., Frank Mayhar, (Fri Mar 7, 7:26 pm)
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