lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1329403677-25629-6-git-send-email-mail@smogura.eu>
Date:	Thu, 16 Feb 2012 15:47:55 +0100
From:	Radosław Smogura <mail@...gura.eu>
To:	linux-mm@...ck.org
Cc:	Yongqiang Yang <xiaoqiangnk@...il.com>, mail@...gura.eu,
	linux-ext4@...r.kernel.org
Subject: [WIP 16/18] SHM: Support for splitting on truncation

Writeback will be added in next patches, but after experimental support
for huge pages for EXT 4.

Signed-off-by: Radosław Smogura <mail@...gura.eu>
---
 mm/shmem.c |   39 ++++++++++++++++++++++++++++++++++++++-
 1 files changed, 38 insertions(+), 1 deletions(-)

diff --git a/mm/shmem.c b/mm/shmem.c
index 97e76b9..db377bf 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -454,6 +454,7 @@ void shmem_truncate_range(struct inode *inode, loff_t lstart, loff_t lend)
 		mem_cgroup_uncharge_start();
 		for (i = 0; i < pagevec_count(&pvec); i++) {
 			struct page *page = pvec.pages[i];
+			struct page *head = NULL;
 
 			index = indices[i];
 			if (index > end)
@@ -464,12 +465,32 @@ void shmem_truncate_range(struct inode *inode, loff_t lstart, loff_t lend)
 								index, page);
 				continue;
 			}
-
 			if (!trylock_page(page))
 				continue;
+			if (PageCompound(page)) {
+				head = compound_head(page);
+				switch (compound_try_freeze(head, false)) {
+				case -1:
+					head = NULL;
+					break;
+				case 1:
+					unlock_page(page);
+					continue;
+				case 0:
+					if (!split_huge_page_file(head, page))
+						head = NULL;
+					break;
+				}
+			}
+			/* Truncate inode page may try to freez, so unfreez. */
 			if (page->mapping == mapping) {
 				VM_BUG_ON(PageWriteback(page));
+				if (head != NULL)
+					compound_unfreeze(head);
 				truncate_inode_page(mapping, page);
+			} else {
+				if (head != NULL)
+					compound_unfreeze(head);
 			}
 			unlock_page(page);
 		}
@@ -511,6 +532,7 @@ void shmem_truncate_range(struct inode *inode, loff_t lstart, loff_t lend)
 		mem_cgroup_uncharge_start();
 		for (i = 0; i < pagevec_count(&pvec); i++) {
 			struct page *page = pvec.pages[i];
+			struct page *head = NULL;
 
 			index = indices[i];
 			if (index > end)
@@ -523,9 +545,24 @@ void shmem_truncate_range(struct inode *inode, loff_t lstart, loff_t lend)
 			}
 
 			lock_page(page);
+			if (PageCompound(page)) {
+				head = compound_head(page);
+				if (compound_freeze(head)) {
+					if (!split_huge_page_file(head, page))
+						head = NULL;
+				} else {
+					head = NULL;
+				}
+			}
+			/* Truncate inode page may try to freez, so unfreez. */
 			if (page->mapping == mapping) {
 				VM_BUG_ON(PageWriteback(page));
+				if (head != NULL)
+					compound_unfreeze(head);
 				truncate_inode_page(mapping, page);
+			} else {
+				if (head != NULL)
+					compound_unfreeze(head);
 			}
 			unlock_page(page);
 		}
-- 
1.7.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