lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250812094740-68fe99d9-25b0-42cc-bdd0-188bb956a798@linutronix.de>
Date: Tue, 12 Aug 2025 09:51:05 +0200
From: Thomas Weißschuh <thomas.weissschuh@...utronix.de>
To: Peter Zijlstra <peterz@...radead.org>
Cc: Anna-Maria Behnsen <anna-maria@...utronix.de>, 
	Frederic Weisbecker <frederic@...nel.org>, Thomas Gleixner <tglx@...utronix.de>, 
	Ingo Molnar <mingo@...hat.com>, Juri Lelli <juri.lelli@...hat.com>, 
	Vincent Guittot <vincent.guittot@...aro.org>, Dietmar Eggemann <dietmar.eggemann@....com>, 
	Steven Rostedt <rostedt@...dmis.org>, Ben Segall <bsegall@...gle.com>, Mel Gorman <mgorman@...e.de>, 
	Valentin Schneider <vschneid@...hat.com>, Matt Wu <wuqiang.matt@...edance.com>, 
	Andrew Morton <akpm@...ux-foundation.org>, Jaroslav Kysela <perex@...ex.cz>, Takashi Iwai <tiwai@...e.com>, 
	Sean Young <sean@...s.org>, Mauro Carvalho Chehab <mchehab@...nel.org>, 
	Jan Kiszka <jan.kiszka@...mens.com>, Kieran Bingham <kbingham@...nel.org>, 
	linux-kernel@...r.kernel.org, linux-sound@...r.kernel.org, linux-media@...r.kernel.org
Subject: Re: [PATCH 8/8] hrtimer: Remove hrtimer_clock_base::get_time

On Tue, Aug 12, 2025 at 09:42:46AM +0200, Peter Zijlstra wrote:
> On Tue, Aug 12, 2025 at 08:08:16AM +0200, Thomas Weißschuh wrote:
> 
> > @@ -76,42 +77,34 @@ DEFINE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases) =
> >  		{
> >  			.index = HRTIMER_BASE_MONOTONIC,
> >  			.clockid = CLOCK_MONOTONIC,
> > -			.get_time = &ktime_get,
> >  		},
> >  		{
> >  			.index = HRTIMER_BASE_REALTIME,
> >  			.clockid = CLOCK_REALTIME,
> > -			.get_time = &ktime_get_real,
> >  		},
> >  		{
> >  			.index = HRTIMER_BASE_BOOTTIME,
> >  			.clockid = CLOCK_BOOTTIME,
> > -			.get_time = &ktime_get_boottime,
> >  		},
> >  		{
> >  			.index = HRTIMER_BASE_TAI,
> >  			.clockid = CLOCK_TAI,
> > -			.get_time = &ktime_get_clocktai,
> >  		},
> >  		{
> >  			.index = HRTIMER_BASE_MONOTONIC_SOFT,
> >  			.clockid = CLOCK_MONOTONIC,
> > -			.get_time = &ktime_get,
> >  		},
> >  		{
> >  			.index = HRTIMER_BASE_REALTIME_SOFT,
> >  			.clockid = CLOCK_REALTIME,
> > -			.get_time = &ktime_get_real,
> >  		},
> >  		{
> >  			.index = HRTIMER_BASE_BOOTTIME_SOFT,
> >  			.clockid = CLOCK_BOOTTIME,
> > -			.get_time = &ktime_get_boottime,
> >  		},
> >  		{
> >  			.index = HRTIMER_BASE_TAI_SOFT,
> >  			.clockid = CLOCK_TAI,
> > -			.get_time = &ktime_get_clocktai,
> >  		},
> >  	},
> >  	.csd = CSD_INIT(retrigger_next_event, NULL)
> > @@ -1253,7 +1246,7 @@ static int __hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim,
> >  	remove_hrtimer(timer, base, true, force_local);
> >  
> >  	if (mode & HRTIMER_MODE_REL)
> > -		tim = ktime_add_safe(tim, base->get_time());
> > +		tim = ktime_add_safe(tim, __hrtimer_cb_get_time(base->clockid));
> >  
> >  	tim = hrtimer_update_lowres(timer, tim, mode);
> >  
> > @@ -1588,6 +1581,29 @@ static inline int hrtimer_clockid_to_base(clockid_t clock_id)
> >  	}
> >  }
> >  
> > +static ktime_t __hrtimer_cb_get_time(clockid_t clock_id)
> > +{
> > +	switch (clock_id) {
> > +	case CLOCK_REALTIME:
> > +		return ktime_get_real();
> > +	case CLOCK_MONOTONIC:
> > +		return ktime_get();
> > +	case CLOCK_BOOTTIME:
> > +		return ktime_get_boottime();
> > +	case CLOCK_TAI:
> > +		return ktime_get_clocktai();
> 
> It would've been nice if these had the same order as the other array.

Yeah. This is the same order as in hrtimer_clockid_to_base(), right above
this function. I'll add a patch to reorder that one, too.

> 
> > +	default:
> > +		WARN(1, "Invalid clockid %d. Using MONOTONIC\n", clock_id);
> > +		return ktime_get();
> > +	}
> > +}

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