public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Cyrill Gorcunov <gorcunov@gmail.com>,
	Frederic Weisbecker <frederic@kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Anna-Maria Behnsen <anna-maria@linutronix.de>,
	Benjamin Segall <bsegall@google.com>,
	Eric Dumazet <edumazet@google.com>,
	Andrey Vagin <avagin@openvz.org>,
	Pavel Tikhomirov <ptikhomirov@virtuozzo.com>,
	Peter Zijlstra <peterz@infradead.org>
Subject: Re: [patch V3a 17/18] posix-timers: Provide a mechanism to allocate a given timer ID
Date: Wed, 12 Mar 2025 12:24:54 +0100	[thread overview]
Message-ID: <87bju6ze2h.ffs@tglx> (raw)
In-Reply-To: <Z9E-L1pvl1j_4E3f@grain>

On Wed, Mar 12 2025 at 10:56, Cyrill Gorcunov wrote:
> On Tue, Mar 11, 2025 at 11:32:58PM +0100, Frederic Weisbecker wrote:
> ...
>> > 
>> > Recreating two timers with IDs 1000000 and 2000000 takes 1.5 seconds with
>> > the create/delete method. With the prctl() it takes 3 microseconds.
>> > 
>> > Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
>> 
>> Reviewed-by: Frederic Weisbecker <frederic@kernel.org>
>
> One thing which just popped up in my head -- this interface may be used not
> only by criu but any application which wants to create timer with specified
> id (hell know why, but whatever). As far as I understand we don't provide

Sure. Application developers are creative :)

> an interface to _read_ this property, don't we? Thus criu will restore such
> application which already has this bit set incorrectly.

Delta patch below.

Thanks,

        tglx
