From: Peter Zijlstra <peterz@infradead.org>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: LKML <linux-kernel@vger.kernel.org>,
Anna-Maria Behnsen <anna-maria@linutronix.de>,
Frederic Weisbecker <frederic@kernel.org>,
Benjamin Segall <bsegall@google.com>,
Eric Dumazet <edumazet@google.com>,
Andrey Vagin <avagin@openvz.org>,
Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Subject: Re: [patch 04/11] posix-timers: Remove pointless unlock_timer() wrapper
Date: Mon, 24 Feb 2025 22:55:55 +0100 [thread overview]
Message-ID: <20250224215555.GF11590@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <87seo3fak1.ffs@tglx>
On Mon, Feb 24, 2025 at 07:43:26PM +0100, Thomas Gleixner wrote:
> On Mon, Feb 24 2025 at 17:21, Peter Zijlstra wrote:
> > On Mon, Feb 24, 2025 at 11:15:28AM +0100, Thomas Gleixner wrote:
> >> It's just a wrapper around spin_unlock_irqrestore() with zero value.
> >
> > Well, I disagree... the value is that is matches lock_timer(). Both in
> > naming and in argument types.
>
> Sure, but it's not used consistently as we have places where
> lock_timer() is not involved.
>
> > @@ -327,14 +350,13 @@ bool posixtimer_deliver_signal(struct ke
> > * Release siglock to ensure proper locking order versus
> > * timr::it_lock. Keep interrupts disabled.
> > */
> > - spin_unlock(¤t->sighand->siglock);
> > + guard(spinlock)(¤t->sighand->siglock);
>
> How is that equivalent?
I R idiot :-)
> So the resulting code is:
>
> scoped_guard (lock_timer, timer_id) {
> struct k_itimer *timr = __guard_ptr(lock_timer)(&scope);
> const struct k_clock *kc;
>
> memset(setting, 0, sizeof(*setting));
> kc = timr->kclock;
> if (WARN_ON_ONCE(!kc || !kc->timer_get))
> return -EINVAL;
>
> return 0;
> }
> return -EINVAL;
>
> I had to go and stare at the guard/class muck 10 times to convince
> myself, that this actually works. This really wants to be express the
> condition of the scoped_guard() somehow, e.g. scoped_cond_guard() or
> such.
Right, so the alternative form is something like:
scoped_cond_guard (lock_timer, return -EINVAL, timer_id) {
struct k_itimer *timr = __guard_ptr(lock_timer)(&scope);
const struct k_clock *kc;
memset(setting, 0, sizeof(*setting));
kc = timr->kclock;
if (WARN_ON_ONCE(!kc || !kc->timer_get))
return -EINVAL;
}
return 0;
Is that really so much better?
> > /* Delete a POSIX.1b interval timer. */
> > SYSCALL_DEFINE1(timer_delete, timer_t, timer_id)
> > {
> > - return posix_timer_delete(NULL, timer_id);
> > + scoped_guard (lock_timer, timer_id) {
> > + posix_timer_invalidate(scope.lock, scope.flags);
> > + scoped_guard_end(lock_timer);
> > + posix_timer_unhash_and_free(scope.lock);
>
> Not sure whether it's a good idea to free the scope.lock and not
> scope.timer :)
There is no scope.timer, the way this work is that the main pointer is
.lock, per the __DEFINE_UNLOCK_GUARD() helper.
I said there were rough edges :-/
Anyway, should I continue poking at this to see if I can clean it up /
extract more useful helpers.
Or shall I just let it be.
next prev parent reply other threads:[~2025-02-24 21:55 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-24 10:15 [patch 00/11] posix-timers: Rework the global hash table and provide a sane mechanism for CRIU Thomas Gleixner
2025-02-24 10:15 ` [patch 01/11] posix-timers: Initialise timer before adding it to the hash table Thomas Gleixner
2025-02-24 10:15 ` [patch 02/11] posix-timers: Add cond_resched() to posix_timer_add() search loop Thomas Gleixner
2025-02-24 10:15 ` [patch 03/11] posix-timers: Cleanup includes Thomas Gleixner
2025-02-24 10:15 ` [patch 04/11] posix-timers: Remove pointless unlock_timer() wrapper Thomas Gleixner
2025-02-24 16:21 ` Peter Zijlstra
2025-02-24 18:43 ` Thomas Gleixner
2025-02-24 21:55 ` Peter Zijlstra [this message]
2025-02-24 10:15 ` [patch 05/11] posix-timers: Rework timer removal Thomas Gleixner
2025-02-24 10:15 ` [patch 06/11] posix-timers: Make signal_struct::next_posix_timer_id an atomic_t Thomas Gleixner
2025-02-24 13:20 ` Peter Zijlstra
2025-02-24 13:34 ` Eric Dumazet
2025-02-24 19:38 ` Thomas Gleixner
2025-02-24 10:15 ` [patch 07/11] posix-timers: Improve hash table performance Thomas Gleixner
2025-02-24 19:45 ` Thomas Gleixner
2025-02-24 10:15 ` [patch 08/11] posix-timers: Make per process list RCU safe Thomas Gleixner
2025-02-24 10:15 ` [patch 09/11] posix-timers: Dont iterate /proc/$PID/timers with sighand::siglock held Thomas Gleixner
2025-02-24 10:15 ` [patch 10/11] posix-timers: Provide a mechanism to allocate a given timer ID Thomas Gleixner
2025-02-24 10:15 ` [patch 11/11] selftests/timers/posix-timers: Add a test for exact allocation mode 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=20250224215555.GF11590@noisy.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=anna-maria@linutronix.de \
--cc=avagin@openvz.org \
--cc=bsegall@google.com \
--cc=edumazet@google.com \
--cc=frederic@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ptikhomirov@virtuozzo.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.