* [PATCH] posix-cpu-timers: Fix spuriously armed 0-value itimer
@ 2021-09-13 14:53 Frederic Weisbecker
2021-09-23 9:57 ` [tip: timers/urgent] posix-cpu-timers: Prevent " tip-bot2 for Frederic Weisbecker
2021-09-26 12:58 ` [PATCH] posix-cpu-timers: Fix " Stafford Horne
0 siblings, 2 replies; 3+ messages in thread
From: Frederic Weisbecker @ 2021-09-13 14:53 UTC (permalink / raw)
To: Thomas Gleixner; +Cc: LKML, Frederic Weisbecker, Victor Stinner, Peter Zijlstra
Resetting/stopping an itimer eventually leads to it being reprogrammed
with an actual "0" value. As a result the itimer expires on the next
tick, triggering an unexpected signal.
To fix this, make sure that
struct signal_struct::it[CPUCLOCK_PROF/VIRT]::expires is set to 0 when
setitimer() passes a 0 it_value, indicating that the timer must stop.
Reported-by: Victor Stinner <vstinner@redhat.com>
Fixes: 406dd42bd1ba ("posix-cpu-timers: Force next expiration recalc after itimer reset")
Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
Cc: Peter Zijlstra (Intel) <peterz@infradead.org>
---
kernel/time/posix-cpu-timers.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c
index ee736861b18f..643d412ac623 100644
--- a/kernel/time/posix-cpu-timers.c
+++ b/kernel/time/posix-cpu-timers.c
@@ -1404,7 +1404,8 @@ void set_process_cpu_timer(struct task_struct *tsk, unsigned int clkid,
}
}
- *newval += now;
+ if (*newval)
+ *newval += now;
}
/*
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [tip: timers/urgent] posix-cpu-timers: Prevent spuriously armed 0-value itimer
2021-09-13 14:53 [PATCH] posix-cpu-timers: Fix spuriously armed 0-value itimer Frederic Weisbecker
@ 2021-09-23 9:57 ` tip-bot2 for Frederic Weisbecker
2021-09-26 12:58 ` [PATCH] posix-cpu-timers: Fix " Stafford Horne
1 sibling, 0 replies; 3+ messages in thread
From: tip-bot2 for Frederic Weisbecker @ 2021-09-23 9:57 UTC (permalink / raw)
To: linux-tip-commits
Cc: Victor Stinner, Chris Hixon, Frederic Weisbecker,
Thomas Gleixner, x86, linux-kernel
The following commit has been merged into the timers/urgent branch of tip:
Commit-ID: 8cd9da85d2bd87ce889043e7b1735723dd10eb89
Gitweb: https://git.kernel.org/tip/8cd9da85d2bd87ce889043e7b1735723dd10eb89
Author: Frederic Weisbecker <frederic@kernel.org>
AuthorDate: Mon, 13 Sep 2021 16:53:32 +02:00
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Thu, 23 Sep 2021 11:53:51 +02:00
posix-cpu-timers: Prevent spuriously armed 0-value itimer
Resetting/stopping an itimer eventually leads to it being reprogrammed
with an actual "0" value. As a result the itimer expires on the next
tick, triggering an unexpected signal.
To fix this, make sure that
struct signal_struct::it[CPUCLOCK_PROF/VIRT]::expires is set to 0 when
setitimer() passes a 0 it_value, indicating that the timer must stop.
Fixes: 406dd42bd1ba ("posix-cpu-timers: Force next expiration recalc after itimer reset")
Reported-by: Victor Stinner <vstinner@redhat.com>
Reported-by: Chris Hixon <linux-kernel-bugs@hixontech.com>
Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20210913145332.232023-1-frederic@kernel.org
---
kernel/time/posix-cpu-timers.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c
index ee73686..643d412 100644
--- a/kernel/time/posix-cpu-timers.c
+++ b/kernel/time/posix-cpu-timers.c
@@ -1404,7 +1404,8 @@ void set_process_cpu_timer(struct task_struct *tsk, unsigned int clkid,
}
}
- *newval += now;
+ if (*newval)
+ *newval += now;
}
/*
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] posix-cpu-timers: Fix spuriously armed 0-value itimer
2021-09-13 14:53 [PATCH] posix-cpu-timers: Fix spuriously armed 0-value itimer Frederic Weisbecker
2021-09-23 9:57 ` [tip: timers/urgent] posix-cpu-timers: Prevent " tip-bot2 for Frederic Weisbecker
@ 2021-09-26 12:58 ` Stafford Horne
1 sibling, 0 replies; 3+ messages in thread
From: Stafford Horne @ 2021-09-26 12:58 UTC (permalink / raw)
To: Frederic Weisbecker
Cc: Thomas Gleixner, LKML, Victor Stinner, Peter Zijlstra, GLIBC patches
Hello,
Ccing libc-alpha,
On Mon, Sep 13, 2021 at 04:53:32PM +0200, Frederic Weisbecker wrote:
> Resetting/stopping an itimer eventually leads to it being reprogrammed
> with an actual "0" value. As a result the itimer expires on the next
> tick, triggering an unexpected signal.
Thanks for this I just tracked down the same issue.
I just wanted to give an FYI in case anyone else notices this.
This was causing gprof (gcc -pg) to fail. I noticed this when running the glibc
test suite, tests: gmon/tst-gmon-static, gmon/tst-gmon
Gprof uses ITIMER_PROF, as per:
- https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/posix/profil.c;h=fbf1184df1ccc6e1d2098f92c7d87fc28f5a8f09;hb=HEAD
I was seeing the extra SIGPROF signal after profil de-registered the timer and
signal handler. The spurious signal causes all profiled programs to be killed
and collect no gprof data.
-Stafford
> To fix this, make sure that
> struct signal_struct::it[CPUCLOCK_PROF/VIRT]::expires is set to 0 when
> setitimer() passes a 0 it_value, indicating that the timer must stop.
>
> Reported-by: Victor Stinner <vstinner@redhat.com>
> Fixes: 406dd42bd1ba ("posix-cpu-timers: Force next expiration recalc after itimer reset")
> Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
> Cc: Peter Zijlstra (Intel) <peterz@infradead.org>
> ---
> kernel/time/posix-cpu-timers.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c
> index ee736861b18f..643d412ac623 100644
> --- a/kernel/time/posix-cpu-timers.c
> +++ b/kernel/time/posix-cpu-timers.c
> @@ -1404,7 +1404,8 @@ void set_process_cpu_timer(struct task_struct *tsk, unsigned int clkid,
> }
> }
>
> - *newval += now;
> + if (*newval)
> + *newval += now;
> }
>
> /*
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-09-26 12:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-13 14:53 [PATCH] posix-cpu-timers: Fix spuriously armed 0-value itimer Frederic Weisbecker
2021-09-23 9:57 ` [tip: timers/urgent] posix-cpu-timers: Prevent " tip-bot2 for Frederic Weisbecker
2021-09-26 12:58 ` [PATCH] posix-cpu-timers: Fix " Stafford Horne
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).