From patchwork Fri Mar 17 13:40:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Gardner X-Patchwork-Id: 740324 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 3vl60y1vVwz9s2x; Sat, 18 Mar 2017 00:40:33 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical-com.20150623.gappssmtp.com header.i=@canonical-com.20150623.gappssmtp.com header.b="1u/+HQfA"; dkim-atps=neutral Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1cos7F-0000mZ-P6; Fri, 17 Mar 2017 13:40:25 +0000 Received: from mail-it0-f47.google.com ([209.85.214.47]) by huckleberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1cos7A-0000kP-Td for kernel-team@lists.ubuntu.com; Fri, 17 Mar 2017 13:40:21 +0000 Received: by mail-it0-f47.google.com with SMTP id m27so25991844iti.1 for ; Fri, 17 Mar 2017 06:40:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=IAQqO+iSVGJ/cLiJa3oVfMUxKD14wc5+8sQWmh2yoQg=; b=1u/+HQfA1lma8fxnegIPk81q91a55XHS/LQ9xpweXT0ef019Y6n3Rsz+7GgzwwKTxG Z7WEj+7cHoguvt10KafNDvDjeSIX24wvh/PGOm/gkBwQ9Vfq09/WrcCBnOplFoLSWajb kzAfSFw1psIUlfrMyT85Omm16ucw48Vo1StNU/f1xJ2Xpj+rydRdcvLXFs8CkfondOyo b0RyQVzR0pnSzKYsMyUJfwVKpzzJpuUiil2m2rTDzfiNNuhmzqMqrKTjqw8ze/sEZs5d haZ9te/g1yqtXERMZNwttTuTbixUdufskeLSxSFzUJ1y/pgXzsKdtNaoi72U6KcwlpIJ NOJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=IAQqO+iSVGJ/cLiJa3oVfMUxKD14wc5+8sQWmh2yoQg=; b=kOLXRBmYLCGOvbsBkfwWY9a2odpBRwK3SJ4ozxC63Jp4b23Hpzb3EEB/xqbDA+59nu evwKtypic43UlwKG31CrD+JNOXi7EdxLl7U7YTpWo+AGCTH6l2rHnfHGUBlcJ8N1WL2u dIkcmiglbSRl5WXL+g9Rc5k6LsqOTKQLOYwm+QTCrLzK1HJrlQQwozgf0a4U+A8f3/Vu +GtD+4fKoNoDFTYMcIjafbWQwJtYMxzs63WHphqixwNeKLnZ2DOXh2TebNws/9srPR6l 3vbNUtXUGE5o5r+0hC6gWQEP3iOmPWqDXK5Wemz+mlcW5JlxG55jN6zlnOXt7kJvIrME JSXA== X-Gm-Message-State: AFeK/H1QxGf0vxwk9bln9fN6lsim5JfLVlL6Ug56wbGtxcqPpeWXbERplGS6WJzOMYW1MkZ9 X-Received: by 10.36.181.23 with SMTP id v23mr2962677ite.100.1489758019332; Fri, 17 Mar 2017 06:40:19 -0700 (PDT) Received: from localhost.localdomain (host-98-127-250-84.bln-mt.client.bresnan.net. [98.127.250.84]) by smtp.gmail.com with ESMTPSA id 7sm1061474itv.16.2017.03.17.06.40.18 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 17 Mar 2017 06:40:18 -0700 (PDT) From: Tim Gardner To: kernel-team@lists.ubuntu.com Subject: [PATCH 1/2] mm: fix remote numa hits statistics Date: Fri, 17 Mar 2017 07:40:10 -0600 Message-Id: <1489758011-29363-2-git-send-email-tim.gardner@canonical.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1489758011-29363-1-git-send-email-tim.gardner@canonical.com> References: <1489758011-29363-1-git-send-email-tim.gardner@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: kernel-team-bounces@lists.ubuntu.com From: Michal Hocko BugLink: http://bugs.launchpad.net/bugs/1672953 Jia He has noticed that commit b9f00e147f27 ("mm, page_alloc: reduce branches in zone_statistics") has an unintentional side effect that remote node allocation requests are accounted as NUMA_MISS rathat than NUMA_HIT and NUMA_OTHER if such a request doesn't use __GFP_OTHER_NODE. There are many of these potentially because the flag is used very rarely while we have many users of __alloc_pages_node. Fix this by simply ignoring __GFP_OTHER_NODE (it can be removed in a follow up patch) and treat all allocations that were satisfied from the preferred zone's node as NUMA_HITS because this is the same node we requested the allocation from in most cases. If this is not the local node then we just account it as NUMA_OTHER rather than NUMA_LOCAL. One downsize would be that an allocation request for a node which is outside of the mempolicy nodemask would be reported as a hit which is a bit weird but that was the case before b9f00e147f27 already. Fixes: b9f00e147f27 ("mm, page_alloc: reduce branches in zone_statistics") Link: http://lkml.kernel.org/r/20170102153057.9451-2-mhocko@kernel.org Signed-off-by: Michal Hocko Reported-by: Jia He Reviewed-by: Vlastimil Babka # with cbmc[1] superpowers Acked-by: Mel Gorman Cc: Johannes Weiner Cc: Joonsoo Kim Cc: Taku Izumi Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds (cherry picked from commit 2df26639e708a88dcc22171949da638a9998f3bc) Signed-off-by: Tim Gardner --- mm/page_alloc.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 212a017..0a9bda6 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -2532,30 +2532,23 @@ int __isolate_free_page(struct page *page, unsigned int order) * Update NUMA hit/miss statistics * * Must be called with interrupts disabled. - * - * When __GFP_OTHER_NODE is set assume the node of the preferred - * zone is the local node. This is useful for daemons who allocate - * memory on behalf of other processes. */ static inline void zone_statistics(struct zone *preferred_zone, struct zone *z, gfp_t flags) { #ifdef CONFIG_NUMA - int local_nid = numa_node_id(); enum zone_stat_item local_stat = NUMA_LOCAL; - if (unlikely(flags & __GFP_OTHER_NODE)) { + if (z->node != numa_node_id()) local_stat = NUMA_OTHER; - local_nid = preferred_zone->node; - } - if (z->node == local_nid) { + if (z->node == preferred_zone->node) __inc_zone_state(z, NUMA_HIT); - __inc_zone_state(z, local_stat); - } else { + else { __inc_zone_state(z, NUMA_MISS); __inc_zone_state(preferred_zone, NUMA_FOREIGN); } + __inc_zone_state(z, local_stat); #endif }