mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Easwar Hariharan <eahariha@linux.microsoft.com>
To: Haiyang Zhang <haiyangz@microsoft.com>,
	KY Srinivasan <kys@microsoft.com>, Wei Liu <wei.liu@kernel.org>,
	Dexuan Cui <decui@microsoft.com>,
	"linux-hyperv@vger.kernel.org" <linux-hyperv@vger.kernel.org>,
	Anna-Maria Behnsen <anna-maria@linutronix.de>,
	Thomas Gleixner <tglx@linutronix.de>,
	Geert Uytterhoeven <geert@linux-m68k.org>,
	Marcel Holtmann <marcel@holtmann.org>,
	Johan Hedberg <johan.hedberg@gmail.com>,
	Luiz Augusto von Dentz <luiz.dentz@gmail.com>,
	"linux-bluetooth@vger.kernel.org"
	<linux-bluetooth@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Praveen Kumar <kumarpraveen@linux.microsoft.com>,
	Naman Jain <namjain@linux.microsoft.com>
Cc: eahariha@linux.microsoft.com,
	Michael Kelley <mhklinux@outlook.com>,
	"Von Dentz, Luiz" <luiz.von.dentz@intel.com>
Subject: Re: [PATCH v3 1/2] jiffies: Define secs_to_jiffies()
Date: Thu, 31 Oct 2024 10:05:57 -0700	[thread overview]
Message-ID: <59a29847-2a3b-4aac-82f4-db9f1e52bb10@linux.microsoft.com> (raw)
In-Reply-To: <SA0PR21MB1867075CEEBDFB9D909AFFF2CA552@SA0PR21MB1867.namprd21.prod.outlook.com>

On 10/31/2024 8:54 AM, Haiyang Zhang wrote:
> 
> 
>> -----Original Message-----
>> From: Easwar Hariharan <eahariha@linux.microsoft.com>
>> Sent: Wednesday, October 30, 2024 1:48 PM
>> To: KY Srinivasan <kys@microsoft.com>; Haiyang Zhang
>> <haiyangz@microsoft.com>; Wei Liu <wei.liu@kernel.org>; Dexuan Cui
>> <decui@microsoft.com>; linux-hyperv@vger.kernel.org; Anna-Maria Behnsen
>> <anna-maria@linutronix.de>; Thomas Gleixner <tglx@linutronix.de>; Geert
>> Uytterhoeven <geert@linux-m68k.org>; Marcel Holtmann
>> <marcel@holtmann.org>; Johan Hedberg <johan.hedberg@gmail.com>; Luiz
>> Augusto von Dentz <luiz.dentz@gmail.com>; linux-
>> bluetooth@vger.kernel.org; linux-kernel@vger.kernel.org; Praveen Kumar
>> <kumarpraveen@linux.microsoft.com>; Naman Jain
>> <namjain@linux.microsoft.com>
>> Cc: Michael Kelley <mhklinux@outlook.com>; Easwar Hariharan
>> <eahariha@linux.microsoft.com>; Von Dentz, Luiz
>> <luiz.von.dentz@intel.com>
>> Subject: [PATCH v3 1/2] jiffies: Define secs_to_jiffies()
>>
>> secs_to_jiffies() is defined in hci_event.c and cannot be reused by
>> other call sites. Hoist it into the core code to allow conversion of the
>> ~1150 usages of msecs_to_jiffies() that either:
>> - use a multiplier value of 1000 or equivalently MSEC_PER_SEC, or
>> - have timeouts that are denominated in seconds (i.e. end in 000)
>>
>> This will also allow conversion of yet more sites that use (sec * HZ)
>> directly, and improve their readability.
>>
>> TO: K. Y. Srinivasan <kys@microsoft.com>
>> TO: Haiyang Zhang <haiyangz@microsoft.com>
>> TO: Wei Liu <wei.liu@kernel.org>
>> TO: Dexuan Cui <decui@microsoft.com>
>> TO: linux-hyperv@vger.kernel.org
>> TO: Anna-Maria Behnsen <anna-maria@linutronix.de>
>> TO: Thomas Gleixner <tglx@linutronix.de>
>> TO: Geert Uytterhoeven <geert@linux-m68k.org>
>> TO: Marcel Holtmann <marcel@holtmann.org>
>> TO: Johan Hedberg <johan.hedberg@gmail.com>
>> TO: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
>> TO: linux-bluetooth@vger.kernel.org
>> TO: linux-kernel@vger.kernel.org
>> Suggested-by: Michael Kelley <mhklinux@outlook.com>
>> Reviewed-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>> Signed-off-by: Easwar Hariharan <eahariha@linux.microsoft.com>
>> ---
>>  include/linux/jiffies.h   | 12 ++++++++++++
>>  net/bluetooth/hci_event.c |  2 --
>>  2 files changed, 12 insertions(+), 2 deletions(-)
>>
>> diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h
>> index
>> 1220f0fbe5bf9fb6c559b4efd603db3e97db9b65..e17c220ed56e587fd55fb9cf4a133a5
>> 3588af940 100644
>> --- a/include/linux/jiffies.h
>> +++ b/include/linux/jiffies.h
>> @@ -526,6 +526,18 @@ static __always_inline unsigned long
>> msecs_to_jiffies(const unsigned int m)
>>  	}
>>  }
>>
>> +/**
>> + * secs_to_jiffies: - convert seconds to jiffies
>> + * @_secs: time in seconds
>> + *
>> + * Conversion is done by simple multiplication with HZ
>> + * secs_to_jiffies() is defined as a macro rather than a static inline
>> + * function due to its potential application in struct initializers.
>> + *
>> + * Return: jiffies value
>> + */
>> +#define secs_to_jiffies(_secs) ((_secs) * HZ)
>> +
>>  extern unsigned long __usecs_to_jiffies(const unsigned int u);
>>  #if !(USEC_PER_SEC % HZ)
>>  static inline unsigned long _usecs_to_jiffies(const unsigned int u)
>> diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
>> index
>> 0bbad90ddd6f87e87c03859bae48a7901d39b634..7b35c58bbbeb79f2b50a02212771fb2
>> 83ba5643d 100644
>> --- a/net/bluetooth/hci_event.c
>> +++ b/net/bluetooth/hci_event.c
>> @@ -42,8 +42,6 @@
>>  #define ZERO_KEY "\x00\x00\x00\x00\x00\x00\x00\x00" \
>>  		 "\x00\x00\x00\x00\x00\x00\x00\x00"
>>
>> -#define secs_to_jiffies(_secs) msecs_to_jiffies((_secs) * 1000)
>> -
>>  /* Handle HCI Event packets */
>>
>>  static void *hci_ev_skb_pull(struct hci_dev *hdev, struct sk_buff *skb,
>>
>> --
>> 2.34.1
> 
> All looks good.
> But can you consider naming the macro as s2jiffy()? Just
> to be shorter, so after adopting this macro we don't have
> to split some lines for over 80 characters:)
> 
> Thanks,
> - Haiyang
> 

