[LTP] [PATCH v3 1/3] lib: add functions to adjust oom score
Li Wang
liwang@redhat.com
Tue Dec 21 03:50:26 CET 2021
On Tue, Dec 21, 2021 at 2:34 AM Petr Vorel <pvorel@suse.cz> wrote:
> Hi Li,
>
> > v2 --> v3
> > * rename to tst_disable_oom_protection
> > * support set PID as 0 to protect current process
>
> > +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) {
> We need to check here also /proc/PID/oom_score_adj, i.e. score_path.
>
Good catch, I would add a 'W_OK' checking and skip the setting with
a reminder message if run without root.
how about this?
if (access(score_path, W_OK) == -1) {
tst_res(TINFO, "Warning: %s cannot be accessed for writing,
please check if test run with root user.",
score_path);
return
}
--
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20211221/8c2d66ac/attachment.htm>
More information about the ltp
mailing list