public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
From: Prasanna S Panchamukhi <prasanna@in.ibm.com>
To: Keshavamurthy Anil S <anil.s.keshavamurthy@intel.com>
Cc: Richard J Moore <richardj_moore@uk.ibm.com>,
	systemtap@sources.redhat.com
Subject: Re: thoughts about exception-handling requirements for kprobes
Date: Tue, 21 Mar 2006 09:41:00 -0000	[thread overview]
Message-ID: <20060320185719.GA3320@in.ibm.com> (raw)
In-Reply-To: <20060320103951.A10565@unix-os.sc.intel.com>

On Mon, Mar 20, 2006 at 10:39:51AM -0800, Keshavamurthy Anil S wrote:
> On Sun, Mar 19, 2006 at 09:24:54AM -0800, Prasanna S Panchamukhi wrote:
> > 
> >    On Fri, Mar 17, 2006 at 01:50:57PM -0800, Keshavamurthy Anil S wrote:
> >    > On Thu, Mar 09, 2006 at 07:57:18AM -0800, Richard J Moore wrote:
> >    > >
> >    >  >     I've  been thinking about the need for exception-handling and
> >    how the
> >    > >    current implementation has become a little muddled.
> >    >
> >    > Here is my thinking on this kprobe fault handling...
> >    > Ideally we want the ability to recover from all
> >    > the page faults happening from either pre-handler
> >    > or happening from post-handler transparently in the
> >    > same way as the normal kernel would recover from
> >    > do_page_fault() function. In order for this to happen,
> >    > I think we should not be calling pre-handler/post-handler
> >    > by disabling preempt which is a major design change.
> >    > Also in the current code if fixup_exception() fails to
> >    > fixup the exception then falling back on the normal
> >    > do_page_fault() is a bad thing with preempt disabled.
> >    >
> >    > I was thinking on this issue for the past several days
> >    > and I believe that currently we are disabling preempt
> >    > before calling pre/post handler, because we don;t
> >    > want the process to get migrated to different CPU
> >    > and we don't want another process to be scheduled
> >    > while we are servicing kprobe as the newly scheduled
> >    > process might trigger another probe and we don;t
> >    > have space to save the kprobe control block(kprobe_ctlbk)
> >    > info, because we save kprobe_ctlbk in the per cpu structure.
> >    >
> >    > If we move this saving kprobe_ctlbk to task struct then
> >    > I think we will have the ability to call pre/post-handler
> >    > without having to disable preempt and their by any faults
> >    > happening from either pre/post handler can recover transparently
> >    > in the same way as the normal kernel would recover.
> >    >
> > 
> >    Kprobes user-specified pre/post handler are called within
> >    the interrupt context and if we allow page faults while within
> >    user-specified pre/post handler, then it might sleep.
> >    Is is ok to sleep while within the interrupt handler?
> Prasanna,
> 	I am not getting what you are asking here, if you are
> asking is it okay to sleep while within the interrupt handler,
> then it is BIG NO.

Anil,

> 
> What I am saying is that we should look into kprobes to see
> if we can support calling users pre/post handlers
> without having to disable preempt.
> 
> Currenlty we are calling users pre_handler() and post_handler()
> with preempt disabled. If the user has put a probes on 
> syscalls, then when his pre/post handlers are called he is
> bound to call copy_from_user(), which has a check might_sleep().
> The might_sleep() calls in_atomic() function which checks preempt_count()
> and if preempt_count() is greater than zero( in our case it indeed greater
> than zero, since we are calling pre/post handlers with preempt disabled)
>  the kernel prints a error message
> printk(KERN_ERR "Debug: sleeping function called from invalid"
>                                 " context at %s:%d\n", file, line);

Are you trying to tell here that by allowing preemption() in the
kprobes handler, the above debug message log can be avoided?

> 
> Also if we want to fallback on do_page_fault() function in kprobe_fault_handler() to 
> recover the page, then we should not be in preempt_disabled() state.

We actually do not want to fall back on system do_page_fault() because,
it might sleep. When pre/post handler page faults, we can just try 
calling fixup_exception() (non-ia64 architectures) and try to avoid actual
do_page_fault() to be called because it might sleep().

Thanks
Prasanna
-- 
Prasanna S Panchamukhi
Linux Technology Center
India Software Labs, IBM Bangalore
Email: prasanna@in.ibm.com
Ph: 91-80-51776329

  parent reply	other threads:[~2006-03-21  9:41 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-09 16:00 Richard J Moore
2006-03-10  3:46 ` Frank Ch. Eigler
2006-03-17 21:51 ` Keshavamurthy Anil S
2006-03-19 17:24   ` Prasanna S Panchamukhi
2006-03-20  8:47     ` Richard J Moore
2006-03-20  9:18       ` Prasanna S Panchamukhi
2006-03-20 14:33         ` Frank Ch. Eigler
2006-03-20  9:43       ` Richard J Moore
2006-03-20 18:40     ` Keshavamurthy Anil S
2006-03-21  0:34       ` Richard J Moore
2006-03-21  0:53         ` Keshavamurthy Anil S
2006-03-21  5:23       ` Ananth N Mavinakayanahalli
2006-03-21  9:41       ` Prasanna S Panchamukhi [this message]
2006-03-21 22:46         ` Keshavamurthy Anil S
2006-03-22  2:37           ` Frank Ch. Eigler

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=20060320185719.GA3320@in.ibm.com \
    --to=prasanna@in.ibm.com \
    --cc=anil.s.keshavamurthy@intel.com \
    --cc=richardj_moore@uk.ibm.com \
    --cc=systemtap@sources.redhat.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).