[LTP] [PATCH 1/3] lib: add functions to adjust oom score

Petr Vorel pvorel@suse.cz
Thu Dec 16 08:49:54 CET 2021


Hi Li,

> This introduces function to LTP for adjusting the oom_score_adj of
> target process, which may be helpful in OOM tests to prevent kernel
> killing the main or lib process during test running.
very good idea.

Reviewed-by: Petr Vorel <pvorel@suse.cz>

> The exported global tst_enable_oom_protection function can be used
> at anywhere you want to protect, but please remember that if you
> do enable protection on a process($PID) that all the children will
> inherit its score and be ignored by OOM Killer as well. So that's
> why tst_cancel_oom_protection is recommended to combination in use.

BTW deliberately not documenting it as it should not be commonly
used in tests? Also although oom_score_adj inheritance should be known to
person who will want to add it somewhere, I'd move it from commit message to
source code (into header docs or or C API doc).

> +static void set_oom_score_adj(pid_t pid, int value)
> +{
> +	int val;
> +	char score_path[64];
> +
> +	if (access("/proc/self/oom_score_adj", F_OK) == -1) {
> +		tst_res(TINFO, "Warning: oom_score_adj is not exist");
nit: IMHO "does not exist" or just "not exist"

...

Kind regards,
Petr


More information about the ltp mailing list