From: Julia Lawall <julia.lawall@lip6.fr>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Paul Gortmaker <paul.gortmaker@windriver.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Ingo Molnar <mingo@kernel.org>,
linux-kernel <linux-kernel@vger.kernel.org>,
linux-gpio@vger.kernel.org
Subject: Re: [GIT PULL] pin control bulk changes for v4.16
Date: Mon, 5 Feb 2018 10:58:32 +0100 (CET) [thread overview]
Message-ID: <alpine.DEB.2.20.1802051057120.3292@hadrien> (raw)
In-Reply-To: <CACRpkdb0P38+cvVeSw7imzehb5VM51fmxOBWJWgzdnuEP9ryDQ@mail.gmail.com>
On Mon, 5 Feb 2018, Linus Walleij wrote:
> On Mon, Feb 5, 2018 at 10:27 AM, Julia Lawall <julia.lawall@lip6.fr> wrote:
> > On Mon, 5 Feb 2018, Linus Walleij wrote:
>
> >> We definitely need some better tooling to find these things,
> >> using Ingo's head and your occasional frustration is not going to
> >> scale.
> >>
> >> Julia: do you have ideas on tooling that can loosen #include
> >> deps and advise on when to replace #includes with forward
> >> declarations of structs (etc) to bring down rebuild-triggering
> >> dependencies?
> >
> > Could you explain more? Is the point that you want to remove an include
> > but it has one declaration that you need, and so you want to bring it down
> > into the .c file? Would the need for that actually indicate that the
> > include file is designed incorrectly?
> >
> > Can one assume that each include is self contained, ie it includes the
> > things that it needs and does not rely on the .c file having included
> > other things beforehand?
>
> Usually (in my limited experience, le's see what Ingo and Torvalds
> say) the problem manifests mainly in include files including other
> include files.
>
> So say <linux/foo.h>:
>
> #include <linux/bar.h>
>
> struct foo {
> struct bar *barp;
> };
>
> Since this is only putting a pointer inside its struct and doesn't
> need the information on the whole structs, as the size of a pointer
> is well known we can reduce it to:
>
> struct bar;
>
> struct foo {
> struct bar *barp;
> };
>
> And thus as <linux/bar.h> is not even included, it can change
> all it wants, our foo.h include file is not affected, neither will
> any driver just casually #including <linux/foo.h> need to be
> rebuilt.
>
> This type of case (and variations on this theme) is the reason
> we put a bunch of forward-declarations in kernel .h-files
> just to break dependencies to stuff just referenced by pointer.
>
> There is a counter-pattern saying "files should #include the
> headers prototypes, structs (etc) it uses" that drives a truck
> through this approach. But IMO when done properly, this
> forward-declaring approach is quite readable.
>
> I have very limited idea of where, whether in the preprocessor
> or the compiler itself, the decision to treat struct bar *barp
> as "just some pointer" happens, but it is a real neat trick, the
> dependency chain is broken in CPP AFAICT anyways, and cuts
> down the rebuilds.
OK, thanks for the explanation. It seems like a very interesting problem.
I will think about it and see if something can be done. It seems like it
may need careful checking by a human, due to macros, ifdefs, etc, but
perhaps it can at least be heplful to narrow down the opportunities.
julia
next prev parent reply other threads:[~2018-02-05 9:58 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-02 13:28 Linus Walleij
2018-02-02 22:56 ` Linus Torvalds
2018-02-03 0:44 ` Linus Torvalds
2018-02-03 0:51 ` Linus Torvalds
2018-02-05 9:20 ` Linus Walleij
2018-02-05 9:27 ` Julia Lawall
2018-02-05 9:42 ` Linus Walleij
2018-02-05 9:58 ` Julia Lawall [this message]
2018-02-05 19:08 ` Paul Gortmaker
2018-02-03 10:45 ` Ingo Molnar
2018-02-05 10:09 ` David Laight
2018-02-05 16:55 ` Linus Torvalds
2018-02-05 17:19 ` Linus Torvalds
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=alpine.DEB.2.20.1802051057120.3292@hadrien \
--to=julia.lawall@lip6.fr \
--cc=gregkh@linuxfoundation.org \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=paul.gortmaker@windriver.com \
--cc=torvalds@linux-foundation.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 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®