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-next>] [day] [month] [year] [list]
Date:   Sat, 07 Oct 2017 04:22:10 +0800
From:   "Yang Shi" <yang.s@...baba-inc.com>
To:     kirill.shutemov@...ux.intel.com, hughd@...gle.com,
        mhocko@...nel.org, akpm@...ux-foundation.org
Cc:     "Yang Shi" <yang.s@...baba-inc.com>, <linux-mm@...ck.org>,
        <linux-kernel@...r.kernel.org>
Subject: [RFC PATCH] mm: shm: round up tmpfs size to huge page size when huge=always

When passing "huge=always" option for mounting tmpfs, THP is supposed to
be allocated all the time when it can fit, but when the available space is
smaller than the size of THP (2MB on x86), shmem fault handler still tries
to allocate huge page every time, then fallback to regular 4K page
allocation, i.e.:

	# mount -t tmpfs -o huge,size=3000k tmpfs /tmp
	# dd if=/dev/zero of=/tmp/test bs=1k count=2048
	# dd if=/dev/zero of=/tmp/test1 bs=1k count=2048

The last dd command will handle 952 times page fault handler, then exit
with -ENOSPC.

Rounding up tmpfs size to THP size in order to use THP with "always"
more efficiently. And, it will not wast too much memory (just allocate
511 extra pages in worst case).

Signed-off-by: Yang Shi <yang.s@...baba-inc.com>
---
 mm/shmem.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/mm/shmem.c b/mm/shmem.c
index 07a1d22..b2b595d 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -3567,6 +3567,11 @@ static int shmem_parse_options(char *options, struct shmem_sb_info *sbinfo,
 		}
 	}
 	sbinfo->mpol = mpol;
+#ifdef CONFIG_TRANSPARENT_HUGE_PAGECACHE
+	/* Round up tmpfs size to huge page size */
+	if (sbinfo->max_blocks && sbinfo->huge == SHMEM_HUGE_ALWAYS)
+		sbinfo->max_blocks = round_up(sbinf->max_blocks, HPAGE_PMD_NR);
+#endif
 	return 0;
 
 bad_val:
-- 
1.8.3.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