On Tue, Apr 26, 2022 at 04:26:08PM -0400, Zi Yan wrote: > Thanks for reporting the issue. Do you have a reproducer I can use to debug the code? Nothing fancy. It just try to remove and add back each memory section. #!/usr/bin/env python3 # SPDX-License-Identifier: GPL-2.0 import os import re import subprocess def mem_iter(): base_dir = '/sys/devices/system/memory/' for curr_dir in os.listdir(base_dir): if re.match(r'memory\d+', curr_dir): yield base_dir + curr_dir if __name__ == '__main__': print('- Try to remove each memory section and then add it back.') for mem_dir in mem_iter(): status = f'{mem_dir}/online' if open(status).read().rstrip() == '1': # This could expectedly fail due to many reasons. section = os.path.basename(mem_dir) print(f'- Try to remove {section}.') proc = subprocess.run([f'echo 0 | sudo tee {status}'], shell=True) if proc.returncode == 0: print(f'- Try to add {section}.') subprocess.check_call([f'echo 1 | sudo tee {status}'], shell=True)