mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Josh Poimboeuf <jpoimboe@redhat.com>
To: Joe Lawrence <joe.lawrence@redhat.com>
Cc: Nicholas Mc Guire <der.herr@hofr.at>,
	Nicholas Mc Guire <hofrat@osadl.org>,
	Jessica Yu <jeyu@kernel.org>, Jiri Kosina <jikos@kernel.org>,
	Miroslav Benes <mbenes@suse.cz>, Petr Mladek <pmladek@suse.com>,
	live-patching@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2 V2] livepatch: handle kzalloc failure properly
Date: Thu, 13 Dec 2018 14:49:58 -0600	[thread overview]
Message-ID: <20181213204958.tkapx6qi7fnm5t6h@treble> (raw)
In-Reply-To: <7aa8369b-0e64-ecf4-79a1-986c6ffeb59b@redhat.com>

On Thu, Dec 13, 2018 at 03:39:20PM -0500, Joe Lawrence wrote:
> Ahh, I understand the question now.  Yeah, by making those routines local 
> static, the compiler applied optimizations that renamed the symbols:
> 
>   noinline static
>   % readelf --syms samples/livepatch/livepatch-shadow-mod.o | grep dummy_                                          
>        5: 0000000000000000    20 FUNC    LOCAL  DEFAULT    1 dummy_check.isra.0
>        7: 0000000000000020    52 FUNC    LOCAL  DEFAULT    1 dummy_free.constprop.1
>       12: 00000000000000c0    32 OBJECT  LOCAL  DEFAULT    3 dummy_list_mutex
>       13: 00000000000000e0    16 OBJECT  LOCAL  DEFAULT    3 dummy_list
>       15: 0000000000000160   115 FUNC    LOCAL  DEFAULT    1 dummy_alloc
> 
> 
> I can avoid that optimization (and successfully load all the modules) 
> by using either:
> 
>   __attribute__((optimize("O0"))) noinline static
>   % readelf --syms samples/livepatch/livepatch-shadow-mod.o | grep dummy_
>        6: 0000000000000000  6016 FUNC    LOCAL  DEFAULT    1 dummy_alloc
>       11: 00000000000000c0    32 OBJECT  LOCAL  DEFAULT    3 dummy_list_mutex
>       12: 00000000000000e0    16 OBJECT  LOCAL  DEFAULT    3 dummy_list
>       14: 0000000000001810    73 FUNC    LOCAL  DEFAULT    1 dummy_free
>       16: 0000000000001860   108 FUNC    LOCAL  DEFAULT    1 dummy_check
> 
> or:
> 
>   __noclone noinline static
>   % readelf --syms samples/livepatch/livepatch-shadow-mod.o | grep dummy_
>        5: 0000000000000000    22 FUNC    LOCAL  DEFAULT    1 dummy_check
>        7: 0000000000000020    51 FUNC    LOCAL  DEFAULT    1 dummy_free
>       12: 00000000000000c0    32 OBJECT  LOCAL  DEFAULT    3 dummy_list_mutex
>       13: 00000000000000e0    16 OBJECT  LOCAL  DEFAULT    3 dummy_list
>       15: 0000000000000160   115 FUNC    LOCAL  DEFAULT    1 dummy_alloc
> 
> but I'm not sure if either is the definitive way to avoid such
> optimization.  Anyone know for sure?

Yeah, for now I think "static __noclone" is the way to go.  Soon we'll
have a GCC flag which disables such optimizations for all functions.

And the dummy_list* variables can just be "static".

-- 
Josh

      reply	other threads:[~2018-12-13 20:50 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-13 14:05 [PATCH 1/2 " Nicholas Mc Guire
2018-12-13 14:05 ` [PATCH 2/2 " Nicholas Mc Guire
2018-12-13 14:14   ` Joe Lawrence
2018-12-13 15:39     ` Nicholas Mc Guire
2018-12-13 16:39       ` Joe Lawrence
2018-12-13 18:51         ` Nicholas Mc Guire
2018-12-13 20:39           ` Joe Lawrence
2018-12-13 20:49             ` Josh Poimboeuf [this message]

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=20181213204958.tkapx6qi7fnm5t6h@treble \
    --to=jpoimboe@redhat.com \
    --cc=der.herr@hofr.at \
    --cc=hofrat@osadl.org \
    --cc=jeyu@kernel.org \
    --cc=jikos@kernel.org \
    --cc=joe.lawrence@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=live-patching@vger.kernel.org \
    --cc=mbenes@suse.cz \
    --cc=pmladek@suse.com \
    /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®