Skip to content

pelt scheduler: add new tests to validate pelt#447

Open
vnarapar wants to merge 1 commit into
qualcomm-linux:mainfrom
vnarapar:pelt_scheduler
Open

pelt scheduler: add new tests to validate pelt#447
vnarapar wants to merge 1 commit into
qualcomm-linux:mainfrom
vnarapar:pelt_scheduler

Conversation

@vnarapar
Copy link
Copy Markdown
Contributor

@vnarapar vnarapar commented May 8, 2026

This PR adds new testcases to validate PELT scheduler

  • This validates configs, decay, load tracking, schedutil and different tunables

@smuppand
Copy link
Copy Markdown
Contributor

smuppand commented May 8, 2026

@vnarapar please fix the workflow issues

Copy link
Copy Markdown
Contributor

@smuppand smuppand left a comment

Choose a reason for hiding this comment

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

Since there are multiple files in the PR, I am providing a consolidated review.

  1. CI is failing for executable permissions and Shell Lint.
  2. All run.sh files use [ -z "$__INIT_ENV_LOADED" ]; please switch to ${__INIT_ENV_LOADED:-}.
  3. All run.sh files call check_dependencies but do not check the return value.
  4. PELT_decay Method 1 reads /proc/self/sched through grep, so it reads the grep process sched data instead of the shell workload. Please read /proc/$$/sched instead.
  5. PELT_sched_debug checks only whether /sys/kernel/debug exists, not whether debugfs is mounted. Please validate debugfs via /proc/mounts.
  6. PELT_schedutil uses -ge for “frequency increased”, making the equal-frequency warning path unreachable. Use -gt for increase and handle equality separately.
  7. Several scripts write .res and then exit 1. Please exit 0 after writing test FAIL/SKIP results so LAVA can publish the result cleanly.
  8. PELT_config still has copy-paste “DMA-BUF” log messages.
  9. Some tunables/sysfs entries are kernel-version/config dependent and should not be hard failures unless explicitly documented.
  10. YAMLs currently mask cd/run/send-to-lava failures with || true. Please remove unnecessary masking once run.sh result handling is fixed.

After these fixes and runtime evidence on at least one target, this can be reviewed again.

This PR adds new testcases to validate PELT scheduler
- This validates configs, decay, load tracking, schedutil and different
  tunables

Signed-off-by: Vamsee Narapareddi <vnarapar@qti.qualcomm.com>
@vnarapar
Copy link
Copy Markdown
Contributor Author

Hi @smuppand , thanks fixed the issues. Have a query wrt Iusse#2. I see that most scripts are using [ -z "$__INIT_ENV_LOADED" ];, any reason to move to ${__INIT_ENV_LOADED:-}.
Will share the runtime status once done.

@smuppand
Copy link
Copy Markdown
Contributor

Hi @smuppand , thanks fixed the issues. Have a query wrt Iusse#2. I see that most scripts are using [ -z "$__INIT_ENV_LOADED" ];, any reason to move to ${__INIT_ENV_LOADED:-}. Will share the runtime status once done.

because ${var:-} is safe when the variable is unset.

In the current script, the code directly expands "$__INIT_ENV_LOADED" before sourcing init_env.

Why it matters

In normal /bin/sh without set -u, both may work.

But if the script is run by a stricter wrapper, CI harness, or future common runner with:

set -u

then this line can fail:

"$__INIT_ENV_LOADED"

because the variable may not exist yet.

You can get an error like:

__INIT_ENV_LOADED: parameter not set

Using this form avoids that:

"${__INIT_ENV_LOADED:-}"

It means:

Use $__INIT_ENV_LOADED if it is set; otherwise use empty string.

So the test becomes safe even when the variable is unset.

Why we use it in repo scripts

This pattern is already safer and more portable:

if [ -z "${__INIT_ENV_LOADED:-}" ]; then
. "$INIT_ENV"
fi

It avoids:

log_info "================================================================================"
log_info "Validates kernel configuration required for PELT (Per-Entity Load Tracking)"

if ! check_dependencies grep; then
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

uses zgrep but dependency check only checks grep. Also better to log_skip with proper message to console for better debugging.


log_info "Checking optional Scheduler configurations..."
for cfg in $OPTIONAL_CONFIGS; do
if zgrep -qE "^${cfg}=(y|m)" /proc/config.gz 2>/dev/null; then
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please use check_optional_config function from functestlib.sh

log_warn "/proc/config.gz not found - kernel config checks will be skipped"
log_warn "Ensure CONFIG_IKCONFIG and CONFIG_IKCONFIG_PROC are enabled in the kernel"
else
CORE_CONFIGS="CONFIG_FAIR_GROUP_SCHED CONFIG_SMP"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Keep CONFIG_SMP required and move CONFIG_FAIR_GROUP_SCHED to optional unless the test is specifically validating group-scheduler PELT

# ---------------------------------------------------------------------------
log_info "=== debugfs Mount Check ==="

if ! grep -q "debugfs" /proc/mounts 2>/dev/null; then
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This only checks whether any debugfs mount exists, not whether debugfs is mounted at /sys/kernel/debug.
If debugfs is mounted somewhere else, the script may continue and then fail on /sys/kernel/debug/sched.

log_info "================================================================================"
log_info "Validates the scheduler debugfs interface used to inspect PELT state"

if ! check_dependencies grep awk cat; then
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

include id, mount, basename


# Validate ordering: latency >= min_granularity (CFS invariant)
lat_path="$SYSCTL_DIR/sched_latency_ns"
gran_path="$SYSCTL_DIR/sched_min_granularity_ns"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Current script still fails if these are missing:

sched_min_granularity_ns
sched_latency_ns
sched_wakeup_granularity_ns

run.sh
These sysctls can be kernel-version/config dependent. The test can fail a valid target just because those tunables are not exposed.
Recommended fix: Either document these as mandatory for this test, or make missing tunables warning-only:

log_warn " $tunable not found at $path (kernel/config dependent)"

Do not set pass="false" for absence unless this test is explicitly enforcing those knobs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants