All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
	Andrew Cooper <andrew.cooper3@citrix.com>
Subject: Re: [PATCH v4 6/8] x86/HPET: simplify "expire" check a little in reprogram_hpet_evt_channel()
Date: Thu, 22 Jan 2026 12:30:35 +0100	[thread overview]
Message-ID: <aXIKWwYYXf9UgplM@Mac.lan> (raw)
In-Reply-To: <73daede9-d7ac-44bf-a018-b76d39b3eeb4@suse.com>

On Thu, Jan 22, 2026 at 11:15:49AM +0100, Jan Beulich wrote:
> On 22.01.2026 11:10, Roger Pau Monné wrote:
> > On Thu, Jan 22, 2026 at 10:28:51AM +0100, Jan Beulich wrote:
> >> On 22.01.2026 10:18, Roger Pau Monné wrote:
> >>> On Mon, Nov 17, 2025 at 03:39:30PM +0100, Jan Beulich wrote:
> >>>> When this was added, the log message was updated correctly, but the zero
> >>>> case was needlessly checked separately: hpet_broadcast_enter() had a zero
> >>>> check added at the same time, while handle_hpet_broadcast() can't possibly
> >>>> pass 0 here anyway.
> >>>>
> >>>> Fixes: 7145897cfb81 ("cpuidle: Fix for timer_deadline==0 case")
> >>>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> >>>
> >>> Acked-by: Roger Pau Monné <roger.pau@citrix.com>
> >>
> >> Thanks.
> >>
> >>> Similar to the previous commit, I wonder whether it would make sense
> >>> to add an ASSERT_UNREACHABLE() if that error path is not reachable
> >>> given the logic in the callers.
> >>
> >> That would mean
> >>
> >>     if ( unlikely(expire < 0) )
> >>     {
> >>         printk(KERN_DEBUG "reprogram: expire <= 0\n");
> >>         return -ETIME;
> >>     }
> >>
> >>     if ( unlikely(expire == 0) )
> >>     {
> >>         ASSERT_UNREACHABLE();
> >>         return -ETIME;
> >>     }
> >>
> >> which I fear I don't like (for going too far). Even
> >>
> >>     if ( unlikely(expire <= 0) )
> >>     {
> >>         printk(KERN_DEBUG "reprogram: expire <= 0\n");
> >>         ASSERT(expire);
> >>         return -ETIME;
> >>     }
> >>
> >> I'd be uncertain about, as that needlessly gives 0 a meaning that isn't
> >> required anymore in this function.
> > 
> > Hm, OK, I was under the impression that both < 0 and 0 should never be
> > passed by the callers.  If expire == 0 is a possible input then I
> > don't think the ASSERT() is that helpful.
> 
> Oh, so you were after
> 
>     if ( unlikely(expire <= 0) )
>     {
>         printk(KERN_DEBUG "reprogram: expire <= 0\n");
>         ASSERT_UNREACHABLE();
>         return -ETIME;
>     }
> 
> (perhaps even with the printk() dropped)? That I could buy off on, as NOW()
> is expected to only ever return valid (positive) s_time_t values.

Yes, that's what I was thinking off, but your previous reply made me
think there are possible cases where expire < 0 gets passed to the
function?

If that's not the case, adding the ASSERT_UNREACHABLE() would be my
preference.

Thanks, Roger.


  reply	other threads:[~2026-01-22 11:31 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-17 14:35 [PATCH v4 0/8] x86/HPET: tidying / improvements Jan Beulich
2025-11-17 14:37 ` [PATCH v4 1/8] x86/HPET: avoid indirect call to event handler Jan Beulich
2026-01-21 16:19   ` Roger Pau Monné
2025-11-17 14:37 ` [PATCH v4 2/8] x86/HPET: make another channel flags update atomic Jan Beulich
2026-01-21 17:55   ` Roger Pau Monné
2025-11-17 14:37 ` [PATCH v4 3/8] x86/HPET: move legacy tick IRQ count adjustment Jan Beulich
2026-01-22  8:50   ` Roger Pau Monné
2026-01-22 10:31     ` Jan Beulich
2026-01-22 11:21       ` Roger Pau Monné
2025-11-17 14:38 ` [PATCH v4 4/8] x86/HPET: reduce hpet_next_event() call sites Jan Beulich
2026-01-22  9:00   ` Roger Pau Monné
2025-11-17 14:39 ` [PATCH v4 5/8] x86/HPET: drop "long timeout" handling from reprogram_hpet_evt_channel() Jan Beulich
2026-01-22  9:03   ` Roger Pau Monné
2026-01-22  9:23     ` Jan Beulich
2025-11-17 14:39 ` [PATCH v4 6/8] x86/HPET: simplify "expire" check a little in reprogram_hpet_evt_channel() Jan Beulich
2026-01-22  9:18   ` Roger Pau Monné
2026-01-22  9:28     ` Jan Beulich
2026-01-22 10:10       ` Roger Pau Monné
2026-01-22 10:15         ` Jan Beulich
2026-01-22 11:30           ` Roger Pau Monné [this message]
2026-01-22 12:50             ` Jan Beulich
2025-11-17 14:39 ` [PATCH v4 7/8] x86/HPET: drop .set_affinity hook Jan Beulich
2026-01-22 10:05   ` Roger Pau Monné
2025-11-17 14:40 ` [PATCH v4 8/8] x86/HPET: don't arbitrarily cap delta in reprogram_hpet_evt_channel() Jan Beulich
2026-01-22 10:23   ` Roger Pau Monné
2026-01-22 10:35     ` Jan Beulich
2026-01-22 11:29       ` Roger Pau Monné

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=aXIKWwYYXf9UgplM@Mac.lan \
    --to=roger.pau@citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=xen-devel@lists.xenproject.org \
    /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.