From: Petr Mladek <pmladek@suse.com>
To: John Ogness <john.ogness@linutronix.de>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>,
Steven Rostedt <rostedt@goodmis.org>,
Thomas Gleixner <tglx@linutronix.de>,
linux-kernel@vger.kernel.org,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: Re: [PATCH printk v3 5/7] printk: nbcon: Add sequence handling
Date: Thu, 7 Sep 2023 09:45:50 +0200 [thread overview]
Message-ID: <ZPl_rvMGCg_u538g@alley> (raw)
In-Reply-To: <20230903150539.245076-6-john.ogness@linutronix.de>
On Sun 2023-09-03 17:11:37, John Ogness wrote:
> From: Thomas Gleixner <tglx@linutronix.de>
>
> Add an atomic_long_t field @nbcon_seq to the console struct to
> store the sequence number for nbcon consoles. For nbcon consoles
> this will be used instead of the non-atomic @seq field. The new
> field allows for safe atomic sequence number updates without
> requiring any locking.
>
> On 64bit systems the new field stores the full sequence number.
> On 32bit systems the new field stores the lower 32 bits of the
> sequence number, which are expanded to 64bit as needed by
> folding the values based on the sequence numbers available in
> the ringbuffer.
>
> For 32bit systems, having a 32bit representation in the console
> is sufficient. If a console ever gets more than 2^31 records
> behind the ringbuffer then this is the least of the problems.
>
> --- a/kernel/printk/nbcon.c
> +++ b/kernel/printk/nbcon.c
> +/**
> + * nbcon_seq_try_update - Try to update the console sequence number
> + * @ctxt: Pointer to an acquire context that contains
> + * all information about the acquire mode
> + * @new_seq: The new sequence number to set
> + *
> + * @ctxt->seq is updated to the new value of @con::nbcon_seq. This could
> + * be a different value than @new_seq if nbcon_seq_force() was used or the
> + * current context no longer owns the console. In the later case, it will
> + * stop printing anyway.
> + */
> +__maybe_unused
> +static void nbcon_seq_try_update(struct nbcon_context *ctxt, u64 new_seq)
> +{
> + unsigned long nbcon_seq = __seq_to_nbcon_seq(ctxt->seq);
> + struct console *con = ctxt->console;
> +
> + if (atomic_long_try_cmpxchg(&ACCESS_PRIVATE(con, nbcon_seq), &nbcon_seq,
> + __seq_to_nbcon_seq(new_seq))) {
> + ctxt->seq = new_seq;
> + } else {
> + ctxt->seq = atomic_long_read(&ACCESS_PRIVATE(con, nbcon_seq));
This should be:
ctxt->seq = nbcon_seq_read(con);
so that it extends the 32-bit nbcon_seq to the full 64-bit seq on
32-bit systems.
> + }
> +}
> +
> /**
> * nbcon_context_try_acquire_direct - Try to acquire directly
> * @ctxt: The context of the caller
Otherwise, it looks good. With the above fix:
Reviewed-by: Petr Mladek <pmladek@suse.com>
Best Regards,
Petr
next prev parent reply other threads:[~2023-09-07 17:33 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-03 15:05 [PATCH printk v3 0/7] provide nbcon base John Ogness
2023-09-03 15:05 ` [PATCH printk v3 1/7] printk: Add non-BKL (nbcon) console basic infrastructure John Ogness
2023-09-05 11:45 ` Petr Mladek
2023-09-03 15:05 ` [PATCH printk v3 2/7] printk: nbcon: Add acquire/release logic John Ogness
2023-09-03 16:32 ` kernel test robot
2023-09-05 9:07 ` John Ogness
2023-09-03 16:43 ` kernel test robot
2023-09-06 13:01 ` Petr Mladek
2023-09-03 15:05 ` [PATCH printk v3 3/7] printk: nbcon: Add buffer management John Ogness
2023-09-06 13:26 ` Petr Mladek
2023-09-08 13:03 ` John Ogness
2023-09-03 15:05 ` [PATCH printk v3 4/7] printk: nbcon: Add ownership state functions John Ogness
2023-09-06 13:57 ` Petr Mladek
2023-09-08 13:20 ` John Ogness
2023-09-03 15:05 ` [PATCH printk v3 5/7] printk: nbcon: Add sequence handling John Ogness
2023-09-07 7:45 ` Petr Mladek [this message]
2023-09-03 15:05 ` [PATCH printk v3 6/7] printk: nbcon: Add emit function and callback function for atomic printing John Ogness
2023-09-07 8:22 ` Petr Mladek
2023-09-03 15:05 ` [PATCH printk v3 7/7] printk: nbcon: Add functions for drivers to mark unsafe regions John Ogness
2023-09-07 8:24 ` Petr Mladek
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=ZPl_rvMGCg_u538g@alley \
--to=pmladek@suse.com \
--cc=gregkh@linuxfoundation.org \
--cc=john.ogness@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=senozhatsky@chromium.org \
--cc=tglx@linutronix.de \
/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