[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <476aa5a107994d293dcdfc5a620cc52f625768c2.1681430907.git.ackerleytng@google.com>
Date: Fri, 14 Apr 2023 00:11:50 +0000
From: Ackerley Tng <ackerleytng@...gle.com>
To: kvm@...r.kernel.org, linux-api@...r.kernel.org,
linux-arch@...r.kernel.org, linux-doc@...r.kernel.org,
linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-mm@...ck.org, qemu-devel@...gnu.org
Cc: aarcange@...hat.com, ak@...ux.intel.com, akpm@...ux-foundation.org,
arnd@...db.de, bfields@...ldses.org, bp@...en8.de,
chao.p.peng@...ux.intel.com, corbet@....net, dave.hansen@...el.com,
david@...hat.com, ddutile@...hat.com, dhildenb@...hat.com,
hpa@...or.com, hughd@...gle.com, jlayton@...nel.org,
jmattson@...gle.com, joro@...tes.org, jun.nakajima@...el.com,
kirill.shutemov@...ux.intel.com, linmiaohe@...wei.com,
luto@...nel.org, mail@...iej.szmigiero.name, mhocko@...e.com,
michael.roth@....com, mingo@...hat.com, naoya.horiguchi@....com,
pbonzini@...hat.com, qperret@...gle.com, rppt@...nel.org,
seanjc@...gle.com, shuah@...nel.org, steven.price@....com,
tabba@...gle.com, tglx@...utronix.de, vannapurve@...gle.com,
vbabka@...e.cz, vkuznets@...hat.com, wanpengli@...cent.com,
wei.w.wang@...el.com, x86@...nel.org, yu.c.zhang@...ux.intel.com,
muchun.song@...ux.dev, feng.tang@...el.com, brgerst@...il.com,
rdunlap@...radead.org, masahiroy@...nel.org,
mailhol.vincent@...adoo.fr, Ackerley Tng <ackerleytng@...gle.com>
Subject: [RFC PATCH 1/6] mm: shmem: Refactor out shmem_shared_policy() function
Refactor out shmem_shared_policy() to allow reading of a file's shared
mempolicy
Signed-off-by: Ackerley Tng <ackerleytng@...gle.com>
---
include/linux/shmem_fs.h | 7 +++++++
mm/shmem.c | 10 ++++++----
2 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h
index d9e57485a686..bc1eeb4b4bd9 100644
--- a/include/linux/shmem_fs.h
+++ b/include/linux/shmem_fs.h
@@ -134,6 +134,13 @@ static inline bool shmem_file(struct file *file)
return shmem_mapping(file->f_mapping);
}
+static inline struct shared_policy *shmem_shared_policy(struct file *file)
+{
+ struct inode *inode = file_inode(file);
+
+ return &SHMEM_I(inode)->policy;
+}
+
/*
* If fallocate(FALLOC_FL_KEEP_SIZE) has been used, there may be pages
* beyond i_size's notion of EOF, which fallocate has committed to reserving:
diff --git a/mm/shmem.c b/mm/shmem.c
index b053cd1f12da..4f801f398454 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -2248,20 +2248,22 @@ unsigned long shmem_get_unmapped_area(struct file *file,
}
#ifdef CONFIG_NUMA
+
static int shmem_set_policy(struct vm_area_struct *vma, struct mempolicy *mpol)
{
- struct inode *inode = file_inode(vma->vm_file);
- return mpol_set_shared_policy(&SHMEM_I(inode)->policy, vma, mpol);
+ struct shared_policy *info;
+
+ info = shmem_shared_policy(vma->vm_file);
+ return mpol_set_shared_policy(info, vma, mpol);
}
static struct mempolicy *shmem_get_policy(struct vm_area_struct *vma,
unsigned long addr)
{
- struct inode *inode = file_inode(vma->vm_file);
pgoff_t index;
index = ((addr - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff;
- return mpol_shared_policy_lookup(&SHMEM_I(inode)->policy, index);
+ return mpol_shared_policy_lookup(shmem_shared_policy(vma->vm_file), index);
}
#endif
--
2.40.0.634.g4ca3ef3211-goog
Powered by blists - more mailing lists