systemtap for hwe kernels

Bug #1830726 reported by Andrea Righi
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
systemtap (Ubuntu)
Confirmed
Medium
Andrea Righi
Xenial
Confirmed
Medium
Andrea Righi

Bug Description

[Impact]

systemtap includes some kernel code compiled at runtime every time a stap script is executed. This means that running a different kernel with different ABIs may break systemtap. This is exactly what happens with the hwe kernel.

We need to provide a separate systemtap package (systemtap-hwe for example) that can be installed together with the hwe kernel.

For example on xenial, ideally, we may want to backport systemtap from bionic and call it systemtap-hwe, similarly to what we're doing with the kernel.

[Test Case]

For example, this is what happens in xenial with the hwe kernel installed (linux-image-generic-hwe-16.04):

$ cat /home/ubuntu/hello.stp
#!/usr/bin/env stap
probe oneshot { println("hello world") }

$ sudo /home/ubuntu/hello.stp
In file included from /usr/share/systemtap/runtime/linux/runtime.h:204:0,
                 from /usr/share/systemtap/runtime/runtime.h:24,
                 from /tmp/stapCmbcrm/stap_e18a9aff18b91b2a0f0570b0096c64b1_967_src.c:25:
/usr/share/systemtap/runtime/linux/access_process_vm.h: In function ‘__access_process_vm_’:
/usr/share/systemtap/runtime/linux/access_process_vm.h:24:8: error: implicit declaration of function ‘get_task_mm’ [-Werror=implicit-function-declaration]
   mm = get_task_mm (tsk);
        ^
/usr/share/systemtap/runtime/linux/access_process_vm.h:24:6: error: assignment makes pointer from integer without a cast [-Werror=int-conversion]
   mm = get_task_mm (tsk);
      ^
/usr/share/systemtap/runtime/linux/access_process_vm.h:35:29: error: passing argument 1 of ‘get_user_pages’ makes integer from pointer without a cast [-Werror=int-conversion]
       ret = get_user_pages (tsk, mm, addr, 1, write, 1, &page, &vma);
                             ^
In file included from ./include/linux/pid_namespace.h:7:0,
                 from ./include/linux/ptrace.h:10,
                 from ./include/linux/ftrace.h:14,
                 from ./include/linux/kprobes.h:42,
                 from /usr/share/systemtap/runtime/linux/runtime.h:21,
                 from /usr/share/systemtap/runtime/runtime.h:24,
                 from /tmp/stapCmbcrm/stap_e18a9aff18b91b2a0f0570b0096c64b1_967_src.c:25:
