From: Harry Wentland <harry.wentland@amd.com>
To: "Linus Torvalds" <torvalds@linux-foundation.org>,
"Arnd Bergmann" <arnd@kernel.org>, "Leo Li" <sunpeng.li@amd.com>,
"Alex Deucher" <alexander.deucher@amd.com>,
"Christian König" <christian.koenig@amd.com>,
"Pan, Xinhui" <Xinhui.Pan@amd.com>
Cc: Nathan Chancellor <nathan@kernel.org>,
Guenter Roeck <linux@roeck-us.net>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
llvm@lists.linux.dev, Nick Desaulniers <ndesaulniers@google.com>,
amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH] Enable '-Werror' by default for all kernel builds
Date: Tue, 7 Sep 2021 17:07:31 -0400 [thread overview]
Message-ID: <fb50dc44-fbe4-e6b3-5abc-d90375992292@amd.com> (raw)
In-Reply-To: <CAHk-=wh37UWTqUzbh5qg_x9pFgqBVwpdq_Kf+hnB5mqEUkrjmg@mail.gmail.com>
On 2021-09-07 1:33 p.m., Linus Torvalds wrote:
> On Tue, Sep 7, 2021 at 10:10 AM Linus Torvalds
> <torvalds@linux-foundation.org> wrote:
>>
>> Do I know why? No. I do note that that code is disgusting.
>>
>> It's passing one of those structs around by value, for example. That's
>> a 72-byte structure that is copied on the stack due to stupid calling
>> conventions. Maybe clang generates a few extra temporaries for it as
>> part of the function call stack setup? Who knows..
>
> Ooh, yes.
>
> This attached patch is crap - it converts the helper functions to use
> const pointers instead of passing the whole structure, but it then
> only converts that one file that *uses* them.
>
> So the end result will not compile in general, but you can do
>
> make drivers/gpu/drm/amd/amdgpu/../display/dc/dml/dcn30/display_rq_dlg_calc_30.o
>
> and it compiles for me.
>
> And while gcc doesn't care that much - it will apparently either
> generate the argument stack every call - clang cares deeply.
>
> The nasty 720-byte stack frame that clang generates turns into just a
> 320-byte one, and code generation in general looks a *lot* better.
>
> Now, as mentioned, this patch is broken and incomplete. But I really
> think the AMD GPU people need to do this. It makes those functions go
> from practically unusable to not horribly disgusting.
>
> So Harry/Leo/Alex/Christian and amd-gfx list - can you look into
> making this ugly "make one file compile better" patch actually work
> properly?
>
Yes, will take a look at this tonight. We definitely shouldn't be passing
large structs by value.
Harry
> It *looks* lto me ike that code was perhaps written for a C++ compiler
> and the helpers have been written as a "pass by reference", and the
> arguments used to be
>
> const display_data_rq_misc_params_st& rq_misc_param
>
> and then the compiler will pass the argument as a pointer. And then it
> was converted to C, and the "pass by reference" in the function
> declaration was turned into "pass by value", to avoid changing "." to
> "->" in the use.
>
> But a '&arg' thing in C++ really is a '*arg' pointer in C, and should
> have been done as that.
>
> Of course, it's also possible that that code was simply written by
> somebody who didn't understand just *how* horrible it is to pass
> structures bigger than a word or two by value.
>
> Do we have a compiler warning for passing big structures by value?
>
> Linus
>
next prev parent reply other threads:[~2021-09-07 21:07 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-06 14:26 [PATCH] Enable '-Werror' by default for all kernel builds Guenter Roeck
2021-09-06 16:12 ` Linus Torvalds
2021-09-06 16:18 ` Linus Torvalds
2021-09-06 17:05 ` Guenter Roeck
2021-09-06 23:06 ` Linus Torvalds
2021-09-06 23:49 ` Guenter Roeck
2021-09-07 1:12 ` Linus Torvalds
2021-09-07 2:29 ` Guenter Roeck
2021-09-07 15:50 ` Guenter Roeck
2021-09-07 8:56 ` Arnd Bergmann
2021-09-08 4:28 ` Guenter Roeck
2021-09-08 4:48 ` Al Viro
2021-09-08 5:14 ` Guenter Roeck
2021-09-08 7:11 ` Geert Uytterhoeven
2021-09-08 9:50 ` Arnd Bergmann
2021-09-08 10:10 ` Geert Uytterhoeven
2021-09-08 10:21 ` Geert Uytterhoeven
2021-09-08 12:42 ` Guenter Roeck
2021-09-08 13:19 ` Al Viro
2021-09-08 13:54 ` Guenter Roeck
2021-09-08 14:47 ` David Laight
2021-09-08 4:55 ` Linus Torvalds
2021-09-08 5:46 ` Guenter Roeck
2021-09-07 5:32 ` Huang Rui
2021-09-07 6:15 ` Christian König
2021-09-07 6:58 ` Geert Uytterhoeven
2021-09-07 2:30 ` Nathan Chancellor
2021-09-07 9:11 ` Arnd Bergmann
2021-09-07 17:10 ` Linus Torvalds
2021-09-07 17:33 ` Linus Torvalds
2021-09-07 21:07 ` Harry Wentland [this message]
2021-09-08 3:52 ` Harry Wentland
2021-09-08 4:41 ` Linus Torvalds
2021-09-09 0:48 ` Harry Wentland
2021-09-07 17:48 ` Guenter Roeck
2021-09-07 19:12 ` Nathan Chancellor
2021-09-08 20:55 ` Nathan Chancellor
2021-09-08 21:16 ` Guenter Roeck
2021-09-08 21:58 ` Marco Elver
2021-09-09 5:58 ` Christoph Hellwig
2021-09-09 6:07 ` Guenter Roeck
2021-09-09 7:30 ` Christian König
2021-09-09 14:59 ` Guenter Roeck
2021-09-09 10:53 ` Marco Elver
2021-09-09 11:00 ` Arnd Bergmann
2021-09-09 11:43 ` Marco Elver
2021-09-09 12:55 ` Arnd Bergmann
2021-09-09 16:53 ` Linus Torvalds
2021-09-09 16:46 ` Linus Torvalds
2021-09-21 15:41 ` Arnd Bergmann
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=fb50dc44-fbe4-e6b3-5abc-d90375992292@amd.com \
--to=harry.wentland@amd.com \
--cc=Xinhui.Pan@amd.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=arnd@kernel.org \
--cc=christian.koenig@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=llvm@lists.linux.dev \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=sunpeng.li@amd.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;
as well as URLs for NNTP newsgroup(s).