Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1557819 > unrolled thread

[PATCH] mm, vmscan: do not count freed pages as PGDEACTIVATE

Started byMichal Hocko <mhocko@kernel.org>
First post2017-01-12 22:20 +0100
Last post2017-01-14 17:40 +0100
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] mm, vmscan: do not count freed pages as PGDEACTIVATE Michal Hocko <mhocko@kernel.org> - 2017-01-12 22:20 +0100
    Re: [PATCH] mm, vmscan: do not count freed pages as PGDEACTIVATE Vlastimil Babka <vbabka@suse.cz> - 2017-01-13 11:00 +0100
    Re: [PATCH] mm, vmscan: do not count freed pages as PGDEACTIVATE Johannes Weiner <hannes@cmpxchg.org> - 2017-01-14 17:40 +0100

#1557819 — [PATCH] mm, vmscan: do not count freed pages as PGDEACTIVATE

FromMichal Hocko <mhocko@kernel.org>
Date2017-01-12 22:20 +0100
Subject[PATCH] mm, vmscan: do not count freed pages as PGDEACTIVATE
Message-ID<sYUWR-tD-13@gated-at.bofh.it>
From: Michal Hocko <mhocko@suse.com>

PGDEACTIVATE represents the number of pages moved from the active list
to the inactive list. At least this sounds like the original motivation
of the counter. move_active_pages_to_lru, however, counts pages which
got freed in the mean time as deactivated as well. This is a very rare
event and counting them as deactivation in itself is not harmful but it
makes the code more convoluted than necessary - we have to count both
all pages and those which are freed which is a bit confusing.

After this patch the PGDEACTIVATE should have a slightly more clear
semantic and only count those pages which are moved from the active to
the inactive list which is a plus.

Suggested-by: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Michal Hocko <mhocko@suse.com>
---
Hi,
Vlastimil has pointed out [1] that move_active_pages_to_lru is more
confusing than necessary because we count two things, pgmoved and
nr_moved. I believe that counting freed pages as PGDEACTIVATE is more
confusing than helpful. I doubt that this patch will make any real
difference in the real life but it at least makes the code easier which
is a plus so I think this is more a cleanup than any bug fix.

[1] http://lkml.kernel.org/r/646c3551-e794-611c-5247-490bd89133db@suse.cz

 mm/vmscan.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index cf940af609fd..7e1c3cd91fab 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1878,7 +1878,6 @@ static unsigned move_active_pages_to_lru(struct lruvec *lruvec,
 				     enum lru_list lru)
 {
 	struct pglist_data *pgdat = lruvec_pgdat(lruvec);
-	unsigned long pgmoved = 0;
 	struct page *page;
 	int nr_pages;
 	int nr_moved = 0;
@@ -1893,7 +1892,6 @@ static unsigned move_active_pages_to_lru(struct lruvec *lruvec,
 		nr_pages = hpage_nr_pages(page);
 		update_lru_size(lruvec, lru, page_zonenum(page), nr_pages);
 		list_move(&page->lru, &lruvec->lists[lru]);
-		pgmoved += nr_pages;
 
 		if (put_page_testzero(page)) {
 			__ClearPageLRU(page);
@@ -1913,7 +1911,7 @@ static unsigned move_active_pages_to_lru(struct lruvec *lruvec,
 	}
 
 	if (!is_active_lru(lru))
-		__count_vm_events(PGDEACTIVATE, pgmoved);
+		__count_vm_events(PGDEACTIVATE, nr_moved);
 
 	return nr_moved;
 }
-- 
2.11.0

[toc] | [next] | [standalone]


#1558166

FromVlastimil Babka <vbabka@suse.cz>
Date2017-01-13 11:00 +0100
Message-ID<sZ6Oq-7I1-7@gated-at.bofh.it>
In reply to#1557819
On 01/12/2017 10:12 PM, Michal Hocko wrote:
> From: Michal Hocko <mhocko@suse.com>
>
> PGDEACTIVATE represents the number of pages moved from the active list
> to the inactive list. At least this sounds like the original motivation
> of the counter. move_active_pages_to_lru, however, counts pages which
> got freed in the mean time as deactivated as well. This is a very rare
> event and counting them as deactivation in itself is not harmful but it
> makes the code more convoluted than necessary - we have to count both
> all pages and those which are freed which is a bit confusing.
>
> After this patch the PGDEACTIVATE should have a slightly more clear
> semantic and only count those pages which are moved from the active to
> the inactive list which is a plus.
>
> Suggested-by: Vlastimil Babka <vbabka@suse.cz>
> Signed-off-by: Michal Hocko <mhocko@suse.com>

Acked-by: Vlastimil Babka <vbabka@suse.cz>

[toc] | [prev] | [next] | [standalone]


#1559027

FromJohannes Weiner <hannes@cmpxchg.org>
Date2017-01-14 17:40 +0100
Message-ID<sZzwZ-8bu-11@gated-at.bofh.it>
In reply to#1557819
On Thu, Jan 12, 2017 at 10:12:21PM +0100, Michal Hocko wrote:
> From: Michal Hocko <mhocko@suse.com>
> 
> PGDEACTIVATE represents the number of pages moved from the active list
> to the inactive list. At least this sounds like the original motivation
> of the counter. move_active_pages_to_lru, however, counts pages which
> got freed in the mean time as deactivated as well. This is a very rare
> event and counting them as deactivation in itself is not harmful but it
> makes the code more convoluted than necessary - we have to count both
> all pages and those which are freed which is a bit confusing.
> 
> After this patch the PGDEACTIVATE should have a slightly more clear
> semantic and only count those pages which are moved from the active to
> the inactive list which is a plus.
> 
> Suggested-by: Vlastimil Babka <vbabka@suse.cz>
> Signed-off-by: Michal Hocko <mhocko@suse.com>

I bet it's a small inaccuracy in practice, but now that the trace
patches added a proper counter, might as well consolidate into the
correct one.

Acked-by: Johannes Weiner <hannes@cmpxchg.org>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web