linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Christophe Leroy' <christophe.leroy@csgroup.eu>,
	'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:10:14 +0000	[thread overview]
Message-ID: <05aa3859a0a24a0bb5e3c0affe1eb8b2@AcuMS.aculab.com> (raw)
In-Reply-To: <ae9c5df2-0096-fec6-4416-cbbcc99f33ce@csgroup.eu>

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 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.
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:10 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-14  6:26 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 [this message]
2022-02-14 15:31             ` Christophe Leroy
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=05aa3859a0a24a0bb5e3c0affe1eb8b2@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=akpm@linux-foundation.org \
    --cc=anshuman.khandual@arm.com \
    --cc=christophe.leroy@csgroup.eu \
    --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