[PATCH v2 0/6] Fixes and improvements in /proc/schedstat

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch series adds fixes and improvements to /proc/schedstat. Patches
are based on top of tip/sched/core commit 7675361ff9a1
("sched: deadline: Cleanup goto label in pick_earliest_pushable_dl_task")

Patch 1 and 2: In /proc/schedstat, lb_hot_gained reports the number of
times cache-hot tasks were migrated as a part of load balancing. This
value is incremented in can_migrate_task() if the task is cache hot and
migratable. But after incrementing this value, it is possible that the
task won't get migrated, in which case this value will be incorrect.
Fix this by incrementing it in detach_task().

While at it, cleanup migrate_degrades_locality() by making it return an
enum instead of the {-1,0,1} to improve the readability of
can_migrate_task(). Previously these patches were sent here[1].

Patch 3: Adds new fields to /proc/schedstat. Previously this patch was
sent here[2]. This change is intended to be a part of v17 of
/proc/schedstat.

In /proc/schedstat, lb_imbalance reports the sum of imbalances discovered
in sched domains with each call to sched_balance_rq(), which is not very
useful because lb_imbalance does not mention whether the imbalance is due
to load, utilization, nr_tasks or misfit_tasks. Remove this field from
/proc/schedstat.

Currently there is no field in /proc/schedstat to report different types
of imbalances. Introduce new fields in /proc/schedstat to report the
total imbalances in load, utilization, nr_tasks or misfit_tasks.

Patch 4 and 5: Currently, there does not exist a straightforward way to
extract the names of the sched domains and match them to the per-cpu
domain entry in /proc/schedstat other than looking at the debugfs files
which are only visible after enabling "verbose" debug after commit
34320745dfc9 ("sched/debug: Put sched/domains files under the verbose flag")

Since tools like `perf sched stats`[3] requires displaying per-domain
information in user friendly manner, display the names of sched domain,
alongside their level in /proc/schedstat to aggregate domain level stats
if domain names are shown in /proc/schedstat. But sched domain name is
guarded by CONFIG_SCHED_DEBUG. As per the discussion[4], these patches
moves sched domain name out of CONFIG_SCHED_DEBUG and prints sched
domain name in /proc/schedstat.

Patch 6: Updates the Schedstat version to 17 as more fields are added to
report different kinds of imbalances in the sched domain. Domain fields
also started printing sched domain name.

[1] https://lore.kernel.org/all/20230614102224.12555-1-swapnil.sapkal@xxxxxxx/
[2] https://lore.kernel.org/lkml/66f1e42c-9035-4f9b-8c77-976ab50638bd@xxxxxxx/
[3] https://lore.kernel.org/lkml/20241122084452.1064968-1-swapnil.sapkal@xxxxxxx/
[4] https://lore.kernel.org/lkml/fcefeb4d-3acb-462d-9c9b-3df8d927e522@xxxxxxx/

v1: https://lore.kernel.org/all/20241218043629.1142651-1-swapnil.sapkal@xxxxxxx/
v1->v2:
- Used __schedstat_add() instead of schedstat_add() to avoid calling
  schedstat_enabled() multiple times [Peter Zijlstra]
- Fixed the commit message in patch 2 as it was not consistent with
  comment in the code in v1

K Prateek Nayak (1):
  sched/stats: Print domain name in /proc/schedstat

Peter Zijlstra (2):
  sched/fair: Fix value reported by hot tasks pulled in /proc/schedstat
  sched/fair: Cleanup in migrate_degrades_locality() to improve
    readability

Swapnil Sapkal (3):
  sched: Report the different kinds of imbalances in /proc/schedstat
  sched: Move sched domain name out of CONFIG_SCHED_DEBUG
  docs: Update Schedstat version to 17

 Documentation/scheduler/sched-stats.rst | 126 ++++++++++++++----------
 include/linux/sched.h                   |   1 +
 include/linux/sched/topology.h          |  13 +--
 kernel/sched/fair.c                     |  77 ++++++++++-----
 kernel/sched/stats.c                    |  11 ++-
 kernel/sched/topology.c                 |   4 -
 6 files changed, 140 insertions(+), 92 deletions(-)

-- 
2.43.0





[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux