Skip to content

Commit 566e2d8

Browse files
KAGA-KOKOFrederic Weisbecker
authored andcommitted
posix-timers: Consolidate signal queueing
Rename posix_timer_event() to posix_timer_queue_signal() as this is what the function is about. Consolidate the requeue pending and deactivation updates into that function as there is no point in doing this in all incarnations of posix timers. Signed-off-by: Thomas Gleixner <[email protected]> Signed-off-by: Frederic Weisbecker <[email protected]> Acked-by: Peter Zijlstra (Intel) <[email protected]>
1 parent 24aea4c commit 566e2d8

File tree

4 files changed

+15
-19
lines changed

4 files changed

+15
-19
lines changed

kernel/time/alarmtimer.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -574,15 +574,10 @@ static enum alarmtimer_restart alarm_handle_timer(struct alarm *alarm,
574574
it.alarm.alarmtimer);
575575
enum alarmtimer_restart result = ALARMTIMER_NORESTART;
576576
unsigned long flags;
577-
int si_private = 0;
578577

579578
spin_lock_irqsave(&ptr->it_lock, flags);
580579

581-
ptr->it_active = 0;
582-
if (ptr->it_interval)
583-
si_private = ++ptr->it_requeue_pending;
584-
585-
if (posix_timer_event(ptr, si_private) && ptr->it_interval) {
580+
if (posix_timer_queue_signal(ptr) && ptr->it_interval) {
586581
/*
587582
* Handle ignored signals and rearm the timer. This will go
588583
* away once we handle ignored signals proper. Ensure that

kernel/time/posix-cpu-timers.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -598,9 +598,9 @@ static void cpu_timer_fire(struct k_itimer *timer)
598598
/*
599599
* One-shot timer. Clear it as soon as it's fired.
600600
*/
601-
posix_timer_event(timer, 0);
601+
posix_timer_queue_signal(timer);
602602
cpu_timer_setexpires(ctmr, 0);
603-
} else if (posix_timer_event(timer, ++timer->it_requeue_pending)) {
603+
} else if (posix_timer_queue_signal(timer)) {
604604
/*
605605
* The signal did not get queued because the signal
606606
* was ignored, so we won't get any callback to

kernel/time/posix-timers.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -277,10 +277,17 @@ void posixtimer_rearm(struct kernel_siginfo *info)
277277
unlock_timer(timr, flags);
278278
}
279279

280-
int posix_timer_event(struct k_itimer *timr, int si_private)
280+
int posix_timer_queue_signal(struct k_itimer *timr)
281281
{
282+
int ret, si_private = 0;
282283
enum pid_type type;
283-
int ret;
284+
285+
lockdep_assert_held(&timr->it_lock);
286+
287+
timr->it_active = 0;
288+
if (timr->it_interval)
289+
si_private = ++timr->it_requeue_pending;
290+
284291
/*
285292
* FIXME: if ->sigq is queued we can race with
286293
* dequeue_signal()->posixtimer_rearm().
@@ -309,19 +316,13 @@ int posix_timer_event(struct k_itimer *timr, int si_private)
309316
*/
310317
static enum hrtimer_restart posix_timer_fn(struct hrtimer *timer)
311318
{
319+
struct k_itimer *timr = container_of(timer, struct k_itimer, it.real.timer);
312320
enum hrtimer_restart ret = HRTIMER_NORESTART;
313-
struct k_itimer *timr;
314321
unsigned long flags;
315-
int si_private = 0;
316322

317-
timr = container_of(timer, struct k_itimer, it.real.timer);
318323
spin_lock_irqsave(&timr->it_lock, flags);
319324

320-
timr->it_active = 0;
321-
if (timr->it_interval != 0)
322-
si_private = ++timr->it_requeue_pending;
323-
324-
if (posix_timer_event(timr, si_private)) {
325+
if (posix_timer_queue_signal(timr)) {
325326
/*
326327
* The signal was not queued due to SIG_IGN. As a
327328
* consequence the timer is not going to be rearmed from

kernel/time/posix-timers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ extern const struct k_clock clock_process;
3636
extern const struct k_clock clock_thread;
3737
extern const struct k_clock alarm_clock;
3838

39-
int posix_timer_event(struct k_itimer *timr, int si_private);
39+
int posix_timer_queue_signal(struct k_itimer *timr);
4040

4141
void common_timer_get(struct k_itimer *timr, struct itimerspec64 *cur_setting);
4242
int common_timer_set(struct k_itimer *timr, int flags,

0 commit comments

Comments
 (0)