Re: [PATCH 2/4] mm: Add a .to_text() method for shrinkers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu 21-04-22 19:48:26, Kent Overstreet wrote:
> This adds a new callback method to shrinkers which they can use to
> describe anything relevant to memory reclaim about their internal state,
> for example object dirtyness.
> 
> This uses the new printbufs to output to heap allocated strings, so that
> the .to_text() methods can be used both for messages logged to the
> console, and also sysfs/debugfs.
> 
> This patch also adds shrinkers_to_text(), which reports on the top 10
> shrinkers - by object count - in sorted order, to be used in OOM
> reporting.

Let's put aside whether doing the sorting is useful or not for a moment.
The primary concern I have here is that pr_buf is internally relying on
memory allocations. This makes it really risky to use from the OOM path
which is the primary motivation here AFAICS.

Especially the oom killer path where we _know_ the memory is depleted.
The only way to pursue the allocation is to rely on PF_MEMALLOC and
memory reserves.

If you want to have a generic way to dump shrinker's internal state then
those would really need a prellocated buffer and .to_text would need to
be documented to not depend on any locking that could be directly or
indirectly depending on memory allocations.

> Signed-off-by: Kent Overstreet <kent.overstreet@xxxxxxxxx>
> ---
>  include/linux/shrinker.h |  5 +++
>  mm/vmscan.c              | 75 ++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 80 insertions(+)
-- 
Michal Hocko
SUSE Labs



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux