File tree 2 files changed +19
-0
lines changed
2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -512,6 +512,8 @@ impl Balloon {
512
512
) ?;
513
513
514
514
svc. set_slice ( Slice :: Sys . name ( ) )
515
+ // Make sure memory allocation completed once started
516
+ . add_prop ( "Type" . into ( ) , systemd:: Prop :: String ( "notify" . into ( ) ) )
515
517
. add_prop ( "MemorySwapMax" . into ( ) , systemd:: Prop :: U64 ( 0 ) )
516
518
. add_prop (
517
519
"Slice" . into ( ) ,
Original file line number Diff line number Diff line change 2
2
# Copyright (c) Facebook, Inc. and its affiliates
3
3
4
4
import mmap
5
+ import os
5
6
import sys
6
7
import time
8
+ import socket
7
9
8
10
9
11
if len (sys .argv ) < 2 :
10
12
print ("Usage: memory-balloon.py BYTES" , file = sys .stderr )
11
13
sys .exit (1 )
12
14
15
+ try :
16
+ sd_socket = socket .socket (socket .AF_UNIX , socket .SOCK_DGRAM )
17
+ sd_addr = os .getenv ("NOTIFY_SOCKET" )
18
+ assert sd_addr , "$NOTIFY_SOCKET not available"
19
+ sd_socket .connect (sd_addr )
20
+ except Exception :
21
+ print ("Failed to create systemd socket" )
22
+ raise
23
+
13
24
nr_pages = int ((int (sys .argv [1 ]) + 4095 ) / 4096 )
14
25
mm = mmap .mmap (- 1 , nr_pages * 4096 , flags = mmap .MAP_PRIVATE )
15
26
21
32
print (f"Touched { i * 4096 / (1 << 30 ):.2f} G" )
22
33
last_at = time .time ()
23
34
35
+ try :
36
+ sd_socket .sendall (b"READY=1" )
37
+ except Exception :
38
+ print ("Failed to send ready notification to systemd" )
39
+ raise
40
+
24
41
print ("Allocation done, sleeping..." )
25
42
while True :
26
43
time .sleep (600 )
You can’t perform that action at this time.
0 commit comments