[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <6a130701-7093-4d34-a42d-bee9ba57d33a@paulmck-laptop>
Date: Fri, 26 Dec 2025 10:44:56 -0800
From: "Paul E. McKenney" <paulmck@...nel.org>
To: Steven Rostedt <rostedt@...dmis.org>
Cc: Theodore Tso <tytso@....edu>, Sasha Levin <sashal@...nel.org>,
Julia Lawall <julia.lawall@...ia.fr>,
Gabriele Paoloni <gpaoloni@...hat.com>,
Kate Stewart <kstewart@...uxfoundation.org>,
Chuck Wolber <chuckwolber@...il.com>,
Dmitry Vyukov <dvyukov@...gle.com>,
Mark Rutland <mark.rutland@....com>,
Thomas Gleixner <tglx@...utronix.de>,
Lorenzo Stoakes <lorenzo.stoakes@...cle.com>,
Shuah Khan <skhan@...uxfoundation.org>, Chris Mason <clm@...a.com>,
linux-kernel@...r.kernel.org
Subject: Re: Follow-up on Linux-kernel code accessibility
On Fri, Dec 26, 2025 at 11:48:30AM -0500, Steven Rostedt wrote:
> On Thu, 25 Dec 2025 10:03:31 -0500
> "Theodore Tso" <tytso@....edu> wrote:
>
> > > 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.
>
> Agreed, but knowing what the function is doing should give you some idea of
> how it is doing it.
>
> "Loop doing repeated quiescent-state forcing until the grace period ends."
>
> Is the only description of "what the function is doing", but it gives you
> no clue to why it's using those magic numbers. There should be comments
> about how the magic numbers relate to the what.
Wait... How can you be certain of this in advance of the walkthrough,
but at the same time be uncertain of the value (or lack thereof) of
per-local-variable inline comments? ;-)
> As Julia said in one of our meetings, the "what a function is doing" should
> describe enough so that if you gave that to two different developers they
> would come up with similar code. Different implementations, but at least
> they should have the same result.
For many Linux-kernel subsystems, including RCU, I stand by my point
about background information, as exemplified by Lorenzo's 1300-page book
on mm, and by Mel Gorman's earlier 750-page book. Similar material,
but nowhere near as complete, on RCU may be found in Documentation/RCU.
All that aside, I have no objection to improvements in header comments.
There were quite a few patches to comments that resulted from walking
other RCU maintainers through the code, after all. The rcu_gp_fqs_loop()
header comment was not considered to be lacking for whatever reason,
but who knows?
Thanx, Paul
> > 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. :-)
>
> Reminds me of a saying I saw posted to a developer's desk back in 1992 at
> Martin Marietta: "I don't document my code. If it was hard to write, it
> should be hard to understand!" :-p
>
> -- Steve
Powered by blists - more mailing lists