All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] sys/prctl: expose TASK_SIZE value to userspace
@ 2019-05-02 20:52 Joel Savitz
  2019-05-02 20:52 ` [PATCH v2 1/2] kernel/sys: add PR_GET_TASK_SIZE option to prctl(2) Joel Savitz
                   ` (3 more replies)
  0 siblings, 4 replies; 16+ messages in thread
From: Joel Savitz @ 2019-05-02 20:52 UTC (permalink / raw)
  To: linux-kernel
  Cc: Joel Savitz, Thomas Gleixner, Ingo Molnar, Masami Hiramatsu,
	Waiman Long, Mauro Carvalho Chehab, Kristina Martsenko,
	Andrew Morton, Cyrill Gorcunov, Kees Cook, Gustavo A. R. Silva,
	YueHaibing, Micah Morton, Yang Shi, Jann Horn, Alexey Dobriyan,
	Rafael Aquini, Michael Kerrisk, Yury Norov

In the mainline kernel, there is no quick mechanism to get the virtual
memory size of the current process from userspace.

Despite the current state of affairs, this information is available to the
user through several means, one being a linear search of the entire address
space. This is an inefficient use of cpu cycles.

A component of the libhugetlb kernel test does exactly this, and as
systems' address spaces increase beyond 32-bits, this method becomes
exceedingly tedious.

For example, on a ppc64le system with a 47-bit address space, the linear
search causes the test to hang for some unknown amount of time. I
couldn't give you an exact number because I just ran it for about 10-20
minutes and went to go do something else, probably to get coffee or
something, and when I came back, I just killed the test and patched it
to use this new mechanism. I re-ran my new version of the test using a
kernel with this patch, and of course it passed through the previously
bottlenecking codepath nearly instantaneously.

As such, I propose that the prctl syscall be extended to include the
option to retrieve TASK_SIZE from the kernel.

This patch will allow us to upgrade an O(n) codepath to O(1) in an
architecture-independent manner, and provide a mechanism for others
to do the same.

Joel Savitz(2):
  sys/prctl: add PR_GET_TASK_SIZE option to prctl(2)
  prctl.2: Document the new PR_GET_TASK_SIZE option

 include/uapi/linux/prctl.h |  3 +++
 kernel/sys.c               | 10 ++++++++++
 2 files changed, 13 insertions(+)

 man2/prctl.2 | 9 +++++++++
 1 file changed, 9 insertions(+)

--
2.18.1


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2019-05-03 11:31 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-02 20:52 [PATCH v2 0/2] sys/prctl: expose TASK_SIZE value to userspace Joel Savitz
2019-05-02 20:52 ` [PATCH v2 1/2] kernel/sys: add PR_GET_TASK_SIZE option to prctl(2) Joel Savitz
2019-05-02 21:09   ` Cyrill Gorcunov
2019-05-02 21:46     ` Joel Savitz
2019-05-03  8:31       ` Cyrill Gorcunov
2019-05-03 11:31         ` David Laight
2019-05-02 21:24   ` Rafael Aquini
2019-05-02 21:49   ` Yury Norov
2019-05-02 20:52 ` [PATCH v2 2/2] prctl.2: Document the new PR_GET_TASK_SIZE option Joel Savitz
2019-05-02 22:23   ` Yury Norov
2019-05-03  1:49     ` Rafael Aquini
2019-05-02 21:01 ` [PATCH v2 0/2] sys/prctl: expose TASK_SIZE value to userspace Waiman Long
2019-05-02 21:10   ` Cyrill Gorcunov
2019-05-02 21:22     ` Joel Savitz
2019-05-02 21:34       ` Yury Norov
2019-05-02 21:26 ` Rafael Aquini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.