When calculating used swap space, only use anonymous pages

up_daemon_check_swap_space uses the Active: line from /proc/meminfo to
determine the amount of swap the system needs to be able to suspend.  However,
because Active: includes both anonymous and file-backed pages, this greatly
overestimates the amount of swap needed.  File-backed pages can be written back
to disk and so do not consume swap.

Instead, up_daemon_check_swap_space should use Active(anon): from /proc/meminfo
because only anonymous pages need to be written out to swap during a suspend.

Signed-off-by: Richard Hughes <richard@hughsie.com>
This commit is contained in:
Steven Walter 2010-05-29 13:12:57 +01:00 committed by Richard Hughes
parent 37504601f3
commit 6bb6602c06

View file

@ -511,7 +511,7 @@ up_backend_get_used_swap (UpBackend *backend)
swap_free = atoi (tokens[len-2]);
if (g_strcmp0 (tokens[0], "SwapTotal") == 0)
swap_total = atoi (tokens[len-2]);
else if (g_strcmp0 (tokens[0], "Active") == 0)
else if (g_strcmp0 (tokens[0], "Active(anon)") == 0)
active = atoi (tokens[len-2]);
}
g_strfreev (tokens);