All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Theodore Tso" <tytso@mit.edu>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: "Paul E. McKenney" <paulmck@kernel.org>,
	Sasha Levin <sashal@kernel.org>,
	Julia Lawall <julia.lawall@inria.fr>,
	Gabriele Paoloni <gpaoloni@redhat.com>,
	Kate Stewart <kstewart@linuxfoundation.org>,
	Chuck Wolber <chuckwolber@gmail.com>,
	Dmitry Vyukov <dvyukov@google.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Lorenzo Stoakes <lorenzo.stoakes@oracle.com>,
	Shuah Khan <skhan@linuxfoundation.org>,
	Chris Mason <clm@meta.com>,
	linux-kernel@vger.kernel.org
Subject: Re: Follow-up on Linux-kernel code accessibility
Date: Thu, 25 Dec 2025 10:03:31 -0500	[thread overview]
Message-ID: <20251225150331.GB15088@macsyma.lan> (raw)
In-Reply-To: <20251224091158.6ab443cb@gandalf.local.home>

On Wed, Dec 24, 2025 at 09:11:58AM -0500, Steven Rostedt wrote:
> /*
>  * Loop doing repeated quiescent-state forcing until the grace period ends.
>  */
> static noinline_for_stack void rcu_gp_fqs_loop(void)
> {
> 	bool first_gp_fqs = true;
> 	int gf = 0;
> 	unsigned long j;
> 	int ret;
> 	struct rcu_node *rnp = rcu_get_root();
> 
> 	j = READ_ONCE(jiffies_till_first_fqs);
> 	if (rcu_state.cbovld)
> 		gf = RCU_GP_FLAG_OVLD;
> 	ret = 0;
> 	for (;;) {
> 		if (rcu_state.cbovld) {
> 			j = (j + 2) / 3;
> 			if (j <= 0)
> 				j = 1;
> 		}
> 		if (!ret || time_before(jiffies + j, rcu_state.jiffies_force_qs)) {
> 			WRITE_ONCE(rcu_state.jiffies_force_qs, jiffies + j);
> 			/*
> 			 * jiffies_force_qs before RCU_GP_WAIT_FQS state
> 			 * update; required for stall checks.
> 			 */
> 			smp_wmb();
> 			WRITE_ONCE(rcu_state.jiffies_kick_kthreads,
> 				   jiffies + (j ? 3 * j : 2));
> 		}
> 
> There's a bit of magical manipulation of "j" that I have no idea why it's
> doing that. ;-)
> 
> I would love if Julia or Gabriele came up with some specification for that
> function.

I think we need to separate out two different things.  The first is
<<what>> the function is doing, and the other is <<how>> the function
is doing it.  The first is the specification, or the interface
contract.  The second is the implementation details that are important
if you need to modify the function, or want to verify its corrections.

I'm reminded of the ancient Unix documentation of how context
switching was implemented on a PDP-11, "You are not expected to
understand this".  But as long as you understood what it was doing,
the fact the magic wasn't described in the source code might be OK.
OTOH, it's what inspired the Lion's Commentary on the Unix Source
Code book.   :-)

						- Ted

  reply	other threads:[~2025-12-25 15:04 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-18 19:49 Follow-up on Linux-kernel code accessibility Paul E. McKenney
2025-12-18 22:09 ` David Laight
2025-12-19  0:20   ` Paul E. McKenney
2025-12-19  6:51 ` Julia Lawall
2025-12-19 17:09   ` Theodore Tso
2025-12-19 17:59     ` Sasha Levin
2025-12-19 18:28       ` Steven Rostedt
2025-12-20  0:36         ` Paul E. McKenney
2025-12-22 15:42           ` Steven Rostedt
2025-12-23 23:46             ` Paul E. McKenney
2025-12-24 14:11               ` Steven Rostedt
2025-12-25 15:03                 ` Theodore Tso [this message]
2025-12-25 18:22                   ` Paul E. McKenney
2025-12-26 16:48                   ` Steven Rostedt
2025-12-26 18:44                     ` Paul E. McKenney
2025-12-26 19:22                     ` Theodore Tso
2025-12-26 20:35                       ` Steven Rostedt
2025-12-27  1:04                       ` Paul E. McKenney
2025-12-27  6:16                         ` Julia Lawall
2025-12-27 23:28                           ` Paul E. McKenney
2025-12-27 23:32                             ` Julia Lawall
2025-12-28  1:26                               ` Paul E. McKenney
2025-12-28  1:48                                 ` Dr. David Alan Gilbert
2025-12-28  5:16                                   ` Paul E. McKenney
2025-12-28  9:36                                     ` Julia Lawall
2025-12-29 15:40                                       ` Steven Rostedt
2025-12-29 16:16                                         ` Paul E. McKenney
2025-12-29 17:02                                           ` Dr. David Alan Gilbert
2025-12-29 17:37                                             ` Paul E. McKenney
2025-12-29 18:10                                               ` Dr. David Alan Gilbert
2025-12-29 18:59                                                 ` Paul E. McKenney
2025-12-29 20:35                                                   ` Steven Rostedt
2025-12-29 22:05                                                     ` Dr. David Alan Gilbert
2026-01-09  1:35                                                       ` Paul E. McKenney
2026-01-09  1:34                                                     ` Paul E. McKenney
2026-01-09 14:58                                                       ` Steven Rostedt
2026-01-09 18:31                                                         ` Paul E. McKenney
2026-01-11  3:30                                                         ` Theodore Tso
2026-01-11 17:11                                                           ` Steven Rostedt
2026-01-12  5:06                                                             ` Paul E. McKenney
2026-01-12  7:05                                                               ` Julia Lawall
2026-01-12 16:57                                                                 ` Paul E. McKenney
2025-12-29 23:50                                                   ` Theodore Tso
2025-12-30  0:19                                                     ` Steven Rostedt
2025-12-30  0:34                                                       ` Steven Rostedt
2026-01-09  2:23                                                     ` Paul E. McKenney
2025-12-28 12:46                                     ` Dr. David Alan Gilbert
2025-12-29  0:03                                       ` Paul E. McKenney
2025-12-25 18:18                 ` Paul E. McKenney
2025-12-26 16:51                   ` Steven Rostedt
2025-12-26 18:36                     ` Paul E. McKenney
2025-12-19 21:05     ` Chris Mason
2025-12-20  4:00       ` Theodore Tso
2026-01-06 18:08       ` Lorenzo Stoakes
2026-01-13 13:03         ` Chris Mason
2025-12-20  0:31   ` Paul E. McKenney
2026-01-06 18:05 ` Lorenzo Stoakes
2026-01-09  1:40   ` Paul E. McKenney

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=20251225150331.GB15088@macsyma.lan \
    --to=tytso@mit.edu \
    --cc=chuckwolber@gmail.com \
    --cc=clm@meta.com \
    --cc=dvyukov@google.com \
    --cc=gpaoloni@redhat.com \
    --cc=julia.lawall@inria.fr \
    --cc=kstewart@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lorenzo.stoakes@oracle.com \
    --cc=mark.rutland@arm.com \
    --cc=paulmck@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=sashal@kernel.org \
    --cc=skhan@linuxfoundation.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.