Re: [PATCH] sched/debug: reject zero writes to numa_balancing scan_size_mb

From: Zhan Xusheng

Date: Tue Jul 21 2026 - 05:19:14 EST


On Mon, Jul 14, 2026 at 01:30PM +0800, Li RongQing wrote:
> + debugfs_create_file("scan_size_mb", 0644, numa,
> + &sysctl_numa_balancing_scan_size, &numa_scan_size_fops);

DEFINE_DEBUGFS_ATTRIBUTE() is meant to be paired with
debugfs_create_file_unsafe() rather than debugfs_create_file():
debugfs_attr_read()/write() already take removal protection via
debugfs_file_get()/put(), so debugfs_create_file() just adds a
redundant full_proxy layer. The "verbose" knob in this same file
uses debugfs_create_file_unsafe() for that reason.

> + if (val == 0 || val > UINT_MAX)
> + return -ERANGE;

The changelog says the value is rejected with -EINVAL, but the code
returns -ERANGE -- could you make the two consistent? -ERANGE is fine.

The write-time rejection is the right approach; just the two points above.

Thanks,
Xusheng