Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp7689024yba; Thu, 2 May 2019 14:28:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqygxEWZK6r4k8gU0stzmT3o4qhvxxQ/gxbqBj+R0BGOLyplajpfgFHX+o4r4eFWq5l/ACSn X-Received: by 2002:a62:b40b:: with SMTP id h11mr6380194pfn.133.1556832537512; Thu, 02 May 2019 14:28:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556832537; cv=none; d=google.com; s=arc-20160816; b=q+JXTwAl8CMc2VNQvfYC9hpt+l7I16RFlp0e7Nqd/KueAhbGPZPHoCpTknktBw8ZhN ERLbnQPCiz7DvoczIsjj5iqIDzruBLl64OtvuJE36l++iYJct/nnlKJ1jaUCae036IDt MLGmGTfOsBaogSkoHSuiZAfNsyB3xhofd/O+0Lni8zXdC9EhUMfF9BcWkji4rRtdeUQl urId+P+QB3EyH0YbTqpPDPGtLLc9ATU+ScrnclTscV6cZtPuYEVyZBrk3A720IFj9MW3 k6jX/kJkfZ6p9QrTlB+mvQGCfC9mt9VC1b1C/cGCd1s21xWc4eCHmdKg3wyXFlVcLdX0 9GFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=zRlKrSeneiCvd56/XbFBovcXnSeMUmcSjsbtZhPWg4s=; b=PalNy8iUi0KjPZg//deGNU+S8tKWysnlLs1NYuk6YrAj9/2+B3SXHjv7cna7W3ml4n IwU01i9+7eKqFdthSpxXJhQ//NyTqElXVXnwTMD/Iy9IHjZxxaZz1B0HeElUCIT3BblO D2ybCJWA0wB2KcZpjG9MdWw7JMi+MnuiiI8w6KXwf4hUSxHB/TnB+nVnq0+T39Ckd7L7 qXfcledVJ9k0sp2caNw5eyDuKD2shyvNTBLMgebZLpdbmnQ9RHndGo+GWnB4O8tm6Vxx BR3vIXkQ+0qQWwo1Il3oPJmUsBfzF1eCaz72UzYKI3296udhdvg2uFh0rnodmkXHtCC1 jbFQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u13si163247pgj.542.2019.05.02.14.28.42; Thu, 02 May 2019 14:28:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726197AbfEBV0m (ORCPT + 99 others); Thu, 2 May 2019 17:26:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36644 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725995AbfEBV0m (ORCPT ); Thu, 2 May 2019 17:26:42 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F18643086215; Thu, 2 May 2019 21:26:41 +0000 (UTC) Received: from x230.aquini.net (dhcp-17-61.bos.redhat.com [10.18.17.61]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1B049608A5; Thu, 2 May 2019 21:26:38 +0000 (UTC) Date: Thu, 2 May 2019 17:26:36 -0400 From: Rafael Aquini To: Joel Savitz Cc: linux-kernel@vger.kernel.org, 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 , Michael Kerrisk , Yury Norov Subject: Re: [PATCH v2 0/2] sys/prctl: expose TASK_SIZE value to userspace Message-ID: <20190502212636.GB13077@x230.aquini.net> References: <1556830342-32307-1-git-send-email-jsavitz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1556830342-32307-1-git-send-email-jsavitz@redhat.com> User-Agent: Mutt/1.11.3 (2019-02-01) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Thu, 02 May 2019 21:26:42 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 02, 2019 at 04:52:20PM -0400, Joel Savitz wrote: > 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 > If you decide to repost patch 1/2 to sort out the minor nit I pointed out, you can keep my ack. Acked-by: Rafael Aquini