Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1546786

Re: [PATCH v3 13/15] livepatch: change to a per-task consistency model

From Miroslav Benes <mbenes@suse.cz>
Newsgroups linux.kernel
Subject Re: [PATCH v3 13/15] livepatch: change to a per-task consistency model
Date 2016-12-23 10:30 +0100
Message-ID <sRukO-53Q-3@gated-at.bofh.it> (permalink)
References <sMbst-Yb-9@gated-at.bofh.it> <sMbsu-Yb-45@gated-at.bofh.it> <sQwym-89-1@gated-at.bofh.it> <sQWCt-fm-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


> > > diff --git a/kernel/livepatch/patch.c b/kernel/livepatch/patch.c
> > > index 5efa262..e79ebb5 100644
> > > --- a/kernel/livepatch/patch.c
> > > +++ b/kernel/livepatch/patch.c
> > > @@ -29,6 +29,7 @@
> > >  #include <linux/bug.h>
> > >  #include <linux/printk.h>
> > >  #include "patch.h"
> > > +#include "transition.h"
> > >  
> > >  static LIST_HEAD(klp_ops);
> > >  
> > > @@ -54,15 +55,53 @@ static void notrace klp_ftrace_handler(unsigned long ip,
> > >  {
> > >  	struct klp_ops *ops;
> > >  	struct klp_func *func;
> > > +	int patch_state;
> > >  
> > >  	ops = container_of(fops, struct klp_ops, fops);
> > >  
> > >  	rcu_read_lock();
> > > +
> > >  	func = list_first_or_null_rcu(&ops->func_stack, struct klp_func,
> > >  				      stack_node);
> > > -	if (WARN_ON_ONCE(!func))
> > > +
> > > +	if (!func)
> > >  		goto unlock;
> > 
> > Why do you removed the WARN_ON_ONCE(), please?
> > 
> > We still add the function on the stack before registering
> > the ftrace handler. Also we unregister the ftrace handler
> > before removing the the last entry from the stack.
> > 
> > AFAIK, unregister_ftrace_function() calls rcu_synchronize()'
> > to make sure that no-one is inside the handler once finished.
> > Mirek knows more about it.
> 
> Hm, this is news to me.  Mirek, please share :-)

Well, I think the whole thing is well described in emails I exchanged with 
Steven few months ago. See [1].

[1] http://lkml.kernel.org/r/alpine.LNX.2.00.1608081041060.10833@pobox.suse.cz
 
> > If this is not true, we have a problem. For example,
> > we call kfree(ops) after unregister_ftrace_function();
> 
> Agreed.

TL;DR - we should be ok as long as we do not do crazy things in the 
handler, deliberate sleeping for example.

WARN_ON_ONCE() may be crazy too. I think we discussed it long ago and we 
came to an agreement to remove it.

Miroslav, very slowly going through the patch set

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: [PATCH v3 13/15] livepatch: change to a per-task consistency  model Petr Mladek <pmladek@suse.com> - 2016-12-20 18:40 +0100
  Re: [PATCH v3 13/15] livepatch: change to a per-task consistency  model Josh Poimboeuf <jpoimboe@redhat.com> - 2016-12-21 22:30 +0100
    Re: [PATCH v3 13/15] livepatch: change to a per-task consistency  model Petr Mladek <pmladek@suse.com> - 2016-12-22 15:40 +0100
      Re: [PATCH v3 13/15] livepatch: change to a per-task consistency  model Josh Poimboeuf <jpoimboe@redhat.com> - 2016-12-22 19:40 +0100
    Re: [PATCH v3 13/15] livepatch: change to a per-task consistency  model Miroslav Benes <mbenes@suse.cz> - 2016-12-23 10:30 +0100
      Re: [PATCH v3 13/15] livepatch: change to a per-task consistency  model Petr Mladek <pmladek@suse.com> - 2016-12-23 11:20 +0100

csiph-web