Skip to contentSkip to conversation

mm: handle simple case in free_pcppages_bulk()

RFC PATCH In review Namhyung Kim 3 participants 6 messages Feb 10, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 mm: handle simple case in free_pcppages_bulk()

Now I'm seeing that there are some cases to free all pages in a pcp lists. In that case, just frees all pages in the lists instead of being bothered with round-robin lists traversal.

---
 mm/page_alloc.c |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)
mm/page_alloc.c +22 -0
index e8b02771ccea..959c54450ddf 100644
@@ -596,6 +596,28 @@ static void free_pcppages_bulk(struct zone *zone, int count,
 	zone->all_unreclaimable = 0;
 	zone->pages_scanned = 0;
 
+	/* Simple case: Free all */
+	if (to_free == pcp->count) {
+		LIST_HEAD(freelist);
+
+		for (; migratetype < MIGRATE_PCPTYPES; migratetype++)
+			if (!list_empty(&pcp->lists[migratetype]))
+				list_move(&pcp->lists[migratetype], &freelist);
+
+		while (!list_empty(&freelist)) {
+			struct page *page;
+
+			page = list_first_entry(&freelist, struct page, lru);
+			/* must delete as __free_one_page list manipulates */
+			list_del(&page->lru);
+			/* MIGRATE_MOVABLE list may include MIGRATE_RESERVEs */
+			__free_one_page(page, zone, 0, page_private(page));
+			trace_mm_page_pcpu_drain(page, 0, page_private(page));
+			to_free--;
+		}
+		VM_BUG_ON(to_free);
+	}
+
 	while (to_free) {
 		struct page *page;
 		struct list_head *list;
Signature · 1 line
1.7.4
#1 lore raw

Hello Namhyung,

Quoted 3 lines · Namhyung Kim

Now I'm seeing that there are some cases to free all pages in a pcp lists. In that case, just frees all pages in the lists instead of being bothered with round-robin lists traversal.

I though about that but I didn't send the patch.
That's because many cases which calls free_pcppages_bulk(, pcp->count,..) are slow path so it adds comparison overhead on fast path while it loses the effectiveness in slow path.

Signature · 2 lines
Kind regards,
Minchan Kim
#2 lore raw

2011-02-10 (ea(C)), 22:10 +0900, Minchan Kim:

Quoted 2 lines

Hello Namhyung,

Hi Minchan,

Quoted 10 lines · Namhyung Kim
Quoted 3 lines

Now I'm seeing that there are some cases to free all pages in a pcp lists. In that case, just frees all pages in the lists instead of being bothered with round-robin lists traversal.

I though about that but I didn't send the patch.
That's because many cases which calls free_pcppages_bulk(, pcp->count,..) are slow path so it adds comparison overhead on fast path while it loses the effectiveness in slow path.

Hmm.. How about adding unlikely() then? Doesn't it help much here?

Signature · 10 lines
Regards,
Namhyung Kim


--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#3 lore raw
Quoted 12 lines · Namhyung Kim

2011-02-10 (목), 22:10 +0900, Minchan Kim:

Quoted 2 lines

Hello Namhyung,

Hi Minchan,

Quoted 5 lines · Namhyung Kim
Quoted 3 lines

Now I'm seeing that there are some cases to free all pages in a pcp lists. In that case, just frees all pages in the lists instead of being bothered with round-robin lists traversal.

Quoted 7 lines
Quoted 5 lines

I though about that but I didn't send the patch.
That's because many cases which calls free_pcppages_bulk(, pcp->count,..) are slow path so it adds comparison overhead on fast path while it loses the effectiveness in slow path.

Hmm.. How about adding unlikely() then? Doesn't it help much here?

Yes. It would help but I am not sure how much it is. AFAIR, when Mel submit the patch, he tried to prove the effectiveness with some experiment and profiler.
I think if you want it really, we might need some number. I am not sure it's worth.

Signature · 9 lines
Kind regards,
Minchan Kim

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#4 lore raw

2011-02-10 (목), 22:38 +0900, Minchan Kim:

Quoted 8 lines
Quoted 1 line

Hmm.. How about adding unlikely() then? Doesn't it help much here?

Yes. It would help but I am not sure how much it is. AFAIR, when Mel submit the patch, he tried to prove the effectiveness with some experiment and profiler.
I think if you want it really, we might need some number. I am not sure it's worth.

OK. Thanks for the comments. :)

And it would be really great if you (or somebody) told me how could I make the numbers on my desktop.

Signature · 2 lines
Regards,
Namhyung Kim
#5 lore raw
In reply to Minchan Kim
Quoted 19 lines · Minchan Kim
Quoted 18 lines · Namhyung Kim

2011-02-10 (???), 22:10 +0900, Minchan Kim:

Quoted 2 lines

Hello Namhyung,

Hi Minchan,

Quoted 10 lines · Namhyung Kim
Quoted 3 lines

Now I'm seeing that there are some cases to free all pages in a pcp lists. In that case, just frees all pages in the lists instead of being bothered with round-robin lists traversal.

I though about that but I didn't send the patch.
That's because many cases which calls free_pcppages_bulk(, pcp->count,..) are slow path so it adds comparison overhead on fast path while it loses the effectiveness in slow path.

Quoted 5 lines
Quoted 1 line

Hmm.. How about adding unlikely() then? Doesn't it help much here?

Yes. It would help but I am not sure how much it is. AFAIR, when Mel submit the patch, he tried to prove the effectiveness with some experiment and profiler.

Yep. Principally I *think* used netperf running UDP_STREAM for different buffer sizes and compared oprofile output but I also ran a battery of benchmarks to check for any other unexpected regression without profiling.

Signature · 9 lines
Mel Gorman
SUSE Labs

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>