Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for watchpoint on kernel space address #1552

Merged
merged 6 commits into from
Oct 22, 2020

Conversation

htbegin
Copy link
Contributor

@htbegin htbegin commented Oct 11, 2020

Description

Add support for watchpoint on absolute kernel space address, so the following command can run correctly:

# bpftrace -e "watchpoint::0x$(awk '$3 == "jiffies" {print $1}' /proc/kallsyms):8:w {@[kstack] = count();}"
Attaching 1 probe...   
^C
@[
    do_timer+12
    tick_do_update_jiffies64.part.22+89
    tick_sched_do_timer+103
    tick_sched_timer+39
    __hrtimer_run_queues+256
    hrtimer_interrupt+256
    smp_apic_timer_interrupt+106
    apic_timer_interrupt+15
    cpuidle_enter_state+188
    cpuidle_enter+41
    do_idle+536
    cpu_startup_entry+25
    start_secondary+355
    secondary_startup_64+164
]: 319
Checklist
  • Language changes are updated in docs/reference_guide.md
  • User-visible and non-trivial changes updated in CHANGELOG.md
  • The new behaviour is covered by tests

Copy link
Member

@danobi danobi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the patch!

Can you update the changelog as well? Other than that and a small nit, LGTM.

src/attached_probe.cpp Outdated Show resolved Hide resolved
If using strtoll(), for integer which is larger than LONG_MAX
(e.g. address in kernel space), strtoll() will return LONG_MAX
unexpectedly.

For negative integer, if it is not less than LONG_MIN, the negative
integer support in parser will make strtoul() work.

So use strtoul() instead.

Signed-off-by: htbegin <hotforest@gmail.com>
If there is no related pid, we consider it as a watchpoint
for address in kernel space and attach the bpf program
to perf event on each online CPUs.

Signed-off-by: htbegin <hotforest@gmail.com>
One case is used to demonstrate strtoul() still works for
LONG_MIN, and another case is used to show ULONG_MAX can
be parsed correctly.

Signed-off-by: htbegin <hotforest@gmail.com>
The update of jiffies is necessary for kernel, so add
a watchpoint on it for test purpose.

Signed-off-by: htbegin <hotforest@gmail.com>
Signed-off-by: htbegin <hotforest@gmail.com>
Signed-off-by: htbegin <hotforest@gmail.com>
Copy link
Member

@danobi danobi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fbs Do you think this should be a squash + rebase + merge or just rebase + merge?

@fbs
Copy link
Member

fbs commented Oct 21, 2020

@fbs Do you think this should be a squash + rebase + merge or just rebase + merge?

Looking at the individual commit messages an rebase+merge seems ok to me. But for cases where its a simple add test for a single change a squash sounds better to me

@danobi danobi merged commit a03b5c4 into bpftrace:master Oct 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants