linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm, vmscan: do not count freed pages as PGDEACTIVATE
@ 2017-01-12 21:12 Michal Hocko
  2017-01-13  9:55 ` Vlastimil Babka
  2017-01-14 16:39 ` Johannes Weiner
  0 siblings, 2 replies; 3+ messages in thread
From: Michal Hocko @ 2017-01-12 21:12 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Vlastimil Babka, Hugh Dickins, Johannes Weiner, Mel Gorman,
	linux-mm, LKML, Michal Hocko

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

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] mm, vmscan: do not count freed pages as PGDEACTIVATE
  2017-01-12 21:12 [PATCH] mm, vmscan: do not count freed pages as PGDEACTIVATE Michal Hocko
@ 2017-01-13  9:55 ` Vlastimil Babka
  2017-01-14 16:39 ` Johannes Weiner
  1 sibling, 0 replies; 3+ messages in thread
From: Vlastimil Babka @ 2017-01-13  9:55 UTC (permalink / raw)
  To: Michal Hocko, Andrew Morton
  Cc: Hugh Dickins, Johannes Weiner, Mel Gorman, linux-mm, LKML,
	Michal Hocko

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>

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mm, vmscan: do not count freed pages as PGDEACTIVATE
  2017-01-12 21:12 [PATCH] mm, vmscan: do not count freed pages as PGDEACTIVATE Michal Hocko
  2017-01-13  9:55 ` Vlastimil Babka
@ 2017-01-14 16:39 ` Johannes Weiner
  1 sibling, 0 replies; 3+ messages in thread
From: Johannes Weiner @ 2017-01-14 16:39 UTC (permalink / raw)
  To: Michal Hocko
  Cc: Andrew Morton, Vlastimil Babka, Hugh Dickins, Mel Gorman,
	linux-mm, LKML, Michal Hocko

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>

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-01-14 16:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-12 21:12 [PATCH] mm, vmscan: do not count freed pages as PGDEACTIVATE Michal Hocko
2017-01-13  9:55 ` Vlastimil Babka
2017-01-14 16:39 ` Johannes Weiner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).