From patchwork Wed Sep 12 20:24:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prakash Sangappa X-Patchwork-Id: 10598297 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C88D014DB for ; Wed, 12 Sep 2018 20:25:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B57D227C0B for ; Wed, 12 Sep 2018 20:25:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A94F52A7D5; Wed, 12 Sep 2018 20:25:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 22EC827C0B for ; Wed, 12 Sep 2018 20:25:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 117498E0002; Wed, 12 Sep 2018 16:25:05 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 0D3F38E0004; Wed, 12 Sep 2018 16:25:05 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ED03D8E0002; Wed, 12 Sep 2018 16:25:04 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-it0-f69.google.com (mail-it0-f69.google.com [209.85.214.69]) by kanga.kvack.org (Postfix) with ESMTP id C144B8E0001 for ; Wed, 12 Sep 2018 16:25:04 -0400 (EDT) Received: by mail-it0-f69.google.com with SMTP id n194-v6so5454798itn.0 for ; Wed, 12 Sep 2018 13:25:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=ELoFsMn5o98Zemi8jSkmdeZ9l+KekLYzbuwPi51dF9A=; b=VX7nit398dwAwsDkHcIfs2USqhi9g1TbAG5F3GJK/mUxHMbN92soPlOPFmKcDpkJHf wBqlTGTd9pfPcBlWwi1z1tbu+d43vk8rIIN56wvIK5GXqXP5tHAhM7n8STJphMXweADD m/+eDlXy5n5RrG5gwu6lxPnNM5c/iVotcIsWNQQKN/vak1D1pGbAyDaTuzwosvkSyOfX W7JfRd1WrAZba5Y4PYyksoLcOD35hmMm07Ag39n74rlrNKJxl1LXBDPcaypV7SStZsko 6qaEDb3gQSBeZuYjFfiSb328wu4ihqtioPwDjhBbHpmM6g3bURg0SNGsY2/jZ2l4V0Z2 r7EA== X-Gm-Message-State: APzg51DMyR86+S+89jwdJTjXMTSnnTbx9r22YNX+bmBla2OnpRzSoJ80 dhQLNayrzuWvzCL1Rp4lcQlkZcfF10hpmbDEtDumsEBlc25qN+XUtXUHtCMCOYHZt9lSl42JvTc 2wOXXy7PKmAiUPxt2UgT+Wzwpcb+9UwMu9A/nw12D7O0OuKwxjatQsXSvdzS0NeoINw== X-Received: by 2002:a24:7983:: with SMTP id z125-v6mr3475899itc.148.1536783904522; Wed, 12 Sep 2018 13:25:04 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbCX3iESeQHYJgeXD6MrlzYOs3vipEo9SdcDajesUpMq6W9Cph3oUEwoF86igN4WpatwlXV X-Received: by 2002:a24:7983:: with SMTP id z125-v6mr3475830itc.148.1536783903342; Wed, 12 Sep 2018 13:25:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536783903; cv=none; d=google.com; s=arc-20160816; b=i4/97ikK98Fd2UWU+gw5LC2q4GoliDujH16gS9Y2CyR2kbi9Nxyu7Gqg5IPDbM5zNg SV4faNfWWuwOgwn+NioY4psGV0RamMnyN1dZP7tq3tFylF05M6pdTA+rvobWK/Y4ubgd esRYH9cxkL24Ud0o1Ipoa2q8cLtCcq4/a/hZ+S31tm1Pa3LOz8SfXTUhYYohiVfmXjDx MlIMObxCodrT/jG8pUJkweKVrrkldm1ECvHXY0woS11jz7Hk7KyR+iyhkIq/ZW7vTqeS 0Q1nk643H9jho9tL+jaqDfhd7P2d10aYD54RSlJvkmachjBTISV2chOs1fomdt71UDP6 i3Tg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ELoFsMn5o98Zemi8jSkmdeZ9l+KekLYzbuwPi51dF9A=; b=sw59nnr30JTq7hkGbyA1ESmSzWN/l0FPgxNlEwLbEwWBLb2KOXjWDfnDoYrI+tGWX7 gq72A4jHsDYVdqab19STrKeQJx320gF1HRYQ45r9M3H5TvEReepghhYzCWv2cc+tZKx9 u51ch1V8XOVFvDsryoqRUP3PCqBk/cFGW7DJ7Tkag34elHpMwIljN9Jhofs5EKV1EDcC 9AStr/VqXMADQr8gdncbNsrcBLaD7GsApjm/q1N3DNBaan/soYxDrMyZVfkZnviEwE4L MGS8fm7tEUi70glrX0dXmJQTb6bKFOufj9CZG5HsO4slSBt02Oh2Ea7UruryCsKDQK27 6BQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=MFLdfO7y; spf=pass (google.com: domain of prakash.sangappa@oracle.com designates 141.146.126.78 as permitted sender) smtp.mailfrom=prakash.sangappa@oracle.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from aserp2120.oracle.com (aserp2120.oracle.com. [141.146.126.78]) by mx.google.com with ESMTPS id l9-v6si1300698ioj.255.2018.09.12.13.25.02 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Sep 2018 13:25:03 -0700 (PDT) Received-SPF: pass (google.com: domain of prakash.sangappa@oracle.com designates 141.146.126.78 as permitted sender) client-ip=141.146.126.78; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=MFLdfO7y; spf=pass (google.com: domain of prakash.sangappa@oracle.com designates 141.146.126.78 as permitted sender) smtp.mailfrom=prakash.sangappa@oracle.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w8CKO5BD084468; Wed, 12 Sep 2018 20:24:59 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2018-07-02; bh=ELoFsMn5o98Zemi8jSkmdeZ9l+KekLYzbuwPi51dF9A=; b=MFLdfO7yDSZkFeIlwVCoNg04udYGoj/1O1FDBkNuLhGvg2mbFpQ0ZQsxp139E37iwGrh dSHfjTHGlBwtYu5xasIWYjhvVyxgLSVoHyf33HKBzhKK3iSoKOwVclhE4t1/aLhc2dIo 36NjsT+rSIOOsKNPQEaOqetqQAsZv3cQq5g8J4YPCbd9mZNWrYrMGJJURGeBV0NPUga5 pyUz75nz5mpKo7elvlwLPQZUah1uwE/7uuf+CUGDSps9IpeckAkMBW0boog9Vjyqxa0T giV8kjOpmYUVi3wair2A9nCgdoE1DgNJf31zw8LjuUtEqPVegpIG6RssJBfZh+SPFx6e Wg== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2120.oracle.com with ESMTP id 2mc6cpvd7g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 12 Sep 2018 20:24:59 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w8CKOxjb015214 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 12 Sep 2018 20:24:59 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w8CKOwiN015836; Wed, 12 Sep 2018 20:24:58 GMT Received: from pp-ThinkCentre-M82.us.oracle.com (/10.132.93.61) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 12 Sep 2018 13:24:58 -0700 From: Prakash Sangappa To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: dave.hansen@intel.com, mhocko@suse.com, nao.horiguchi@gmail.com, akpm@linux-foundation.org, kirill.shutemov@linux.intel.com, khandual@linux.vnet.ibm.com, steven.sistare@oracle.com, prakash.sangappa@oracle.com Subject: [PATCH V2 2/6] Add /proc//numa_vamaps file for numa node information Date: Wed, 12 Sep 2018 13:24:00 -0700 Message-Id: <1536783844-4145-3-git-send-email-prakash.sangappa@oracle.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1536783844-4145-1-git-send-email-prakash.sangappa@oracle.com> References: <1536783844-4145-1-git-send-email-prakash.sangappa@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9014 signatures=668708 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1809120201 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Introduce supporting data structures and file operations. Later patch will provide changes for generating file content. Signed-off-by: Prakash Sangappa Reviewed-by: Steve Sistare --- fs/proc/base.c | 2 ++ fs/proc/internal.h | 1 + fs/proc/task_mmu.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+) diff --git a/fs/proc/base.c b/fs/proc/base.c index ccf86f1..1af99ae 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -2927,6 +2927,7 @@ static const struct pid_entry tgid_base_stuff[] = { REG("maps", S_IRUGO, proc_pid_maps_operations), #ifdef CONFIG_NUMA REG("numa_maps", S_IRUGO, proc_pid_numa_maps_operations), + REG("numa_vamaps", S_IRUGO, proc_numa_vamaps_operations), #endif REG("mem", S_IRUSR|S_IWUSR, proc_mem_operations), LNK("cwd", proc_cwd_link), @@ -3313,6 +3314,7 @@ static const struct pid_entry tid_base_stuff[] = { #endif #ifdef CONFIG_NUMA REG("numa_maps", S_IRUGO, proc_pid_numa_maps_operations), + REG("numa_vamaps", S_IRUGO, proc_numa_vamaps_operations), #endif REG("mem", S_IRUSR|S_IWUSR, proc_mem_operations), LNK("cwd", proc_cwd_link), diff --git a/fs/proc/internal.h b/fs/proc/internal.h index 5185d7f..994c7fd 100644 --- a/fs/proc/internal.h +++ b/fs/proc/internal.h @@ -298,6 +298,7 @@ extern const struct file_operations proc_pid_smaps_operations; extern const struct file_operations proc_pid_smaps_rollup_operations; extern const struct file_operations proc_clear_refs_operations; extern const struct file_operations proc_pagemap_operations; +extern const struct file_operations proc_numa_vamaps_operations; extern unsigned long task_vsize(struct mm_struct *); extern unsigned long task_statm(struct mm_struct *, diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 0e2095c..02b553c 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -1583,6 +1583,16 @@ struct numa_maps_private { struct numa_maps md; }; +#define NUMA_VAMAPS_BUFSZ 1024 +struct numa_vamaps_private { + struct mm_struct *mm; + struct numa_maps md; + u64 vm_start; + size_t from; + size_t count; /* residual bytes in buf at offset 'from' */ + char buf[NUMA_VAMAPS_BUFSZ]; /* buffer */ +}; + static void gather_stats(struct page *page, struct numa_maps *md, int pte_dirty, unsigned long nr_pages) { @@ -1848,6 +1858,34 @@ static int pid_numa_maps_open(struct inode *inode, struct file *file) sizeof(struct numa_maps_private)); } +static int numa_vamaps_open(struct inode *inode, struct file *file) +{ + struct mm_struct *mm; + struct numa_vamaps_private *nvm; + nvm = kzalloc(sizeof(struct numa_vamaps_private), GFP_KERNEL); + if (!nvm) + return -ENOMEM; + + mm = proc_mem_open(inode, PTRACE_MODE_READ); + if (IS_ERR(mm)) { + kfree(nvm); + return PTR_ERR(mm); + } + nvm->mm = mm; + file->private_data = nvm; + return 0; +} + +static int numa_vamaps_release(struct inode *inode, struct file *file) +{ + struct numa_vamaps_private *nvm = file->private_data; + + if (nvm->mm) + mmdrop(nvm->mm); + kfree(nvm); + return 0; +} + const struct file_operations proc_pid_numa_maps_operations = { .open = pid_numa_maps_open, .read = seq_read, @@ -1855,4 +1893,8 @@ const struct file_operations proc_pid_numa_maps_operations = { .release = proc_map_release, }; +const struct file_operations proc_numa_vamaps_operations = { + .open = numa_vamaps_open, + .release = numa_vamaps_release, +}; #endif /* CONFIG_NUMA */