---
--- a/include/uapi/linux/prctl.h
+++ b/include/uapi/linux/prctl.h
@@ -362,5 +362,6 @@ struct prctl_mm_map {
 #define PR_TIMER_CREATE_RESTORE_IDS		77
 # define PR_TIMER_CREATE_RESTORE_IDS_OFF	0
 # define PR_TIMER_CREATE_RESTORE_IDS_ON		1
+# define PR_TIMER_CREATE_RESTORE_IDS_GET	2
 
 #endif /* _LINUX_PRCTL_H */
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -391,11 +391,17 @@ static enum hrtimer_restart posix_timer_
 
 long posixtimer_create_prctl(unsigned long ctrl)
 {
-	if (ctrl > PR_TIMER_CREATE_RESTORE_IDS_ON)
-		return -EINVAL;
-
-	current->signal->timer_create_restore_ids = ctrl == PR_TIMER_CREATE_RESTORE_IDS_ON;
-	return 0;
+	switch (ctrl) {
+	case PR_TIMER_CREATE_RESTORE_IDS_OFF:
+		current->signal->timer_create_restore_ids = 0;
+		return 0;
+	case PR_TIMER_CREATE_RESTORE_IDS_ON:
+		current->signal->timer_create_restore_ids = 0;
+		return 0;
+	case PR_TIMER_CREATE_RESTORE_IDS_GET:
+		return current->signal->timer_create_restore_ids;
+	}
+	return -EINVAL;
 }
 
 static struct pid *good_sigevent(sigevent_t * event)

  reply	other threads:[~2025-03-12 11:24 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-08 16:48 [patch V3 00/18] posix-timers: Rework the global hash table and provide a sane mechanism for CRIU Thomas Gleixner
2025-03-08 16:48 ` [patch V3 01/18] posix-timers: Ensure that timer initialization is fully visible Thomas Gleixner
2025-03-08 21:39   ` Frederic Weisbecker
2025-03-13 11:31   ` [tip: timers/core] " tip-bot2 for Thomas Gleixner
2025-03-08 16:48 ` [patch V3 02/18] posix-timers: Initialise timer before adding it to the hash table Thomas Gleixner
2025-03-11 13:25   ` Frederic Weisbecker
2025-03-11 14:16     ` Thomas Gleixner
2025-03-13 11:31   ` [tip: timers/core] " tip-bot2 for Eric Dumazet
2025-03-08 16:48 ` [patch V3 03/18] posix-timers: Add cond_resched() to posix_timer_add() search loop Thomas Gleixner
2025-03-13 11:31   ` [tip: timers/core] " tip-bot2 for Eric Dumazet
2025-03-08 16:48 ` [patch V3 04/18] posix-timers: Cleanup includes Thomas Gleixner
2025-03-13 11:31   ` [tip: timers/core] " tip-bot2 for Thomas Gleixner
2025-03-08 16:48 ` [patch V3 05/18] posix-timers: Remove a few paranoid warnings Thomas Gleixner
2025-03-13 11:31   ` [tip: timers/core] " tip-bot2 for Thomas Gleixner
2025-03-08 16:48 ` [patch V3 06/18] posix-timers: Remove SLAB_PANIC from kmem cache Thomas Gleixner
2025-03-13 11:31   ` [tip: timers/core] " tip-bot2 for Thomas Gleixner
2025-03-08 16:48 ` [patch V3 07/18] posix-timers: Use guards in a few places Thomas Gleixner
2025-03-13 11:31   ` [tip: timers/core] " tip-bot2 for Thomas Gleixner
2025-03-08 16:48 ` [patch V3 08/18] posix-timers: Simplify lock/unlock_timer() Thomas Gleixner
2025-03-13 11:31   ` [tip: timers/core] " tip-bot2 for Thomas Gleixner
2025-03-08 16:48 ` [patch V3 09/18] posix-timers: Rework timer removal Thomas Gleixner
2025-03-09 23:17   ` Frederic Weisbecker
2025-03-10  6:33     ` Thomas Gleixner
2025-03-10  8:13   ` [patch V3a " Thomas Gleixner
2025-03-13 11:31     ` [tip: timers/core] " tip-bot2 for Thomas Gleixner
2025-03-08 16:48 ` [patch V3 10/18] posix-timers: Make lock_timer() use guard() Thomas Gleixner
2025-03-10 11:57   ` Frederic Weisbecker
2025-03-10 17:36     ` Thomas Gleixner
2025-03-10 22:16       ` Frederic Weisbecker
2025-03-13 11:31   ` [tip: timers/core] " tip-bot2 for Peter Zijlstra
2025-03-08 16:48 ` [patch V3 11/18] posix-timers: Make signal_struct:: Next_posix_timer_id an atomic_t Thomas Gleixner
2025-03-10 22:57   ` Frederic Weisbecker
2025-03-11 13:41   ` Frederic Weisbecker
2025-03-13 11:31   ` [tip: timers/core] " tip-bot2 for Eric Dumazet
2025-03-08 16:48 ` [patch V3 12/18] posix-timers: Improve hash table performance Thomas Gleixner
2025-03-11 13:44   ` Frederic Weisbecker
2025-03-13 11:31   ` [tip: timers/core] " tip-bot2 for Thomas Gleixner
2025-03-08 16:48 ` [patch V3 13/18] posix-timers: Switch to jhash32() Thomas Gleixner
2025-03-13 11:31   ` [tip: timers/core] " tip-bot2 for Thomas Gleixner
2025-03-08 16:48 ` [patch V3 14/18] posix-timers: Avoid false cacheline sharing Thomas Gleixner
2025-03-11 13:53   ` Frederic Weisbecker
2025-03-13 11:31   ` [tip: timers/core] " tip-bot2 for Thomas Gleixner
2025-03-13 22:13   ` [patch V3 14/18] " David Laight
2025-03-17  6:20   ` Nysal Jan K.A.
2025-03-08 16:48 ` [patch V3 15/18] posix-timers: Make per process list RCU safe Thomas Gleixner
2025-03-11 15:29   ` Frederic Weisbecker
2025-03-13 11:31   ` [tip: timers/core] " tip-bot2 for Thomas Gleixner
2025-03-08 16:48 ` [patch V3 16/18] posix-timers: Dont iterate /proc/$PID/timers with sighand:: Siglock held Thomas Gleixner
2025-03-08 22:38   ` Cyrill Gorcunov
2025-03-11 15:26   ` Frederic Weisbecker
2025-03-13 11:31   ` [tip: timers/core] " tip-bot2 for Thomas Gleixner
2025-03-08 16:48 ` [patch V3 17/18] posix-timers: Provide a mechanism to allocate a given timer ID Thomas Gleixner
2025-03-08 22:25   ` Cyrill Gorcunov
2025-03-11 21:35   ` Frederic Weisbecker
2025-03-11 22:05     ` Thomas Gleixner
2025-03-11 22:07       ` [patch V3a " Thomas Gleixner
2025-03-11 22:32         ` Frederic Weisbecker
2025-03-12  7:56           ` Cyrill Gorcunov
2025-03-12 11:24             ` Thomas Gleixner [this message]
2025-03-12 11:31               ` Thomas Gleixner
2025-03-12 12:41               ` Cyrill Gorcunov
2025-03-12 17:45                 ` Thomas Gleixner
2025-03-13 11:31         ` [tip: timers/core] " tip-bot2 for Thomas Gleixner
2025-03-12 12:59     ` [patch V3 17/18] " Cyrill Gorcunov
2025-03-08 16:48 ` [patch V3 18/18] selftests/timers/posix-timers: Add a test for exact allocation mode Thomas Gleixner
2025-03-10  8:11   ` [patch V3a " Thomas Gleixner
2025-03-11 21:44     ` Frederic Weisbecker
2025-03-13 11:31     ` [tip: timers/core] " tip-bot2 for Thomas Gleixner

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=87bju6ze2h.ffs@tglx \
    --to=tglx@linutronix.de \
    --cc=anna-maria@linutronix.de \
    --cc=avagin@openvz.org \
    --cc=bsegall@google.com \
    --cc=edumazet@google.com \
    --cc=frederic@kernel.org \
    --cc=gorcunov@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=ptikhomirov@virtuozzo.com \
    /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