Hi Petr, On Thu, Dec 16, 2021 at 3:50 PM Petr Vorel wrote: > 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 > > > 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 > Yes, actually it's not a commendatory API to users, and I think we do really avoid using it unless we have no better choice. (at least for OOM tests I can tell this) The main reason we use it is current kernel OOM is not very perfect, we just use it to help get the completed log for LTP. > 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). > Sounds reasonable, will add this in V2. > > > +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" > Agree. -- Regards, Li Wang