File tree Expand file tree Collapse file tree 3 files changed +14
-0
lines changed
Expand file tree Collapse file tree 3 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -85,6 +85,9 @@ pub struct ExecutableSpec {
8585 /// Requires `no_new_privs = true`.
8686 #[ serde( default ) ]
8787 pub seccomp : Option < SeccompFilter > ,
88+
89+ /// An optional out-of-memory score adjustment value.
90+ pub oom_score_adj : Option < i32 > ,
8891}
8992
9093#[ derive( Default , Debug , Serialize , Deserialize ) ]
Original file line number Diff line number Diff line change @@ -211,6 +211,11 @@ impl CreateRequestBuilder {
211211 self
212212 }
213213
214+ pub fn set_oom_score_adj ( mut self , score : i32 ) -> CreateRequestBuilder {
215+ self . config . exec . oom_score_adj = Some ( score) ;
216+ self
217+ }
218+
214219 pub fn set_hostname ( mut self , hostname : & str ) -> CreateRequestBuilder {
215220 self . config . hostname = hostname. to_string ( ) . into ( ) ;
216221 self
Original file line number Diff line number Diff line change @@ -639,6 +639,12 @@ impl Wrappable for CreateRequest {
639639
640640 debug ! ( "mount tree finalized, doing final prep" ) ;
641641
642+ // Ensure the process receives the desired out-of-memory score adjustment.
643+ // If not specified, we do want to pro-actively set this value to the
644+ // kernel-default of zero, else the subprocess inherits the styrolite
645+ // oom score (which is typcially set to a very low value).
646+ fs:: write ( "/proc/self/oom_score_adj" , self . exec . oom_score_adj . unwrap_or ( 0 ) . to_string ( ) ) ?;
647+
642648 // We need to toggle SECBIT before we change UID/GID,
643649 // or else changing UID/GID may cause us to lose the capabilities
644650 // we need to explicitly drop capabilities later on.
You can’t perform that action at this time.
0 commit comments