All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
To: Joel Fernandes <joel@joelfernandes.org>
Cc: "Paul E. McKenney" <paulmck@linux.ibm.com>,
	Josh Triplett <josh@joshtriplett.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Lai Jiangshan <jiangshanlai@gmail.com>,
	Jonathan Corbet <corbet@lwn.net>,
	rcu@vger.kernel.org, linux-doc@vger.kernel.org,
	Markus Heiser <markus.heiser@darmarit.de>
Subject: Re: [PATCH v2 25/26] docs: rcu: convert some articles from html to ReST
Date: Fri, 26 Jul 2019 16:14:05 -0300	[thread overview]
Message-ID: <20190726161405.278e7cfc@coco.lan> (raw)
In-Reply-To: <20190726180201.GE146401@google.com>

Em Fri, 26 Jul 2019 14:02:01 -0400
Joel Fernandes <joel@joelfernandes.org> escreveu:

> On Fri, Jul 26, 2019 at 09:51:35AM -0300, Mauro Carvalho Chehab wrote:
> [snip]
> > +| until the assignment to ``gp``, by which time both fields are fully   |
> > +| initialized. So reordering the assignments to ``p->a`` and ``p->b``   |
> > +| cannot possibly cause any problems.                                   |
> > ++-----------------------------------------------------------------------+
> > +
> > +It is tempting to assume that the reader need not do anything special to
> > +control its accesses to the RCU-protected data, as shown in
> > +``do_something_gp_buggy()`` below:
> > +
> > +   ::
> > +
> > +       1 bool do_something_gp_buggy(void)
> > +       2 {
> > +       3   rcu_read_lock();
> > +       4   p = gp;  /* OPTIMIZATIONS GALORE!!! */
> > +       5   if (p) {
> > +       6     do_something(p->a, p->b);
> > +       7     rcu_read_unlock();
> > +       8     return true;
> > +       9   }
> > +      10   rcu_read_unlock();
> > +      11   return false;
> > +      12 }
> > +
> > +However, this temptation must be resisted because there are a
> > +surprisingly large number of ways that the compiler (to say nothing of
> > +`DEC Alpha CPUs <https://h71000.www7.hp.com/wizard/wiz_2637.html>`__)
> > +can trip this code up. For but one example, if the compiler were short
> > +of registers, it might choose to refetch from ``gp`` rather than keeping
> > +a separate copy in ``p`` as follows:
> > +
> > +   ::
> > +
> > +       1 bool do_something_gp_buggy_optimized(void)
> > +       2 {
> > +       3   rcu_read_lock();
> > +       4   if (gp) { /* OPTIMIZATIONS GALORE!!! */
> > +       5     do_something(gp->a, gp->b);
> > +       6     rcu_read_unlock();
> > +       7     return true;
> > +       8   }
> > +       9   rcu_read_unlock();
> > +      10   return false;
> > +      11 }
> > +
> > +If this function ran concurrently with a series of updates that replaced
> > +the current structure with a new one, the fetches of ``gp->a`` and
> > +``gp->b`` might well come from two different structures, which could
> > +cause serious confusion. To prevent this (and much else besides),
> > +``do_something_gp()`` uses ``rcu_dereference()`` to fetch from ``gp``:
> > +
> > +   ::
> > +
> > +       1 bool do_something_gp(void)
> > +       2 {
> > +       3   rcu_read_lock();
> > +       4   p = rcu_dereference(gp);
> > +       5   if (p) {
> > +       6     do_something(p->a, p->b);
> > +       7     rcu_read_unlock();
> > +       8     return true;
> > +       9   }
> > +      10   rcu_read_unlock();
> > +      11   return false;
> > +      12 }
> > +
> > +The ``rcu_dereference()`` uses volatile casts and (for DEC Alpha) memory
> > +barriers in the Linux kernel. Should a `high-quality implementation of
> > +C11 ``memory_order_consume``
> > +[PDF] <http://www.rdrop.com/users/paulmck/RCU/consume.2015.07.13a.pdf>`__
> > +ever appear, then ``rcu_dereference()`` could be implemented as a
> > +``memory_order_consume`` load. Regardless of the exact implementation, a
> > +pointer fetched by ``rcu_dereference()`` may not be used outside of the
> > +outermost RCU read-side critical section containing that
> > +``rcu_dereference()``, unless protection of the corresponding data
> > +element has been passed from RCU to some other synchronization
> > +mechanism, most commonly locking or `reference
> > +counting <https://www.kernel.org/doc/Documentation/RCU/rcuref.txt>`__.  
> 
> From the make htmldocs output, this appears very poorly for me, I get
> something like this in the browser:
> 
> The rcu_dereference() uses volatile casts and (for DEC Alpha) memory barriers
> in the Linux kernel. Should a high-quality implementation of C11
> ``memory_order_consume` [PDF]
> <http://www.rdrop.com/users/paulmck/RCU/consume.2015.07.13a.pdf>`__ ever
> appear, then rcu_dereference() could be implemented as a memory_order_consume
> load.
> 
> Is there a syntax issue here?

Maybe. I tested those with Sphinx 2.0.1. Didn't test with older versions.

I'll do some tests with Sphinx 1.7.9 (with is the current minimal
recommended version) and do some cleanup on those references.

> One more feedback,
> the image under "RCU read-side critical section that started before the current
> grace period:" should probably be blown up a bit.

Unfortunately, the Kernel Sphinx image extension doesn't allow image scaling.

We had to add our own image extension at the Kernel, as otherwise,
for every image, we would need to add one parser for PDF and another
one for SVG. 

We would also need an extra parser for DOT.

Markus solved all the 3 image formats with a single extension, but
it currently doesn't allow passing the image size.

-

Markus,

Any reason for the kernel-image extension to not support scaling?

-

If this can't be easily solved at the kernel-image.py extension, a
simple alternative would be to simply scale the SVG file
directly. It should be trivial to re-scale with inkscape, although
the diff may be big.




Thanks,
Mauro

  parent reply	other threads:[~2019-07-26 19:14 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-26 12:51 [PATCH v2 00/26] ReST conversion of text files without .txt extension Mauro Carvalho Chehab
2019-07-26 12:51 ` Mauro Carvalho Chehab
2019-07-26 12:51 ` Mauro Carvalho Chehab
2019-07-26 12:51 ` [OpenRISC] " Mauro Carvalho Chehab
2019-07-26 12:51 ` Mauro Carvalho Chehab
2019-07-26 12:51 ` [PATCH v2 01/26] docs: power: add it to to the main documentation index Mauro Carvalho Chehab
2019-07-31 19:03   ` Jonathan Corbet
2019-07-31 19:16     ` Mauro Carvalho Chehab
2019-07-31 19:34       ` Jonathan Corbet
2019-07-31 19:58         ` Mauro Carvalho Chehab
2019-07-31 20:02           ` Jonathan Corbet
2019-07-26 12:51 ` [PATCH v2 02/26] docs: thermal: add it to the driver API Mauro Carvalho Chehab
2019-07-26 12:51   ` Mauro Carvalho Chehab
2019-07-26 12:51   ` Mauro Carvalho Chehab
2019-07-26 12:51 ` [PATCH v2 03/26] docs: powerpc: convert docs to ReST and rename to *.rst Mauro Carvalho Chehab
2019-07-26 12:51   ` Mauro Carvalho Chehab
2019-07-26 12:51   ` Mauro Carvalho Chehab
2019-07-26 12:51   ` Mauro Carvalho Chehab
2019-07-26 12:51 ` [PATCH v2 04/26] docs: ubifs-authentication.md: convert to ReST Mauro Carvalho Chehab
2019-07-26 12:51 ` [PATCH v2 05/26] docs: writing-schema.md: convert from markdown " Mauro Carvalho Chehab
2019-07-26 12:51   ` Mauro Carvalho Chehab
2019-07-26 12:51 ` [PATCH v2 06/26] docs: i2c: convert to ReST and add to driver-api bookset Mauro Carvalho Chehab
2019-07-26 12:51 ` [PATCH v2 07/26] docs: w1: convert to ReST and add to the kAPI group of docs Mauro Carvalho Chehab
2019-07-26 12:51 ` [PATCH v2 08/26] spi: docs: convert to ReST and add it to the kABI bookset Mauro Carvalho Chehab
2019-07-26 12:51 ` [PATCH v2 09/26] docs: ipmb: place it at driver-api and convert to ReST Mauro Carvalho Chehab
2019-07-26 12:51 ` [PATCH v2 10/26] docs: packing: move it to core-api book and adjust markups Mauro Carvalho Chehab
2019-07-26 12:51 ` [PATCH v2 11/26] docs: admin-guide: add auxdisplay files to it after conversion to ReST Mauro Carvalho Chehab
2019-07-26 12:51 ` [PATCH v2 12/26] docs: README.buddha: convert to ReST and add to m68k book Mauro Carvalho Chehab
2019-07-26 12:51 ` [PATCH v2 13/26] docs: parisc: convert to ReST and add to documentation body Mauro Carvalho Chehab
2019-07-26 12:51 ` [PATCH v2 14/26] docs: openrisc: " Mauro Carvalho Chehab
2019-07-26 12:51   ` [OpenRISC] " Mauro Carvalho Chehab
2019-07-26 12:51 ` [PATCH v2 15/26] docs: isdn: convert to ReST and add to kAPI bookset Mauro Carvalho Chehab
2019-07-26 12:51 ` [PATCH v2 16/26] docs: fs: cifs: convert to ReST and add to admin-guide book Mauro Carvalho Chehab
2019-07-26 12:51 ` [PATCH v2 17/26] docs: fs: convert docs without extension to ReST Mauro Carvalho Chehab
2019-07-26 12:51 ` [PATCH v2 18/26] docs: fs: convert porting " Mauro Carvalho Chehab
2019-07-26 12:51 ` [PATCH v2 19/26] docs: index.rst: don't use genindex for pdf output Mauro Carvalho Chehab
2019-07-26 12:51   ` Mauro Carvalho Chehab
2019-07-26 12:51 ` [PATCH v2 20/26] docs: wimax: convert to ReST and add to admin-guide Mauro Carvalho Chehab
2019-07-26 12:51 ` [PATCH v2 21/26] docs: mips: add to the documentation body as ReST Mauro Carvalho Chehab
2019-07-26 12:51 ` [PATCH v2 22/26] docs: hwmon: pxe1610: convert to ReST format and add to the index Mauro Carvalho Chehab
2019-07-26 12:51 ` [PATCH v2 23/26] docs: nios2: add it to the main Documentation body Mauro Carvalho Chehab
2019-07-26 12:51 ` [PATCH v2 24/26] docs: net: convert two README files to ReST format Mauro Carvalho Chehab
2019-07-26 13:05 ` [PATCH v2 00/26] ReST conversion of text files without .txt extension Mauro Carvalho Chehab
2019-07-26 13:05   ` Mauro Carvalho Chehab
2019-07-26 13:05   ` Mauro Carvalho Chehab
2019-07-26 13:05   ` [OpenRISC] " Mauro Carvalho Chehab
     [not found] ` <8444797277eea7be474f40625bb190775a9cee33.1564145354.git.mchehab+samsung@kernel.org>
     [not found]   ` <20190726162002.GA146401@google.com>
     [not found]     ` <20190726140028.38abb5fa@coco.lan>
2019-07-26 17:55       ` [PATCH v2 25/26] docs: rcu: convert some articles from html to ReST Joel Fernandes
2019-07-26 18:45         ` Mauro Carvalho Chehab
2019-07-26 18:02   ` Joel Fernandes
2019-07-26 19:01     ` [PATCH] tools: memory-model: add it to the Documentation body Mauro Carvalho Chehab
2019-07-27 14:14       ` Joel Fernandes
2019-07-27 15:37         ` Mauro Carvalho Chehab
2019-07-30 22:17           ` Joel Fernandes
2019-07-30 22:57             ` Mauro Carvalho Chehab
2019-07-31 13:52               ` Alan Stern
2019-07-31 13:52                 ` Alan Stern
2019-07-31 15:19                 ` Akira Yokosawa
2019-07-31 20:25                   ` Paul E. McKenney
2019-08-30 11:32                     ` Peter Zijlstra
2019-09-01 13:35                       ` Paul E. McKenney
2019-07-26 19:14     ` Mauro Carvalho Chehab [this message]
2019-07-30 22:06       ` [PATCH v2 25/26] docs: rcu: convert some articles from html to ReST Joel Fernandes
2019-07-30 21:22   ` Paul E. McKenney
2019-07-30 21:50     ` Joel Fernandes
2019-07-30 22:00       ` Mauro Carvalho Chehab
2019-07-30 22:21         ` Joel Fernandes
2019-07-30 23:00           ` Mauro Carvalho Chehab
2019-07-30 23:15             ` Joel Fernandes
2019-07-30 21:50     ` Mauro Carvalho Chehab
2019-07-30 23:37       ` Paul E. McKenney
2019-07-31  0:04         ` Paul E. McKenney
2019-07-31  0:47           ` Mauro Carvalho Chehab
2019-07-31  1:06             ` Paul E. McKenney
2019-07-31  1:33               ` Mauro Carvalho Chehab

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=20190726161405.278e7cfc@coco.lan \
    --to=mchehab+samsung@kernel.org \
    --cc=corbet@lwn.net \
    --cc=jiangshanlai@gmail.com \
    --cc=joel@joelfernandes.org \
    --cc=josh@joshtriplett.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=markus.heiser@darmarit.de \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=paulmck@linux.ibm.com \
    --cc=rcu@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    /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.