* [PATCH][2.4] update ref counts on all allocated pages
@ 2002-11-27 0:07 Matt Porter
2002-11-27 10:31 ` David S. Miller
0 siblings, 1 reply; 4+ messages in thread
From: Matt Porter @ 2002-11-27 0:07 UTC (permalink / raw)
To: linux-kernel
The following patch sets the ref count on all pages of an
allocation. This allows an allocation with order>0 to be freed
via individual __free_page() calls within vfree().
This is important on non cache coherent processors which
have a pci_alloc_consistent/consistent_alloc() implementation
that involves creating a vmalloc area cache inhibited mapping
of allocated pages.
Because of this implementation, the implementation
of pci_free_consistent/consistent_free is done via
a vfree(). Without this patch only the first page
of the allocated memory is freed since successive pages
all have ref counts of zero.
-Matt
===== mm/page_alloc.c 1.56 vs edited =====
--- 1.56/mm/page_alloc.c Tue Aug 20 04:39:48 2002
+++ edited/mm/page_alloc.c Tue Nov 26 12:03:38 2002
@@ -203,6 +203,7 @@
struct list_head *head, *curr;
unsigned long flags;
struct page *page;
+ int i;
spin_lock_irqsave(&zone->lock, flags);
do {
@@ -224,7 +225,10 @@
page = expand(zone, page, index, order, curr_order, area);
spin_unlock_irqrestore(&zone->lock, flags);
- set_page_count(page, 1);
+ /* Set ref count on all pages */
+ for (i = 0; i < (1 << order); i++)
+ set_page_count(page+i, 1);
+
if (BAD_RANGE(zone,page))
BUG();
if (PageLRU(page))
--
Matt Porter
porter@cox.net
This is Linux Country. On a quiet night, you can hear Windows reboot.
--
Matt Porter
porter@cox.net
This is Linux Country. On a quiet night, you can hear Windows reboot.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH][2.4] update ref counts on all allocated pages
2002-11-27 0:07 [PATCH][2.4] update ref counts on all allocated pages Matt Porter
@ 2002-11-27 10:31 ` David S. Miller
2002-11-27 15:25 ` Matt Porter
0 siblings, 1 reply; 4+ messages in thread
From: David S. Miller @ 2002-11-27 10:31 UTC (permalink / raw)
To: Matt Porter; +Cc: linux-kernel
On Tue, 2002-11-26 at 16:07, Matt Porter wrote:
> The following patch sets the ref count on all pages of an
> allocation. This allows an allocation with order>0 to be freed
> via individual __free_page() calls within vfree().
If your pci_alloc_consistent implementation is doing something
strang, _it_ should be doing the per-page reference counts.
Don't make every caller eat this overhead.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH][2.4] update ref counts on all allocated pages
2002-11-27 10:31 ` David S. Miller
@ 2002-11-27 15:25 ` Matt Porter
2002-11-28 3:33 ` David S. Miller
0 siblings, 1 reply; 4+ messages in thread
From: Matt Porter @ 2002-11-27 15:25 UTC (permalink / raw)
To: David S. Miller; +Cc: Matt Porter, linux-kernel
On Wed, Nov 27, 2002 at 02:31:31AM -0800, David S. Miller wrote:
> On Tue, 2002-11-26 at 16:07, Matt Porter wrote:
> > The following patch sets the ref count on all pages of an
> > allocation. This allows an allocation with order>0 to be freed
> > via individual __free_page() calls within vfree().
>
> If your pci_alloc_consistent implementation is doing something
> strang, _it_ should be doing the per-page reference counts.
>
> Don't make every caller eat this overhead.
I'm surprised that's the recommended solution. It seems pretty
dangerous to have allocated pages in the system where the per-page
ref counts are bogus.
To clarify then, on an order>0 allocation, it is only valid/defined
to free the same order of pages. Is that a true statement? If so,
I'll submit a docs patch and adjust our our local implementation.
Thanks,
--
Matt Porter
porter@cox.net
This is Linux Country. On a quiet night, you can hear Windows reboot.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH][2.4] update ref counts on all allocated pages
2002-11-27 15:25 ` Matt Porter
@ 2002-11-28 3:33 ` David S. Miller
0 siblings, 0 replies; 4+ messages in thread
From: David S. Miller @ 2002-11-28 3:33 UTC (permalink / raw)
To: Matt Porter; +Cc: linux-kernel
On Wed, 2002-11-27 at 07:25, Matt Porter wrote:
> To clarify then, on an order>0 allocation, it is only valid/defined
> to free the same order of pages. Is that a true statement? If so,
> I'll submit a docs patch and adjust our our local implementation.
Yes, this is correct and it's what everyone does. The exceptions
mess with the page counts themselves, look at the sparc64
pmd/pte dual-page allocations for example.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2002-11-28 3:03 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-27 0:07 [PATCH][2.4] update ref counts on all allocated pages Matt Porter
2002-11-27 10:31 ` David S. Miller
2002-11-27 15:25 ` Matt Porter
2002-11-28 3:33 ` David S. Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®