netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 00/15] timers: Cleanup delay/sleep related mess
@ 2024-09-11  5:13 Anna-Maria Behnsen
  2024-09-11  5:13 ` [PATCH v2 12/15] iopoll/regmap/phy/snd: Fix comment referencing outdated timer documentation Anna-Maria Behnsen
  2024-09-16 20:20 ` [PATCH v2 00/15] timers: Cleanup delay/sleep related mess Christophe JAILLET
  0 siblings, 2 replies; 8+ messages in thread
From: Anna-Maria Behnsen @ 2024-09-11  5:13 UTC (permalink / raw)
  To: Frederic Weisbecker, Thomas Gleixner, Jonathan Corbet
  Cc: linux-kernel, Len Brown, Rafael J. Wysocki, Anna-Maria Behnsen,
	Andrew Morton, damon, linux-mm, SeongJae Park, Arnd Bergmann,
	linux-arch, Heiner Kallweit, David S. Miller, Andy Whitcroft,
	Joe Perches, Dwaipayan Ray, Liam Girdwood, Mark Brown,
	Andrew Lunn, Jaroslav Kysela, Takashi Iwai, netdev, linux-sound,
	Michael Ellerman, Nathan Lynch, linuxppc-dev,
	Mauro Carvalho Chehab, linux-media

Hi,

a question about which sleeping function should be used in acpi_os_sleep()
started a discussion and examination about the existing documentation and
implementation of functions which insert a sleep/delay.

The result of the discussion was, that the documentation is outdated and
the implemented fsleep() reflects the outdated documentation but doesn't
help to reflect reality which in turns leads to the queue which covers the
following things:

- Split out all timeout and sleep related functions from hrtimer.c and timer.c
  into a separate file

- Update function descriptions of sleep related functions

- Change fsleep() to reflect reality

- Rework all comments or users which obviously rely on the outdated
  documentation as they reference "Documentation/timers/timers-howto.rst"

- Last but not least (as there are no more references): Update the outdated
  documentation and move it into a file with a self explaining file name

The queue is available here and applies on top of tip/timers/core:

  git://git.kernel.org/pub/scm/linux/kernel/git/anna-maria/linux-devel.git timers/misc

Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
---
Changes in v2:
- change udelay() and ndelay() as suggested by Thomas
- Update some formatting in the new sleep_timeout.c file
- minor typo changes and other small review remarks

Thanks,

        Anna-Maria

---
Anna-Maria Behnsen (15):
      MAINTAINERS: Add missing file include/linux/delay.h
      timers: Move *sleep*() and timeout functions into a separate file
      timers: Update schedule_[hr]timeout*() related function descriptions
      timers: Rename usleep_idle_range() to usleep_range_idle()
      timers: Update function descriptions of sleep/delay related functions
      delay: Rework udelay and ndelay
      timers: Adjust flseep() to reflect reality
      mm/damon/core: Use generic upper bound recommondation for usleep_range()
      timers: Add a warning to usleep_range_state() for wrong order of arguments
      checkpatch: Remove broken sleep/delay related checks
      regulator: core: Use fsleep() to get best sleep mechanism
      iopoll/regmap/phy/snd: Fix comment referencing outdated timer documentation
      powerpc/rtas: Use fsleep() to minimize additional sleep duration
      media: anysee: Fix link to outdated sleep function documentation
      timers/Documentation: Cleanup delay/sleep documentation

 Documentation/dev-tools/checkpatch.rst         |   6 -
 Documentation/timers/delay_sleep_functions.rst | 122 ++++++++
 Documentation/timers/index.rst                 |   2 +-
 Documentation/timers/timers-howto.rst          | 115 --------
 MAINTAINERS                                    |   2 +
 arch/powerpc/kernel/rtas.c                     |  21 +-
 drivers/media/usb/dvb-usb-v2/anysee.c          |   6 +-
 drivers/regulator/core.c                       |  47 +---
 include/asm-generic/delay.h                    |  95 +++++--
 include/linux/delay.h                          |  79 ++++--
 include/linux/iopoll.h                         |  52 ++--
 include/linux/phy.h                            |   9 +-
 include/linux/regmap.h                         |  38 +--
 kernel/time/Makefile                           |   2 +-
 kernel/time/hrtimer.c                          | 120 --------
 kernel/time/sleep_timeout.c                    | 376 +++++++++++++++++++++++++
 kernel/time/timer.c                            | 192 -------------
 mm/damon/core.c                                |   5 +-
 scripts/checkpatch.pl                          |  38 ---
 sound/soc/sof/ops.h                            |   8 +-
 20 files changed, 701 insertions(+), 634 deletions(-)


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2 12/15] iopoll/regmap/phy/snd: Fix comment referencing outdated timer documentation
  2024-09-11  5:13 [PATCH v2 00/15] timers: Cleanup delay/sleep related mess Anna-Maria Behnsen
@ 2024-09-11  5:13 ` Anna-Maria Behnsen
  2024-09-11 12:08   ` Andrew Lunn
  2024-10-09 16:14   ` Frederic Weisbecker
  2024-09-16 20:20 ` [PATCH v2 00/15] timers: Cleanup delay/sleep related mess Christophe JAILLET
  1 sibling, 2 replies; 8+ messages in thread
From: Anna-Maria Behnsen @ 2024-09-11  5:13 UTC (permalink / raw)
  To: Frederic Weisbecker, Thomas Gleixner, Jonathan Corbet
  Cc: linux-kernel, Len Brown, Rafael J. Wysocki, Anna-Maria Behnsen,
	Andrew Lunn, Heiner Kallweit, Jaroslav Kysela, Takashi Iwai,
	netdev, linux-sound

Function descriptions in iopoll.h, regmap.h, phy.h and sound/soc/sof/ops.h
copied all the same outdated documentation about sleep/delay function
limitations. In those comments, the generic (and still outdated) timer
documentation file is referenced.

As proper function descriptions for used delay and sleep functions are in
place, simply update the descriptions to reference to them. While at it fix
missing colon after "Returns" in function description and move return value
description to the end of the function description.

Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Heiner Kallweit <hkallweit1@gmail.com>
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.com>
Cc: netdev@vger.kernel.org
Cc: linux-sound@vger.kernel.org
Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
---
v2: Add cleanup of usage of 'Returns' in function description
---
 include/linux/iopoll.h | 52 +++++++++++++++++++++++++-------------------------
 include/linux/phy.h    |  9 +++++----
 include/linux/regmap.h | 38 ++++++++++++++++++------------------
 sound/soc/sof/ops.h    |  8 ++++----
 4 files changed, 54 insertions(+), 53 deletions(-)

diff --git a/include/linux/iopoll.h b/include/linux/iopoll.h
index 19a7b00baff4..91324c331a4b 100644
--- a/include/linux/iopoll.h
+++ b/include/linux/iopoll.h
@@ -19,19 +19,19 @@
  * @op: accessor function (takes @args as its arguments)
  * @val: Variable to read the value into
  * @cond: Break condition (usually involving @val)
- * @sleep_us: Maximum time to sleep between reads in us (0
- *            tight-loops).  Should be less than ~20ms since usleep_range
- *            is used (see Documentation/timers/timers-howto.rst).
+ * @sleep_us: Maximum time to sleep between reads in us (0 tight-loops). Please
+ *            read usleep_range() function description for details and
+ *            limitations.
  * @timeout_us: Timeout in us, 0 means never timeout
  * @sleep_before_read: if it is true, sleep @sleep_us before read.
  * @args: arguments for @op poll
  *
- * Returns 0 on success and -ETIMEDOUT upon a timeout. In either
- * case, the last read value at @args is stored in @val. Must not
- * be called from atomic context if sleep_us or timeout_us are used.
- *
  * When available, you'll probably want to use one of the specialized
  * macros defined below rather than this macro directly.
+ *
+ * Returns: 0 on success and -ETIMEDOUT upon a timeout. In either
+ * case, the last read value at @args is stored in @val. Must not
+ * be called from atomic context if sleep_us or timeout_us are used.
  */
 #define read_poll_timeout(op, val, cond, sleep_us, timeout_us, \
 				sleep_before_read, args...) \
@@ -64,22 +64,22 @@
  * @op: accessor function (takes @args as its arguments)
  * @val: Variable to read the value into
  * @cond: Break condition (usually involving @val)
- * @delay_us: Time to udelay between reads in us (0 tight-loops).  Should
- *            be less than ~10us since udelay is used (see
- *            Documentation/timers/timers-howto.rst).
+ * @delay_us: Time to udelay between reads in us (0 tight-loops). Please
+ *            read udelay() function description for details and
+ *            limitations.
  * @timeout_us: Timeout in us, 0 means never timeout
  * @delay_before_read: if it is true, delay @delay_us before read.
  * @args: arguments for @op poll
  *
- * Returns 0 on success and -ETIMEDOUT upon a timeout. In either
- * case, the last read value at @args is stored in @val.
- *
  * This macro does not rely on timekeeping.  Hence it is safe to call even when
  * timekeeping is suspended, at the expense of an underestimation of wall clock
  * time, which is rather minimal with a non-zero delay_us.
  *
  * When available, you'll probably want to use one of the specialized
  * macros defined below rather than this macro directly.
+ *
+ * Returns: 0 on success and -ETIMEDOUT upon a timeout. In either
+ * case, the last read value at @args is stored in @val.
  */
 #define read_poll_timeout_atomic(op, val, cond, delay_us, timeout_us, \
 					delay_before_read, args...) \
@@ -119,17 +119,17 @@
  * @addr: Address to poll
  * @val: Variable to read the value into
  * @cond: Break condition (usually involving @val)
- * @sleep_us: Maximum time to sleep between reads in us (0
- *            tight-loops).  Should be less than ~20ms since usleep_range
- *            is used (see Documentation/timers/timers-howto.rst).
+ * @sleep_us: Maximum time to sleep between reads in us (0 tight-loops). Please
+ *            read usleep_range() function description for details and
+ *            limitations.
  * @timeout_us: Timeout in us, 0 means never timeout
  *
- * Returns 0 on success and -ETIMEDOUT upon a timeout. In either
- * case, the last read value at @addr is stored in @val. Must not
- * be called from atomic context if sleep_us or timeout_us are used.
- *
  * When available, you'll probably want to use one of the specialized
  * macros defined below rather than this macro directly.
+ *
+ * Returns: 0 on success and -ETIMEDOUT upon a timeout. In either
+ * case, the last read value at @addr is stored in @val. Must not
+ * be called from atomic context if sleep_us or timeout_us are used.
  */
 #define readx_poll_timeout(op, addr, val, cond, sleep_us, timeout_us)	\
 	read_poll_timeout(op, val, cond, sleep_us, timeout_us, false, addr)
@@ -140,16 +140,16 @@
  * @addr: Address to poll
  * @val: Variable to read the value into
  * @cond: Break condition (usually involving @val)
- * @delay_us: Time to udelay between reads in us (0 tight-loops).  Should
- *            be less than ~10us since udelay is used (see
- *            Documentation/timers/timers-howto.rst).
+ * @delay_us: Time to udelay between reads in us (0 tight-loops). Please
+ *            read udelay() function description for details and
+ *            limitations.
  * @timeout_us: Timeout in us, 0 means never timeout
  *
- * Returns 0 on success and -ETIMEDOUT upon a timeout. In either
- * case, the last read value at @addr is stored in @val.
- *
  * When available, you'll probably want to use one of the specialized
  * macros defined below rather than this macro directly.
+ *
+ * Returns: 0 on success and -ETIMEDOUT upon a timeout. In either
+ * case, the last read value at @addr is stored in @val.
  */
 #define readx_poll_timeout_atomic(op, addr, val, cond, delay_us, timeout_us) \
 	read_poll_timeout_atomic(op, val, cond, delay_us, timeout_us, false, addr)
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 6b7d40d49129..cadf51441ee1 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -1374,12 +1374,13 @@ int phy_read_mmd(struct phy_device *phydev, int devad, u32 regnum);
  * @regnum: The register on the MMD to read
  * @val: Variable to read the register into
  * @cond: Break condition (usually involving @val)
- * @sleep_us: Maximum time to sleep between reads in us (0
- *            tight-loops).  Should be less than ~20ms since usleep_range
- *            is used (see Documentation/timers/timers-howto.rst).
+ * @sleep_us: Maximum time to sleep between reads in us (0 tight-loops). Please
+ *            read usleep_range() function description for details and
+ *            limitations.
  * @timeout_us: Timeout in us, 0 means never timeout
  * @sleep_before_read: if it is true, sleep @sleep_us before read.
- * Returns 0 on success and -ETIMEDOUT upon a timeout. In either
+ *
+ * Returns: 0 on success and -ETIMEDOUT upon a timeout. In either
  * case, the last read value at @args is stored in @val. Must not
  * be called from atomic context if sleep_us or timeout_us are used.
  */
diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index 122e38161acb..d733b08466fd 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -106,17 +106,17 @@ struct reg_sequence {
  * @addr: Address to poll
  * @val: Unsigned integer variable to read the value into
  * @cond: Break condition (usually involving @val)
- * @sleep_us: Maximum time to sleep between reads in us (0
- *            tight-loops).  Should be less than ~20ms since usleep_range
- *            is used (see Documentation/timers/timers-howto.rst).
+ * @sleep_us: Maximum time to sleep between reads in us (0 tight-loops). Please
+ *            read usleep_range() function description for details and
+ *            limitations.
  * @timeout_us: Timeout in us, 0 means never timeout
  *
- * Returns 0 on success and -ETIMEDOUT upon a timeout or the regmap_read
+ * This is modelled after the readx_poll_timeout macros in linux/iopoll.h.
+ *
+ * Returns: 0 on success and -ETIMEDOUT upon a timeout or the regmap_read
  * error return value in case of a error read. In the two former cases,
  * the last read value at @addr is stored in @val. Must not be called
  * from atomic context if sleep_us or timeout_us are used.
- *
- * This is modelled after the readx_poll_timeout macros in linux/iopoll.h.
  */
 #define regmap_read_poll_timeout(map, addr, val, cond, sleep_us, timeout_us) \
 ({ \
@@ -133,20 +133,20 @@ struct reg_sequence {
  * @addr: Address to poll
  * @val: Unsigned integer variable to read the value into
  * @cond: Break condition (usually involving @val)
- * @delay_us: Time to udelay between reads in us (0 tight-loops).
- *            Should be less than ~10us since udelay is used
- *            (see Documentation/timers/timers-howto.rst).
+ * @delay_us: Time to udelay between reads in us (0 tight-loops). Please
+ *            read udelay() function description for details and
+ *            limitations.
  * @timeout_us: Timeout in us, 0 means never timeout
  *
- * Returns 0 on success and -ETIMEDOUT upon a timeout or the regmap_read
- * error return value in case of a error read. In the two former cases,
- * the last read value at @addr is stored in @val.
- *
  * This is modelled after the readx_poll_timeout_atomic macros in linux/iopoll.h.
  *
  * Note: In general regmap cannot be used in atomic context. If you want to use
  * this macro then first setup your regmap for atomic use (flat or no cache
  * and MMIO regmap).
+ *
+ * Returns: 0 on success and -ETIMEDOUT upon a timeout or the regmap_read
+ * error return value in case of a error read. In the two former cases,
+ * the last read value at @addr is stored in @val.
  */
 #define regmap_read_poll_timeout_atomic(map, addr, val, cond, delay_us, timeout_us) \
 ({ \
@@ -177,17 +177,17 @@ struct reg_sequence {
  * @field: Regmap field to read from
  * @val: Unsigned integer variable to read the value into
  * @cond: Break condition (usually involving @val)
- * @sleep_us: Maximum time to sleep between reads in us (0
- *            tight-loops).  Should be less than ~20ms since usleep_range
- *            is used (see Documentation/timers/timers-howto.rst).
+ * @sleep_us: Maximum time to sleep between reads in us (0 tight-loops). Please
+ *            read usleep_range() function description for details and
+ *            limitations.
  * @timeout_us: Timeout in us, 0 means never timeout
  *
- * Returns 0 on success and -ETIMEDOUT upon a timeout or the regmap_field_read
+ * This is modelled after the readx_poll_timeout macros in linux/iopoll.h.
+ *
+ * Returns: 0 on success and -ETIMEDOUT upon a timeout or the regmap_field_read
  * error return value in case of a error read. In the two former cases,
  * the last read value at @addr is stored in @val. Must not be called
  * from atomic context if sleep_us or timeout_us are used.
- *
- * This is modelled after the readx_poll_timeout macros in linux/iopoll.h.
  */
 #define regmap_field_read_poll_timeout(field, val, cond, sleep_us, timeout_us) \
 ({ \
diff --git a/sound/soc/sof/ops.h b/sound/soc/sof/ops.h
index 2584621c3b2d..d73644e85b6e 100644
--- a/sound/soc/sof/ops.h
+++ b/sound/soc/sof/ops.h
@@ -597,12 +597,12 @@ snd_sof_is_chain_dma_supported(struct snd_sof_dev *sdev, u32 dai_type)
  * @addr: Address to poll
  * @val: Variable to read the value into
  * @cond: Break condition (usually involving @val)
- * @sleep_us: Maximum time to sleep between reads in us (0
- *            tight-loops).  Should be less than ~20ms since usleep_range
- *            is used (see Documentation/timers/timers-howto.rst).
+ * @sleep_us: Maximum time to sleep between reads in us (0 tight-loops). Please
+ *            read usleep_range() function description for details and
+ *            limitations.
  * @timeout_us: Timeout in us, 0 means never timeout
  *
- * Returns 0 on success and -ETIMEDOUT upon a timeout. In either
+ * Returns: 0 on success and -ETIMEDOUT upon a timeout. In either
  * case, the last read value at @addr is stored in @val. Must not
  * be called from atomic context if sleep_us or timeout_us are used.
  *

-- 
2.39.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 12/15] iopoll/regmap/phy/snd: Fix comment referencing outdated timer documentation
  2024-09-11  5:13 ` [PATCH v2 12/15] iopoll/regmap/phy/snd: Fix comment referencing outdated timer documentation Anna-Maria Behnsen
@ 2024-09-11 12:08   ` Andrew Lunn
  2024-10-09 16:14   ` Frederic Weisbecker
  1 sibling, 0 replies; 8+ messages in thread
From: Andrew Lunn @ 2024-09-11 12:08 UTC (permalink / raw)
  To: Anna-Maria Behnsen
  Cc: Frederic Weisbecker, Thomas Gleixner, Jonathan Corbet,
	linux-kernel, Len Brown, Rafael J. Wysocki, Heiner Kallweit,
	Jaroslav Kysela, Takashi Iwai, netdev, linux-sound

On Wed, Sep 11, 2024 at 07:13:38AM +0200, Anna-Maria Behnsen wrote:
> Function descriptions in iopoll.h, regmap.h, phy.h and sound/soc/sof/ops.h
> copied all the same outdated documentation about sleep/delay function
> limitations. In those comments, the generic (and still outdated) timer
> documentation file is referenced.
> 
> As proper function descriptions for used delay and sleep functions are in
> place, simply update the descriptions to reference to them. While at it fix
> missing colon after "Returns" in function description and move return value
> description to the end of the function description.
> 
> Cc: Andrew Lunn <andrew@lunn.ch>
> Cc: Heiner Kallweit <hkallweit1@gmail.com>
> Cc: Jaroslav Kysela <perex@perex.cz>
> Cc: Takashi Iwai <tiwai@suse.com>
> Cc: netdev@vger.kernel.org
> Cc: linux-sound@vger.kernel.org
> Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
> ---
> v2: Add cleanup of usage of 'Returns' in function description
> ---
>  include/linux/iopoll.h | 52 +++++++++++++++++++++++++-------------------------
>  include/linux/phy.h    |  9 +++++----

For the phy.h parts:

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 00/15] timers: Cleanup delay/sleep related mess
  2024-09-11  5:13 [PATCH v2 00/15] timers: Cleanup delay/sleep related mess Anna-Maria Behnsen
  2024-09-11  5:13 ` [PATCH v2 12/15] iopoll/regmap/phy/snd: Fix comment referencing outdated timer documentation Anna-Maria Behnsen
@ 2024-09-16 20:20 ` Christophe JAILLET
  2024-09-17  5:22   ` Christophe JAILLET
  2024-10-02 15:02   ` Thomas Gleixner
  1 sibling, 2 replies; 8+ messages in thread
From: Christophe JAILLET @ 2024-09-16 20:20 UTC (permalink / raw)
  To: Frederic Weisbecker, Thomas Gleixner, Jonathan Corbet,
	Anna-Maria Behnsen
  Cc: linux-kernel, Len Brown, Rafael J. Wysocki, Anna-Maria Behnsen,
	Andrew Morton, damon, linux-mm, SeongJae Park, Arnd Bergmann,
	linux-arch, Heiner Kallweit, David S. Miller, Andy Whitcroft,
	Joe Perches, Dwaipayan Ray, Liam Girdwood, Mark Brown,
	Andrew Lunn, Jaroslav Kysela, Takashi Iwai, netdev, linux-sound,
	Michael Ellerman, Nathan Lynch, linuxppc-dev,
	Mauro Carvalho Chehab, linux-media

Le 11/09/2024 à 07:13, Anna-Maria Behnsen a écrit :
> Hi,
> 
> a question about which sleeping function should be used in acpi_os_sleep()
> started a discussion and examination about the existing documentation and
> implementation of functions which insert a sleep/delay.
> 
> The result of the discussion was, that the documentation is outdated and
> the implemented fsleep() reflects the outdated documentation but doesn't
> help to reflect reality which in turns leads to the queue which covers the
> following things:
> 
> - Split out all timeout and sleep related functions from hrtimer.c and timer.c
>    into a separate file
> 
> - Update function descriptions of sleep related functions
> 
> - Change fsleep() to reflect reality
> 
> - Rework all comments or users which obviously rely on the outdated
>    documentation as they reference "Documentation/timers/timers-howto.rst"
> 
> - Last but not least (as there are no more references): Update the outdated
>    documentation and move it into a file with a self explaining file name
> 
> The queue is available here and applies on top of tip/timers/core:
> 
>    git://git.kernel.org/pub/scm/linux/kernel/git/anna-maria/linux-devel.git timers/misc
> 
> Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>

Hi,

not directly related to your serie, but some time ago I sent a patch to 
micro-optimize Optimize usleep_range(). (See [1])

The idea is that the 2 parameters of usleep_range() are usually 
constants and some code reordering could easily let the compiler compute 
a few things at compilation time.

There was consensus on the value of the change (see [2]), but as you are 
touching things here, maybe it makes sense now to save a few cycles at 
runtime and a few bytes of code?

CJ

[1]: 
https://lore.kernel.org/all/f0361b83a0a0b549f8ec5ab8134905001a6f2509.1659126514.git.christophe.jaillet@wanadoo.fr/

[2]: 
https://lore.kernel.org/all/03c2bbe795fe4ddcab66eb852bae3715@AcuMS.aculab.com/



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 00/15] timers: Cleanup delay/sleep related mess
  2024-09-16 20:20 ` [PATCH v2 00/15] timers: Cleanup delay/sleep related mess Christophe JAILLET
@ 2024-09-17  5:22   ` Christophe JAILLET
  2024-09-23 15:12     ` Anna-Maria Behnsen
  2024-10-02 15:02   ` Thomas Gleixner
  1 sibling, 1 reply; 8+ messages in thread
From: Christophe JAILLET @ 2024-09-17  5:22 UTC (permalink / raw)
  To: Anna-Maria Behnsen
  Cc: linux-kernel, Len Brown, Rafael J. Wysocki, Andrew Morton, damon,
	linux-mm, SeongJae Park, Arnd Bergmann, linux-arch,
	Heiner Kallweit, David S. Miller, Andy Whitcroft, Joe Perches,
	Dwaipayan Ray, Liam Girdwood, Mark Brown, Andrew Lunn,
	Jaroslav Kysela, Takashi Iwai, netdev, linux-sound,
	Michael Ellerman, Nathan Lynch, linuxppc-dev,
	Mauro Carvalho Chehab, linux-media, Frederic Weisbecker,
	Thomas Gleixner, Jonathan Corbet



Le 16/09/2024 à 22:20, Christophe JAILLET a écrit :
> Le 11/09/2024 à 07:13, Anna-Maria Behnsen a écrit :
>> Hi,
>>
>> a question about which sleeping function should be used in 
>> acpi_os_sleep()
>> started a discussion and examination about the existing documentation and
>> implementation of functions which insert a sleep/delay.
>>
>> The result of the discussion was, that the documentation is outdated and
>> the implemented fsleep() reflects the outdated documentation but doesn't
>> help to reflect reality which in turns leads to the queue which covers 
>> the
>> following things:
>>
>> - Split out all timeout and sleep related functions from hrtimer.c and 
>> timer.c
>>    into a separate file
>>
>> - Update function descriptions of sleep related functions
>>
>> - Change fsleep() to reflect reality
>>
>> - Rework all comments or users which obviously rely on the outdated
>>    documentation as they reference "Documentation/timers/timers- 
>> howto.rst"
>>
>> - Last but not least (as there are no more references): Update the 
>> outdated
>>    documentation and move it into a file with a self explaining file name
>>
>> The queue is available here and applies on top of tip/timers/core:
>>
>>    git://git.kernel.org/pub/scm/linux/kernel/git/anna-maria/linux- 
>> devel.git timers/misc
>>
>> Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
> 
> Hi,
> 
> not directly related to your serie, but some time ago I sent a patch to 
> micro-optimize Optimize usleep_range(). (See [1])
> 
> The idea is that the 2 parameters of usleep_range() are usually 
> constants and some code reordering could easily let the compiler compute 
> a few things at compilation time.
> 
> There was consensus on the value of the change (see [2]), but as you are 

Typo: there was *no* consensus...

> touching things here, maybe it makes sense now to save a few cycles at 
> runtime and a few bytes of code?
> 
> CJ
> 
> [1]: https://lore.kernel.org/all/ 
> f0361b83a0a0b549f8ec5ab8134905001a6f2509.1659126514.git.christophe.jaillet@wanadoo.fr/
> 
> [2]: https://lore.kernel.org/ 
> all/03c2bbe795fe4ddcab66eb852bae3715@AcuMS.aculab.com/
> 
> 
> 
> 


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 00/15] timers: Cleanup delay/sleep related mess
  2024-09-17  5:22   ` Christophe JAILLET
@ 2024-09-23 15:12     ` Anna-Maria Behnsen
  0 siblings, 0 replies; 8+ messages in thread
From: Anna-Maria Behnsen @ 2024-09-23 15:12 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: linux-kernel, Len Brown, Rafael J. Wysocki, Andrew Morton, damon,
	linux-mm, SeongJae Park, Arnd Bergmann, linux-arch,
	Heiner Kallweit, David S. Miller, Andy Whitcroft, Joe Perches,
	Dwaipayan Ray, Liam Girdwood, Mark Brown, Andrew Lunn,
	Jaroslav Kysela, Takashi Iwai, netdev, linux-sound,
	Michael Ellerman, Nathan Lynch, linuxppc-dev,
	Mauro Carvalho Chehab, linux-media, Frederic Weisbecker,
	Thomas Gleixner, Jonathan Corbet

Christophe JAILLET <christophe.jaillet@wanadoo.fr> writes:

> Le 16/09/2024 à 22:20, Christophe JAILLET a écrit :
>> Le 11/09/2024 à 07:13, Anna-Maria Behnsen a écrit :
>>> Hi,
>>>
>>> a question about which sleeping function should be used in 
>>> acpi_os_sleep()
>>> started a discussion and examination about the existing documentation and
>>> implementation of functions which insert a sleep/delay.
>>>
>>> The result of the discussion was, that the documentation is outdated and
>>> the implemented fsleep() reflects the outdated documentation but doesn't
>>> help to reflect reality which in turns leads to the queue which covers 
>>> the
>>> following things:
>>>
>>> - Split out all timeout and sleep related functions from hrtimer.c and 
>>> timer.c
>>>    into a separate file
>>>
>>> - Update function descriptions of sleep related functions
>>>
>>> - Change fsleep() to reflect reality
>>>
>>> - Rework all comments or users which obviously rely on the outdated
>>>    documentation as they reference "Documentation/timers/timers- 
>>> howto.rst"
>>>
>>> - Last but not least (as there are no more references): Update the 
>>> outdated
>>>    documentation and move it into a file with a self explaining file name
>>>
>>> The queue is available here and applies on top of tip/timers/core:
>>>
>>>    git://git.kernel.org/pub/scm/linux/kernel/git/anna-maria/linux- 
>>> devel.git timers/misc
>>>
>>> Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
>> 
>> Hi,
>> 
>> not directly related to your serie, but some time ago I sent a patch to 
>> micro-optimize Optimize usleep_range(). (See [1])
>> 
>> The idea is that the 2 parameters of usleep_range() are usually 
>> constants and some code reordering could easily let the compiler compute 
>> a few things at compilation time.
>> 
>> There was consensus on the value of the change (see [2]), but as you are 
>
> Typo: there was *no* consensus...
>
>> touching things here, maybe it makes sense now to save a few cycles at 
>> runtime and a few bytes of code?
>> 

Sorry for the late reply. I'll check it and will come back to you.

Thanks,
	Anna-Maria


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 00/15] timers: Cleanup delay/sleep related mess
  2024-09-16 20:20 ` [PATCH v2 00/15] timers: Cleanup delay/sleep related mess Christophe JAILLET
  2024-09-17  5:22   ` Christophe JAILLET
@ 2024-10-02 15:02   ` Thomas Gleixner
  1 sibling, 0 replies; 8+ messages in thread
From: Thomas Gleixner @ 2024-10-02 15:02 UTC (permalink / raw)
  To: Christophe JAILLET, Frederic Weisbecker, Jonathan Corbet,
	Anna-Maria Behnsen
  Cc: linux-kernel, Len Brown, Rafael J. Wysocki, Anna-Maria Behnsen,
	Andrew Morton, damon, linux-mm, SeongJae Park, Arnd Bergmann,
	linux-arch, Heiner Kallweit, David S. Miller, Andy Whitcroft,
	Joe Perches, Dwaipayan Ray, Liam Girdwood, Mark Brown,
	Andrew Lunn, Jaroslav Kysela, Takashi Iwai, netdev, linux-sound,
	Michael Ellerman, Nathan Lynch, linuxppc-dev,
	Mauro Carvalho Chehab, linux-media

On Mon, Sep 16 2024 at 22:20, Christophe JAILLET wrote:
> Le 11/09/2024 à 07:13, Anna-Maria Behnsen a écrit :
>
> not directly related to your serie, but some time ago I sent a patch to 
> micro-optimize Optimize usleep_range(). (See [1])
>
> The idea is that the 2 parameters of usleep_range() are usually 
> constants and some code reordering could easily let the compiler compute 
> a few things at compilation time.
>
> There was consensus on the value of the change (see [2]), but as you are 
> touching things here, maybe it makes sense now to save a few cycles at 
> runtime and a few bytes of code?

For the price of yet another ugly interface and pushing the
multiplication into the non-constant call sites.

Seriously usleep() is not a hotpath operation and the multiplication is
not even measurable except in micro benchmarks.

Thanks,

        tglx

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 12/15] iopoll/regmap/phy/snd: Fix comment referencing outdated timer documentation
  2024-09-11  5:13 ` [PATCH v2 12/15] iopoll/regmap/phy/snd: Fix comment referencing outdated timer documentation Anna-Maria Behnsen
  2024-09-11 12:08   ` Andrew Lunn
@ 2024-10-09 16:14   ` Frederic Weisbecker
  1 sibling, 0 replies; 8+ messages in thread
From: Frederic Weisbecker @ 2024-10-09 16:14 UTC (permalink / raw)
  To: Anna-Maria Behnsen
  Cc: Thomas Gleixner, Jonathan Corbet, linux-kernel, Len Brown,
	Rafael J. Wysocki, Andrew Lunn, Heiner Kallweit, Jaroslav Kysela,
	Takashi Iwai, netdev, linux-sound

Le Wed, Sep 11, 2024 at 07:13:38AM +0200, Anna-Maria Behnsen a écrit :
> Function descriptions in iopoll.h, regmap.h, phy.h and sound/soc/sof/ops.h
> copied all the same outdated documentation about sleep/delay function
> limitations. In those comments, the generic (and still outdated) timer
> documentation file is referenced.
> 
> As proper function descriptions for used delay and sleep functions are in
> place, simply update the descriptions to reference to them. While at it fix
> missing colon after "Returns" in function description and move return value
> description to the end of the function description.
> 
> Cc: Andrew Lunn <andrew@lunn.ch>
> Cc: Heiner Kallweit <hkallweit1@gmail.com>
> Cc: Jaroslav Kysela <perex@perex.cz>
> Cc: Takashi Iwai <tiwai@suse.com>
> Cc: netdev@vger.kernel.org
> Cc: linux-sound@vger.kernel.org
> Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>

Reviewed-by: Frederic Weisbecker <frederic@kernel.org>

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-10-09 16:14 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-11  5:13 [PATCH v2 00/15] timers: Cleanup delay/sleep related mess Anna-Maria Behnsen
2024-09-11  5:13 ` [PATCH v2 12/15] iopoll/regmap/phy/snd: Fix comment referencing outdated timer documentation Anna-Maria Behnsen
2024-09-11 12:08   ` Andrew Lunn
2024-10-09 16:14   ` Frederic Weisbecker
2024-09-16 20:20 ` [PATCH v2 00/15] timers: Cleanup delay/sleep related mess Christophe JAILLET
2024-09-17  5:22   ` Christophe JAILLET
2024-09-23 15:12     ` Anna-Maria Behnsen
2024-10-02 15:02   ` Thomas Gleixner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).