Skip to contentSkip to conversation

__alloc_pages_limit pages_min

PATCH In review Roger Larsson 2 participants 4 messages Aug 22, 2001

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

PATCH 1/1 __alloc_pages_limit pages_min

Hi all,

If __alloc_pages_limit is called with PAGES_HIGH and direct_reclaim. It might alloc the last free page of a zone....

How:
* inactive_clean_pages >= pages_high

first if gives

if (free_pages + inactive_clean >= pages_high) => true

No direct_reclaim gives no attempt to call reclaim_page. Instead rmqueue will be called...
now we have one page less - run it again... free_pages will be decremented until zero...

Last page gone in a at PAGES_HIGH alloc!!!

Note: reclaim_page will fix this situation direct it is allowed to run since it is kicked in __alloc_pages. But since we cannot guarantee that this will never happen...

/RogerL

this patch is against 2.4.8-pre3 as it was my current kernel. (searching for a USB storage bug...)
*******************************************
Patch prepared by: [email protected]

mm/page_alloc.c renamed from mm/page_alloc.c.orig +3 -2
@@ -256,8 +256,9 @@
 			/* If possible, reclaim a page directly. */
 			if (direct_reclaim)
 				page = reclaim_page(z);
-			/* If that fails, fall back to rmqueue. */
-			if (!page)
+			/* If that fails, fall back to rmqueue, but do never
+			*  go below free_pages for any zone*/
+			if (!page && z->free_pages >= z->pages_min)
 				page = rmqueue(z, order);
 			if (page)
 				return page;

--
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/

#1 lore raw
Quoted 3 lines · Roger Larsson

Note: reclaim_page will fix this situation direct it is allowed to run since it is kicked in __alloc_pages. But since we cannot guarantee that this will never happen...

In this case kreclaimd will be woken up and the free pages will be refilled.

Rik
--
IA64: a worthy successor to the i860.

		http://www.surriel.com/

http://www.conectiva.com/ http://distro.conectiva.com/

--
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/

#2 lore raw
Quoted 9 lines · Rik van Riel
Quoted 3 lines · Roger Larsson

Note: reclaim_page will fix this situation direct it is allowed to run since it is kicked in __alloc_pages. But since we cannot guarantee that this will never happen...

In this case kreclaimd will be woken up and the free pages will be refilled.

Rik

Yes it will be woken up - but when will it actually do something? (we might have lots of stuff before in the run queue)

Suppose we are at low for all zones on free pages - the natural. And we get requsts for DMA pages, non direct_reclaim. (with inactive_clean greater than pages_high)

An alloc will then take let you allocate at the first __alloc_pages_limit until zero pages left. You might have got it anyway but not until a later test in __alloc_pages but it is not guaranteed.

We should not accept to let free_pages go (more than one) under pages_min, at least not as a undocumented feature of __alloc_pages_limit...

It might be worse then first tought of since all allocations with order != 0 are non direct_reclaim... you might eat the free pages fast...

And this limit at the end of alloc_pages

		if (z->free_pages < z->pages_min / 4 &&
				!(current->flags & PF_MEMALLOC))

is not enforced earlier in the same code...

/RogerL

Signature · 7 lines
Roger Larsson
Skelleftea
Sweden
--
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/
#3 lore raw
Quoted 9 lines · Roger Larsson
Quoted 7 lines · Rik van Riel
Quoted 3 lines · Roger Larsson

Note: reclaim_page will fix this situation direct it is allowed to run since it is kicked in __alloc_pages. But since we cannot guarantee that this will never happen...

In this case kreclaimd will be woken up and the free pages will be refilled.

Quoted 6 lines

Yes it will be woken up - but when will it actually do something?

And this limit at the end of alloc_pages

		if (z->free_pages < z->pages_min / 4 &&
				!(current->flags & PF_MEMALLOC))

is not enforced earlier in the same code...

Please read the code. The first loop in __alloc_pages(), before we even call __alloc_pages_limit() will wake up kreclaimd as soon as 'z->free_pages < z->pages_min'.

If you have any more questions about the source code, don't hesitate to ask ;)

Rik
--
IA64: a worthy successor to the i860.

		http://www.surriel.com/

http://www.conectiva.com/ http://distro.conectiva.com/

--
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/