Updated Answer
The "default" value of many sysctl kernel parameters is compiled into the kernel itself.
Example: kernel.numa_balancing_scan_delay_ms is set to 1000 by default in ./kernel/sched/fair.c, which is loaded in ./kernel/sysctl.c.
You can change these at runtime with sysctl3. systemd does this at boot with systemd-sysctl.service early in the boot process.
For some reason, it sounds like you are initializing something very early that a kernel parameter can't be set later and must be set on boot. If early boot service is still too late and you can't tolerate sysctl setting parameters that late, perhaps you can set the parameters at boot2 in your bootloader's kernel line.
If you can't do that, you may need to compile a custom kernel1 with the default values you want.
From the Arch Linux wiki:
There are three ways to pass options to the kernel and thus control
its behaviour:
- When building the kernel. See Kernel Compilation for details.
- When starting the kernel (usually, when invoked from a boot loader).
- At runtime (through the files in
/proc and /sys). See sysctl for details.
Original Answer
Set the values in /etc/sysctl.conf or in a *.conf file in /etc/sysctl.d/.
Once they're set, you can reload the configuration by running sudo sysctl --system.
Additional Resources
kernel.numa_balancing_scan_delay_msis set to1000by default in./kernel/sched/fair.c, which is loaded in./kernel/sysctl.c. If you can't toleratesysctlsetting a parameter later in boot, perhaps you can set the parameter at boot in your bootloader's kernel line. If you can't do that, you may need a custom kernel. – Deltik Jun 16 '17 at 17:59