public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Corey Minyard <cminyard@mvista.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: y2038@lists.linaro.org, Corey Minyard <minyard@acm.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-kernel@vger.kernel.org,
	openipmi-developer@lists.sourceforge.net
Subject: Re: [PATCH 4/8] ipmi: kill off 'timespec' usage again
Date: Fri, 8 Nov 2019 16:11:06 -0600	[thread overview]
Message-ID: <20191108221106.GT10313@minyard.net> (raw)
In-Reply-To: <20191108203435.112759-5-arnd@arndb.de>

On Fri, Nov 08, 2019 at 09:34:27PM +0100, Arnd Bergmann wrote:
> 'struct timespec' is getting removed from the kernel. The usage in ipmi
> was fixed before in commit 48862ea2ce86 ("ipmi: Update timespec usage
> to timespec64"), but unfortunately it crept back in.
> 
> The busy looping code can better use ktime_t anyway, so use that
> there to simplify the implementation.

Thanks, this is a big improvement.  I have this queued, but if you
are going to submit this, I can remove it, and:

Reviewed-by: Corey Minyard <cminyard@mvista.com>

Do you think this should go in to 5.4?

-corey

> 
> Fixes: cbb19cb1eef0 ("ipmi_si: Convert timespec64 to timespec")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  drivers/char/ipmi/ipmi_si_intf.c | 40 +++++++++++---------------------
>  1 file changed, 13 insertions(+), 27 deletions(-)
> 
> diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
> index 6b9a0593d2eb..c7cc8538b84a 100644
> --- a/drivers/char/ipmi/ipmi_si_intf.c
> +++ b/drivers/char/ipmi/ipmi_si_intf.c
> @@ -265,10 +265,10 @@ static void cleanup_ipmi_si(void);
>  #ifdef DEBUG_TIMING
>  void debug_timestamp(char *msg)
>  {
> -	struct timespec t;
> +	struct timespec64 t;
>  
> -	ktime_get_ts(&t);
> -	pr_debug("**%s: %ld.%9.9ld\n", msg, (long) t.tv_sec, t.tv_nsec);
> +	ktime_get_ts64(&t);
> +	pr_debug("**%s: %lld.%9.9ld\n", msg, t.tv_sec, t.tv_nsec);
>  }
>  #else
>  #define debug_timestamp(x)
> @@ -935,38 +935,25 @@ static void set_run_to_completion(void *send_info, bool i_run_to_completion)
>  }
>  
>  /*
> - * Use -1 in the nsec value of the busy waiting timespec to tell that
> - * we are spinning in kipmid looking for something and not delaying
> - * between checks
> + * Use -1 as a special constant to tell that we are spinning in kipmid
> + * looking for something and not delaying between checks
>   */
> -static inline void ipmi_si_set_not_busy(struct timespec *ts)
> -{
> -	ts->tv_nsec = -1;
> -}
> -static inline int ipmi_si_is_busy(struct timespec *ts)
> -{
> -	return ts->tv_nsec != -1;
> -}
> -
> +#define IPMI_TIME_NOT_BUSY ns_to_ktime(-1ull)
>  static inline bool ipmi_thread_busy_wait(enum si_sm_result smi_result,
>  					 const struct smi_info *smi_info,
> -					 struct timespec *busy_until)
> +					 ktime_t *busy_until)
>  {
>  	unsigned int max_busy_us = 0;
>  
>  	if (smi_info->si_num < num_max_busy_us)
>  		max_busy_us = kipmid_max_busy_us[smi_info->si_num];
>  	if (max_busy_us == 0 || smi_result != SI_SM_CALL_WITH_DELAY)
> -		ipmi_si_set_not_busy(busy_until);
> -	else if (!ipmi_si_is_busy(busy_until)) {
> -		ktime_get_ts(busy_until);
> -		timespec_add_ns(busy_until, max_busy_us * NSEC_PER_USEC);
> +		*busy_until = IPMI_TIME_NOT_BUSY;
> +	else if (*busy_until == IPMI_TIME_NOT_BUSY) {
> +		*busy_until = ktime_get() + max_busy_us * NSEC_PER_USEC;
>  	} else {
> -		struct timespec now;
> -
> -		ktime_get_ts(&now);
> -		if (unlikely(timespec_compare(&now, busy_until) > 0)) {
> -			ipmi_si_set_not_busy(busy_until);
> +		if (unlikely(ktime_get() > *busy_until)) {
> +			*busy_until = IPMI_TIME_NOT_BUSY;
>  			return false;
>  		}
>  	}
> @@ -988,9 +975,8 @@ static int ipmi_thread(void *data)
>  	struct smi_info *smi_info = data;
>  	unsigned long flags;
>  	enum si_sm_result smi_result;
> -	struct timespec busy_until = { 0, 0 };
> +	ktime_t busy_until = IPMI_TIME_NOT_BUSY;
>  
> -	ipmi_si_set_not_busy(&busy_until);
>  	set_user_nice(current, MAX_NICE);
>  	while (!kthread_should_stop()) {
>  		int busy_wait;
> -- 
> 2.20.0
> 

  reply	other threads:[~2019-11-08 22:11 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-08 20:34 [PATCH 0/8] y2038: bug fixes from y2038 work Arnd Bergmann
2019-11-08 20:34 ` [PATCH 1/8] y2038: timex: remove incorrect time_t truncation Arnd Bergmann
2019-11-10 20:44   ` Deepa Dinamani
2019-11-12  7:16   ` [tip: timers/urgent] ntp/y2038: Remove " tip-bot2 for Arnd Bergmann
2019-11-08 20:34 ` [PATCH 2/8] timekeeping: optimize ns_to_timespec64 Arnd Bergmann
2019-11-10 20:46   ` Deepa Dinamani
2019-11-12  7:22   ` [tip: timers/core] time: Optimize ns_to_timespec64() tip-bot2 for Arnd Bergmann
2019-11-08 20:34 ` [PATCH 3/8] powerpc: fix vdso32 for ppc64le Arnd Bergmann
2019-11-20 19:13   ` [Y2038] " Ben Hutchings
2019-11-20 19:35     ` Arnd Bergmann
2019-11-20 21:49       ` Ben Hutchings
2019-11-21 10:02         ` Arnd Bergmann
2019-11-21 15:56           ` Ben Hutchings
2019-11-08 20:34 ` [PATCH 4/8] ipmi: kill off 'timespec' usage again Arnd Bergmann
2019-11-08 22:11   ` Corey Minyard [this message]
2019-11-09 11:23     ` Arnd Bergmann
2019-11-08 20:34 ` [PATCH 5/8] netfilter: xt_time: use time64_t Arnd Bergmann
2019-11-15 22:43   ` Pablo Neira Ayuso
2019-11-08 20:34 ` [PATCH 6/8] lp: fix sparc64 LPSETTIMEOUT ioctl Arnd Bergmann
2019-11-20 19:27   ` [Y2038] " Ben Hutchings
2019-11-20 19:46     ` Arnd Bergmann
2019-11-20 22:10       ` Ben Hutchings
2019-11-21 14:04         ` Arnd Bergmann
2019-11-21 16:00           ` Ben Hutchings
2019-11-08 20:34 ` [PATCH 7/8] ppdev: fix PPGETTIME/PPSETTIME ioctls Arnd Bergmann
2019-11-20 19:29   ` [Y2038] " Ben Hutchings
2019-11-21 14:06     ` Arnd Bergmann
2019-11-08 20:34 ` [PATCH 8/8] Input: input_event: fix struct padding on sparc64 Arnd Bergmann
2019-11-11 18:28   ` Dmitry Torokhov
2019-11-11 19:18     ` Arnd Bergmann

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=20191108221106.GT10313@minyard.net \
    --to=cminyard@mvista.com \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=minyard@acm.org \
    --cc=openipmi-developer@lists.sourceforge.net \
    --cc=y2038@lists.linaro.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox