From: "Christian König" <ckoenig.leichtzumerken@gmail.com>
To: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
intel-gfx@lists.freedesktop.org, amd-gfx@lists.freedesktop.org,
nouveau@lists.freedesktop.org, linux-tegra@vger.kernel.org,
linux-fsdevel@vger.kernel.org, linux-mm@kvack.org,
dri-devel@lists.freedesktop.org
Cc: mhocko@suse.com, "Christian König" <christian.koenig@amd.com>
Subject: [PATCH 04/14] mm: shmem: provide RSS for shmem files
Date: Fri, 24 Jun 2022 10:04:34 +0200 [thread overview]
Message-ID: <20220624080444.7619-5-christian.koenig@amd.com> (raw)
In-Reply-To: <20220624080444.7619-1-christian.koenig@amd.com>
This gives the OOM killer an additional hint which processes are
referencing shmem files with potentially no other accounting for them.
Signed-off-by: Christian König <christian.koenig@amd.com>
---
mm/shmem.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/mm/shmem.c b/mm/shmem.c
index a6f565308133..b068ac5ba4bf 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -2209,6 +2209,21 @@ unsigned long shmem_get_unmapped_area(struct file *file,
return inflated_addr;
}
+static long shmem_file_rss(struct file *file)
+{
+ struct inode *inode = file_inode(file);
+ unsigned long nrpages;
+
+ /* Only account shmem files which aren't part of any fs */
+ if (atomic_read(&inode->i_count) > 1)
+ return 0;
+
+ xa_lock(&file->f_mapping->i_pages);
+ nrpages = file->f_mapping->nrpages;
+ xa_unlock(&file->f_mapping->i_pages);
+ return nrpages;
+}
+
#ifdef CONFIG_NUMA
static int shmem_set_policy(struct vm_area_struct *vma, struct mempolicy *mpol)
{
@@ -3811,6 +3826,7 @@ EXPORT_SYMBOL(shmem_aops);
static const struct file_operations shmem_file_operations = {
.mmap = shmem_mmap,
.get_unmapped_area = shmem_get_unmapped_area,
+ .file_rss = shmem_file_rss,
#ifdef CONFIG_TMPFS
.llseek = shmem_file_llseek,
.read_iter = shmem_file_read_iter,
--
2.25.1
next prev parent reply other threads:[~2022-06-24 8:04 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-24 8:04 [RFC] Per file OOM-badness / RSS once more Christian König
2022-06-24 8:04 ` [PATCH 01/14] fs: add per file RSS Christian König
2022-06-24 8:04 ` [PATCH 02/14] oom: take per file RSS into account Christian König
2022-06-24 8:04 ` [PATCH 03/14] proc: expose per file RSS Christian König
2022-06-24 8:04 ` Christian König [this message]
2022-06-24 8:04 ` [PATCH 05/14] dma-buf: provide file RSS for DMA-buf files Christian König
2022-06-24 8:04 ` [PATCH 06/14] drm/gem: adjust per file RSS on handling buffers Christian König
2022-06-24 8:04 ` [PATCH 07/14] drm/gma500: use drm_file_rss Christian König
2022-06-24 8:04 ` [PATCH 08/14] drm/amdgpu: " Christian König
2022-06-24 8:04 ` [PATCH 09/14] drm/radeon: use drm_oom_badness Christian König
2022-06-28 10:34 ` Michel Dänzer
2022-06-24 8:04 ` [PATCH 10/14] drm/i915: use drm_file_rss Christian König
2022-06-24 8:04 ` [PATCH 11/14] drm/nouveau: " Christian König
2022-06-24 8:04 ` [PATCH 12/14] drm/omap: " Christian König
2022-06-24 8:04 ` [PATCH 13/14] drm/vmwgfx: " Christian König
2022-06-24 8:04 ` [PATCH 14/14] drm/tegra: " Christian König
2022-06-24 9:59 ` [RFC] Per file OOM-badness / RSS once more Michal Hocko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220624080444.7619-5-christian.koenig@amd.com \
--to=ckoenig.leichtzumerken@gmail.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-tegra@vger.kernel.org \
--cc=mhocko@suse.com \
--cc=nouveau@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox