]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
posix-timers: Convert timer list to hlist
authorThomas Gleixner <tglx@linutronix.de>
Mon, 10 Jun 2024 16:42:28 +0000 (18:42 +0200)
committerFrederic Weisbecker <frederic@kernel.org>
Mon, 29 Jul 2024 19:57:35 +0000 (21:57 +0200)
No requirement for a real list. Spare a few bytes.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
fs/proc/base.c
include/linux/posix-timers.h
include/linux/sched/signal.h
init/init_task.c
kernel/fork.c
kernel/time/posix-timers.c

index 72a1acd03675cc77da7320a14426f40e6fc9513f..dd579332a7f8abfef7a075a0efae6f0d86411058 100644 (file)
@@ -2456,13 +2456,13 @@ static void *timers_start(struct seq_file *m, loff_t *pos)
        if (!tp->sighand)
                return ERR_PTR(-ESRCH);
 
-       return seq_list_start(&tp->task->signal->posix_timers, *pos);
+       return seq_hlist_start(&tp->task->signal->posix_timers, *pos);
 }
 
 static void *timers_next(struct seq_file *m, void *v, loff_t *pos)
 {
        struct timers_private *tp = m->private;
-       return seq_list_next(v, &tp->task->signal->posix_timers, pos);
+       return seq_hlist_next(v, &tp->task->signal->posix_timers, pos);
 }
 
 static void timers_stop(struct seq_file *m, void *v)
@@ -2491,7 +2491,7 @@ static int show_timer(struct seq_file *m, void *v)
                [SIGEV_THREAD] = "thread",
        };
 
-       timer = list_entry((struct list_head *)v, struct k_itimer, list);
+       timer = hlist_entry((struct hlist_node *)v, struct k_itimer, list);
        notify = timer->it_sigev_notify;
 
        seq_printf(m, "ID: %d\n", timer->it_id);
index dc7b738de2998383552db62cd08e8d84724e456a..453691710839645d966af8b852f88af254b0ffc2 100644 (file)
@@ -158,7 +158,7 @@ static inline void posix_cputimers_init_work(void) { }
  * @rcu:               RCU head for freeing the timer.
  */
 struct k_itimer {
-       struct list_head        list;
+       struct hlist_node       list;
        struct hlist_node       t_hash;
        spinlock_t              it_lock;
        const struct k_clock    *kclock;
index 0a0e23c45406fe477a8c32534326bde451e4a45a..622fdef78e141b463b2a20a8ebe243f9f2672841 100644 (file)
@@ -137,7 +137,7 @@ struct signal_struct {
 
        /* POSIX.1b Interval Timers */
        unsigned int            next_posix_timer_id;
-       struct list_head        posix_timers;
+       struct hlist_head       posix_timers;
 
        /* ITIMER_REAL timer for the process */
        struct hrtimer real_timer;
index eeb110c65fe22f16b6cf1974a5caa394c08ff8e0..5d0399bc8d2f825af51ec53a9f603407288074d2 100644 (file)
@@ -29,7 +29,7 @@ static struct signal_struct init_signals = {
        .cred_guard_mutex = __MUTEX_INITIALIZER(init_signals.cred_guard_mutex),
        .exec_update_lock = __RWSEM_INITIALIZER(init_signals.exec_update_lock),
 #ifdef CONFIG_POSIX_TIMERS
-       .posix_timers = LIST_HEAD_INIT(init_signals.posix_timers),
+       .posix_timers   = HLIST_HEAD_INIT,
        .cputimer       = {
                .cputime_atomic = INIT_CPUTIME_ATOMIC,
        },
index cc760491f20127f44ab5db96ec7e858dcce77f54..c1b343cba5601ca1a1727557a61f4af5881c3652 100644 (file)
@@ -1861,7 +1861,7 @@ static int copy_signal(unsigned long clone_flags, struct task_struct *tsk)
        prev_cputime_init(&sig->prev_cputime);
 
 #ifdef CONFIG_POSIX_TIMERS
-       INIT_LIST_HEAD(&sig->posix_timers);
+       INIT_HLIST_HEAD(&sig->posix_timers);
        hrtimer_init(&sig->real_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
        sig->real_timer.function = it_real_fn;
 #endif
index 53a993e4dbfad35eea1b24fe20d1e3667758e919..fa75e9493fd6107e5dfb68b5a80bb2f0c8ff6b1e 100644 (file)
@@ -515,7 +515,7 @@ static int do_timer_create(clockid_t which_clock, struct sigevent *event,
        spin_lock_irq(&current->sighand->siglock);
        /* This makes the timer valid in the hash table */
        WRITE_ONCE(new_timer->it_signal, current->signal);
-       list_add(&new_timer->list, &current->signal->posix_timers);
+       hlist_add_head(&new_timer->list, &current->signal->posix_timers);
        spin_unlock_irq(&current->sighand->siglock);
        /*
         * After unlocking sighand::siglock @new_timer is subject to
@@ -1025,7 +1025,7 @@ retry_delete:
        }
 
        spin_lock(&current->sighand->siglock);
-       list_del(&timer->list);
+       hlist_del(&timer->list);
        spin_unlock(&current->sighand->siglock);
        /*
         * A concurrent lookup could check timer::it_signal lockless. It
@@ -1075,7 +1075,7 @@ retry_delete:
 
                goto retry_delete;
        }
-       list_del(&timer->list);
+       hlist_del(&timer->list);
 
        /*
         * Setting timer::it_signal to NULL is technically not required
@@ -1096,22 +1096,19 @@ retry_delete:
  */
 void exit_itimers(struct task_struct *tsk)
 {
-       struct list_head timers;
-       struct k_itimer *tmr;
+       struct hlist_head timers;
 
-       if (list_empty(&tsk->signal->posix_timers))
+       if (hlist_empty(&tsk->signal->posix_timers))
                return;
 
        /* Protect against concurrent read via /proc/$PID/timers */
        spin_lock_irq(&tsk->sighand->siglock);
-       list_replace_init(&tsk->signal->posix_timers, &timers);
+       hlist_move_list(&tsk->signal->posix_timers, &timers);
        spin_unlock_irq(&tsk->sighand->siglock);
 
        /* The timers are not longer accessible via tsk::signal */
-       while (!list_empty(&timers)) {
-               tmr = list_first_entry(&timers, struct k_itimer, list);
-               itimer_delete(tmr);
-       }
+       while (!hlist_empty(&timers))
+               itimer_delete(hlist_entry(timers.first, struct k_itimer, list));
 }
 
 SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,