Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp7666009yba; Thu, 2 May 2019 14:02:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqx9D79Uub80HrCCinGkSkwWdUjRtvHbmKD0gEPwESKXpxxCqQsngl6WiRd6WvJEJv86RdrD X-Received: by 2002:a62:5144:: with SMTP id f65mr6372131pfb.13.1556830974961; Thu, 02 May 2019 14:02:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556830974; cv=none; d=google.com; s=arc-20160816; b=RZo5+eeAs8u26RyzuEBIMjtRaBqPRsqtQHvy0u/e4UzKw6B7ViIZUDP54YrBs33ON5 54ov+AHW/aWNgeln7Y+pbxfAh+tMNvMxAIrdws2Xc/1dZUflWDQlONvcFJoI59IDmfOx hfn4u2X6hRnhSzWvepmvobshdGD3m7OxwWww1c8MC6lSEfLUOFuXTr7pJDfhu222w5KK iKwKbHGwo5vcMVXAB1qagzd+yyPzEh2qDwIZPgycXAzIZkEJbV24HRmjcfsf7vOYrjSX DFgde96097fSjy9d1s2jzSssR9bRp4hmqr4FkQnWmNGjeS2GyqjyJQpK/lLJolzffeq6 RZLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject; bh=fFHKVGA14ZOWA5dOz1cCBpF8VE1OP4ok16RTteEo/BE=; b=yW5QI9hxPRdaie/SoY4RvXkPfs6BFQoC/sc8s3A1l1NHl7Mcerrd4fbpGvqeaFqy8N SAzjmyDcEriLjteFxfrbc5+b/WASyP++ctjkJfwBvxzcLQSOKhQay7JqvbX9kNUAY73X STfUYEcNl33vP1RcfHc+TT2ayDngOUqd0NfEtNTI1EHtQGghhErG2Fgwss053Rdhi5y4 n+i2tPe/cNZt1f1MR0E/+25eJ0SYClr2ZwOog1M32BFbIrP0mIL9dcW/qQLMOqCr+5wZ UB7sTUApFoLGVacMoMOkj8aHYUwAFPm3BHZPGXwdKbp644YEziuUXuyC8l5B/N7HeQRb YC+Q== 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 91si248331ply.104.2019.05.02.14.02.39; Thu, 02 May 2019 14:02:54 -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 S1726376AbfEBVBr (ORCPT + 99 others); Thu, 2 May 2019 17:01:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39792 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725962AbfEBVBq (ORCPT ); Thu, 2 May 2019 17:01:46 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 16B583151C47; Thu, 2 May 2019 21:01:46 +0000 (UTC) Received: from llong.remote.csb (dhcp-17-85.bos.redhat.com [10.18.17.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9B5631001DC1; Thu, 2 May 2019 21:01:38 +0000 (UTC) Subject: Re: [PATCH v2 0/2] sys/prctl: expose TASK_SIZE value to userspace To: Joel Savitz , linux-kernel@vger.kernel.org Cc: Thomas Gleixner , Ingo Molnar , Masami Hiramatsu , 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 References: <1556830342-32307-1-git-send-email-jsavitz@redhat.com> From: Waiman Long Organization: Red Hat Message-ID: <8bb9fe29-65d3-e977-1932-4a2f17ead333@redhat.com> Date: Thu, 2 May 2019 17:01:38 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <1556830342-32307-1-git-send-email-jsavitz@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Thu, 02 May 2019 21:01:46 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/2/19 4:52 PM, 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 What did you change in v2 versus v1? Cheers, Longman