Re: [PATCH 4/5] mm, shmem: Add shmem swap memory accounting

From: Hugh Dickins
Date: Fri Aug 01 2014 - 01:06:53 EST


On Tue, 22 Jul 2014, Jerome Marchand wrote:

> Adds get_mm_shswap() which compute the size of swaped out shmem. It
> does so by pagewalking the mm and using the new shmem_locate() function
> to get the physical location of shmem pages.
> The result is displayed in the new VmShSw line of /proc/<pid>/status.
> Use mm_walk an shmem_locate() to account paged out shmem pages.
>
> It significantly slows down /proc/<pid>/status acccess speed when
> there is a big shmem mapping. If that is an issue, we can drop this
> patch and only display this counter in the inherently slower
> /proc/<pid>/smaps file (cf. next patch).
>
> Signed-off-by: Jerome Marchand <jmarchan@xxxxxxxxxx>

Definite NAK to this one. As you guessed yourself, it is always a
mistake to add one potentially very slow-to-gather number to a stats
file showing a group of quickly gathered numbers.

Is there anything you could do instead? I don't know if it's worth
the (little) extra mm_struct storage and maintenance, but you could
add a VmShmSize, which shows that subset of VmSize (total_vm) which
is occupied by shmem mappings.

It's ambiguous what to deduce when VmShm is less than VmShmSize:
the difference might be swapped out, it might be holes in the sparse
object, it might be instantiated in the object but never faulted
into the mapping: in general it will be a mix of all of those.
So, sometimes useful info, but easy to be misled by it.

As I say, I don't know if VmShmSize would be worth adding, given its
deficiencies; and it could be worked out from /proc/<pid>/maps anyway.

Hugh
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/