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; }