Skip to content

Conversation

prakashsurya
Copy link
Contributor

Here's the upstream commit that introduced asm_inline:

Without this patch BCC fails with the following:

$ sudo /usr/share/bcc/tools/opensnoop
In file included from /virtual/main.c:2:
In file included from include/uapi/linux/ptrace.h:142:
In file included from ./arch/x86/include/asm/ptrace.h:5:
./arch/x86/include/asm/segment.h:254:2: error: expected '(' after 'asm'
        alternative_io ("lsl %[seg],%[p]",
        ^
./arch/x86/include/asm/alternative.h:240:2: note: expanded from macro 'alternative_io'
        asm_inline volatile (ALTERNATIVE(oldinstr, newinstr, feature)   \
        ^
include/linux/compiler_types.h:210:24: note: expanded from macro 'asm_inline'
                       ^

Here's the upstream commit that introduced `asm_inline`:

* torvalds/linux@eb11186

Without this patch BCC fails with the following:

```
$ sudo /usr/share/bcc/tools/opensnoop
In file included from /virtual/main.c:2:
In file included from include/uapi/linux/ptrace.h:142:
In file included from ./arch/x86/include/asm/ptrace.h:5:
./arch/x86/include/asm/segment.h:254:2: error: expected '(' after 'asm'
        alternative_io ("lsl %[seg],%[p]",
        ^
./arch/x86/include/asm/alternative.h:240:2: note: expanded from macro 'alternative_io'
        asm_inline volatile (ALTERNATIVE(oldinstr, newinstr, feature)   \
        ^
include/linux/compiler_types.h:210:24: note: expanded from macro 'asm_inline'
                       ^
```
@prakashsurya
Copy link
Contributor Author

git-ab-pre-push is here

This is a clean cherry-pick of the upstream commit (2d1497c) to our 6.0/stage branch.

I've tested this with git-linux-pkg to build and deploy this change to a 6.0.5.0 based VM, and verified the profile command now works:

$ sudo /usr/share/bcc/tools/profile -adfI --stack-storage-size 1024 5
postgres;[unknown];__libc_start_main;main;PostmasterMain;ServerLoop;PostgresMain;ReadyForQuery;socket_flush;internal_flush;send;-;entry_SYSCALL_64_after_hwframe_[k];do_syscall_64_[k];__x64_sys_sendto_[k];__sys_sendto_[k];sock_sendmsg_[k];inet_sendmsg_[k];tcp_sendmsg_[k];tcp_sendmsg_locked_[k];tcp_push_[k];__tcp_push_pending_frames_[k];tcp_write_xmit_[k];tcp_event_new_data_sent_[k];tcp_rearm_rto_[k];sk_reset_timer_[k];mod_timer_[k];__lock_text_start_[k];__lock_text_start_[k] 1
z_wr_int;ret_from_fork_[k];kthread_[k];taskq_thread_[k];zio_execute_[k];zio_vdev_io_done_[k];vdev_queue_io_done_[k];zio_nowait_[k];zio_vdev_io_start_[k];vdev_disk_io_start_[k];__vdev_disk_physio.constprop.0_[k];vdev_submit_bio_[k];vdev_submit_bio_impl_[k];submit_bio_[k];generic_make_request_[k];generic_make_request_checks_[k];percpu_counter_add_batch_[k];percpu_counter_add_batch_[k] 1
swapper/1;secondary_startup_64_[k];start_secondary_[k];cpu_startup_entry_[k];do_idle_[k];default_idle_call_[k];arch_cpu_idle_[k];__sched_text_end_[k];native_safe_halt_[k];ret_from_intr_[k];do_IRQ_[k];irq_exit_[k];__softirqentry_text_start_[k];net_rx_action_[k];vmxnet3_poll_rx_only_[k];vmxnet3_poll_rx_only_[k] 1
z_ioctl_int;ret_from_fork_[k];kthread_[k];taskq_thread_[k];schedule_[k];__sched_text_start_[k];finish_task_switch_[k];finish_task_switch_[k] 1
z_wr_iss;ret_from_fork_[k];kthread_[k];taskq_thread_[k];zio_execute_[k];zio_write_compress_[k];zio_compress_data_[k];lzjb_compress_[k];lzjb_compress_[k] 1
swapper/1;secondary_startup_64_[k];start_secondary_[k];cpu_startup_entry_[k];do_idle_[k];default_idle_call_[k];arch_cpu_idle_[k];__sched_text_end_[k];native_safe_halt_[k];native_safe_halt_[k] 242
swapper/0;secondary_startup_64_[k];x86_64_start_kernel_[k];x86_64_start_reservations_[k];start_kernel_[k];arch_call_rest_init_[k];rest_init_[k];cpu_startup_entry_[k];do_idle_[k];default_idle_call_[k];arch_cpu_idle_[k];__sched_text_end_[k];native_safe_halt_[k];native_safe_halt_[k] 243

@prakashsurya prakashsurya requested review from pzakha and sebroy October 20, 2020 19:49
@prakashsurya prakashsurya changed the base branch from 6.0/stage to 6.0/release October 20, 2020 20:01
@pzakha
Copy link
Contributor

pzakha commented Oct 20, 2020

@prakashsurya I think instead of cherry-picking a particular commit, let's fast-forward bcc on 6.0/stage to point to the same commit as master, which has that change.

@prakashsurya
Copy link
Contributor Author

I'll leave that decision up to you and @sebroy. I'm fine with that, but it does mean more changes will be going into the release branch, and I can't comment on if that's safe (or not) to do.

I do feel relatively confident in landing this PR in isolation for the upcoming release branch, though.

Feel free to close this, and do the bulk merge if that's the the approach you want to take.

@pzakha
Copy link
Contributor

pzakha commented Oct 20, 2020

I've opened a PR for the bulk merge here: #6

@prakashsurya
Copy link
Contributor Author

@pzakha Keep in mind, 6.0/stage is 6.0.6.0. So unless we re-target that PR for 6.0/release, it wouldn't apply for 6.0.5.0.

@pzakha pzakha closed this Oct 20, 2020
@pzakha pzakha reopened this Oct 20, 2020
@prakashsurya prakashsurya merged commit ef9a7c7 into delphix:6.0/release Oct 21, 2020
prakashsurya pushed a commit that referenced this pull request Nov 8, 2022
…for -v option

Add additional information and change format of backtrace
- add symbol base offset, dso name, dso base offset
- symbol and dso info is included if it's available in target binary
- changed format:
INDEX ADDR [SYMBOL+OFFSET] (MODULE+OFFSET)

Print backtrace of ip if it failed to get syms.

Before:
  # offcputime -v
    psiginfo
    vscanf
    __snprintf_chk
    [unknown]
    [unknown]
    [unknown]
    [unknown]
    [unknown]
    sd_event_exit
    sd_event_dispatch
    sd_event_run
    [unknown]
    __libc_start_main
    [unknown]
    -                systemd-journal (204)
        1

    xas_load
    xas_find
    filemap_map_pages
    __handle_mm_fault
    handle_mm_fault
    do_page_fault
    do_translation_fault
    do_mem_abort
    do_el0_ia_bp_hardening
    el0_ia
    xas_load
    --
failed to get syms
      -                PmLogCtl (138757)
        1

After:
  # offcputime -v
    #0  0xffffffc01018b7e8 __arm64_sys_clock_nanosleep+0x0
    #1  0xffffffc01009a93c el0_svc_handler+0x34
    #2  0xffffffc010084a08 el0_svc+0x8
    #3  0xffffffc01018b7e8 __arm64_sys_clock_nanosleep+0x0
    --
    #4  0x0000007fa0bffd14 clock_nanosleep+0x94 (/usr/lib/libc-2.31.so+0x9ed14)
    #5  0x0000007fa0c0530c nanosleep+0x1c (/usr/lib/libc-2.31.so+0xa430c)
    #6  0x0000007fa0c051e4 sleep+0x34 (/usr/lib/libc-2.31.so+0xa41e4)
    #7  0x000000558a5a9608 flb_loop+0x28 (/usr/bin/fluent-bit+0x52608)
    #8  0x000000558a59f1c4 flb_main+0xa84 (/usr/bin/fluent-bit+0x481c4)
    #9  0x0000007fa0b85124 __libc_start_main+0xe4 (/usr/lib/libc-2.31.so+0x24124)
    #10 0x000000558a59d828 _start+0x34 (/usr/bin/fluent-bit+0x46828)
    -                fluent-bit (1238)
        1

    #0  0xffffffc01027daa4 generic_copy_file_checks+0x334
    #1  0xffffffc0102ba634 __handle_mm_fault+0x8dc
    #2  0xffffffc0102baa20 handle_mm_fault+0x168
    #3  0xffffffc010ad23c0 do_page_fault+0x148
    #4  0xffffffc010ad27c0 do_translation_fault+0xb0
    #5  0xffffffc0100816b0 do_mem_abort+0x50
    #6  0xffffffc0100843b0 el0_da+0x1c
    #7  0xffffffc01027daa4 generic_copy_file_checks+0x334
    --
    #8  0x0000007f8dc12648 [unknown]
    #9  0x0000007f8dc0aef8 [unknown]
    #10 0x0000007f8dc1c990 [unknown]
    #11 0x0000007f8dc08b0c [unknown]
    #12 0x0000007f8dc08e48 [unknown]
    #13 0x0000007f8dc081c8 [unknown]
    -                PmLogCtl (2412)
        1

Fixed: #3884
Signed-off-by: Eunseon Lee <es.lee@lge.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants