Received: by 2002:ab2:1347:0:b0:1f4:ac9d:b246 with SMTP id g7csp65630lqg; Wed, 10 Apr 2024 15:50:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUydtdkUXwaK9LWIrcPkfZqvGAHbzThfroi5BMAx7hRCURW2ca/rIWy+pVvf316tKgsaO+S+oWCN9ELj5CPogBKIbxvsIAv17R5fVUU+w== X-Google-Smtp-Source: AGHT+IGevhYsFDEtMkMMadB2hTFR8kYCPssgkQyhwmLWCK6Pu8z9B0I3B2SqvOVBUVREKlacFFuw X-Received: by 2002:a05:6a20:6a04:b0:1a7:9dd7:6a31 with SMTP id p4-20020a056a206a0400b001a79dd76a31mr1061415pzk.31.1712789418364; Wed, 10 Apr 2024 15:50:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712789418; cv=pass; d=google.com; s=arc-20160816; b=t4Bcv7R2WptWHI+iJL2pKxcrzIGt/TWZKqdlUIiPp9KyrMEM3sTNhcaPb1guhA0mzZ xtvG8r8uC7M6w4nCvylu13gZncmHd3ASDq8h4QmqmFzzAYzMhijcZP71KY4J0iwbHYY0 LuTZw5AgM3dBGKA7zL7cioTcjFoKya73k4xapqfcIB6cMpU+HeIPo3LIYc1YUIu71irh MnozEuG1sRpFouDJPmbMz645DdiMU2+vBeBJeGbjH+YnZ+hZoijaS+ELhU7Ys+KdmtB1 NnYE0407BVwIAL6YL/A5QR26VHxiQO0jqQwMuWn08LSfNMXuFgLCKy4JE1StpETXZD4b qlkw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=date:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:subject:cc:to:from:dkim-signature :dkim-signature:message-id; bh=6GMzkiAHRvFkC+fzhDyL20WSpzWzUN7g85C6W+O5hxI=; fh=joBs/8L+orz77ylyCy6wqNwwi35f7sYhLR+/TQjQjhI=; b=EgPiCVuQ4y7th6gJX1+DiopAB1iFu/niXVKaXSYQqf82n7H5kkluwCmC2pbJ90yKPi XrLZebRUo926ojmoJDL7c5ax4/E0CfugK3OukrNEi0qIyy9Y1J9VzoccpZwGPlivAnJ3 +Xuj3pMP/wNuA/B9Us39tvtYW1zIXLoPBgmJ7/lewn6nR5Gih1G4a1dMuERntH32k9Ht Nu7eiOoHuBLr9KMFrpvd/XO6Qx4xxaTrDOFoKwqq538B/LAlxLgdSffrCkSPYeRkJmh4 stRHouN1dz4ovwjEwRV4n94cCdL3Y3iIcFKJizp8g6v7z+19IlREeESkNiWxn0KUxOfO w4nQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=HEm37kCg; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-139472-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139472-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 139-20020a630291000000b005f072090d58si85076pgc.743.2024.04.10.15.50.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 15:50:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-139472-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=HEm37kCg; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-139472-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139472-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 0939E282D4E for ; Wed, 10 Apr 2024 22:50:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2F5A551033; Wed, 10 Apr 2024 22:46:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="HEm37kCg"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="wKIWlwuE" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 96A0F50A79 for ; Wed, 10 Apr 2024 22:46:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712789209; cv=none; b=fUCFX700RVWEDZdOd2P9gOoJxmK6nhmR1ecO4AoovN7QI80EGZqTNPuIx4A+NgLpXRXGHHhYcQdTPjc5YeCkSOW9yWwhvLdqdg5XY8a0iH3b3u4HqsHFIMJSvAxB5LJKLmxkBp2cy0AXQw39ggfLFsf+sPYWRp7xF5yvTAvV0eY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712789209; c=relaxed/simple; bh=pmCbpSGE0XRK0ukKqo1U6qxPo/JyzQDl0umJpcWyXGY=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=Ig+F5iJOsb9ndo0oZnyV6p1k6QlH1N0tTODxwyz3Bk1jAKHKSdNoj5ENfQX3hNTnRhs94q7pZ1x6EKsPLkI6RnMQg40vkSd4kegchaTxipPT69BJCArbTqBKGGlLJt3z9+woH5rPQ2dsj1fK8sCjx4+Xstr+yxDffh/Y0dfJibY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=HEm37kCg; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=wKIWlwuE; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Message-ID: <20240410165552.133844381@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1712789206; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=6GMzkiAHRvFkC+fzhDyL20WSpzWzUN7g85C6W+O5hxI=; b=HEm37kCgKIYq1xXA7Xhxbl8h4sWdXv5kXz//YqGI7k0AiHBNWfn5QH7xh2DBmS5ZoquJGq PMTySSzPlY741xYVP2ymhWjlggwQxjlmxGLEcQewa0YooznKYwuyZLoqFALSGSFsxciM1F CJ05jPO5CelgyoR9ByWYa9DoMeLmqtCh1hrnaZuOA7WVSYK+AHI+0fSWa8V9o6PlaApjyI GOou4O7ThGoRJadYOM4Zmj6Kt5/ODvp5tf9dps9lrbQeBjoUGAHRsAucLYFGmWsPxxDtqN liYOawtC7FkrWIdKaDZdFRSoOTYCKXOEPs4GoSV+W2WhCZh+zGscw0J8EhEmmw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1712789206; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=6GMzkiAHRvFkC+fzhDyL20WSpzWzUN7g85C6W+O5hxI=; b=wKIWlwuE0WHxWUlDrbEqKDSA7uQv9EvXU/k4BPGT34IeHBUL/ycWuYeH3SxjCx0NvXEnmi SrL/KGTagzcUCYAQ== From: Thomas Gleixner To: LKML Cc: Anna-Maria Behnsen , Frederic Weisbecker , John Stultz , Peter Zijlstra , Ingo Molnar , Stephen Boyd , Eric Biederman , Oleg Nesterov Subject: [patch V2 19/50] posix-timers: Convert timer list to hlist References: <20240410164558.316665885@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Date: Thu, 11 Apr 2024 00:46:45 +0200 (CEST) No requirement for a real list. Spare a few bytes. Signed-off-by: Thomas Gleixner Reviewed-by: Frederic Weisbecker --- fs/proc/base.c | 6 +++--- include/linux/posix-timers.h | 2 +- include/linux/sched/signal.h | 2 +- init/init_task.c | 2 +- kernel/fork.c | 2 +- kernel/time/posix-timers.c | 19 ++++++++----------- 6 files changed, 15 insertions(+), 18 deletions(-) --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -2456,13 +2456,13 @@ static void *timers_start(struct seq_fil 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 [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); --- a/include/linux/posix-timers.h +++ b/include/linux/posix-timers.h @@ -158,7 +158,7 @@ static inline void posix_cputimers_init_ * @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; --- a/include/linux/sched/signal.h +++ b/include/linux/sched/signal.h @@ -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; --- a/init/init_task.c +++ b/init/init_task.c @@ -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, }, --- a/kernel/fork.c +++ b/kernel/fork.c @@ -1876,7 +1876,7 @@ static int copy_signal(unsigned long clo 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 --- a/kernel/time/posix-timers.c +++ b/kernel/time/posix-timers.c @@ -515,7 +515,7 @@ static int do_timer_create(clockid_t whi spin_lock_irq(¤t->sighand->siglock); /* This makes the timer valid in the hash table */ WRITE_ONCE(new_timer->it_signal, current->signal); - list_add(&new_timer->list, ¤t->signal->posix_timers); + hlist_add_head(&new_timer->list, ¤t->signal->posix_timers); spin_unlock_irq(¤t->sighand->siglock); /* * After unlocking sighand::siglock @new_timer is subject to @@ -1025,7 +1025,7 @@ SYSCALL_DEFINE1(timer_delete, timer_t, t } spin_lock(¤t->sighand->siglock); - list_del(&timer->list); + hlist_del(&timer->list); spin_unlock(¤t->sighand->siglock); /* * A concurrent lookup could check timer::it_signal lockless. It @@ -1075,7 +1075,7 @@ static void itimer_delete(struct k_itime 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 @@ static void itimer_delete(struct k_itime */ 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,