Thanks for the review! The patch introducing the macro has already been
accepted into timers/core in tip[1], so unfortunately I can't make that
change anymore. For readability considerations, I also find it better to
match the remaining APIs in the jiffies family, i.e. msecs_to_jiffies(),
nsecs_to_jiffies(), usecs_to_jiffies().

[1] https://git.kernel.org/tip/b35108a51cf7bab58d7eace1267d7965978bcdb8

Thanks,
Easwar

  reply	other threads:[~2024-10-31 17:05 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-30 17:47 [PATCH v3 0/2] Converge on secs_to_jiffies() Easwar Hariharan
2024-10-30 17:47 ` [PATCH v3 1/2] jiffies: Define secs_to_jiffies() Easwar Hariharan
2024-10-30 18:52   ` [tip: timers/core] " tip-bot2 for Easwar Hariharan
2024-10-31 15:54   ` [PATCH v3 1/2] " Haiyang Zhang
2024-10-31 17:05     ` Easwar Hariharan [this message]
2024-10-31 17:28       ` Haiyang Zhang
2024-10-30 17:47 ` [PATCH v3 2/2] drivers: hv: Convert open-coded timeouts to secs_to_jiffies() Easwar Hariharan
2024-10-31  2:03   ` Michael Kelley
2024-12-07  7:52   ` Wei Liu

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=59a29847-2a3b-4aac-82f4-db9f1e52bb10@linux.microsoft.com \
    --to=eahariha@linux.microsoft.com \
    --cc=anna-maria@linutronix.de \
    --cc=decui@microsoft.com \
    --cc=geert@linux-m68k.org \
    --cc=haiyangz@microsoft.com \
    --cc=johan.hedberg@gmail.com \
    --cc=kumarpraveen@linux.microsoft.com \
    --cc=kys@microsoft.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luiz.dentz@gmail.com \
    --cc=luiz.von.dentz@intel.com \
    --cc=marcel@holtmann.org \
    --cc=mhklinux@outlook.com \
    --cc=namjain@linux.microsoft.com \
    --cc=tglx@linutronix.de \
    --cc=wei.liu@kernel.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

all inboxes | Powered by JetHome®