When I try to perform hibernation on imx series board,i.e., echo disk > /sys/power/state, kernel gets into infinite loop like Freeing memory .... and so on.When I added some debug statements to mm/vmscan.c where actually freeing memory(reclaiming pages) takes place in kernel source (linux 4.4), I saw the loop  while reclaiming pages at below code.if (global_reclaim(sc) &&            !reclaimable && zone_reclaimable(zone))            reclaimable = true;This issue gets solved by removing the above lines. Similar Issue is seen here. And it is solved through a patch removing the offending lines. But it does not explain why the zone reclaimable goes into infinite loop and what causes it? After some debugging, I found a userspace process in sleeping state and has three threads. This process is in pause state through system_pause()(waiting for some event to occur) and is accessing shared memory(/dev/shm) which is created with 100m size. This shared memory has some semaphore related files. Also this process has some anonymous private and shared mappings when I saw the output of pmap -d PID and there is no swap space in the system.Another solution to this hang situation is to remove that userspace process and hibernation works fine. But how can that be a solution since kernel should be able to handle any exception.So my questions are:How can this sleeping process in pause state cause issue in freeing memory for hibernation?How are the pages reclaimed from sleeping process which is using shared memory in linux?I tried to unmount /dev/shm but was not possible since process was using it. Can we release shared memory by any way? I tried munmap but no use.How removing offending lines actually solves the issue?Is removing the offending lines a correct solution? Will there be any kind of issues by removing the offending lines since it is related to reclaiming pages?Any info would be helpful.
Error in freeing memory for suspend to disk
linux;kernel;linux kernel;arm