Re: [PATCH v7 4/4] perf sched latency: Add histogram and time interval options

Aaron Tomlin <[email protected]>
Newsgroups gmane.linux.kernel,gmane.linux.kernel.perf.user
Message-ID <zjntzmhulwpk7gf63xudwbfvyuvzjwh4wi7uuphlllwnyx57mg@a3sf5pvdtyh6>
On Mon, Aug 03, 2026 at 11:06:16AM -0700, Namhyung Kim wrote:
> > @@ -1168,7 +1306,13 @@ add_sched_in_event(struct work_atoms *atoms, u64 timestamp)
> >  		atoms->max_lat_start = atom->wake_up_time;
> >  		atoms->max_lat_end = timestamp;
> >  	}
> > +
> >  	atoms->nb_atoms++;
> > +
> > +	b = latency_bucket(sched, delta);
> > +	atoms->hist[b]++;
> > +	if (strcmp(thread__comm_str(atoms->thread), "swapper"))
> > +		sched->global_hist[b]++;
> 
> Why is the swapper thread not included in the global hist?
> 
> Also it's probably better to check thread__tid being 0.

Hi Namhyung,

The CPU-specific "swapper" thread runs when CPUs are idle. Therefore,
preemption/wakeup timings for idle threads do not represent _real_ task
scheduling latency. Throughout (e.g., in output_lat_thread()), idle threads
are explicitly ignored to avoid inflating 'sched->all_count' etc.

Indeed, testing for 'TID == 0' is superior. For example:

@@ -1168,7 +1306,13 @@ add_sched_in_event(struct work_atoms *atoms, u64 timestamp)
                atoms->max_lat_start = atom->wake_up_time;
                atoms->max_lat_end = timestamp;
        }
+
        atoms->nb_atoms++;
+
+       b = latency_bucket(sched, delta);
+       atoms->hist[b]++;
+       if (thread__tid(atoms->thread) != 0)
+               sched->global_hist[b]++;

> > @@ -3659,6 +3831,21 @@ static int perf_sched__lat(struct perf_sched *sched)
> >  	perf_sched__merge_lat(sched);
> >  	perf_sched__sort_lat(sched);
> >  
> > +	next = rb_first_cached(&sched->sorted_atom_root);
> > +	while (next) {
> > +		struct work_atoms *work_list = rb_entry(next, struct work_atoms, node);
> > +
> > +		if (work_list->nb_atoms && strcmp(thread__comm_str(work_list->thread), "swapper"))
> 
> Ditto.  Comparing TID would be faster.

Acknowledged. Thanks!


Kind regards,
-- 
Aaron Tomlin
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.