Skip to content
This repository has been archived by the owner on Jun 18, 2024. It is now read-only.

Implement ops.dump(), dump_cpu() and dump_task(). #195

Merged
merged 2 commits into from
May 2, 2024
Merged

Conversation

htejun
Copy link
Collaborator

@htejun htejun commented May 2, 2024

Implement ops.dump(), dump_cpu() and dump_task() which allows the BPF
scheduler to include scheduler specific information in debug dump.

The below example output from scx_qmap shows full dump of qmap's FIFO queues
and per-CPU and per-task contexts.

  $ scx_qmap -e 3
  stats  : enq=9 dsp=0 delta=9 reenq=5 deq=9 core=0 exp=0
  cpuperf: cur min/avg/max=0/0/0 target min/avg/max=0/0/0

  DEBUG DUMP
  ================================================================================

  scx_qmap[1627] triggered exit kind 1025:
    scx_bpf_error (test triggering error)

  Backtrace:
    scx_bpf_error_bstr+0x60/0x80
    bpf_prog_5ab320c9dc9e846d_qmap_enqueue+0xd1/0x283

  QMAP FIFO[0]:
  QMAP FIFO[1]:
  QMAP FIFO[2]: 1581 1583 1584 1585 1586 1588 1593 1594 1595
  QMAP FIFO[3]:
  QMAP FIFO[4]:

  CPU states
  ----------

  CPU 0   : nr_run=2 flags=0x0 cpu_rel=1 ops_qseq=4 pnt_seq=12
	    curr=stress[1590] class=ext_sched_class

    QMAP: dsp_idx=0 dsp_cnt=0 avg_weight=0 cpuperf_target=0

   *R stress[1590] +0ms
	scx_state/flags=3/0x5 dsq_flags=0x0 ops_state/qseq=0/0
	sticky/holding_cpu=-1/-1 dsq_id=(n/a)
	cpus=ff

      QMAP: force_local=0 core_sched_seq=0

    R stress[1585] +0ms
	scx_state/flags=3/0x1 dsq_flags=0x0 ops_state/qseq=2/3
	sticky/holding_cpu=-1/-1 dsq_id=(n/a)
	cpus=ff

      QMAP: force_local=0 core_sched_seq=3

      irqentry_exit+0x31/0x80
      sysvec_apic_timer_interrupt+0x44/0x80
      asm_sysvec_apic_timer_interrupt+0x1b/0x20
  ...

htejun added 2 commits May 1, 2024 15:32
- String formatting part in bpf_exit_bstr_common() is factored into
  bstr_format(). The exit part is moved to the callers.

- bstr helpers in common.bpf.h don't necessarily have much to do with
  exiting. Renamed.
Implement ops.dump(), dump_cpu() and dump_task() which allows the BPF
scheduler to include scheduler specific information in debug dump.

The below example output from scx_qmap shows full dump of qmap's FIFO queues
and per-CPU and per-task contexts.

  $ scx_qmap -e 3
  stats  : enq=9 dsp=0 delta=9 reenq=5 deq=9 core=0 exp=0
  cpuperf: cur min/avg/max=0/0/0 target min/avg/max=0/0/0

  DEBUG DUMP
  ================================================================================

  scx_qmap[1627] triggered exit kind 1025:
    scx_bpf_error (test triggering error)

  Backtrace:
    scx_bpf_error_bstr+0x60/0x80
    bpf_prog_5ab320c9dc9e846d_qmap_enqueue+0xd1/0x283

  QMAP FIFO[0]:
  QMAP FIFO[1]:
  QMAP FIFO[2]: 1581 1583 1584 1585 1586 1588 1593 1594 1595
  QMAP FIFO[3]:
  QMAP FIFO[4]:

  CPU states
  ----------

  CPU 0   : nr_run=2 flags=0x0 cpu_rel=1 ops_qseq=4 pnt_seq=12
	    curr=stress[1590] class=ext_sched_class

    QMAP: dsp_idx=0 dsp_cnt=0 avg_weight=0 cpuperf_target=0

   *R stress[1590] +0ms
	scx_state/flags=3/0x5 dsq_flags=0x0 ops_state/qseq=0/0
	sticky/holding_cpu=-1/-1 dsq_id=(n/a)
	cpus=ff

      QMAP: force_local=0 core_sched_seq=0

    R stress[1585] +0ms
	scx_state/flags=3/0x1 dsq_flags=0x0 ops_state/qseq=2/3
	sticky/holding_cpu=-1/-1 dsq_id=(n/a)
	cpus=ff

      QMAP: force_local=0 core_sched_seq=3

      irqentry_exit+0x31/0x80
      sysvec_apic_timer_interrupt+0x44/0x80
      asm_sysvec_apic_timer_interrupt+0x1b/0x20
  ...
@htejun htejun requested a review from Byte-Lab May 2, 2024 01:34
Copy link
Collaborator

@Byte-Lab Byte-Lab left a comment

Choose a reason for hiding this comment

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

Looks perfect, thanks!

Comment on lines 4524 to +4526
seq_buf_printf(s, "\n %c%c %s[%d] %+ldms\n",
marker, task_state_to_char(p), p->comm, p->pid,
jiffies_delta_msecs(p->scx.runnable_at, now));
jiffies_delta_msecs(p->scx.runnable_at, dctx->at_jiffies));
Copy link
Collaborator

Choose a reason for hiding this comment

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

A bit tangential to this change, but would it be useful to also print p->scx.dsq_vtime? If a task hasn't been scheduled for a while, it seems like vtime could be a common culprit. Though with this change, maybe that's not necessary anymore.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, I'm gonna do more work on the dump stuff. Will add vtime.

@htejun htejun merged commit 25f52fc into sched_ext May 2, 2024
1 check passed
@htejun htejun deleted the htejun/dump-ops branch May 2, 2024 16:27
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants