public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@elte.hu>
To: Frank Mayhar <fmayhar@google.com>
Cc: Roland McGrath <roland@redhat.com>,
	linux-kernel@vger.kernel.org,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH 2.6.25-rc6] Fix itimer/many thread hang.
Date: Fri, 28 Mar 2008 11:28:44 +0100	[thread overview]
Message-ID: <20080328102844.GE633@elte.hu> (raw)
In-Reply-To: <1206665568.426.24.camel@bobble.smo.corp.google.com>


* Frank Mayhar <fmayhar@google.com> wrote:

> +static inline void thread_group_times_init(struct signal_struct *sig)
> +{
> +	sig->thread_group_times = NULL;
> +}
> +
> +static inline void thread_group_times_free(struct signal_struct *sig)
> +{
> +	if (sig->thread_group_times)
> +		free_percpu(sig->thread_group_times);
> +}
> +
> +/*
> + * Allocate the thread_group_cputime struct appropriately and fill in the current
> + * values of the fields.  Called from do_setitimer() when setting an interval
> + * timer (ITIMER_PROF or ITIMER_VIRTUAL).  Assumes interrupts are enabled when
> + * it's called.  Note that there is no corresponding deallocation done from
> + * do_setitimer(); the structure is freed at process exit.
> + */
> +static inline int thread_group_times_alloc(struct task_struct *tsk)
> +{
> +	struct signal_struct *sig = tsk->signal;
> +	struct thread_group_cputime *thread_group_times;
> +	struct task_struct *t;
> +	cputime_t utime, stime;
> +	unsigned long long sum_exec_runtime;
> +
> +	/*
> +	 * If we don't already have a thread_group_cputime struct, allocate
> +	 * one and fill it in with the accumulated times.
> +	 */
> +	if (sig->thread_group_times)
> +		return 0;
> +	thread_group_times = alloc_percpu(struct thread_group_cputime);
> +	if (thread_group_times == NULL)
> +		return -ENOMEM;
> +	read_lock(&tasklist_lock);
> +	spin_lock_irq(&tsk->sighand->siglock);
> +	if (sig->thread_group_times) {
> +		spin_unlock_irq(&tsk->sighand->siglock);
> +		read_unlock(&tasklist_lock);
> +		free_percpu(thread_group_times);
> +		return 0;
> +	}
> +	sig->thread_group_times = thread_group_times;
> +	utime = sig->utime;
> +	stime = sig->stime;
> +	sum_exec_runtime = tsk->se.sum_exec_runtime;
> +	t = tsk;
> +	do {
> +		utime = cputime_add(utime, t->utime);
> +		stime = cputime_add(stime, t->stime);
> +		sum_exec_runtime += t->se.sum_exec_runtime;
> +	} while_each_thread(tsk, t);
> +	thread_group_times = per_cpu_ptr(sig->thread_group_times, get_cpu());
> +	thread_group_times->utime = utime;
> +	thread_group_times->stime = stime;
> +	thread_group_times->sum_exec_runtime = sum_exec_runtime;
> +	put_cpu_no_resched();
> +	spin_unlock_irq(&tsk->sighand->siglock);
> +	read_unlock(&tasklist_lock);
> +	return 0;
> +}

please dont put such a huge inline into a header.

> +
> +#define thread_group_update(sig, field, val, op) ({ \
> +	if (sig && sig->thread_group_times) {				\
> +		int cpu;						\
> +		struct thread_group_cputime *thread_group_times;	\
> +									\
> +		cpu = get_cpu();					\
> +		thread_group_times =					\
> +			per_cpu_ptr(sig->thread_group_times, cpu);	\
> +		thread_group_times->field =				\
> +			op(thread_group_times->field, val);		\
> +		put_cpu_no_resched();					\
> +	}								\
> +})

nor use any macros that includes code.

> +static inline int thread_group_cputime(struct thread_group_cputime *thread_group_times,
> +	struct signal_struct *sig)

ditto, line length as well.

> +	if (!sig->thread_group_times)
> +		return(0);

return 0 is the proper form - please run your patch through 
scripts/checkpatch.pl.

	Ingo

  reply	other threads:[~2008-03-28 10:29 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-9906-10286@http.bugzilla.kernel.org/>
2008-02-07  0:50 ` [Bugme-new] [Bug 9906] New: Weird hang with NPTL and SIGPROF Andrew Morton
2008-02-07  0:58   ` Frank Mayhar
2008-02-07  2:57     ` Parag Warudkar
2008-02-07 15:22       ` Alejandro Riveira Fernández
2008-02-07 15:53         ` Parag Warudkar
2008-02-07 15:56           ` Parag Warudkar
2008-02-07 15:54             ` Alejandro Riveira Fernández
2008-02-07 16:01               ` Parag Warudkar
2008-02-07 16:53                 ` Parag Warudkar
2008-02-29 19:55                   ` Frank Mayhar
2008-03-04  7:00                     ` Roland McGrath
2008-03-04 19:52                       ` Frank Mayhar
2008-03-05  4:08                         ` Roland McGrath
2008-03-06 19:04                           ` Frank Mayhar
2008-03-11  7:50                             ` posix-cpu-timers revamp Roland McGrath
2008-03-11 21:05                               ` Frank Mayhar
2008-03-11 21:35                                 ` Roland McGrath
2008-03-14  0:37                                   ` Frank Mayhar
2008-03-21  7:18                                     ` Roland McGrath
2008-03-21 17:57                                       ` Frank Mayhar
2008-03-22 21:58                                         ` Roland McGrath
2008-03-24 17:34                                           ` Frank Mayhar
2008-03-24 22:43                                             ` Frank Mayhar
2008-03-31  5:44                                             ` Roland McGrath
2008-03-31 20:24                                               ` Frank Mayhar
2008-04-02  2:07                                                 ` Roland McGrath
2008-04-02 16:34                                                   ` Frank Mayhar
2008-04-02 17:42                                                   ` Frank Mayhar
2008-04-02 19:48                                                     ` Roland McGrath
2008-04-02 20:34                                                       ` Frank Mayhar
2008-04-02 21:42                                                         ` Frank Mayhar
2008-04-04  0:53                                                           ` Frank Mayhar
2008-04-04 23:17                                                         ` Roland McGrath
2008-04-06  5:26                                                           ` Frank Mayhar
2008-04-07 20:08                                                             ` Roland McGrath
2008-04-07 21:31                                                               ` Frank Mayhar
2008-04-07 22:02                                                                 ` Roland McGrath
2008-04-08 21:27                                                               ` Frank Mayhar
2008-04-08 21:52                                                                 ` Frank Mayhar
2008-04-08 22:49                                                                 ` Roland McGrath
2008-04-09 16:29                                                                   ` Frank Mayhar
2008-04-02 18:42                                                   ` Frank Mayhar
2008-03-28  0:52                                           ` [PATCH 2.6.25-rc6] Fix itimer/many thread hang Frank Mayhar
2008-03-28 10:28                                             ` Ingo Molnar [this message]
2008-03-28 22:46                                             ` [PATCH 2.6.25-rc7 resubmit] " Frank Mayhar
2008-04-01 18:45                                               ` Andrew Morton
2008-04-01 21:46                                                 ` Frank Mayhar
2008-03-21 20:40                                       ` posix-cpu-timers revamp Frank Mayhar
2008-03-07 23:26                           ` [Bugme-new] [Bug 9906] New: Weird hang with NPTL and SIGPROF Frank Mayhar
2008-03-08  0:01                             ` Frank Mayhar
2008-02-07 17:36           ` Frank Mayhar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080328102844.GE633@elte.hu \
    --to=mingo@elte.hu \
    --cc=a.p.zijlstra@chello.nl \
    --cc=fmayhar@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=roland@redhat.com \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox