[PATCH printk v3 01/19] printk: nbcon: Clarify nbcon_get_default_prio() context

John Ogness posted 19 patches 1 year, 4 months ago
There is a newer version of this series
[PATCH printk v3 01/19] printk: nbcon: Clarify nbcon_get_default_prio() context
Posted by John Ogness 1 year, 4 months ago
Correct the kerneldoc and code comments that claimed migration must
be disabled for nbcon_get_default_prio(). This is not true.

Add the explation in the kerneldoc.

Signed-off-by: John Ogness <john.ogness@linutronix.de>
---
 kernel/printk/nbcon.c  | 5 ++++-
 kernel/printk/printk.c | 2 --
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/kernel/printk/nbcon.c b/kernel/printk/nbcon.c
index ef6e76db0f5a..d8388faa6500 100644
--- a/kernel/printk/nbcon.c
+++ b/kernel/printk/nbcon.c
@@ -970,9 +970,12 @@ static __ref unsigned int *nbcon_get_cpu_emergency_nesting(void)
  * nbcon_get_default_prio - The appropriate nbcon priority to use for nbcon
  *				printing on the current CPU
  *
- * Context:	Any context which could not be migrated to another CPU.
+ * Context:	Any context.
  * Return:	The nbcon_prio to use for acquiring an nbcon console in this
  *		context for printing.
+ *
+ * Allowing migration enabled relies on the fact that a context cannot be
+ * migrated to panic or emergency state CPUs.
  */
 enum nbcon_prio nbcon_get_default_prio(void)
 {
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index d0bff0b0abfd..5090c0591f88 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -2401,8 +2401,6 @@ asmlinkage int vprintk_emit(int facility, int level,
 		 * printing of all remaining records to all consoles so that
 		 * this context can return as soon as possible. Hopefully
 		 * another printk() caller will take over the printing.
-		 *
-		 * Also, nbcon_get_default_prio() requires migration disabled.
 		 */
 		preempt_disable();
 
-- 
2.39.2
Re: [PATCH printk v3 01/19] printk: nbcon: Clarify nbcon_get_default_prio() context
Posted by Petr Mladek 1 year, 4 months ago
On Mon 2024-07-22 19:25:21, John Ogness wrote:
> Correct the kerneldoc and code comments that claimed migration must
> be disabled for nbcon_get_default_prio(). This is not true.
> 
> Add the explation in the kerneldoc.
> 
> Signed-off-by: John Ogness <john.ogness@linutronix.de>
> ---
>  kernel/printk/nbcon.c  | 5 ++++-
>  kernel/printk/printk.c | 2 --
>  2 files changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/kernel/printk/nbcon.c b/kernel/printk/nbcon.c
> index ef6e76db0f5a..d8388faa6500 100644
> --- a/kernel/printk/nbcon.c
> +++ b/kernel/printk/nbcon.c
> @@ -970,9 +970,12 @@ static __ref unsigned int *nbcon_get_cpu_emergency_nesting(void)
>   * nbcon_get_default_prio - The appropriate nbcon priority to use for nbcon
>   *				printing on the current CPU
>   *
> - * Context:	Any context which could not be migrated to another CPU.
> + * Context:	Any context.
>   * Return:	The nbcon_prio to use for acquiring an nbcon console in this
>   *		context for printing.
> + *
> + * Allowing migration enabled relies on the fact that a context cannot be
> + * migrated to panic or emergency state CPUs.

The sentence sounds really cryptic to me. I personally prefer
straightforward descriptions for dummies ;-) What about the following?

 * The function reads per-CPU variables but it is safe in any context.
 * The CPU migration is disabled in panic or emergency CPU context
 * by definition.

>   */
>  enum nbcon_prio nbcon_get_default_prio(void)
>  {

I do not resist on the comment update. Feel free to use:

Reviewed-by: Petr Mladek <pmladek@suse.com>

Best Regards,
Petr