Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1373225
| From | Petr Mladek <pmladek@suse.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [RFC PATCH v1.9 05/14] sched: horrible way to detect whether a task has been preempted |
| Date | 2016-04-07 11:50 +0200 |
| Message-ID | <rleJB-1Ne-41@gated-at.bofh.it> (permalink) |
| References | <rgFKp-6zA-3@gated-at.bofh.it> <rgFKq-6zA-29@gated-at.bofh.it> <rkVnz-4fv-7@gated-at.bofh.it> <rkYEO-6IT-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Wed 2016-04-06 11:33:56, Josh Poimboeuf wrote:
> On Wed, Apr 06, 2016 at 03:06:19PM +0200, Petr Mladek wrote:
> > On Fri 2016-03-25 14:34:52, Josh Poimboeuf wrote:
> > > This is a horrible way to detect whether a task has been preempted.
> > > Come up with something better: task flag? or is there already an
> > > existing mechanism?
> >
> > What about using kallsyms_lookup_size_offset() to check the address.
> > It is more heavyweight but less hacky. The following code seems
> > to work for me:
> >
> > bool in_preempt_schedule_irq(unsigned long addr)
> > {
> > static unsigned long size;
> >
> > if (unlikely(!size)) {
> > int ret;
> >
> > ret = kallsyms_lookup_size_offset(
> > (unsigned long)preempt_schedule_irq,
> > size, NULL);
^^^^
It works even better with &size ;-)
> >
> > /*
> > * Warn when the function is used without kallsyms or
> > * when it is unable to locate preempt_schedule_irq().
> > * Be conservative and always return true in this case.
> > */
> > if (WARN_ON(!ret))
> > size = -1L;
> > }
> >
> > return (addr - (unsigned long)preempt_schedule_irq <= size);
> > }
>
> Yeah, that would definitely be better. Though still somewhat hacky.
Yeah. Well this is the same approach that we use to check if a patched
function is on the stack. We could even move this check into the
livepatch code but then print_context_stack_reliable() will not
always give reliable results.
Best Regards,
Petr
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: [RFC PATCH v1.9 05/14] sched: horrible way to detect whether a task has been preempted Petr Mladek <pmladek@suse.com> - 2016-04-06 15:10 +0200
Re: [RFC PATCH v1.9 05/14] sched: horrible way to detect whether a task has been preempted Josh Poimboeuf <jpoimboe@redhat.com> - 2016-04-06 18:40 +0200
Re: [RFC PATCH v1.9 05/14] sched: horrible way to detect whether a task has been preempted Petr Mladek <pmladek@suse.com> - 2016-04-07 11:50 +0200
Re: [RFC PATCH v1.9 05/14] sched: horrible way to detect whether a task has been preempted Josh Poimboeuf <jpoimboe@redhat.com> - 2016-04-07 16:40 +0200
Re: [RFC PATCH v1.9 05/14] sched: horrible way to detect whether a task has been preempted Petr Mladek <pmladek@suse.com> - 2016-04-08 10:10 +0200
Re: [RFC PATCH v1.9 05/14] sched: horrible way to detect whether a task has been preempted Josh Poimboeuf <jpoimboe@redhat.com> - 2016-04-08 16:40 +0200
csiph-web