./include/linux/mm.h:1398:6: note: expected ‘long unsigned int’ but argument is of type ‘struct task_struct *’
 long get_user_pages(unsigned long start, unsigned long nr_pages,
      ^
In file included from /usr/share/systemtap/runtime/linux/runtime.h:204:0,
                 from /usr/share/systemtap/runtime/runtime.h:24,
                 from /tmp/stapCmbcrm/stap_e18a9aff18b91b2a0f0570b0096c64b1_967_src.c:25:
/usr/share/systemtap/runtime/linux/access_process_vm.h:35:34: error: passing argument 2 of ‘get_user_pages’ makes integer from pointer without a cast [-Werror=int-conversion]
       ret = get_user_pages (tsk, mm, addr, 1, write, 1, &page, &vma);
                                  ^
In file included from ./include/linux/pid_namespace.h:7:0,
                 from ./include/linux/ptrace.h:10,
                 from ./include/linux/ftrace.h:14,
                 from ./include/linux/kprobes.h:42,
                 from /usr/share/systemtap/runtime/linux/runtime.h:21,
                 from /usr/share/systemtap/runtime/runtime.h:24,
                 from /tmp/stapCmbcrm/stap_e18a9aff18b91b2a0f0570b0096c64b1_967_src.c:25:
./include/linux/mm.h:1398:6: note: expected ‘long unsigned int’ but argument is of type ‘struct mm_struct *’
 long get_user_pages(unsigned long start, unsigned long nr_pages,
      ^
In file included from /usr/share/systemtap/runtime/linux/runtime.h:204:0,
                 from /usr/share/systemtap/runtime/runtime.h:24,
                 from /tmp/stapCmbcrm/stap_e18a9aff18b91b2a0f0570b0096c64b1_967_src.c:25:
/usr/share/systemtap/runtime/linux/access_process_vm.h:35:44: error: passing argument 4 of ‘get_user_pages’ makes pointer from integer without a cast [-Werror=int-conversion]
       ret = get_user_pages (tsk, mm, addr, 1, write, 1, &page, &vma);
                                            ^
In file included from ./include/linux/pid_namespace.h:7:0,
                 from ./include/linux/ptrace.h:10,
                 from ./include/linux/ftrace.h:14,
                 from ./include/linux/kprobes.h:42,
                 from /usr/share/systemtap/runtime/linux/runtime.h:21,
                 from /usr/share/systemtap/runtime/runtime.h:24,
                 from /tmp/stapCmbcrm/stap_e18a9aff18b91b2a0f0570b0096c64b1_967_src.c:25:
./include/linux/mm.h:1398:6: note: expected ‘struct page **’ but argument is of type ‘int’
 long get_user_pages(unsigned long start, unsigned long nr_pages,
      ^
In file included from /usr/share/systemtap/runtime/linux/runtime.h:204:0,
                 from /usr/share/systemtap/runtime/runtime.h:24,
                 from /tmp/stapCmbcrm/stap_e18a9aff18b91b2a0f0570b0096c64b1_967_src.c:25:
/usr/share/systemtap/runtime/linux/access_process_vm.h:35:47: error: passing argument 5 of ‘get_user_pages’ makes pointer from integer without a cast [-Werror=int-conversion]
       ret = get_user_pages (tsk, mm, addr, 1, write, 1, &page, &vma);
                                               ^
In file included from ./include/linux/pid_namespace.h:7:0,
                 from ./include/linux/ptrace.h:10,
                 from ./include/linux/ftrace.h:14,
                 from ./include/linux/kprobes.h:42,
                 from /usr/share/systemtap/runtime/linux/runtime.h:21,
                 from /usr/share/systemtap/runtime/runtime.h:24,
                 from /tmp/stapCmbcrm/stap_e18a9aff18b91b2a0f0570b0096c64b1_967_src.c:25:
./include/linux/mm.h:1398:6: note: expected ‘struct vm_area_struct **’ but argument is of type ‘int’
 long get_user_pages(unsigned long start, unsigned long nr_pages,
      ^
In file included from /usr/share/systemtap/runtime/linux/runtime.h:204:0,
                 from /usr/share/systemtap/runtime/runtime.h:24,
                 from /tmp/stapCmbcrm/stap_e18a9aff18b91b2a0f0570b0096c64b1_967_src.c:25:
/usr/share/systemtap/runtime/linux/access_process_vm.h:35:13: error: too many arguments to function ‘get_user_pages’
       ret = get_user_pages (tsk, mm, addr, 1, write, 1, &page, &vma);
             ^
In file included from ./include/linux/pid_namespace.h:7:0,
                 from ./include/linux/ptrace.h:10,
                 from ./include/linux/ftrace.h:14,
                 from ./include/linux/kprobes.h:42,
                 from /usr/share/systemtap/runtime/linux/runtime.h:21,
                 from /usr/share/systemtap/runtime/runtime.h:24,
                 from /tmp/stapCmbcrm/stap_e18a9aff18b91b2a0f0570b0096c64b1_967_src.c:25:
./include/linux/mm.h:1398:6: note: declared here
 long get_user_pages(unsigned long start, unsigned long nr_pages,
      ^
In file included from /usr/share/systemtap/runtime/linux/runtime.h:204:0,
                 from /usr/share/systemtap/runtime/runtime.h:24,
                 from /tmp/stapCmbcrm/stap_e18a9aff18b91b2a0f0570b0096c64b1_967_src.c:25:
/usr/share/systemtap/runtime/linux/access_process_vm.h:55:7: error: implicit declaration of function ‘page_cache_release’ [-Werror=implicit-function-declaration]
       page_cache_release (page);
       ^
/usr/share/systemtap/runtime/linux/access_process_vm.h:61:3: error: implicit declaration of function ‘mmput’ [-Werror=implicit-function-declaration]
   mmput (mm);
   ^
In file included from /usr/share/systemtap/runtime/stp_utrace.c:30:0,
                 from /usr/share/systemtap/runtime/linux/task_finder2.c:4,
                 from /usr/share/systemtap/runtime/linux/task_finder.c:17,
                 from /usr/share/systemtap/runtime/linux/runtime.h:217,
                 from /usr/share/systemtap/runtime/runtime.h:24,
                 from /tmp/stapCmbcrm/stap_e18a9aff18b91b2a0f0570b0096c64b1_967_src.c:25:
/usr/share/systemtap/runtime/stp_helper_lock.h: In function ‘stp_spin_unlock_wait’:
/usr/share/systemtap/runtime/stp_helper_lock.h:60:61: error: implicit declaration of function ‘spin_unlock_wait’ [-Werror=implicit-function-declaration]
 static inline void stp_spin_unlock_wait(spinlock_t *lock) { spin_unlock_wait(lock); }
                                                             ^
In file included from /usr/share/systemtap/runtime/linux/task_finder2.c:4:0,
                 from /usr/share/systemtap/runtime/linux/task_finder.c:17,
                 from /usr/share/systemtap/runtime/linux/runtime.h:217,
                 from /usr/share/systemtap/runtime/runtime.h:24,
                 from /tmp/stapCmbcrm/stap_e18a9aff18b91b2a0f0570b0096c64b1_967_src.c:25:
/usr/share/systemtap/runtime/stp_utrace.c: In function ‘utrace_do_stop’:
/usr/share/systemtap/runtime/stp_utrace.c:1095:4: error: implicit declaration of function ‘__set_task_state’ [-Werror=implicit-function-declaration]
    __set_task_state(target, TASK_TRACED);
    ^
In file included from /usr/share/systemtap/runtime/transport/transport.c:68:0,
                 from /usr/share/systemtap/runtime/linux/print.c:17,
                 from /usr/share/systemtap/runtime/print.c:17,
                 from /usr/share/systemtap/runtime/runtime_context.h:22,
                 from /tmp/stapCmbcrm/stap_e18a9aff18b91b2a0f0570b0096c64b1_967_src.c:55:
/usr/share/systemtap/runtime/transport/relay_v2.c: In function ‘__stp_relay_timer_init’:
/usr/share/systemtap/runtime/transport/relay_v2.c:147:2: error: implicit declaration of function ‘init_timer’ [-Werror=implicit-function-declaration]
  init_timer(&_stp_relay_data.timer);
  ^
/usr/share/systemtap/runtime/transport/relay_v2.c:149:33: error: assignment from incompatible pointer type [-Werror=incompatible-pointer-types]
  _stp_relay_data.timer.function = __stp_relay_wakeup_timer;
                                 ^
/usr/share/systemtap/runtime/transport/relay_v2.c:150:23: error: ‘struct timer_list’ has no member named ‘data’
  _stp_relay_data.timer.data = 0;
                       ^
In file included from /usr/share/systemtap/runtime/linux/print.c:17:0,
                 from /usr/share/systemtap/runtime/print.c:17,
                 from /usr/share/systemtap/runtime/runtime_context.h:22,
                 from /tmp/stapCmbcrm/stap_e18a9aff18b91b2a0f0570b0096c64b1_967_src.c:55:
/usr/share/systemtap/runtime/transport/transport.c: In function ‘_stp_attach’:
/usr/share/systemtap/runtime/transport/transport.c:324:31: error: assignment from incompatible pointer type [-Werror=incompatible-pointer-types]
  _stp_ctl_work_timer.function = _stp_ctl_work_callback;
                               ^
/usr/share/systemtap/runtime/transport/transport.c:325:21: error: ‘struct timer_list’ has no member named ‘data’
  _stp_ctl_work_timer.data= 0;
                     ^
/usr/share/systemtap/runtime/transport/transport.c: In function ‘_stp_lock_inode’:
/usr/share/systemtap/runtime/transport/transport.c:506:19: error: ‘struct inode’ has no member named ‘i_mutex’
  mutex_lock(&inode->i_mutex);
                   ^
/usr/share/systemtap/runtime/transport/transport.c: In function ‘_stp_unlock_inode’:
/usr/share/systemtap/runtime/transport/transport.c:515:21: error: ‘struct inode’ has no member named ‘i_mutex’
  mutex_unlock(&inode->i_mutex);
                     ^
cc1: all warnings being treated as errors
scripts/Makefile.build:330: recipe for target '/tmp/stapCmbcrm/stap_e18a9aff18b91b2a0f0570b0096c64b1_967_src.o' failed
make[1]: *** [/tmp/stapCmbcrm/stap_e18a9aff18b91b2a0f0570b0096c64b1_967_src.o] Error 1
Makefile:1552: recipe for target '_module_/tmp/stapCmbcrm' failed
make: *** [_module_/tmp/stapCmbcrm] Error 2
WARNING: kbuild exited with status: 2
Pass 4: compilation failed. [man error::pass4]
Tip: /usr/share/doc/systemtap/README.Debian should help you get started.

Andrea Righi (arighi)
Changed in systemtap (Ubuntu):
assignee: nobody → Andrea Righi (arighi)
importance: Undecided → Medium
status: New → Confirmed
Andrea Righi (arighi)
Changed in systemtap (Ubuntu Xenial):
importance: Undecided → Medium
assignee: nobody → Andrea Righi (arighi)
description: updated
Andrea Righi (arighi)
Changed in systemtap (Ubuntu Xenial):
status: New → Confirmed
Revision history for this message
Frank Ch. Eigler (fche) wrote :

Does git/master systemtap, or the recently released v4.1 not work on -all- your kernels?

Revision history for this message
Andrea Righi (arighi) wrote :

Here's is a ppa that provides a working systemtap for the hwe kernel in xenial: https://launchpad.net/~arighi/+archive/ubuntu/systemtap-hwe

Revision history for this message
Andrea Righi (arighi) wrote :

@fche I just tested systemtap 4.1 and my small test case works fine with both kernels. However, I don't know if a major systemtap change like that is acceptable as an SRU. Potentially the API change can break old existing scripts... while having a separate package would be safer.

Revision history for this message
Frank Ch. Eigler (fche) wrote :

Thanks for testing. systemtap goes to a lot of trouble to provide backward compatibility to preexisting scripts, so really that should not be a problem.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.