From patchwork Wed Sep 12 20:23:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prakash Sangappa X-Patchwork-Id: 10598299 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 61B9A112B for ; Wed, 12 Sep 2018 20:25:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 50E9E27C0B for ; Wed, 12 Sep 2018 20:25:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4332A2A7D5; Wed, 12 Sep 2018 20:25:09 +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 C213727C0B for ; Wed, 12 Sep 2018 20:25:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5B7D58E0004; 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 5342C8E0001; 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 424018E0004; Wed, 12 Sep 2018 16:25:05 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yb1-f197.google.com (mail-yb1-f197.google.com [209.85.219.197]) by kanga.kvack.org (Postfix) with ESMTP id 06BD78E0001 for ; Wed, 12 Sep 2018 16:25:05 -0400 (EDT) Received: by mail-yb1-f197.google.com with SMTP id 1-v6so3108368ybe.18 for ; Wed, 12 Sep 2018 13:25:05 -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=LPbElgD1pjqcX2q4LMCQ5E4+C12izc55GF8PnMhHfqY=; b=fitt5UfyjRtzPk6NklemmeQDqjikBfgyTdNGTQ6soojtTDyxDui9zPIulcLryp+ilT V77obM3apZWlJhVP2D+ctsmTe3FpuTLRkX6Dwj+BKw2B2AFYyRJXxlOpqEMfLQQG6oRM CyWg0ufA8olL8yOwXsjtMhng4RUkearjr9+vnK5USxWxPc0AMlXVbYqbnuo6kfF21Tn1 0U2sTgQ2x2RQSaCkcUwzpo1HmcR2/DsF6I4gwHezLVT619V0kUsYy06t+hgSzi+XwYnv 8cEFpxITHc24UBqi4RlTJCsV/vhoYXaLtzlnrmGFMZjUpLn09uHiOrpK2sufrPCQxB8E lKwg== X-Gm-Message-State: APzg51AuUVL/qWBWEZjfh6ovhwcisycmHasH2XWEZu1eCx/1xyH/fv2R M205RQOj+tdtIhLhfdlxnuVKK7a3OKS1zBdGAPjpC2hquYrKhDF3Fr8k24i/0Hf9Mr6O137Modo V323IzVwm/ip8vEPq8VsId/k17qTO5MWB8TC7rxXDbF1UdtcOhc+JzjpZ2HAQUXNnVg== X-Received: by 2002:a81:148d:: with SMTP id 135-v6mr1807477ywu.28.1536783904745; Wed, 12 Sep 2018 13:25:04 -0700 (PDT) X-Google-Smtp-Source: ANB0Vda9yND2dLFLoMqaziaLJmR5h/ShUT5/o76/P4zoHi49l8mOCy/uoU69J9Kp2vbhVCTPTlKE X-Received: by 2002:a81:148d:: with SMTP id 135-v6mr1807455ywu.28.1536783903805; 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=GM3tB3BCAdodP7zg5lQVKCzJ/qqY1+M7xCmpFqliryaN0hvkSs9CDCC0Svv249623L 1AARmYNU/IwXWIxIhnWaYoT0jScAZzHWRTO0gXs33+r5NiHdgAjbT39pj5ptUN/MqNZ5 6B0Y2BHqCDBYjNY0ZLugsVsM/JWQ9eaBrIQIbz4dhBYevciwCvhYBzhYysqED2aeiXi3 /wAw/U7cD9MXXz4aIz2gkWcQHk/MJd1BQkpPpEUtJV8szN/Z7HTqCV6AJGnPE54xF9EO b6OWYxMIuypC5E7gT6KmHmInGAyrpSywMFD2bEDLJvPcIjs1TFw9fwbER1fuMBewE8K9 SLWg== 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=LPbElgD1pjqcX2q4LMCQ5E4+C12izc55GF8PnMhHfqY=; b=VhPXSLWypDXy+MbvJ3hurz+6kebBOkVIYS8KqdatempfySxAJwL2XU/kIxwR/E4m/J o9t0DE0aSd+utzopIvYPS8W5hK5foAjvjitQC7Nuz2VT+2zBsMZoUbdlw2C1x3qzJ9za SXuSWACjOyyIvx7FGG0s4kjnxVUgY9mHXenCkyDIAQwVJ2nyZX/gAIlz7yszlWti9xAo pVcvWlaVOCnqFE7m4XSRHFB9GJqj0bE9GQUqHbOsTx4nrU0VJBG/MgxrYpIeSHGrQbYR Y398HygGClztRVaI1LZuAjtuMarjjxYoPSvm/tGgNZe3yOU+3a6jKbPDRmfvQMNxBoal EgJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=OgoWKQ7d; spf=pass (google.com: domain of prakash.sangappa@oracle.com designates 156.151.31.86 as permitted sender) smtp.mailfrom=prakash.sangappa@oracle.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from userp2130.oracle.com (userp2130.oracle.com. [156.151.31.86]) by mx.google.com with ESMTPS id x4-v6si485449ywb.562.2018.09.12.13.25.03 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 156.151.31.86 as permitted sender) client-ip=156.151.31.86; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=OgoWKQ7d; spf=pass (google.com: domain of prakash.sangappa@oracle.com designates 156.151.31.86 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 (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w8CKOqel064255; Wed, 12 Sep 2018 20:25:00 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=LPbElgD1pjqcX2q4LMCQ5E4+C12izc55GF8PnMhHfqY=; b=OgoWKQ7dyHbbAKQDA9GUsXRlMKKJyhvt2zGzjop5gHZ131dW802OunB5izfFMRWjcQJc CmY2BOaIcIL9U8bMhw/D7oPo3FJkmJJGwyWf0LLCiXPCjCCMMsnou5erP9xNgV4Ijhom Ov8hCWrMpcKdyXz4cVuzONHmKUMBVR6OvJU/jFOYEFVx3n1rpLikEJtFBwDGZA3KK+z4 jYYL0So7rIrQF74cOq1XRd7cMmUoqPH/1iAltiwMmC3M+W6kuXRwOSr2nPV71rqodOcr YTtB5yZDMl9V9n/ETMr9KSIy6IMIFhRKtga9bIY+gX7u+5zD5eL8FifuO9P1NtvwzdvP Sg== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2130.oracle.com with ESMTP id 2mc5utmeuq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 12 Sep 2018 20:25:00 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w8CKOwB1015194 (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 userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w8CKOvih024073; Wed, 12 Sep 2018 20:24:57 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:57 -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 1/6] Add check to match numa node id when gathering pte stats Date: Wed, 12 Sep 2018 13:23:59 -0700 Message-Id: <1536783844-4145-2-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 Add support to check if numa node id matches when gathering pte stats, to be used by later patches. Signed-off-by: Prakash Sangappa Reviewed-by: Steve Sistare --- fs/proc/task_mmu.c | 44 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 5ea1d64..0e2095c 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -1569,9 +1569,15 @@ struct numa_maps { unsigned long mapcount_max; unsigned long dirty; unsigned long swapcache; + unsigned long nextaddr; + long nid; + long isvamaps; unsigned long node[MAX_NUMNODES]; }; +#define NUMA_VAMAPS_NID_NOPAGES (-1) +#define NUMA_VAMAPS_NID_NONE (-2) + struct numa_maps_private { struct proc_maps_private proc_maps; struct numa_maps md; @@ -1653,6 +1659,20 @@ static struct page *can_gather_numa_stats_pmd(pmd_t pmd, } #endif +static bool +vamap_match_nid(struct numa_maps *md, unsigned long addr, struct page *page) +{ + long target = (page ? page_to_nid(page) : NUMA_VAMAPS_NID_NOPAGES); + + if (md->nid == NUMA_VAMAPS_NID_NONE) + md->nid = target; + if (md->nid == target) + return 0; + /* did not match */ + md->nextaddr = addr; + return 1; +} + static int gather_pte_stats(pmd_t *pmd, unsigned long addr, unsigned long end, struct mm_walk *walk) { @@ -1661,6 +1681,7 @@ static int gather_pte_stats(pmd_t *pmd, unsigned long addr, spinlock_t *ptl; pte_t *orig_pte; pte_t *pte; + int ret = 0; #ifdef CONFIG_TRANSPARENT_HUGEPAGE ptl = pmd_trans_huge_lock(pmd, vma); @@ -1668,11 +1689,13 @@ static int gather_pte_stats(pmd_t *pmd, unsigned long addr, struct page *page; page = can_gather_numa_stats_pmd(*pmd, vma, addr); - if (page) + if (md->isvamaps) + ret = vamap_match_nid(md, addr, page); + if (page && !ret) gather_stats(page, md, pmd_dirty(*pmd), HPAGE_PMD_SIZE/PAGE_SIZE); spin_unlock(ptl); - return 0; + return ret; } if (pmd_trans_unstable(pmd)) @@ -1681,6 +1704,10 @@ static int gather_pte_stats(pmd_t *pmd, unsigned long addr, orig_pte = pte = pte_offset_map_lock(walk->mm, pmd, addr, &ptl); do { struct page *page = can_gather_numa_stats(*pte, vma, addr); + if (md->isvamaps && vamap_match_nid(md, addr, page)) { + ret = 1; + break; + } if (!page) continue; gather_stats(page, md, pte_dirty(*pte), 1); @@ -1688,7 +1715,7 @@ static int gather_pte_stats(pmd_t *pmd, unsigned long addr, } while (pte++, addr += PAGE_SIZE, addr != end); pte_unmap_unlock(orig_pte, ptl); cond_resched(); - return 0; + return ret; } #ifdef CONFIG_HUGETLB_PAGE static int gather_hugetlb_stats(pte_t *pte, unsigned long hmask, @@ -1697,15 +1724,18 @@ static int gather_hugetlb_stats(pte_t *pte, unsigned long hmask, pte_t huge_pte = huge_ptep_get(pte); struct numa_maps *md; struct page *page; + int ret = 0; + md = walk->private; if (!pte_present(huge_pte)) - return 0; + return (md->isvamaps ? vamap_match_nid(md, addr, NULL) : 0); page = pte_page(huge_pte); - if (!page) - return 0; + if (md->isvamaps) + ret = vamap_match_nid(md, addr, page); + if (!page || ret) + return ret; - md = walk->private; gather_stats(page, md, pte_dirty(huge_pte), 1); return 0; } 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 */ From patchwork Wed Sep 12 20:24:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prakash Sangappa X-Patchwork-Id: 10598305 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 BF72414DB for ; Wed, 12 Sep 2018 20:25:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF0E927C0B for ; Wed, 12 Sep 2018 20:25:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A32D32A7D5; Wed, 12 Sep 2018 20:25:16 +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 1210927C0B for ; Wed, 12 Sep 2018 20:25:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6CC6D8E0007; Wed, 12 Sep 2018 16:25:06 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 61E928E0006; Wed, 12 Sep 2018 16:25:06 -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 33E398E0006; Wed, 12 Sep 2018 16:25:06 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-it0-f72.google.com (mail-it0-f72.google.com [209.85.214.72]) by kanga.kvack.org (Postfix) with ESMTP id EB2B48E0007 for ; Wed, 12 Sep 2018 16:25:05 -0400 (EDT) Received: by mail-it0-f72.google.com with SMTP id z72-v6so5387068itc.8 for ; Wed, 12 Sep 2018 13:25:05 -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=0PPy+WGxUyuEgizIqbyTH5ifjbGa9WJweV7bgCsDBug=; b=c4KqG7klFITMh2e/ouiIsrVjWPNeCq/p/IY1nM+okORZFG8Ym+71IzlrlJb80oNYlb iPk3g+i4OOF6ch35uwCOV9+yZEsUiTODxYt+t2IfsNaocojdILGTvPmCR7Y1JbY1tpv6 tQf0U8QKUthqQWMp2hsLYGeXSupOOHatJA+ouGnGe7qrsm/3CPybQ3EI0Xydm0wJRYqV hIXEj2C0KH2v9uKgdSW8kaNadnQsZpKNRm7Oixl9zM5sMWb63z8pRXga9o9VODKAyEtk 7R+J5r4zeKBU69tKOug66NyrS2q00urR8npsC3MqquDAJcfTk/RLYINDEeReBscmmrfQ XSlw== X-Gm-Message-State: APzg51BKckTFd8P/iNQz1DapiZjP9UKPrZ3oqAyeaRd1me+egu9Bh1jF QXoed4BdTd+tVJbxrFWju1vlEaq7aF4uo7lXGp/HX9bzZ5fFrU751GIJLia7imrKhDsIdJcoPus awM6SlpMpH1mkIqPB0is0SPnJc+NzaWpU/nBgW+XoobWLFdukLizTY3KqdBOMRyFDZg== X-Received: by 2002:a5e:c80b:: with SMTP id y11-v6mr3413131iol.198.1536783905581; Wed, 12 Sep 2018 13:25:05 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbSRsS+Juu1+mIWPe+UpexXKLi1MyPPpDM/6+Sxjwg/TuyvryYxChMYqKObR40YSeBaiA80 X-Received: by 2002:a5e:c80b:: with SMTP id y11-v6mr3413059iol.198.1536783904369; Wed, 12 Sep 2018 13:25:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536783904; cv=none; d=google.com; s=arc-20160816; b=Q3qLerowsvuFkpkGZ0a4oNutRCD1u/0h7Lz5tP5VqTI6omsqjMumep9wv5Zftw4WQN sIzB/SaNblYEzVrnXvLDm3o0v9w/2iOxkZ4I/vbx9gSm4eS3fGkh6FFnsncy1JgIlKY4 Je69wVTp2ETD7+T05b9A1cmO6m18+M/Qg8AS0HFhYyY7rg+3c1oYictm+hwkuRre+WD8 4KreSyHAcy3loQJWmUmxwdP7B/vQNL2KbNEjf0eUhUWIgcpFY/JyUvs5fnFEDI1M5h/p FvNzgBHxe00x47odgVTgbQGapAB5q/eL0zmEFWaqtJCAF4QlFZr6161LrSpG9OvcsqY2 oG3w== 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=0PPy+WGxUyuEgizIqbyTH5ifjbGa9WJweV7bgCsDBug=; b=dErpt3C9/Iq9zLlpNzEG641rVevXgFKn/TvBPETAhjCTCCIsg5I3E9GJRA3XbEfKuC q3YLVsERZXd/PbojXxG4mnfMd+5C/ffErmVO27Q333tIo/OCeUrqwDkl+bNW5uqVBMMk KzI1AG2jbXoWz2Rh2i7g7NYccG2Nk7IIq7ZLg6yTr5EHndZ4CATjz4GEyZAhSlyrhcde DWxcayXY0c3xoK0WEBGeWYoOyINqbK7p0HqqYchao6qOf66BPwz4CAKaX3OygEOW9xTB QiNmE09uvfFTI1WSJAIALeXsoSGlZCg5iNKwCpPS/OW7nY/nG/LIAcBlXXtW/+iD7CE8 uaug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=EF0N+A4Y; spf=pass (google.com: domain of prakash.sangappa@oracle.com designates 156.151.31.86 as permitted sender) smtp.mailfrom=prakash.sangappa@oracle.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from userp2130.oracle.com (userp2130.oracle.com. [156.151.31.86]) by mx.google.com with ESMTPS id b72-v6si1236866jad.122.2018.09.12.13.25.04 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Sep 2018 13:25:04 -0700 (PDT) Received-SPF: pass (google.com: domain of prakash.sangappa@oracle.com designates 156.151.31.86 as permitted sender) client-ip=156.151.31.86; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=EF0N+A4Y; spf=pass (google.com: domain of prakash.sangappa@oracle.com designates 156.151.31.86 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 (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w8CKP1MO064847; Wed, 12 Sep 2018 20:25:01 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=0PPy+WGxUyuEgizIqbyTH5ifjbGa9WJweV7bgCsDBug=; b=EF0N+A4YJRcUxPipp2vRvo2gwhlmbHJpTj8LaoxsZFB5IJMBO9n93+z7ddpvJKazTLtv jc0n3dJE2uXgGk+ytuLfJ0NBAPCaQSiqmK6Vk5a2wEN50BnrHDVSP4a23fJOWnUKCqRO pdiBge+VzkFi33yl7oC/3kA19Cjls/oV4swVcOMo0dBl33Y87Dx/NeqrS4hThkmwDJMa tjzczViABB5J+lAJYFP8XJ8pbgBA1cpKws7AAcD0TPKEaQTXEF/zgXs4RToUAYpnwkFy xtFsfundptHw3LFXv2pvYicb+EL2r+qoNthNYLEDRyPzvUQEUbSDpUZmpwMVO6EijvuD cQ== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2130.oracle.com with ESMTP id 2mc5utmeur-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 12 Sep 2018 20:25:00 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w8CKOxsK015237 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 12 Sep 2018 20:25:00 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w8CKOxIf024309; Wed, 12 Sep 2018 20:24:59 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 3/6] Provide process address range to numa node id mapping Date: Wed, 12 Sep 2018 13:24:01 -0700 Message-Id: <1536783844-4145-4-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 This patch provides process address range to numa node information thru /proc//numa_vamaps file. For address ranges not having any pages mapped, a '-' is printed instead of the numa node id. Following is the sample of the file format 00400000-00410000 N1 00410000-0047f000 N0 0047f000-00480000 N2 00480000-00481000 - 00481000-004a0000 N0 004a0000-004a2000 - 004a2000-004aa000 N2 004aa000-004ad000 N0 004ad000-004ae000 - .. Signed-off-by: Prakash Sangappa Reviewed-by: Steve Sistare --- fs/proc/task_mmu.c | 158 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 158 insertions(+) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 02b553c..1371e379 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -1845,6 +1845,162 @@ static int show_numa_map(struct seq_file *m, void *v) return 0; } +static int gather_hole_info_vamap(unsigned long start, unsigned long end, + struct mm_walk *walk) +{ + struct numa_maps *md = walk->private; + struct vm_area_struct *vma = walk->vma; + + /* + * If in a nid, end walk at hole start. + * If no nid and vma changes, end walk at next vma start. + */ + if (md->nid >= 0 || vma != find_vma(walk->mm, start)) { + md->nextaddr = start; + return 1; + } + + if (md->nid == NUMA_VAMAPS_NID_NONE) + md->nid = NUMA_VAMAPS_NID_NOPAGES; + + return 0; +} + +static int vamap_vprintf(struct numa_vamaps_private *nvm, const char *f, ...) +{ + va_list args; + int len, space; + + space = NUMA_VAMAPS_BUFSZ - nvm->count; + va_start(args, f); + len = vsnprintf(nvm->buf + nvm->count, space, f, args); + va_end(args); + if (len < space) { + nvm->count += len; + return 0; + } + return 1; +} + +/* + * Display va-range to numa node info via /proc + */ +static ssize_t numa_vamaps_read(struct file *file, char __user *buf, + size_t count, loff_t *ppos) +{ + struct numa_vamaps_private *nvm = file->private_data; + struct vm_area_struct *vma, *tailvma; + struct numa_maps *md = &nvm->md; + struct mm_struct *mm = nvm->mm; + u64 vm_start = nvm->vm_start; + size_t ucount; + struct mm_walk walk = { + .hugetlb_entry = gather_hugetlb_stats, + .pmd_entry = gather_pte_stats, + .pte_hole = gather_hole_info_vamap, + .private = md, + .mm = mm, + }; + int ret = 0, copied = 0, done = 0; + + if (!mm || !mmget_not_zero(mm)) + return 0; + + if (count <= 0) + goto out_mm; + + /* First copy leftover contents in buffer */ + if (nvm->from) + goto docopy; + +repeat: + down_read(&mm->mmap_sem); + vma = find_vma(mm, vm_start); + if (!vma) { + done = 1; + goto out; + } + + if (vma->vm_start > vm_start) + vm_start = vma->vm_start; + + while (nvm->count < count) { + u64 vm_end; + + /* Ensure we start with an empty numa_maps statistics */ + memset(md, 0, sizeof(*md)); + md->nid = NUMA_VAMAPS_NID_NONE; /* invalid nodeid at start */ + md->nextaddr = 0; + md->isvamaps = 1; + + if (walk_page_range(vm_start, vma->vm_end, &walk) < 0) + break; + + /* nextaddr ends the range. if 0, reached the vma end */ + vm_end = (md->nextaddr ? md->nextaddr : vma->vm_end); + + /* break if buffer full */ + if (md->nid >= 0 && md->node[md->nid]) { + if (vamap_vprintf(nvm, "%08lx-%08lx N%ld\n", vm_start, + vm_end, md->nid)) + break; + } else if (vamap_vprintf(nvm, "%08lx-%08lx - \n", vm_start, + vm_end)) { + break; + } + + /* advance to next VA */ + vm_start = vm_end; + if (vm_end == vma->vm_end) { + vma = vma->vm_next; + if (!vma) { + done = 1; + break; + } + vm_start = vma->vm_start; + } + } +out: + /* last, add gate vma details */ + if (!vma && (tailvma = get_gate_vma(mm)) != NULL && + vm_start < tailvma->vm_end) { + done = 0; + if (!vamap_vprintf(nvm, "%08lx-%08lx - \n", + tailvma->vm_start, tailvma->vm_end)) { + done = 1; + vm_start = tailvma->vm_end; + } + } + + up_read(&mm->mmap_sem); +docopy: + ucount = min(count, nvm->count); + if (ucount && copy_to_user(buf, nvm->buf + nvm->from, ucount)) { + ret = -EFAULT; + goto out_mm;; + } + copied += ucount; + count -= ucount; + nvm->count -= ucount; + buf += ucount; + if (!done && count) { + nvm->from = 0; + goto repeat; + } + /* somthing left in the buffer */ + if (nvm->count) + nvm->from += ucount; + else + nvm->from = 0; + + nvm->vm_start = vm_start; + ret = copied; + *ppos += copied; +out_mm: + mmput(mm); + return ret; +} + static const struct seq_operations proc_pid_numa_maps_op = { .start = m_start, .next = m_next, @@ -1895,6 +2051,8 @@ const struct file_operations proc_pid_numa_maps_operations = { const struct file_operations proc_numa_vamaps_operations = { .open = numa_vamaps_open, + .read = numa_vamaps_read, + .llseek = noop_llseek, .release = numa_vamaps_release, }; #endif /* CONFIG_NUMA */ From patchwork Wed Sep 12 20:24:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prakash Sangappa X-Patchwork-Id: 10598301 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 C18B1112B for ; Wed, 12 Sep 2018 20:25:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B23B227C0B for ; Wed, 12 Sep 2018 20:25:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A68A52A7D5; Wed, 12 Sep 2018 20:25:11 +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 34BF827C0B for ; Wed, 12 Sep 2018 20:25:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C49358E0005; 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 B283D8E0001; 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 9C6FF8E0001; Wed, 12 Sep 2018 16:25:05 -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 70BBC8E0005 for ; Wed, 12 Sep 2018 16:25:05 -0400 (EDT) Received: by mail-it0-f69.google.com with SMTP id e62-v6so5429744itb.3 for ; Wed, 12 Sep 2018 13:25:05 -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=jv2gOdozZBt8RfOmySF/IIWmh2gd+llfLCyQhB8Gt2w=; b=hYjyTNWjDibK9V0T4iMt6Mgjzx7SAjLUrFwqE5jL2uqgCimIRXpBe5EijqRkuc7QKO ERLholUQMbCMWDlIxLz6HylNOKztKi7mamtO+iEWMZQeZfzjRX5BlwfF6oEIOrlfSJlM 6PKCpSv7lDNkOG0wmyiuMztqLkvBHTkZG8I69ydMSbpuZctIaytg9HFNlB1fMFXgkGaV m/DoFDMbnPzv8Ym19k689vzXohqYg0Z10a5l9zDgziflkVb1UAu9P3hcL0EvRNjpZ4jJ 3TXkK1BO3MDlep6usgTlOV4tYXJnH8sJ6HqPMmj9sR8kfdkX8mh+kMBJcKdTcidnIvTm oSdA== X-Gm-Message-State: APzg51Dzo89arf5zrcv4RVIpyKULSHyOyBtibZ8XwjUfYCEDJtevMYLU mY0sLWng9PWlje7nlokNaLa1oEKBA0s7fOR8krDUUUPE9vkjYLwzMcRPWVchkBQXy2kNsL5ga0c Zv/qUChjYfbmRxvA22MMQUHW+khfeSoreu0kXCiW+CEavimmssGaij4E10Zb7le9JzQ== X-Received: by 2002:a6b:dd18:: with SMTP id f24-v6mr3389911ioc.114.1536783905242; Wed, 12 Sep 2018 13:25:05 -0700 (PDT) X-Google-Smtp-Source: ANB0Vda0+h9cFhhznyhhEvr/hNXwEoDzo3nQb34Rwx0w/rKzrD9flGWcZtebu9ssOhn5oSiiGqyk X-Received: by 2002:a6b:dd18:: with SMTP id f24-v6mr3389853ioc.114.1536783904275; Wed, 12 Sep 2018 13:25:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536783904; cv=none; d=google.com; s=arc-20160816; b=Uk8e6bJl9u10Tn7QeGiq0DmrAnLMqxUMvWF+zXoFqKqUp9/DsmF3J56MWTR56Al3UK be1m9C17QzMhqwv1ImGUEqY68L+o/hi4bN8H8WNcX1+lMz8U4G59N0CmX+204y2x3CdS Ri4AWOzP49CRg8+jrTJoB7L9Ebme3oA/RQ8qczK0td55oKAg24SROyANoZpzg/ijFXRn Hs/N4hlVILHRCcLA/Hn87UWs5/otlfiKR2k0VCuLKLRsXNtcmASfPW7vDx+hB1StL+gJ z/sBeyDVLPOoZrfaNbwx7dBbDi770jaUhwvpCHeQZk3Pek52kmmfZsTx6PR4br9U65et WZFw== 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=jv2gOdozZBt8RfOmySF/IIWmh2gd+llfLCyQhB8Gt2w=; b=ZZzeoxuQDr/Hw+M9hqVCp4Aj3GXkPAQuFBAW9gI42f3ce+YzF9/lOjkxNZagIbdn7A WqbfhiyMellDfCTIgt62SGfyM2UueioUPxOaB0vB9iELvqJ+vJMJmo3ZFBgQCtStX6mJ Zk0IYsFktrGabfwNQAdICM54If1xBOgXOpA0Mx1zAnzS15TlXtHrb7DiFoDt2RgvTq6P AYcF+P4P62ICaTJp7OBE/D8nmKyCqHu/Y943jCcbZFnElbuV5zOdSorxw1WR8qatfDon LO2ZGFBzyS5smUA4++JatTOgOLIiL9ZmI2ZMukIjwE8tGHKCaHLwpR3rgqr3PbYKQVZi YObQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=P1lIUvk9; 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 b62-v6si1616292iti.112.2018.09.12.13.25.04 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Sep 2018 13:25:04 -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=P1lIUvk9; 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 w8CKO6LB084494; Wed, 12 Sep 2018 20:25:01 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=jv2gOdozZBt8RfOmySF/IIWmh2gd+llfLCyQhB8Gt2w=; b=P1lIUvk9b+Z/DAZVGAy2Zf58rJ1fc5O1bxJqkp5l86Uc0CM5X4v21jIKSNLipOGBqshd biWb7mlxkIwrHdorzdJBioUjaNaKIU+21qiMGcdEl65xwyLSnq39HU8G/KKEy2AYcM7B 6mJAhGjUrZdm4YVp06HHbidHBWta8hiFrJad2lfAAMMDtjYpWTtIWEYxoVqLYp3Zkqi5 1e7JKJZeO6aXNPdbpuSo1WZCEopRzF+SN1Kozre9TrqpOgCHdeA6/dM9quUG8DqwDWoK Fl6DD2zsDapfAuBX4FeWVt0yIJSxiaU+mcIQ4hkDVQ4cMnF7y3M1R0WBFiBiiEqjonKT 6A== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2120.oracle.com with ESMTP id 2mc6cpvd7h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 12 Sep 2018 20:25:01 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w8CKOxuQ010208 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 12 Sep 2018 20:25:00 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w8CKOxhK032107; Wed, 12 Sep 2018 20:24:59 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:59 -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 4/6] Add support to lseek /proc//numa_vamaps file Date: Wed, 12 Sep 2018 13:24:02 -0700 Message-Id: <1536783844-4145-5-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 Allow lseeking to a process virtual address(VA), starting from where the address range to numa node information can be read. The lseek offset will be the process virtual address. Signed-off-by: Prakash Sangappa Reviewed-by: Steve Sistare --- fs/proc/task_mmu.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 1371e379..93dce46 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -1866,6 +1866,27 @@ static int gather_hole_info_vamap(unsigned long start, unsigned long end, return 0; } +static loff_t numa_vamaps_llseek(struct file *file, loff_t offset, int orig) +{ + struct numa_vamaps_private *nvm = file->private_data; + + if (orig == SEEK_CUR && offset < 0 && nvm->vm_start < -offset) + return -EINVAL; + + switch (orig) { + case SEEK_SET: + nvm->vm_start = offset & PAGE_MASK; + break; + case SEEK_CUR: + nvm->vm_start += offset; + nvm->vm_start = nvm->vm_start & PAGE_MASK; + break; + default: + return -EINVAL; + } + return nvm->vm_start; +} + static int vamap_vprintf(struct numa_vamaps_private *nvm, const char *f, ...) { va_list args; @@ -2052,7 +2073,7 @@ const struct file_operations proc_pid_numa_maps_operations = { const struct file_operations proc_numa_vamaps_operations = { .open = numa_vamaps_open, .read = numa_vamaps_read, - .llseek = noop_llseek, + .llseek = numa_vamaps_llseek, .release = numa_vamaps_release, }; #endif /* CONFIG_NUMA */ From patchwork Wed Sep 12 20:24:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prakash Sangappa X-Patchwork-Id: 10598307 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 3F50D112B for ; Wed, 12 Sep 2018 20:25:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2FDAB27C0B for ; Wed, 12 Sep 2018 20:25:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 23B4A2A7D5; Wed, 12 Sep 2018 20:25:19 +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 B995727C0B for ; Wed, 12 Sep 2018 20:25:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A4AA08E0006; Wed, 12 Sep 2018 16:25:06 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 757148E000A; Wed, 12 Sep 2018 16:25:06 -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 5D37A8E0009; Wed, 12 Sep 2018 16:25:06 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yb1-f199.google.com (mail-yb1-f199.google.com [209.85.219.199]) by kanga.kvack.org (Postfix) with ESMTP id 1EDCC8E0008 for ; Wed, 12 Sep 2018 16:25:06 -0400 (EDT) Received: by mail-yb1-f199.google.com with SMTP id m9-v6so3135630ybm.20 for ; Wed, 12 Sep 2018 13:25:06 -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=Y0l/v4ChhDfpmg8ZWlOjGIPE6pA9rPqMOnxUCcNtxuw=; b=WqqHwpH2keZj45Lzi+X1j9fE+5qYOuqXSbYk4cBxnwQGx2ZVNNKUsmkWvDYvNKKV/O 1G/ymauJLpuXYxW1s1ArFU8dYfLGD2Kpibz2xYs6J9+WmcmJDwFTGikxeSHMZoqB9IAE bT/ghBvkss33JPIXqxwyJxqufusCNlSHsa3RCcBC+W+DSXdJ/hhutUck2UZDNtNOGIMt 2a5/cv/GMXlxkTRy2hPT8AtPOTSQ1mv82cyjMWtXMU7aNerxmFa3rrV5fM1FIrn6BbFe z5Og5xfHJgncwA2cVf+MUGCR/sMT5bOWdkcW9vS7fIsMfcoqtRbMV7tdLqYU3Ehxj35A McxA== X-Gm-Message-State: APzg51BYBpTWJoJxrBKcnT4aN4pOo2/ktnemRgDvZRvVgM4jMWozSCzM xACz7bio2AVtfx7CXUJvb6xiiUQWfm8g/vhllq/2bVmVp59BDy4YhEd4T+i0m6ORHmEKq/5HwIm bZFsqiQHfiLjyCdLdk3g+tSo/uHe/HdpqNBrtiWOj7VFKzawM2BL3NoxorNqKZpr0xg== X-Received: by 2002:a81:6d16:: with SMTP id i22-v6mr1806333ywc.112.1536783905867; Wed, 12 Sep 2018 13:25:05 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYaX8Oc+f92p07OdXOMHNylqPEAf7iC1GLfI3vnXs1IwLywiNk7TXUb7sS4bvljRUJ+4Q/V X-Received: by 2002:a81:6d16:: with SMTP id i22-v6mr1806317ywc.112.1536783905006; Wed, 12 Sep 2018 13:25:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536783904; cv=none; d=google.com; s=arc-20160816; b=qzuZrKMKpr48uwoi2Cx8MUBMubRjyr9eL8/kT26xwsO5AOuradd9bUm9UrGO69qbmy 3JkbpShKyGz6QrsT1bZhTNpUPT8yCjfIQT/CWiVEZ+g9EtjLFd+aBJyt+8PnFup/yDf2 FdoyKW+9J4FW1IVcT6FxUGQvMQhvI+v3qfe2Z8nGYyA24zoEcxj0mJzD2G0RCD8rgDHV k+QvymtFUCCy1RL74qvLfIYJYfozL3ddpS6ZGlaDyKMRJ4Ys00f9Fu7hIJqx+9PCcXUD yFzmmAYgUYZeAvPOumW6unEJdtt2HpkbPs/ubadVtVn+9VIyo2+8O0JJycqdpgngECs4 IxUA== 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=Y0l/v4ChhDfpmg8ZWlOjGIPE6pA9rPqMOnxUCcNtxuw=; b=ZuDNn57Vv8NYc5hZc7/BTjWyBOuJ7kCi5JAGnBO8jsFm6VF7T41/bRZFVAQmaq6y39 F6d2zxM6RXd+ews2+XGadL9MZo8uibGMpVCvNtNeB67XHlsaL9EVThGDDniMkc6TDl1H rNn1YwmgqAmS8oe5oSF3+nHIzINMChYHJrG8MpJzDNPYxioKvBTJNCeZojks3FaU/prY ANpvcPjnNhgbm8+8gFeDvcinaB4M5kQH3wg1gZ0aJ+mx6BKrBNbwLsCZlkEN370ZL/Og MvWWm+oy8BMTrMXp3QYQ7humMnSt6NAI2etZjtTBLAI9VZpZreNVfqd5ueKzUHPlvZUq qp0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=dxS0rfKs; 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 191-v6si528277ybt.587.2018.09.12.13.25.04 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Sep 2018 13:25:04 -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=dxS0rfKs; 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 w8CKO66A084516; Wed, 12 Sep 2018 20:25:01 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=Y0l/v4ChhDfpmg8ZWlOjGIPE6pA9rPqMOnxUCcNtxuw=; b=dxS0rfKsKju22sqRkmq90rgMGeyxuu1cTGZIOpxJ2B3J6toBGsH8zY/kGZawq97J3b+G G486sbMzF0ut7DamaOi+wktauKqCHHCyZF854y/TTfJoGiGRdX6L8GylmJK3ib2ax5O1 w8btCMGGGM7G28SPXmt0cAuWWrbSKQKX+tXv6WfFYg4tvaWUM6fTGsEVptsneAQVwr6g P4bSlsaVPjfVzM6Mo/FTliefXwMHioYEqEm0yRtoFcgx1mrzLKl+jKqyvOw64TDhS+Su SoSkoplefjux75VAUQxW+vawv4su/MwTGwc7H7sldR+p+viW375BmEFiJ/6cN40rCylk lA== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2120.oracle.com with ESMTP id 2mc6cpvd7m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 12 Sep 2018 20:25:01 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w8CKP0W1010267 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 12 Sep 2018 20:25:01 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w8CKP08W024321; Wed, 12 Sep 2018 20:25:00 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:25:00 -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 5/6] File /proc//numa_vamaps access needs PTRACE_MODE_READ_REALCREDS check Date: Wed, 12 Sep 2018 13:24:03 -0700 Message-Id: <1536783844-4145-6-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=968 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 Permission to access /proc//numa_vamaps file should be governed by PTRACE_READ_REALCREADS check to restrict getting specific VA range to numa node mapping information. Signed-off-by: Prakash Sangappa Reviewed-by: Steve Sistare --- fs/proc/base.c | 4 +++- fs/proc/task_mmu.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/proc/base.c b/fs/proc/base.c index 1af99ae..3c19a55 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -745,7 +745,9 @@ struct mm_struct *proc_mem_open(struct inode *inode, unsigned int mode) struct mm_struct *mm = ERR_PTR(-ESRCH); if (task) { - mm = mm_access(task, mode | PTRACE_MODE_FSCREDS); + if (!(mode & PTRACE_MODE_REALCREDS)) + mode |= PTRACE_MODE_FSCREDS; + mm = mm_access(task, mode); put_task_struct(task); if (!IS_ERR_OR_NULL(mm)) { diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 93dce46..30b29d2 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -2043,7 +2043,7 @@ static int numa_vamaps_open(struct inode *inode, struct file *file) if (!nvm) return -ENOMEM; - mm = proc_mem_open(inode, PTRACE_MODE_READ); + mm = proc_mem_open(inode, PTRACE_MODE_READ | PTRACE_MODE_REALCREDS); if (IS_ERR(mm)) { kfree(nvm); return PTR_ERR(mm); From patchwork Wed Sep 12 20:24:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prakash Sangappa X-Patchwork-Id: 10598309 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 F215014DB for ; Wed, 12 Sep 2018 20:25:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E253927C0B for ; Wed, 12 Sep 2018 20:25:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D6B312A7D5; Wed, 12 Sep 2018 20:25:21 +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 6879227C0B for ; Wed, 12 Sep 2018 20:25:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D91DD8E0008; Wed, 12 Sep 2018 16:25:06 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9AB448E0009; Wed, 12 Sep 2018 16:25:06 -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 6CC8F8E0008; Wed, 12 Sep 2018 16:25:06 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by kanga.kvack.org (Postfix) with ESMTP id 38B828E0007 for ; Wed, 12 Sep 2018 16:25:06 -0400 (EDT) Received: by mail-qk1-f198.google.com with SMTP id x204-v6so2861118qka.6 for ; Wed, 12 Sep 2018 13:25:06 -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=BgUFdWmTW4g8bFO+cR3WOQwK/nWdihiqPWZP+p36KpQ=; b=ujZqN1yk9a40oFhz7PvKuYnT9rvG0plTaALBPFTNifBM+EjLbY3G+yY91DD0w1jlq/ 1BpvIAechPvUTWBDv0ozX4KWu62xrTiloNAWCxfvugqivenn4InWQ5IJDpNcF4pXB5/E NOr5bDLMJT/oHoWRKESNWml/1GxY/+tfzRPGf6OA/qL48mSu7KOMEo5R+uLoSMm/voE6 +PApwL1NnL4FbK6X57vlssPSuxQ40QyjX5O7B5JOL875shWpHNlz6oW6MaNPJYgsl+fV YpgRUbMneBfVvls2Bft1zMH4nE2H7N7eozjiT30XzT6Wa4g3ZnaWT9yaOKnx7Llbytwv 9pcQ== X-Gm-Message-State: APzg51BiZ4RCETyBrVj6is++GxKbIPEsRuMAtUarfp3nCQFGSyN8rBbS +zbrRTMDw7L56GXeB/JFJ2b8jXX6tAVZ0nHliEcGdzF/8c5HNoiemFqh1JPCUNlqdbNk44yc25u Qg+c7KVspVUZUuRUsjhERdXgMc1bYKdpiHw/g1IwLiMKQYm+YPByhLOlSsQ5ueMDeqw== X-Received: by 2002:ac8:2a13:: with SMTP id k19-v6mr2849711qtk.245.1536783905925; Wed, 12 Sep 2018 13:25:05 -0700 (PDT) X-Google-Smtp-Source: ANB0VdapZpx3KeXa0+VI/cR8m87swglHTJ0UaXT/Oq/ZRC1THrqQxJ/J154N7iqbasFUU5eKa+B3 X-Received: by 2002:ac8:2a13:: with SMTP id k19-v6mr2849678qtk.245.1536783905075; Wed, 12 Sep 2018 13:25:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536783905; cv=none; d=google.com; s=arc-20160816; b=wbVDJnMfoufYzjMP5ZLaZqfDOc4+GVtyyLHhjKM3hXXI0ktewI4gBveC6KiYOp9cw2 oFpiqWNcE6p+c+ILc67CADqHTxdvMki9tWMG6SQLrrJt6pM4cVJFCBvAUnnQ+OTz5EWm cTKaR94U0eA8kMNH37mTs3IXuN9Rdo2g8aBqkWUFqmtRVwkKprffyXBkCP12Rg2bYVLz FHst5eCnYxiPVoeTUI2ucCvTZPHOJVvhtn+Tn+8RSWSIAnBy18Q9WgjNxfAShV41RXvs PUmfFZPe7B6xFpXlOown+gNPMpPEcAZ+D7WjZwl625wbnhh6jsqSLDhJEvvQVTfrdkvb EADA== 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=BgUFdWmTW4g8bFO+cR3WOQwK/nWdihiqPWZP+p36KpQ=; b=aSlJNySAdumDu9275q7BRfOzKkymAAtYYEbRrkytMnz42DVchx5Psf374OmZL4OPw9 t9vOdbb8rlo/PeZDwjDJZSNg7FnBUnqRm01QViNCvgEXaFrPbdy/4Mz+HvpT/RBfsE84 QmlEgRbtbiaKAo7CTFSCb+GrP10o4GndHnb0VanehRObYAS7p/fTGFQSFR2Qj7UeOYXM SyZk7aenSiOgaEY8i9d8vSIzMXx889/nwtUJeHKMBPwQE2DRVPeh7wv/RyU3CjgICgbt h3poFmdrm0CUJTKk47AA/9d0YjFHpGYlnsHZCTyUK2YgEnMqkzbuBo343VTjbzSh3KXS 9YSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=T37IkL7f; spf=pass (google.com: domain of prakash.sangappa@oracle.com designates 156.151.31.85 as permitted sender) smtp.mailfrom=prakash.sangappa@oracle.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from userp2120.oracle.com (userp2120.oracle.com. [156.151.31.85]) by mx.google.com with ESMTPS id q8-v6si1456450qvh.274.2018.09.12.13.25.04 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Sep 2018 13:25:05 -0700 (PDT) Received-SPF: pass (google.com: domain of prakash.sangappa@oracle.com designates 156.151.31.85 as permitted sender) client-ip=156.151.31.85; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=T37IkL7f; spf=pass (google.com: domain of prakash.sangappa@oracle.com designates 156.151.31.85 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 (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w8CKO6D5041220; Wed, 12 Sep 2018 20:25:02 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=BgUFdWmTW4g8bFO+cR3WOQwK/nWdihiqPWZP+p36KpQ=; b=T37IkL7fRt667QSrO0DhbhjBMVgkatGJQ8UWVbbEeUxcBVIuZjIDt7SuK+etZxmAPXoM ycfqNgV3jlG+onleGUryB/KSafqNUkKQJBbpssxkWKZCndlT9a/f+dsPmJZgMB2Q3ukd 7XOer//7YFA6rqjh2BZLjVveW7lyhnoh4m2o0MCFt0tqkeIZRrfS2YEGQP4oNV6UDkGx Kk0yYuk9PkOg91FOzy3sgcz3/gk1y1zDkB3Ik031gm03LJp7L/5HzJrQOY+vNIP8cpTM kTKvJmvSbHjVUaMO91dHGeVfwBRLEMEzFGnXqV6RN78ja7hBX5ceMUYKgXhYQWcttZB/ sg== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2120.oracle.com with ESMTP id 2mc72qvbvx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 12 Sep 2018 20:25:01 +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 w8CKP1i5015346 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 12 Sep 2018 20:25:01 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 w8CKP1BL015860; Wed, 12 Sep 2018 20:25:01 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:25:00 -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 6/6] /proc/pid/numa_vamaps: document in Documentation/filesystems/proc.txt Date: Wed, 12 Sep 2018 13:24:04 -0700 Message-Id: <1536783844-4145-7-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=854 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 Add documentation for /proc//numa_vamaps in Documentation/filesystems/proc.txt Signed-off-by: Prakash Sangappa Reviewed-by: Steve Sistare --- Documentation/filesystems/proc.txt | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Documentation/filesystems/proc.txt b/Documentation/filesystems/proc.txt index 22b4b00..7095216 100644 --- a/Documentation/filesystems/proc.txt +++ b/Documentation/filesystems/proc.txt @@ -150,6 +150,9 @@ Table 1-1: Process specific entries in /proc each mapping and flags associated with it numa_maps an extension based on maps, showing the memory locality and binding policy as well as mem usage (in pages) of each mapping. + numa_vamaps Presents information about mapped address ranges to numa node + from where the physical memory is allocated. + .............................................................................. For example, to get the status information of a process, all you have to do is @@ -571,6 +574,24 @@ Where: node locality page counters (N0 == node0, N1 == node1, ...) and the kernel page size, in KB, that is backing the mapping up. +The /proc/pid/numa_vamaps shows mapped address ranges to numa node id from +where the physical pages are allocated. For mapped address ranges not having +any pages mapped a '-' is shown instead of the node id. Each line in the file +will show address range to one numa node. + +address-range numa-node-id + +00400000-00410000 N1 +00410000-0047f000 N0 +0047f000-00480000 N2 +00480000-00481000 - +00481000-004a0000 N0 +004a0000-004a2000 - +004a2000-004aa000 N2 +004aa000-004ad000 N0 +004ad000-004ae000 - +.. + 1.2 Kernel data ---------------