mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Eric Dumazet <edumazet@google.com>
To: Anna-Maria Behnsen <anna-maria@linutronix.de>,
	Frederic Weisbecker <frederic@kernel.org>,
	 Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel <linux-kernel@vger.kernel.org>,
	Benjamin Segall <bsegall@google.com>,
	 Eric Dumazet <eric.dumazet@gmail.com>,
	Eric Dumazet <edumazet@google.com>
Subject: [PATCH V2 2/4] posix-timers: Initialise timer->it_id in posix_timer_add()
Date: Wed, 19 Feb 2025 12:55:20 +0000	[thread overview]
Message-ID: <20250219125522.2535263-3-edumazet@google.com> (raw)
In-Reply-To: <20250219125522.2535263-1-edumazet@google.com>

A timer is visible only when both timer->signal and timer->i_id
are set to their final values.

We can initialize timer->it_id sooner.

Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 kernel/time/posix-timers.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index 204a351a2fd3..1f73ea955756 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -114,6 +114,7 @@ static int posix_timer_add(struct k_itimer *timer)
 
 		spin_lock(&hash_lock);
 		if (!__posix_timers_find(head, sig, id)) {
+			timer->it_id = (timer_t)id;
 			hlist_add_head_rcu(&timer->t_hash, head);
 			spin_unlock(&hash_lock);
 			return id;
@@ -407,8 +408,7 @@ static int do_timer_create(clockid_t which_clock, struct sigevent *event,
 
 	/*
 	 * Add the timer to the hash table. The timer is not yet valid
-	 * because new_timer::it_signal is still NULL. The timer id is also
-	 * not yet visible to user space.
+	 * because new_timer::it_signal is still NULL.
 	 */
 	new_timer_id = posix_timer_add(new_timer);
 	if (new_timer_id < 0) {
@@ -416,7 +416,6 @@ static int do_timer_create(clockid_t which_clock, struct sigevent *event,
 		return new_timer_id;
 	}
 
-	new_timer->it_id = (timer_t) new_timer_id;
 	new_timer->it_clock = which_clock;
 	new_timer->kclock = kc;
 	new_timer->it_overrun = -1LL;
-- 
2.48.1.601.g30ceb7b040-goog


  parent reply	other threads:[~2025-02-19 12:55 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-19 12:55 [PATCH V2 0/4] posix-timers: Reduce spinlock contention Eric Dumazet
2025-02-19 12:55 ` [PATCH V2 1/4] posix-timers: Make next_posix_timer_id an atomic_t Eric Dumazet
2025-02-20  8:09   ` Thomas Gleixner
2025-02-20  8:49     ` Eric Dumazet
2025-02-20 14:04       ` Thomas Gleixner
2025-02-20 14:32         ` Thomas Gleixner
2025-02-20 15:55           ` Eric Dumazet
2025-02-20 16:19             ` Thomas Gleixner
2025-02-19 12:55 ` Eric Dumazet [this message]
2025-02-20  8:12   ` [PATCH V2 2/4] posix-timers: Initialise timer->it_id in posix_timer_add() Thomas Gleixner
2025-02-20  8:48     ` Eric Dumazet
2025-02-20 14:10       ` Thomas Gleixner
2025-02-19 12:55 ` [PATCH V2 3/4] posix-timers: Initialise timer->it_signal " Eric Dumazet
2025-02-20  8:19   ` Thomas Gleixner
2025-02-20  8:44     ` Eric Dumazet
2025-02-20 14:13       ` Thomas Gleixner
2025-02-19 12:55 ` [PATCH V2 4/4] posix-timers: Use RCU " Eric Dumazet
2025-02-19 19:38   ` David Laight
2025-02-19 19:46     ` Eric Dumazet
2025-02-24  9:33   ` Thomas Gleixner
2025-02-24  9:58     ` Eric Dumazet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250219125522.2535263-3-edumazet@google.com \
    --to=edumazet@google.com \
    --cc=anna-maria@linutronix.de \
    --cc=bsegall@google.com \
    --cc=eric.dumazet@gmail.com \
    --cc=frederic@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®