The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Christophe Leroy <christophe.leroy@csgroup.eu>
To: David Laight <David.Laight@ACULAB.COM>,
	'Anshuman Khandual' <anshuman.khandual@arm.com>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>
Subject: Re: [PATCH v6] mm: Uninline copy_overflow()
Date: Mon, 14 Feb 2022 15:31:56 +0000	[thread overview]
Message-ID: <3fb6ecb8-5c40-7ff4-4a55-7ea5ffad9962@csgroup.eu> (raw)
In-Reply-To: <05aa3859a0a24a0bb5e3c0affe1eb8b2@AcuMS.aculab.com>



Le 14/02/2022 à 16:10, David Laight a écrit :
> From: Christophe Leroy
>> Sent: 14 February 2022 14:58
> ...
>>> I make that 3 extra instructions.
>>> Two are needed to load the format string.
>>> Not sure why the third gets added.
>>
>> Third instruction is 'twui', to 'trap' and get the warning oops.
> 
> I wondered what that did :-)
> Although you really want the -- cut here -- to contain the pr_warn().
> Doesn't WARN() do that for you?

I remember some discussion about that in the past. Will dig into it 
tomorrow.

> 
> I was looking at that last week because the 'scheduling while atomic'
> trace is "BUG: xxxx" but doesn't have the '--- cut here --" marker.
> 
>>> Not really significant in the 12-15 the error call actually takes.
>>> Although a lot of those are just generating the stack frame
>>> in order to call the error function - and wouldn't be there in
>>> a less trivial example.
>>
>>
>> Yes, after looking once more, maybe making it __always_inline would be
>> enough.
>>
>> The starting point was that I got almost 50 times copy_overflow() in my
>> vmlinux, each having its own format string as well.
> 
> Didn't the linker merge the format strings?
> They ought to end up in strdata.ro.1 (or whatever it is called)
> and the linker merge the references.
> 
>> So my patch reduced vmlinux size by 3908 bytes.
>>
>> But with __always_inline I get a reduction by 3560 which is almost the same.
>>
>> So if you prefer, I can just make copy_overflow() __always_inline and voila.
> 
> I suspect #define __inline __always_inline is the way to go.

That was the case until 889b3c1245de ("compiler: remove 
CONFIG_OPTIMIZE_INLINING entirely")


> Probable along with -Winline.
> 
> The kernel shouldn't have inline sprinkled where it isn't needed.
> 
>>> More interesting would be changing copy_overflow() to return the size.
>>> So copy_to_user() becomes:
>>>
>>> 	if (size_valid())
>>> 		return _copy_to_user();
>>> 	return copy_overflow()
>>
>> Yes that's something to try, allthough it means changing all callers of
>> check_copy_size().
> 
> You could use a differently named function so they can be changed in stages.
> 
> 	David
> 
> -
> Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
> Registration No: 1397386 (Wales)

  reply	other threads:[~2022-02-14 15:32 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-14  6:26 [PATCH v6] mm: Uninline copy_overflow() Christophe Leroy
2022-02-14  9:23 ` David Laight
2022-02-14  9:54 ` Anshuman Khandual
2022-02-14 11:31   ` David Laight
2022-02-14 13:21     ` Christophe Leroy
2022-02-14 14:00       ` David Laight
2022-02-14 14:57         ` Christophe Leroy
2022-02-14 15:10           ` David Laight
2022-02-14 15:31             ` Christophe Leroy [this message]
2022-02-15  7:42               ` Christophe Leroy

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=3fb6ecb8-5c40-7ff4-4a55-7ea5ffad9962@csgroup.eu \
    --to=christophe.leroy@csgroup.eu \
    --cc=David.Laight@ACULAB.COM \
    --cc=akpm@linux-foundation.org \
    --cc=anshuman.khandual@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.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