Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1104933imm; Fri, 14 Sep 2018 11:14:53 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZIeXyjSzqzvKxaSewiCecaonCRhwdP66jBXWcZHh2NjJC9vFs6JuV6aER0S7uPr8UQH+Oz X-Received: by 2002:a17:902:b784:: with SMTP id e4-v6mr13395337pls.204.1536948893564; Fri, 14 Sep 2018 11:14:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536948893; cv=none; d=google.com; s=arc-20160816; b=N0QwhwApV0X5ElEas+1LLMu9ePrsDpTw3P2lM60oZkPivwuqwElSNAvLDSya14/MFR BhUD8iLu1qWvzqcsuxQ0AQoYQHDY5HtsQcBFYXEyU/qiOTUJcOmnhluID0R4BI8Tw//6 fhBb5WBNYrhkaO86EpBp0iE+Qe5TszgwYmfgJUsc+NVBuK30ldSuRunXHSeJQC9kcKmO Vm80R26emTTFXrOt0WR1yDJWSK7cKPD04cLw3aqc42LJlBQav5NfOhqcorV5ZMiqfBpj gj+hHL6bIcOHSo5wwTB/Cjco63oQIhP35RFOkh0nEp4flILU6nR4PyxHU3BykwsE+Nsu SZiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=7/+uzcKU7N9eQQP3SFjSAD1qGow0LsUcOH+d4fY3c3w=; b=n5i/HRq4KxmBAHPOHbBtlqEW2UPitGTo1LKu2b6Z5a+ih+/UZDnfIDBvd0zwTdB0sI oRu8nMv+0EOMw6dbaD8FHztvv4d9AsSERJ5u7EibbBJwc2/mAAqqO94otK1AW9FL0WjX sEEAEMrnwZ908+1pl07uny9KuqsQIDe+9HQ/2cYr9cDVAjfcJDQpiGKd0u12qQRNT5ZV wTqsKmfKjBNmHvA7XxaWlPTWmA10spLf2RGgE97vlZ2QyyLMcLIXLv72htB2/DblOkU1 R7e5NCqKiPG/BvgxRnivtXcjtUbPCX/2dPfF2sZs9Lr3jxlHN0iDPM1Tr6UW9oUHcUjy ZRPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=IGaGhTGI; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w68-v6si7522062pfw.308.2018.09.14.11.14.37; Fri, 14 Sep 2018 11:14:53 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=IGaGhTGI; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727598AbeINXaK (ORCPT + 99 others); Fri, 14 Sep 2018 19:30:10 -0400 Received: from mail-ot1-f65.google.com ([209.85.210.65]:35304 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726849AbeINXaK (ORCPT ); Fri, 14 Sep 2018 19:30:10 -0400 Received: by mail-ot1-f65.google.com with SMTP id j9-v6so5453612otl.2 for ; Fri, 14 Sep 2018 11:14:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=7/+uzcKU7N9eQQP3SFjSAD1qGow0LsUcOH+d4fY3c3w=; b=IGaGhTGIkx7hGHOTkmo2YYp3Tjot6ux/bY5dHq6CuFsTLPxeymT+sx8LPD43GztVym mRGJcV2n19S5HfU7UH9k251tIWWhYOh4+xg1tnEzRtIqbclGrL4bk0bDbW5I+ZRpvXxZ UQy9vK3cLb+z4pN8ixt2yC/OrHzDgWuw7E5G5SLVxaE0vnmASi2jEqBLjM8pV2DCa+UB 3DQGi9dmfiwxGPkpEaw2wqyqszlIT+E0JAoCjB++iz370g2NvwkVXYVC61KAVMZa7M6o wNnvQdTy4CjYVRud/jjvt/xwm+4C5+QHQT3JQbFI7S3mD9gwUx77DH8Q4clwYOdpMQ9Y a9JQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=7/+uzcKU7N9eQQP3SFjSAD1qGow0LsUcOH+d4fY3c3w=; b=n5pjurgycZei+7c/7CGlVZXPjahGyXM26WbjYQyCG+ZgesJ8rvSwjQUtXpuFJRjMxw gJOPsShsLGBt6EPRc4+2TJRKM7ZHic6x1du/DqaClf+oqI1jpaVady9+nvGxJqfeALO1 w/16TcNJH5QAiIMpJT3kJ4oxOrFKKicV8Ji7PuGeLCZbmr3rNcUeAcXXFGQgv4kFbS3s nPmtHJNw32AxYDABMHCEvOnaXQ7fbG9OY1mNGlaZy/euwq3+QlB9cYBuoMpem86/igCz 7vM8NcIrl1G2HxOkHg5KHBn3IbuOl1KzgGaZ4tcgbPkQjecquFPCpo0khjJC4lIE5paQ s4Dw== X-Gm-Message-State: APzg51CWUoUZDyAa79vS7A5gr+WtuoCFQxn8ZWiiIOhhlQIyxMiYQZea T1k43gemQHujfvW9mWEFdIqNK7/Tb2ewyLU6t5uz/Q== X-Received: by 2002:a9d:654a:: with SMTP id q10-v6mr4920228otl.256.1536948871100; Fri, 14 Sep 2018 11:14:31 -0700 (PDT) MIME-Version: 1.0 References: <2ce01d91-5fba-b1b7-2956-c8cc1853536d@intel.com> <33f96879-351f-674a-ca23-43f233f4eb1d@linux.vnet.ibm.com> <82d2b35c-272a-ad02-692f-2c109aacdfb6@oracle.com> <8569dabb-4930-aa20-6249-72457e2df51e@intel.com> <51145ccb-fc0d-0281-9757-fb8a5112ec24@oracle.com> <94ee0b6c-4663-0705-d4a8-c50342f6b483@oracle.com> <20180914062132.GI20287@dhcp22.suse.cz> In-Reply-To: From: Jann Horn Date: Fri, 14 Sep 2018 20:14:04 +0200 Message-ID: Subject: Re: [RFC PATCH] Add /proc//numa_vamaps for numa node information To: Prakash Sangappa Cc: Michal Hocko , Dave Hansen , Anshuman Khandual , Andrew Morton , kernel list , Linux-MM , Linux API , "Kirill A . Shutemov" , n-horiguchi@ah.jp.nec.com, Ulrich Drepper , David Rientjes , Horiguchi Naoya , steven.sistare@oracle.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 14, 2018 at 8:08 PM Prakash Sangappa wrote: > On 9/14/18 5:49 AM, Jann Horn wrote: > > On Fri, Sep 14, 2018 at 8:21 AM Michal Hocko wrote: > >> On Fri 14-09-18 03:33:28, Jann Horn wrote: > >>> On Wed, Sep 12, 2018 at 10:43 PM prakash.sangappa > >>> wrote: > >>>> On 05/09/2018 04:31 PM, Dave Hansen wrote: > >>>>> On 05/07/2018 06:16 PM, prakash.sangappa wrote: > >>>>>> It will be /proc//numa_vamaps. Yes, the behavior will be > >>>>>> different with respect to seeking. Output will still be text and > >>>>>> the format will be same. > >>>>>> > >>>>>> I want to get feedback on this approach. > >>>>> I think it would be really great if you can write down a list of the > >>>>> things you actually want to accomplish. Dare I say: you need a > >>>>> requirements list. > >>>>> > >>>>> The numa_vamaps approach continues down the path of an ever-growing list > >>>>> of highly-specialized /proc/ files. I don't think that is > >>>>> sustainable, even if it has been our trajectory for many years. > >>>>> > >>>>> Pagemap wasn't exactly a shining example of us getting new ABIs right, > >>>>> but it sounds like something along those is what we need. > >>>> Just sent out a V2 patch. This patch simplifies the file content. It > >>>> only provides VA range to numa node id information. > >>>> > >>>> The requirement is basically observability for performance analysis. > >>>> > >>>> - Need to be able to determine VA range to numa node id information. > >>>> Which also gives an idea of which range has memory allocated. > >>>> > >>>> - The proc file /proc//numa_vamaps is in text so it is easy to > >>>> directly view. > >>>> > >>>> The V2 patch supports seeking to a particular process VA from where > >>>> the application could read the VA to numa node id information. > >>>> > >>>> Also added the 'PTRACE_MODE_READ_REALCREDS' check when opening the > >>>> file /proc file as was indicated by Michal Hacko > >>> procfs files should use PTRACE_MODE_*_FSCREDS, not PTRACE_MODE_*_REALCREDS. > >> Out of my curiosity, what is the semantic difference? At least > >> kernel_move_pages uses PTRACE_MODE_READ_REALCREDS. Is this a bug? > > No, that's fine. REALCREDS basically means "look at the caller's real > > UID for the access check", while FSCREDS means "look at the caller's > > filesystem UID". The ptrace access check has historically been using > > the real UID, which is sorta weird, but normally works fine. Given > > that this is documented, I didn't see any reason to change it for most > > things that do ptrace access checks, even if the EUID would IMO be > > more appropriate. But things that capture caller credentials at points > > like open() really shouldn't look at the real UID; instead, they > > should use the filesystem UID (which in practice is basically the same > > as the EUID). > > > > So in short, it depends on the interface you're coming through: Direct > > syscalls use REALCREDS, things that go through the VFS layer use > > FSCREDS. > > So in this case can the REALCREDS check be done in the read() system call > when reading the /proc file instead of the open call? No, REALCREDS shouldn't be used in open() and shouldn't be used in read(). FSCREDS can be used in open(); in theory, using ptrace_may_access() in any way in read() is currently unsafe, but in practice, it's used that way anyway. I have plans to clean that up eventually...