]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.9.68/mm-fix-remote-numa-hits-statistics.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.9.68 / mm-fix-remote-numa-hits-statistics.patch
1 From foo@baz Wed Dec 6 17:39:55 CET 2017
2 From: Michal Hocko <mhocko@suse.com>
3 Date: Tue, 10 Jan 2017 16:57:39 -0800
4 Subject: mm: fix remote numa hits statistics
5
6 From: Michal Hocko <mhocko@suse.com>
7
8
9 [ Upstream commit 2df26639e708a88dcc22171949da638a9998f3bc ]
10
11 Jia He has noticed that commit b9f00e147f27 ("mm, page_alloc: reduce
12 branches in zone_statistics") has an unintentional side effect that
13 remote node allocation requests are accounted as NUMA_MISS rathat than
14 NUMA_HIT and NUMA_OTHER if such a request doesn't use __GFP_OTHER_NODE.
15
16 There are many of these potentially because the flag is used very rarely
17 while we have many users of __alloc_pages_node.
18
19 Fix this by simply ignoring __GFP_OTHER_NODE (it can be removed in a
20 follow up patch) and treat all allocations that were satisfied from the
21 preferred zone's node as NUMA_HITS because this is the same node we
22 requested the allocation from in most cases. If this is not the local
23 node then we just account it as NUMA_OTHER rather than NUMA_LOCAL.
24
25 One downsize would be that an allocation request for a node which is
26 outside of the mempolicy nodemask would be reported as a hit which is a
27 bit weird but that was the case before b9f00e147f27 already.
28
29 Fixes: b9f00e147f27 ("mm, page_alloc: reduce branches in zone_statistics")
30 Link: http://lkml.kernel.org/r/20170102153057.9451-2-mhocko@kernel.org
31 Signed-off-by: Michal Hocko <mhocko@suse.com>
32 Reported-by: Jia He <hejianet@gmail.com>
33 Reviewed-by: Vlastimil Babka <vbabka@suse.cz> # with cbmc[1] superpowers
34 Acked-by: Mel Gorman <mgorman@suse.de>
35 Cc: Johannes Weiner <hannes@cmpxchg.org>
36 Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
37 Cc: Taku Izumi <izumi.taku@jp.fujitsu.com>
38 Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
39 Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
40 Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
41 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
42 ---
43 mm/page_alloc.c | 15 ++++-----------
44 1 file changed, 4 insertions(+), 11 deletions(-)
45
46 --- a/mm/page_alloc.c
47 +++ b/mm/page_alloc.c
48 @@ -2592,30 +2592,23 @@ int __isolate_free_page(struct page *pag
49 * Update NUMA hit/miss statistics
50 *
51 * Must be called with interrupts disabled.
52 - *
53 - * When __GFP_OTHER_NODE is set assume the node of the preferred
54 - * zone is the local node. This is useful for daemons who allocate
55 - * memory on behalf of other processes.
56 */
57 static inline void zone_statistics(struct zone *preferred_zone, struct zone *z,
58 gfp_t flags)
59 {
60 #ifdef CONFIG_NUMA
61 - int local_nid = numa_node_id();
62 enum zone_stat_item local_stat = NUMA_LOCAL;
63
64 - if (unlikely(flags & __GFP_OTHER_NODE)) {
65 + if (z->node != numa_node_id())
66 local_stat = NUMA_OTHER;
67 - local_nid = preferred_zone->node;
68 - }
69
70 - if (z->node == local_nid) {
71 + if (z->node == preferred_zone->node)
72 __inc_zone_state(z, NUMA_HIT);
73 - __inc_zone_state(z, local_stat);
74 - } else {
75 + else {
76 __inc_zone_state(z, NUMA_MISS);
77 __inc_zone_state(preferred_zone, NUMA_FOREIGN);
78 }
79 + __inc_zone_state(z, local_stat);
80 #endif
81 }
82