1. 11 2月, 2017 2 次提交
  2. 26 1月, 2017 1 次提交
  3. 04 1月, 2017 1 次提交
    • D
      tools lib traceevent: Fix prev/next_prio for deadline tasks · 07485918
      Daniel Bristot de Oliveira 提交于
      Currently, the sched:sched_switch tracepoint reports deadline tasks with
      priority -1. But when reading the trace via perf script I've got the
      following output:
      
        # ./d & # (d is a deadline task, see [1])
        # perf record -e sched:sched_switch -a sleep 1
        # perf script
            ...
               swapper     0 [000]  2146.962441: sched:sched_switch: swapper/0:0 [120] R ==> d:2593 [4294967295]
                     d  2593 [000]  2146.972472: sched:sched_switch: d:2593 [4294967295] R ==> g:2590 [4294967295]
      
      The task d reports the wrong priority [4294967295]. This happens because
      the "int prio" is stored in an unsigned long long val. Although it is
      set as a %lld, as int is shorter than unsigned long long,
      trace_seq_printf prints it as a positive number.
      
      The fix is just to cast the val as an int, and print it as a %d,
      as in the sched:sched_switch tracepoint's "format".
      
      The output with the fix is:
      
        # ./d &
        # perf record -e sched:sched_switch -a sleep 1
        # perf script
            ...
               swapper     0 [000]  4306.374037: sched:sched_switch: swapper/0:0 [120] R ==> d:10941 [-1]
                     d 10941 [000]  4306.383823: sched:sched_switch: d:10941 [-1] R ==> swapper/0:0 [120]
      
      [1] d.c
      
       ---
        #include <stdio.h>
        #include <unistd.h>
        #include <sys/syscall.h>
        #include <linux/types.h>
        #include <linux/sched.h>
      
        struct sched_attr {
      	__u32 size, sched_policy;
      	__u64 sched_flags;
      	__s32 sched_nice;
      	__u32 sched_priority;
      	__u64 sched_runtime, sched_deadline, sched_period;
        };
      
        int sched_setattr(pid_t pid, const struct sched_attr *attr, unsigned int flags)
        {
      	return syscall(__NR_sched_setattr, pid, attr, flags);
        }
      
        int main(void)
        {
      	struct sched_attr attr = {
      		.size		= sizeof(attr),
      		.sched_policy	= SCHED_DEADLINE, /* This creates a 10ms/30ms reservation */
      		.sched_runtime	= 10 * 1000 * 1000,
      		.sched_period	= attr.sched_deadline = 30 * 1000 * 1000,
      	};
      
      	if (sched_setattr(0, &attr, 0) < 0) {
      		perror("sched_setattr");
      		return -1;
      	}
      
      	for(;;);
        }
       ---
      
      Committer notes:
      
      Got the program from the provided URL, http://bristot.me/lkml/d.c,
      trimmed it and included in the cset log above, so that we have
      everything needed to test it in one place.
      Signed-off-by: NDaniel Bristot de Oliveira <bristot@redhat.com>
      Acked-by: NSteven Rostedt <rostedt@goodmis.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/866ef75bcebf670ae91c6a96daa63597ba981f0d.1483443552.git.bristot@redhat.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      07485918
  4. 03 1月, 2017 1 次提交
  5. 20 12月, 2016 1 次提交
  6. 16 12月, 2016 2 次提交
  7. 11 12月, 2016 1 次提交
  8. 29 11月, 2016 3 次提交
  9. 25 11月, 2016 1 次提交
    • E
      tools lib bpf: Fix maps resolution · 4708bbda
      Eric Leblond 提交于
      It is not correct to assimilate the elf data of the maps section to an
      array of map definition. In fact the sizes differ. The offset provided
      in the symbol section has to be used instead.
      
      This patch fixes a bug causing a elf with two maps not to load
      correctly.
      
      Wang Nan added:
      
      This patch requires a name for each BPF map, so array of BPF maps is not
      allowed. This restriction is reasonable, because kernel verifier forbid
      indexing BPF map from such array unless the index is a fixed value, but
      if the index is fixed why not merging it into name?
      
      For example:
      
      Program like this:
        ...
        unsigned long cpu = get_smp_processor_id();
        int *pval = map_lookup_elem(&map_array[cpu], &key);
        ...
      
      Generates bytecode like this:
      
      0: (b7) r1 = 0
      1: (63) *(u32 *)(r10 -4) = r1
      2: (b7) r1 = 680997
      3: (63) *(u32 *)(r10 -8) = r1
      4: (85) call 8
      5: (67) r0 <<= 4
      6: (18) r1 = 0x112dd000
      8: (0f) r0 += r1
      9: (bf) r2 = r10
      10: (07) r2 += -4
      11: (bf) r1 = r0
      12: (85) call 1
      
      Where instruction 8 is the computation, 8 and 11 render r1 to an invalid
      value for function map_lookup_elem, causes verifier report error.
      Signed-off-by: NEric Leblond <eric@regit.org>
      Cc: Alexei Starovoitov <ast@fb.com>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      [ Merge bpf_object__init_maps_name into bpf_object__init_maps.
        Fix segfault for buggy BPF script Validate obj->maps ]
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/20161115040617.69788-5-wangnan0@huawei.comSigned-off-by: NWang Nan <wangnan0@huawei.com>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      4708bbda
  10. 23 11月, 2016 2 次提交
  11. 25 10月, 2016 1 次提交
  12. 24 10月, 2016 5 次提交
  13. 05 10月, 2016 1 次提交
  14. 04 10月, 2016 1 次提交
  15. 08 9月, 2016 1 次提交
  16. 03 8月, 2016 2 次提交
  17. 02 8月, 2016 1 次提交
  18. 28 7月, 2016 1 次提交
  19. 26 7月, 2016 1 次提交
  20. 16 7月, 2016 2 次提交
  21. 14 7月, 2016 3 次提交
  22. 13 7月, 2016 6 次提交