pingtoo wrote:Did you tried on /proc/sys/vm/nr_overcommit_hugepages? you initial post show you did it on different location.
The
procfs interface to
hugetlbfs is (basically) deprecated, and is there only for backwards-compatibility.
sysfs is now preferred:
Code: Select all
214 │ ``/proc/sys/vm/nr_overcommit_hugepages`` specifies how large the pool of
215 │ huge pages can grow, if more huge pages than ``/proc/sys/vm/nr_hugepages`` are
216 │ requested by applications. Writing any non-zero value into this file
217 │ indicates that the hugetlb subsystem is allowed to try to obtain that
218 │ number of "surplus" huge pages from the kernel's normal page pool, when the
219 │ persistent huge page pool is exhausted. As these surplus huge pages become
220 │ unused, they are freed back to the kernel's normal page pool.
221 │
222 │ When increasing the huge page pool size via ``nr_hugepages``, any existing
223 │ surplus pages will first be promoted to persistent huge pages. Then, additional
224 │ huge pages will be allocated, if necessary and if possible, to fulfill
225 │ the new persistent huge page pool size.
226 │
227 │ The administrator may shrink the pool of persistent huge pages for
228 │ the default huge page size by setting the ``nr_hugepages`` sysctl to a
229 │ smaller value. The kernel will attempt to balance the freeing of huge pages
230 │ across all nodes in the memory policy of the task modifying ``nr_hugepages``.
231 │ Any free huge pages on the selected nodes will be freed back to the kernel's
232 │ normal page pool.
233 │
234 │ Caveat: Shrinking the persistent huge page pool via ``nr_hugepages`` such that
235 │ it becomes less than the number of huge pages in use will convert the balance
236 │ of the in-use huge pages to surplus huge pages. This will occur even if
237 │ the number of surplus pages would exceed the overcommit value. As long as
238 │ this condition holds--that is, until ``nr_hugepages+nr_overcommit_hugepages`` is
239 │ increased sufficiently, or the surplus huge pages go out of use and are freed--
240 │ no more surplus huge pages will be allowed to be allocated.
241 │
242 │ With support for multiple huge page pools at run-time available, much of
243 │ the huge page userspace interface in ``/proc/sys/vm`` has been duplicated in
244 │ sysfs.
245 │ The ``/proc`` interfaces discussed above have been retained for backwards
246 │ compatibility. The root huge page control directory in sysfs is::
247 │
248 │ /sys/kernel/mm/hugepages
249 │
250 │ For each huge page size supported by the running kernel, a subdirectory
251 │ will exist, of the form::
252 │
253 │ hugepages-${size}kB
254 │
255 │ Inside each of these directories, the set of files contained in ``/proc``
256 │ will exist. In addition, two additional interfaces for demoting huge
257 │ pages may exist::
258 │
259 │ demote
260 │ demote_size
261 │ nr_hugepages
262 │ nr_hugepages_mempolicy
263 │ nr_overcommit_hugepages
264 │ free_hugepages
265 │ resv_hugepages
266 │ surplus_hugepages
pingtoo wrote:as for making tmpfs use hugepage (in fact Transparent Huge Page -- THP) in the case of Portage (specifically compiler dump intermediate object files in /tmp). I doubted that will have any significant benefit. Usually compiler intermediate object were read/write in sequential order so there is no benefit use a mmap access so the compiler does not actually use mmap call for the intermediate object file, The default tmpfs memory in kernel allocate can handle this easily, On the other hand the THP is not easily managed, kernel will need to trigger separated kernel thread to handle this will create unnecessary context switch.
Hang on a minute; isn't it true that if (and this should usually be the case) every file in the build tree fits in a single (huge)page (or a few pages, for large binaries), the number of system calls during the build process will be dramatically reduced (the
read() and
write() calls still have to go somewhere, in this case
tmpfs, and if a file only needs one page, then that's less reading farther down in the kernel, I think)? Isn't that desirable?