agp: don't lock pages
PATCH 1/1 agp: don't lock pages
Hi,
Does this patch solve the X problem? Does anyone see anything wrong with it or know why agp was locking the pages?
--
AGP should not need to lock pages. They are not protecting any race because there is no lock_page calls, only SetPageLocked.
This is causing hangs with d00806b183152af6d24f46f0c33f14162ca1262a.
drivers/char/agp/generic.c +0 -2
@@ -1170,7 +1170,6 @@ void *agp_generic_alloc_page(struct agp_map_page_into_agp (page);get_page (page); -SetPageLocked (page);atomic_inc (&agp_bridge->current_memory_agp);return page_address (page); }
@@ -1187,7 +1186,6 @@ void agp_generic_destroy_page(void *addr page =virt_to_page (addr);unmap_page_from_agp (page);put_page (page); -unlock_page (page);free_page ((unsigned long )addr);atomic_dec (&agp_bridge->current_memory_agp); }
drivers/char/agp/intel-agp.c +0 -2
@@ -213,7 +213,6 @@ static void *i8xx_alloc_pages(void) }global_flush_tlb ();get_page (page); -SetPageLocked (page);atomic_inc (&agp_bridge->current_memory_agp);return page_address (page); }
@@ -229,7 +228,6 @@ static void i8xx_destroy_pages(void *addchange_page_attr (page,4 ,PAGE_KERNEL );global_flush_tlb ();put_page (page); -unlock_page (page);__free_pages (page,2 );atomic_dec (&agp_bridge->current_memory_agp); }
drivers/char/agp/sgi-agp.c +0 -1
@@ -51,7 +51,6 @@ static void *sgi_tioca_alloc_page(structreturn NULL ;get_page (page); -SetPageLocked (page);atomic_inc (&agp_bridge->current_memory_agp);return page_address (page); }
Quoted 4 lines · Nick Piggin
Hi,
Does this patch solve the X problem? Does anyone see anything wrong with it or know why agp was locking the pages?
Yeap the mac mini is happy again
Thanks
Quoted 66 lines
--
AGP should not need to lock pages. They are not protecting any race because there is nolock_pagecalls, only SetPageLocked.This is causing hangs with
d00806b183152af6d24f46f0c33f14162ca1262a.Signed-off-by Nick Piggin <[email protected]>drivers/char/agp/generic.c +0
-2@@ -1170,7 +1170,6 @@ void *agp_generic_alloc_page(struct agp_map_page_into_agp (page);get_page (page); -SetPageLocked (page);atomic_inc (&agp_bridge->current_memory_agp);return page_address (page); }@@ -1187,7 +1186,6 @@ void agp_generic_destroy_page(void *addr page =virt_to_page (addr);unmap_page_from_agp (page);put_page (page); -unlock_page (page);free_page ((unsigned long )addr);atomic_dec (&agp_bridge->current_memory_agp); }drivers/char/agp/intel-agp.c +0
-2@@ -213,7 +213,6 @@ static void *i8xx_alloc_pages(void) }global_flush_tlb ();get_page (page); -SetPageLocked (page);atomic_inc (&agp_bridge->current_memory_agp);return page_address (page); }@@ -229,7 +228,6 @@ static void i8xx_destroy_pages(void *addchange_page_attr (page,4 ,PAGE_KERNEL );global_flush_tlb ();put_page (page); -unlock_page (page);__free_pages (page,2 );atomic_dec (&agp_bridge->current_memory_agp); }drivers/char/agp/sgi-agp.c +0
-2@@ -51,7 +51,6 @@ static void *sgi_tioca_alloc_page(structreturn NULL ;get_page (page); -SetPageLocked (page);atomic_inc (&agp_bridge->current_memory_agp);return page_address (page); } -To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Quoted 4 lines · Nick Piggin
Hi,
Does this patch solve the X problem? Does anyone see anything wrong with it or know why agp was locking the pages?
We need to do a little bit of auditing here, but I suspect it will turn out all right. I think the reason it locked them in the first place was to avoid AGP pages mapped into process space from being swapped out.
I think that should be taken care of by appropriate vma flags nowadays, but we need to double check. It also might have been a way around dodgy refcounting at one point but I think we got that right nowadays (I remember fixing issues in that area when we removed PageReserved from those pages back then).
Ben.
Quoted 60 lines
--
AGP should not need to lock pages. They are not protecting any race because there is nolock_pagecalls, only SetPageLocked.This is causing hangs with
d00806b183152af6d24f46f0c33f14162ca1262a.Signed-off-by Nick Piggin <[email protected]>drivers/char/agp/generic.c +0
-2@@ -1170,7 +1170,6 @@ void *agp_generic_alloc_page(struct agp_map_page_into_agp (page);get_page (page); -SetPageLocked (page);atomic_inc (&agp_bridge->current_memory_agp);return page_address (page); }@@ -1187,7 +1186,6 @@ void agp_generic_destroy_page(void *addr page =virt_to_page (addr);unmap_page_from_agp (page);put_page (page); -unlock_page (page);free_page ((unsigned long )addr);atomic_dec (&agp_bridge->current_memory_agp); }drivers/char/agp/intel-agp.c +0
-2@@ -213,7 +213,6 @@ static void *i8xx_alloc_pages(void) }global_flush_tlb ();get_page (page); -SetPageLocked (page);atomic_inc (&agp_bridge->current_memory_agp);return page_address (page); }@@ -229,7 +228,6 @@ static void i8xx_destroy_pages(void *addchange_page_attr (page,4 ,PAGE_KERNEL );global_flush_tlb ();put_page (page); -unlock_page (page);__free_pages (page,2 );atomic_dec (&agp_bridge->current_memory_agp); }drivers/char/agp/sgi-agp.c +0
-1@@ -51,7 +51,6 @@ static void *sgi_tioca_alloc_page(structreturn NULL ;get_page (page); -SetPageLocked (page);atomic_inc (&agp_bridge->current_memory_agp);return page_address (page); }
[forgot to cc Dave Jones...]
Quoted 10 lines · Benjamin Herrenschmidt
Quoted 4 lines · Nick Piggin
Hi,
Does this patch solve the X problem? Does anyone see anything wrong with it or know why agp was locking the pages?
We need to do a little bit of auditing here, but I suspect it will turn out all right. I think the reason it locked them in the first place was to avoid AGP pages mapped into process space from being swapped out.
Quoted 5 lines
I think that should be taken care of by appropriate vma flags nowadays, but we need to double check. It also might have been a way around dodgy refcounting at one point but I think we got that right nowadays (I remember fixing issues in that area when we removed PageReserved from those pages back then).
Yeah I had a bit of a look around, and it seems OK (but would appreciate an ack from someone who knows the code).
These pages will never get seen by page reclaim, so we're OK there. There is a get_page before the SetPageLocked and a put_page right before the unlock_page, so refcounting should not be broken if it wasn't already: note that the lock_page doesn't pin a reference on a page in general -- we can use it as such for pagecache (although it isn't very clean), because the lock pins the page in pagecache and the pagecache holds a ref.
Anyway, if Dave or David can take a look, that would be appreciated. We'll need this for 2.6.23.
Nick
Quoted 63 lines
Ben.
Quoted 60 lines
--
AGP should not need to lock pages. They are not protecting any race because there is nolock_pagecalls, only SetPageLocked.This is causing hangs with
d00806b183152af6d24f46f0c33f14162ca1262a.Signed-off-by Nick Piggin <[email protected]>drivers/char/agp/generic.c +0
-2@@ -1170,7 +1170,6 @@ void *agp_generic_alloc_page(struct agp_map_page_into_agp (page);get_page (page); -SetPageLocked (page);atomic_inc (&agp_bridge->current_memory_agp);return page_address (page); }@@ -1187,7 +1186,6 @@ void agp_generic_destroy_page(void *addr page =virt_to_page (addr);unmap_page_from_agp (page);put_page (page); -unlock_page (page);free_page ((unsigned long )addr);atomic_dec (&agp_bridge->current_memory_agp); }drivers/char/agp/intel-agp.c +0
-2@@ -213,7 +213,6 @@ static void *i8xx_alloc_pages(void) }global_flush_tlb ();get_page (page); -SetPageLocked (page);atomic_inc (&agp_bridge->current_memory_agp);return page_address (page); }@@ -229,7 +228,6 @@ static void i8xx_destroy_pages(void *addchange_page_attr (page,4 ,PAGE_KERNEL );global_flush_tlb ();put_page (page); -unlock_page (page);__free_pages (page,2 );atomic_dec (&agp_bridge->current_memory_agp); }drivers/char/agp/sgi-agp.c +0
-1@@ -51,7 +51,6 @@ static void *sgi_tioca_alloc_page(structreturn NULL ;get_page (page); -SetPageLocked (page);atomic_inc (&agp_bridge->current_memory_agp);return page_address (page); }
[one more try]
Quoted 99 lines · Nick Piggin
[forgot to cc Dave Jones...]
Quoted 10 lines · Benjamin Herrenschmidt
Quoted 4 lines · Nick Piggin
Hi,
Does this patch solve the X problem? Does anyone see anything wrong with it or know why agp was locking the pages?
We need to do a little bit of auditing here, but I suspect it will turn out all right. I think the reason it locked them in the first place was to avoid AGP pages mapped into process space from being swapped out.
Quoted 5 lines
I think that should be taken care of by appropriate vma flags nowadays, but we need to double check. It also might have been a way around dodgy refcounting at one point but I think we got that right nowadays (I remember fixing issues in that area when we removed PageReserved from those pages back then).
Yeah I had a bit of a look around, and it seems OK (but would appreciate an ack from someone who knows the code).
These pages will never get seen by page reclaim, so we're OK there. There is a
get_pagebefore the SetPageLocked and aput_pageright before theunlock_page, so refcounting should not be broken if it wasn't already: note that thelock_pagedoesn't pin a reference on a page in general -- we can use it as such for pagecache (although it isn't very clean), because the lock pins the page in pagecache and the pagecache holds a ref.Anyway, if Dave or David can take a look, that would be appreciated. We'll need this for 2.6.23.
Nick
Quoted 63 lines
Ben.
Quoted 60 lines
--
AGP should not need to lock pages. They are not protecting any race because there is nolock_pagecalls, only SetPageLocked.This is causing hangs with
d00806b183152af6d24f46f0c33f14162ca1262a.Signed-off-by Nick Piggin <[email protected]>drivers/char/agp/generic.c +0
-2@@ -1170,7 +1170,6 @@ void *agp_generic_alloc_page(struct agp_map_page_into_agp (page);get_page (page); -SetPageLocked (page);atomic_inc (&agp_bridge->current_memory_agp);return page_address (page); }@@ -1187,7 +1186,6 @@ void agp_generic_destroy_page(void *addr page =virt_to_page (addr);unmap_page_from_agp (page);put_page (page); -unlock_page (page);free_page ((unsigned long )addr);atomic_dec (&agp_bridge->current_memory_agp); }drivers/char/agp/intel-agp.c +0
-2@@ -213,7 +213,6 @@ static void *i8xx_alloc_pages(void) }global_flush_tlb ();get_page (page); -SetPageLocked (page);atomic_inc (&agp_bridge->current_memory_agp);return page_address (page); }@@ -229,7 +228,6 @@ static void i8xx_destroy_pages(void *addchange_page_attr (page,4 ,PAGE_KERNEL );global_flush_tlb ();put_page (page); -unlock_page (page);__free_pages (page,2 );atomic_dec (&agp_bridge->current_memory_agp); }drivers/char/agp/sgi-agp.c +0
-1@@ -51,7 +51,6 @@ static void *sgi_tioca_alloc_page(structreturn NULL ;get_page (page); -SetPageLocked (page);atomic_inc (&agp_bridge->current_memory_agp);return page_address (page); }
Quoted 29 lines · Benjamin Herrenschmidt
Quoted 10 lines · Nick Piggin
Quoted 4 lines
Hi,
Does this patch solve the X problem? Does anyone see anything wrong with it or know why agp was locking the pages?
We need to do a little bit of auditing here, but I suspect it will turn out all right. I think the reason it locked them in the first place was to avoid AGP pages mapped into process space from being swapped out.
Quoted 5 lines
I think that should be taken care of by appropriate vma flags nowadays, but we need to double check. It also might have been a way around dodgy refcounting at one point but I think we got that right nowadays (I remember fixing issues in that area when we removed PageReserved from those pages back then).
Yeah I had a bit of a look around, and it seems OK (but would appreciate an ack from someone who knows the code).
These pages will never get seen by page reclaim, so we're OK there. There is a
get_pagebefore the SetPageLocked and aput_pageright before theunlock_page, so refcounting should not be broken if it wasn't already: note that thelock_pagedoesn't pin a reference on a page in general -- we can use it as such for pagecache (although it isn't very clean), because the lock pins the page in pagecache and the pagecache holds a ref.
Quoted 2 lines
Anyway, if Dave or David can take a look, that would be appreciated. We'll need this for 2.6.23.
I talked with Ben earlier and I can't see anything inherently wrong with removing the lock_page, I assume it was put there to stop things getting swapped but if the get/put does that then I'd be happy to remove it.
I'm just a bit confused how this didn't get picked up in -mm at all.
Dave.
Quoted 12 lines · Dave Airlie
Quoted 12 lines
Yeah I had a bit of a look around, and it seems OK (but would appreciate an ack from someone who knows the code).
These pages will never get seen by page reclaim, so we're OK there. There is a
get_pagebefore the SetPageLocked and aput_pageright before theunlock_page, so refcounting should not be broken if it wasn't already: note that thelock_pagedoesn't pin a reference on a page in general -- we can use it as such for pagecache (although it isn't very clean), because the lock pins the page in pagecache and the pagecache holds a ref.
Quoted 7 lines
Quoted 2 lines
Anyway, if Dave or David can take a look, that would be appreciated. We'll need this for 2.6.23.
I talked with Ben earlier and I can't see anything inherently wrong with removing the
lock_page, I assume it was put there to stop things getting swapped but if the get/put does that then I'd be happy to remove it.
Well it is prevented from being swapped out because it never gets put on swapout lists, but the get/put certainly doesn't hurt :)
Quoted 1 line
I'm just a bit confused how this didn't get picked up in -mm at all.
Beats me. It was in there for nearly 5 months. Mustn't have been tested or reported.