shmem: split huge pages beyond i_size under memory pressure
Subsystems (2)
[email protected]
maintainerPATCH 117/126 shmem: split huge pages beyond i_size under memory pressure
From: "Kirill A. Shutemov" <[email protected]>
Subject: shmem: split huge pages beyond i_size under memory pressure
Even if user asked to allocate huge pages always (huge=always), we should be able to free up some memory by splitting pages which are partly byound i_size if memory presure comes or once we hit limit on filesystem size (-o size=).
In order to do this we maintain per-superblock list of inodes, which potentially have huge pages on the border of file size.
Per-fs shrinker can reclaim memory by splitting such pages.
If we hit -ENOSPC during shmem_getpage_gfp(), we try to split a page to free up space on the filesystem and retry allocation if it succeed.
---
include/linux/shmem_fs.h | 6 + mm/shmem.c | 175 +++++++++++++++++++++++++++++++++++++ 2 files changed, 180 insertions(+), 1 deletion(-)
include/linux/shmem_fs.h renamed from include/linux/shmem_fs.h~shmem-split-huge-pages-beyond-i_size-under-memory-pressure +5 -1
@@ -16,8 +16,9 @@ struct shmem_inode_info {unsigned long flags;unsigned long alloced;/* data pages alloced to file */ unsigned long swapped;/* subtotal assigned to swap */ -struct shared_policy policy;/* NUMA memory alloc policy */ +struct list_head shrinklist;/* shrinkable hpage inodes */ struct list_head swaplist;/* chain of maybes on swap */ +struct shared_policy policy;/* NUMA memory alloc policy */ struct simple_xattrs xattrs;/* list of xattrs */ struct inode vfs_inode; };
@@ -33,6 +34,9 @@ struct shmem_sb_info {kuid_t uid;/* Mount uid for root directory */ kgid_t gid;/* Mount gid for root directory */ struct mempolicy *mpol;/* default memory policy for mappings */ +spinlock_t shrinklist_lock;/* Protects shrinklist */ +struct list_head shrinklist;/* List of shinkable inodes */ +unsigned long shrinklist_len;/* Length of shrinklist */ };static inline struct shmem_inode_info *SHMEM_I (struct inode *inode)
mm/shmem.c renamed from mm/shmem.c~shmem-split-huge-pages-beyond-i_size-under-memory-pressure +175 -0
246 lines not on this page · raw message
_