login
Login
/
Register
Search
Search this site:
Forums
News
Blogs
Features
Site
Home
»
Mailing list archives
»
linux-kernel
»
2010
»
June
»
11
Re: [PATCH 6/5] fix the racy usage of thread_group_cputimer() in fastpath_timer_check()
view
thread
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
[view in full thread]
From: Oleg Nesterov
Subject:
Re: [PATCH 6/5] fix the racy usage of thread_group_cputimer() in fastpath_timer_check()
Date: Friday, June 11, 2010 - 11:06 am
On 06/11, Oleg Nesterov wrote:
quoted text
> > fastpath_timer_check()->thread_group_cputimer() is racy and > unneeded.
Just in case... this fix doesn't depend on other patches I sent.
quoted text
> It is racy because another thread can clear ->running before > thread_group_cputimer() takes cputimer->lock. In this case > thread_group_cputimer() will set ->running = true again and call > thread_group_cputime(). But since we do not hold tasklist or > siglock, we can race with fork/exit and copy the wrong results > into cputimer->cputime. > > It is unneeded because if ->running == true we can just use > the numbers in cputimer->cputime we already have. > > Change fastpath_timer_check() to copy cputimer->cputime into > the local variable under cputimer->lock. We do not re-check > ->running under cputimer->lock, run_posix_cpu_timers() does > this check later. > > Note: we can add more optimizations on top of this change. > > Signed-off-by: Oleg Nesterov <oleg@redhat.com> > --- > > kernel/posix-cpu-timers.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > --- 35-rc2/kernel/posix-cpu-timers.c~6_FPTC_DONT_SET_RUNNING 2010-06-11 01:08:03.000000000 +0200 > +++ 35-rc2/kernel/posix-cpu-timers.c 2010-06-11 19:40:22.000000000 +0200 > @@ -1287,7 +1287,10 @@ static inline int fastpath_timer_check(s > if (sig->cputimer.running) { > struct task_cputime group_sample; > > - thread_group_cputimer(tsk, &group_sample); > + spin_lock(&sig->cputimer.lock); > + group_sample = sig->cputimer.cputime; > + spin_unlock(&sig->cputimer.lock); > + > if (task_cputime_expired(&group_sample, &sig->cputime_expires)) > return 1; > }
--
unsubscribe notice
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to
majordomo@vger.kernel.org
More majordomo info at
http://vger.kernel.org/majordomo-info.html
Please read the FAQ at
http://www.tux.org/lkml/
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
Messages in current thread:
[PATCH 5/5] run_posix_cpu_timers: don't check ->exit_state ...
, Oleg Nesterov
, (Thu Jun 10, 4:10 pm)
[PATCH 6/5] fix the racy usage of thread_group_cputimer() ...
, Oleg Nesterov
, (Fri Jun 11, 11:04 am)
Re: [PATCH 6/5] fix the racy usage of thread_group_cputime ...
, Oleg Nesterov
, (Fri Jun 11, 11:06 am)
[tip:sched/core] sched: run_posix_cpu_timers: Don't check ...
, tip-bot for Oleg Nes ...
, (Fri Jun 18, 3:20 am)
[tip:sched/core] sched: Fix the racy usage of thread_group ...
, tip-bot for Oleg Nes ...
, (Fri Jun 18, 3:21 am)
Navigation
Create content
Mailing list archives
Recent posts
Popular discussions
linux-kernel
:
Kay Sievers
Re: char/tpm: tpm_infineon no longer loaded for HP 2510p laptop
Eric W. Biederman
[PATCH 8/8] sysfs: user namespaces: fix bug with clone(CLONE_NEWUSER) with fairsched
S K
Re: cpufreq doesn't seem to work in Intel Q9300
Bart Van Assche
Re: Is gcc thread-unsafe?
Aaron Straus
Re: [NFS] blocks of zeros (NULLs) in NFS files in kernels >= 2.6.20
git
:
Junio C Hamano
Re: git-svnimport
Junio C Hamano
Re: [PATCH] git-mv: Keep moved index entries inact
Johannes Schindelin
Re: [PATCH] Fix approxidate("never") to always return 0
A Large Angry SCM
Re: [RFC] origin link for cherry-pick and revert
Juergen Ruehle
Re: [ANNOUNCE] Guilt 0.16
linux-netdev
:
Daniel Lezcano
getsockopt(TCP_DEFER_ACCEPT) value change
David Miller
Re: 2.6.27.18: bnx2/tg3: BUG: "scheduling while atomic" trying to ifenslave a seco...
Ingo Molnar
Re: [regression] nf_iterate(), BUG: unable to handle kernel NULL pointer dereference
Eric W. Biederman
[PATCH 14/20] net: Simplify pppol2tp pernet operations.
Jeff Kirsher
[net-2.6 PATCH 2/5] e1000e: increase swflag acquisition timeout for ICHx/PCH
git-commits-head
:
Linux Kernel Mailing List
ath9k_htc: Allocate URBs properly
Linux Kernel Mailing List
sm501: add power control callback
Linux Kernel Mailing List
MIPS: Cavium: Remove unused watchdog code.
Linux Kernel Mailing List
V4L/DVB (8976): af9015: Add USB ID for AVerMedia A309
Linux Kernel Mailing List
ARM: 5670/1: bcmring: add default configuration for bcmring arch
openbsd-misc
:
daniele.pilenga
snmpd hangs on 4.1 looking up hrSWRunTable
Christophe Rioux
Implementation example of snmp
Nick Holland
Re: booting openbsd on eee without cd-rom
Bryan Irvine
Re: OpenBSD 4.7 Released, May 19 2010
Cabillot Julien
Re: OpenBSD isakmpd and pf vs Cisco PIX or ASA
Colocation donated by:
Syndicate