From: Dan Carpenter <error27@gmail.com>
To: oe-kbuild@lists.linux.dev,
John Ogness <john.ogness@linutronix.de>,
Petr Mladek <pmladek@suse.com>
Cc: lkp@intel.com, oe-kbuild-all@lists.linux.dev,
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 v1 06/18] printk: nobkl: Add acquire/release logic
Date: Mon, 6 Mar 2023 12:07:38 +0300 [thread overview]
Message-ID: <0a7e5230-3a8d-496a-a42b-bda2dc82ea9a@kili.mountain> (raw)
In-Reply-To: <20230302195618.156940-7-john.ogness@linutronix.de>
Hi John,
url: https://github.com/intel-lab-lkp/linux/commits/John-Ogness/kdb-do-not-assume-write-callback-available/20230303-040039
base: 10d639febe5629687dac17c4a7500a96537ce11a
patch link: https://lore.kernel.org/r/20230302195618.156940-7-john.ogness%40linutronix.de
patch subject: [PATCH printk v1 06/18] printk: nobkl: Add acquire/release logic
config: i386-randconfig-m021 (https://download.01.org/0day-ci/archive/20230305/202303051319.m55kZE3v-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-8) 11.3.0
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Link: https://lore.kernel.org/r/202303051319.m55kZE3v-lkp@intel.com/
smatch warnings:
kernel/printk/printk_nobkl.c:391 cons_try_acquire_spin() warn: signedness bug returning '(-16)'
vim +391 kernel/printk/printk_nobkl.c
d444c8549ebdf3 Thomas Gleixner 2023-03-02 284 /**
d444c8549ebdf3 Thomas Gleixner 2023-03-02 285 * cons_try_acquire_spin - Complete the spinwait attempt
d444c8549ebdf3 Thomas Gleixner 2023-03-02 286 * @ctxt: Pointer to an acquire context that contains
d444c8549ebdf3 Thomas Gleixner 2023-03-02 287 * all information about the acquire mode
d444c8549ebdf3 Thomas Gleixner 2023-03-02 288 *
d444c8549ebdf3 Thomas Gleixner 2023-03-02 289 * @ctxt->hov_state contains the handover state that was set in
d444c8549ebdf3 Thomas Gleixner 2023-03-02 290 * state[REQ]
d444c8549ebdf3 Thomas Gleixner 2023-03-02 291 * @ctxt->req_state contains the request state that was set in
d444c8549ebdf3 Thomas Gleixner 2023-03-02 292 * state[CUR]
d444c8549ebdf3 Thomas Gleixner 2023-03-02 293 *
d444c8549ebdf3 Thomas Gleixner 2023-03-02 294 * Returns: 0 if successfully locked. -EBUSY on timeout. -EAGAIN on
d444c8549ebdf3 Thomas Gleixner 2023-03-02 295 * unexpected state values.
Out of date comments.
d444c8549ebdf3 Thomas Gleixner 2023-03-02 296 *
d444c8549ebdf3 Thomas Gleixner 2023-03-02 297 * On success @ctxt->state contains the new state that was set in
d444c8549ebdf3 Thomas Gleixner 2023-03-02 298 * state[CUR]
d444c8549ebdf3 Thomas Gleixner 2023-03-02 299 *
d444c8549ebdf3 Thomas Gleixner 2023-03-02 300 * On -EBUSY failure this context timed out. This context should either
d444c8549ebdf3 Thomas Gleixner 2023-03-02 301 * give up or attempt a hostile takeover.
d444c8549ebdf3 Thomas Gleixner 2023-03-02 302 *
d444c8549ebdf3 Thomas Gleixner 2023-03-02 303 * On -EAGAIN failure this context encountered unexpected state values.
d444c8549ebdf3 Thomas Gleixner 2023-03-02 304 * This context should retry the full handover request setup process (the
d444c8549ebdf3 Thomas Gleixner 2023-03-02 305 * handover request setup by cons_setup_handover() is now invalidated and
d444c8549ebdf3 Thomas Gleixner 2023-03-02 306 * must be performed again).
Out of date.
d444c8549ebdf3 Thomas Gleixner 2023-03-02 307 */
d444c8549ebdf3 Thomas Gleixner 2023-03-02 308 static bool cons_try_acquire_spin(struct cons_context *ctxt)
^^^^
After reviewing the code, it looks the intention was the bool should be
changed to int.
d444c8549ebdf3 Thomas Gleixner 2023-03-02 309 {
d444c8549ebdf3 Thomas Gleixner 2023-03-02 310 struct console *con = ctxt->console;
d444c8549ebdf3 Thomas Gleixner 2023-03-02 311 struct cons_state cur;
d444c8549ebdf3 Thomas Gleixner 2023-03-02 312 struct cons_state new;
d444c8549ebdf3 Thomas Gleixner 2023-03-02 313 int err = -EAGAIN;
d444c8549ebdf3 Thomas Gleixner 2023-03-02 314 int timeout;
d444c8549ebdf3 Thomas Gleixner 2023-03-02 315
d444c8549ebdf3 Thomas Gleixner 2023-03-02 316 /* Now wait for the other side to hand over */
d444c8549ebdf3 Thomas Gleixner 2023-03-02 317 for (timeout = ctxt->spinwait_max_us; timeout >= 0; timeout--) {
d444c8549ebdf3 Thomas Gleixner 2023-03-02 318 /* Timeout immediately if a remote panic is detected. */
d444c8549ebdf3 Thomas Gleixner 2023-03-02 319 if (cons_check_panic())
d444c8549ebdf3 Thomas Gleixner 2023-03-02 320 break;
d444c8549ebdf3 Thomas Gleixner 2023-03-02 321
d444c8549ebdf3 Thomas Gleixner 2023-03-02 322 cons_state_read(con, CON_STATE_CUR, &cur);
d444c8549ebdf3 Thomas Gleixner 2023-03-02 323
d444c8549ebdf3 Thomas Gleixner 2023-03-02 324 /*
d444c8549ebdf3 Thomas Gleixner 2023-03-02 325 * If the real state of the console matches the handover state
d444c8549ebdf3 Thomas Gleixner 2023-03-02 326 * that this context setup, then the handover was a success
d444c8549ebdf3 Thomas Gleixner 2023-03-02 327 * and this context is now the owner.
d444c8549ebdf3 Thomas Gleixner 2023-03-02 328 *
d444c8549ebdf3 Thomas Gleixner 2023-03-02 329 * Note that this might have raced with a new higher priority
d444c8549ebdf3 Thomas Gleixner 2023-03-02 330 * requester coming in after the lock was handed over.
d444c8549ebdf3 Thomas Gleixner 2023-03-02 331 * However, that requester will see that the owner changes and
d444c8549ebdf3 Thomas Gleixner 2023-03-02 332 * setup a new request for the current owner (this context).
d444c8549ebdf3 Thomas Gleixner 2023-03-02 333 */
d444c8549ebdf3 Thomas Gleixner 2023-03-02 334 if (cons_state_bits_match(cur, ctxt->hov_state))
d444c8549ebdf3 Thomas Gleixner 2023-03-02 335 goto success;
d444c8549ebdf3 Thomas Gleixner 2023-03-02 336
d444c8549ebdf3 Thomas Gleixner 2023-03-02 337 /*
d444c8549ebdf3 Thomas Gleixner 2023-03-02 338 * If state changed since the request was made, give up as
d444c8549ebdf3 Thomas Gleixner 2023-03-02 339 * it is no longer consistent. This must include
d444c8549ebdf3 Thomas Gleixner 2023-03-02 340 * state::req_prio since there could be a higher priority
d444c8549ebdf3 Thomas Gleixner 2023-03-02 341 * request available.
d444c8549ebdf3 Thomas Gleixner 2023-03-02 342 */
d444c8549ebdf3 Thomas Gleixner 2023-03-02 343 if (cur.bits != ctxt->req_state.bits)
d444c8549ebdf3 Thomas Gleixner 2023-03-02 344 goto cleanup;
d444c8549ebdf3 Thomas Gleixner 2023-03-02 345
d444c8549ebdf3 Thomas Gleixner 2023-03-02 346 /*
d444c8549ebdf3 Thomas Gleixner 2023-03-02 347 * Finally check whether the handover state is still
d444c8549ebdf3 Thomas Gleixner 2023-03-02 348 * the same.
d444c8549ebdf3 Thomas Gleixner 2023-03-02 349 */
d444c8549ebdf3 Thomas Gleixner 2023-03-02 350 cons_state_read(con, CON_STATE_REQ, &cur);
d444c8549ebdf3 Thomas Gleixner 2023-03-02 351 if (cur.atom != ctxt->hov_state.atom)
d444c8549ebdf3 Thomas Gleixner 2023-03-02 352 goto cleanup;
d444c8549ebdf3 Thomas Gleixner 2023-03-02 353
d444c8549ebdf3 Thomas Gleixner 2023-03-02 354 /* Account time */
d444c8549ebdf3 Thomas Gleixner 2023-03-02 355 if (timeout > 0)
d444c8549ebdf3 Thomas Gleixner 2023-03-02 356 udelay(1);
d444c8549ebdf3 Thomas Gleixner 2023-03-02 357 }
d444c8549ebdf3 Thomas Gleixner 2023-03-02 358
d444c8549ebdf3 Thomas Gleixner 2023-03-02 359 /*
d444c8549ebdf3 Thomas Gleixner 2023-03-02 360 * Timeout. Cleanup the handover state and carefully try to reset
d444c8549ebdf3 Thomas Gleixner 2023-03-02 361 * req_prio in the real state. The reset is important to ensure
d444c8549ebdf3 Thomas Gleixner 2023-03-02 362 * that the owner does not hand over the lock after this context
d444c8549ebdf3 Thomas Gleixner 2023-03-02 363 * has given up waiting.
d444c8549ebdf3 Thomas Gleixner 2023-03-02 364 */
d444c8549ebdf3 Thomas Gleixner 2023-03-02 365 cons_cleanup_handover(ctxt);
d444c8549ebdf3 Thomas Gleixner 2023-03-02 366
d444c8549ebdf3 Thomas Gleixner 2023-03-02 367 cons_state_read(con, CON_STATE_CUR, &cur);
d444c8549ebdf3 Thomas Gleixner 2023-03-02 368 do {
d444c8549ebdf3 Thomas Gleixner 2023-03-02 369 /*
d444c8549ebdf3 Thomas Gleixner 2023-03-02 370 * The timeout might have raced with the owner coming late
d444c8549ebdf3 Thomas Gleixner 2023-03-02 371 * and handing it over gracefully.
d444c8549ebdf3 Thomas Gleixner 2023-03-02 372 */
d444c8549ebdf3 Thomas Gleixner 2023-03-02 373 if (cons_state_bits_match(cur, ctxt->hov_state))
d444c8549ebdf3 Thomas Gleixner 2023-03-02 374 goto success;
d444c8549ebdf3 Thomas Gleixner 2023-03-02 375
d444c8549ebdf3 Thomas Gleixner 2023-03-02 376 /*
d444c8549ebdf3 Thomas Gleixner 2023-03-02 377 * Validate that the state matches with the state at request
d444c8549ebdf3 Thomas Gleixner 2023-03-02 378 * time. If this check fails, there is already a higher
d444c8549ebdf3 Thomas Gleixner 2023-03-02 379 * priority context waiting or the owner has changed (either
d444c8549ebdf3 Thomas Gleixner 2023-03-02 380 * by higher priority or by hostile takeover). In all fail
d444c8549ebdf3 Thomas Gleixner 2023-03-02 381 * cases this context is no longer in line for a handover to
d444c8549ebdf3 Thomas Gleixner 2023-03-02 382 * take place, so no reset is necessary.
d444c8549ebdf3 Thomas Gleixner 2023-03-02 383 */
d444c8549ebdf3 Thomas Gleixner 2023-03-02 384 if (cur.bits != ctxt->req_state.bits)
d444c8549ebdf3 Thomas Gleixner 2023-03-02 385 goto cleanup;
d444c8549ebdf3 Thomas Gleixner 2023-03-02 386
d444c8549ebdf3 Thomas Gleixner 2023-03-02 387 copy_full_state(new, cur);
d444c8549ebdf3 Thomas Gleixner 2023-03-02 388 new.req_prio = 0;
d444c8549ebdf3 Thomas Gleixner 2023-03-02 389 } while (!cons_state_try_cmpxchg(con, CON_STATE_CUR, &cur, &new));
d444c8549ebdf3 Thomas Gleixner 2023-03-02 390 /* Reset worked. Report timeout. */
d444c8549ebdf3 Thomas Gleixner 2023-03-02 @391 return -EBUSY;
d444c8549ebdf3 Thomas Gleixner 2023-03-02 392
d444c8549ebdf3 Thomas Gleixner 2023-03-02 393 success:
d444c8549ebdf3 Thomas Gleixner 2023-03-02 394 /* Store the real state */
d444c8549ebdf3 Thomas Gleixner 2023-03-02 395 copy_full_state(ctxt->state, cur);
d444c8549ebdf3 Thomas Gleixner 2023-03-02 396 ctxt->hostile = false;
d444c8549ebdf3 Thomas Gleixner 2023-03-02 397 err = 0;
d444c8549ebdf3 Thomas Gleixner 2023-03-02 398
d444c8549ebdf3 Thomas Gleixner 2023-03-02 399 cleanup:
d444c8549ebdf3 Thomas Gleixner 2023-03-02 400 cons_cleanup_handover(ctxt);
d444c8549ebdf3 Thomas Gleixner 2023-03-02 401 return err;
d444c8549ebdf3 Thomas Gleixner 2023-03-02 402 }
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
next prev parent reply other threads:[~2023-03-06 9:08 UTC|newest]
Thread overview: 92+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-02 19:56 [PATCH printk v1 00/18] threaded/atomic console support John Ogness
2023-03-02 19:56 ` [PATCH printk v1 01/18] kdb: do not assume write() callback available John Ogness
2023-03-07 14:57 ` Petr Mladek
2023-03-07 16:34 ` Doug Anderson
2023-03-09 10:52 ` Daniel Thompson
2023-03-09 11:26 ` Petr Mladek
2023-03-09 11:30 ` Daniel Thompson
2023-03-02 19:56 ` [PATCH printk v1 02/18] printk: Add NMI check to down_trylock_console_sem() John Ogness
2023-03-07 16:05 ` Petr Mladek
2023-03-17 11:37 ` John Ogness
2023-04-13 13:42 ` Petr Mladek
2023-03-02 19:56 ` [PATCH printk v1 03/18] printk: Consolidate console deferred printing John Ogness
2023-03-08 13:15 ` Petr Mladek
2023-03-17 13:05 ` John Ogness
2023-04-13 15:15 ` Petr Mladek
2023-03-02 19:56 ` [PATCH printk v1 04/18] printk: Add per-console suspended state John Ogness
2023-03-08 14:40 ` Petr Mladek
2023-03-17 13:22 ` John Ogness
2023-04-14 9:56 ` Petr Mladek
2023-03-02 19:56 ` [PATCH printk v1 05/18] printk: Add non-BKL console basic infrastructure John Ogness
2023-03-09 14:08 ` global states: was: " Petr Mladek
2023-03-17 13:29 ` John Ogness
2023-03-09 15:32 ` naming: " Petr Mladek
2023-03-17 13:39 ` John Ogness
2023-03-21 16:04 ` union: was: " Petr Mladek
2023-03-27 16:28 ` John Ogness
2023-03-28 8:20 ` Petr Mladek
2023-03-28 9:42 ` John Ogness
2023-03-28 12:52 ` Petr Mladek
2023-03-28 13:47 ` Steven Rostedt
2023-03-02 19:56 ` [PATCH printk v1 06/18] printk: nobkl: Add acquire/release logic John Ogness
2023-03-06 9:07 ` Dan Carpenter [this message]
2023-03-06 9:39 ` John Ogness
2023-03-13 16:07 ` Petr Mladek
2023-03-17 14:56 ` John Ogness
2023-03-20 16:10 ` Petr Mladek
2023-03-17 17:34 ` simplify: was: " Petr Mladek
2023-03-21 15:36 ` Petr Mladek
2023-04-02 18:39 ` John Ogness
2023-03-02 19:56 ` [PATCH printk v1 07/18] printk: nobkl: Add buffer management John Ogness
2023-03-21 16:38 ` Petr Mladek
2023-03-23 13:38 ` John Ogness
2023-03-23 15:25 ` Petr Mladek
2023-03-02 19:56 ` [PATCH printk v1 08/18] printk: nobkl: Add sequence handling John Ogness
2023-03-27 15:45 ` Petr Mladek
2023-03-02 19:56 ` [PATCH printk v1 09/18] printk: nobkl: Add print state functions John Ogness
2023-03-29 13:58 ` buffer write race: " Petr Mladek
2023-03-29 14:33 ` John Ogness
2023-03-30 11:54 ` Petr Mladek
2023-03-29 14:05 ` misc details: was: " Petr Mladek
2023-03-02 19:56 ` [PATCH printk v1 10/18] printk: nobkl: Add emit function and callback functions for atomic printing John Ogness
2023-03-03 0:19 ` kernel test robot
2023-03-03 10:55 ` John Ogness
2023-03-31 10:29 ` dropped handling: was: " Petr Mladek
2023-03-31 10:36 ` semantic: " Petr Mladek
[not found] ` <87edp29kvq.fsf@jogness.linutronix.de>
[not found] ` <ZCraqrkqFtsfLWuP@alley>
[not found] ` <87ilecsrvl.fsf@jogness.linutronix.de>
2023-04-04 14:09 ` Petr Mladek
2023-03-02 19:56 ` [PATCH printk v1 11/18] printk: nobkl: Introduce printer threads John Ogness
2023-03-03 1:23 ` kernel test robot
2023-03-03 10:56 ` John Ogness
2023-04-05 10:48 ` boot console: was: " Petr Mladek
2023-04-06 8:09 ` wakeup synchronization: " Petr Mladek
2023-04-06 9:46 ` port lock: " Petr Mladek
2023-04-20 9:55 ` Petr Mladek
2023-04-20 10:33 ` John Ogness
2023-04-20 13:33 ` Petr Mladek
2023-04-21 16:15 ` Petr Mladek
2023-04-06 13:19 ` misc: " Petr Mladek
2023-04-13 13:28 ` (k)thread: " Petr Mladek
2023-03-02 19:56 ` [PATCH printk v1 12/18] printk: nobkl: Add printer thread wakeups John Ogness
2023-04-12 9:38 ` Petr Mladek
2023-03-02 19:56 ` [PATCH printk v1 13/18] printk: nobkl: Add write context storage for atomic writes John Ogness
2023-03-02 19:56 ` [PATCH printk v1 14/18] printk: nobkl: Provide functions for atomic write enforcement John Ogness
2023-04-12 14:53 ` Petr Mladek
2023-03-02 19:56 ` [PATCH printk v1 15/18] printk: nobkl: Stop threads on shutdown/reboot John Ogness
2023-04-13 9:03 ` Petr Mladek
2023-03-02 19:56 ` [PATCH printk v1 16/18] kernel/panic: Add atomic write enforcement to warn/panic John Ogness
2023-04-13 10:08 ` Petr Mladek
2023-04-13 12:13 ` John Ogness
2023-04-14 10:10 ` Petr Mladek
2023-03-02 19:56 ` [PATCH printk v1 17/18] rcu: Add atomic write enforcement for rcu stalls John Ogness
2023-04-13 12:10 ` Petr Mladek
2023-03-02 19:56 ` [PATCH printk v1 18/18] printk: Perform atomic flush in console_flush_on_panic() John Ogness
2023-04-13 12:20 ` Petr Mladek
2023-03-02 19:58 ` [PATCH printk v1 00/18] serial: 8250: implement non-BKL console John Ogness
2023-03-28 13:33 ` locking API: was: " Petr Mladek
2023-03-28 13:57 ` John Ogness
2023-03-28 15:10 ` Petr Mladek
2023-03-28 21:47 ` John Ogness
2023-03-29 8:03 ` Petr Mladek
2023-03-28 13:59 ` [PATCH printk v1 00/18] POC: serial: 8250: implement nbcon console John Ogness
2023-03-09 10:55 ` [PATCH printk v1 00/18] threaded/atomic console support Daniel Thompson
2023-03-09 11:14 ` John Ogness
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=0a7e5230-3a8d-496a-a42b-bda2dc82ea9a@kili.mountain \
--to=error27@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=john.ogness@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=lkp@intel.com \
--cc=oe-kbuild-all@lists.linux.dev \
--cc=oe-kbuild@lists.linux.dev \
--cc=pmladek@suse.com \
--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
all inboxes | Powered by JetHome®