Skip to contentSkip to conversation

unpaged: fix sound Bad page states

PATCH Hugh Dickins 3 participants 4 messages Nov 21, 2005

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

Earlier I unifdefed PageCompound, so that snd_pcm_mmap_control_nopage and others can give out a 0-order component of a higher-order page, which won't be mistakenly freed when zap_pte_range unmaps it. But many Bad page states reported a PG_reserved was freed after all: I had missed that we need to say __GFP_COMP to get compound page behaviour.

Some of these higher-order pages are allocated by snd_malloc_pages, some by snd_malloc_dev_pages; or if SBUS, by sbus_alloc_consistent - but that has no gfp arg, so add __GFP_COMP into its sparc32/64 implementations.

I'm still rather puzzled that DRM seems not to need a similar change.

---

 arch/sparc/kernel/ioport.c |    2 +-
 arch/sparc64/kernel/sbus.c |    2 +-
 sound/core/memalloc.c      |    2 ++
 3 files changed, 4 insertions(+), 2 deletions(-)
arch/sparc/kernel/ioport.c +1 -1
@@ -252,7 +252,7 @@ void *sbus_alloc_consistent(struct sbus_
 	}
 
 	order = get_order(len_total);
-	if ((va = __get_free_pages(GFP_KERNEL, order)) == 0)
+	if ((va = __get_free_pages(GFP_KERNEL|__GFP_COMP, order)) == 0)
 		goto err_nopages;
 
 	if ((res = kmalloc(sizeof(struct resource), GFP_KERNEL)) == NULL)
arch/sparc64/kernel/sbus.c +1 -1
@@ -327,7 +327,7 @@ void *sbus_alloc_consistent(struct sbus_
 	order = get_order(size);
 	if (order >= 10)
 		return NULL;
-	first_page = __get_free_pages(GFP_KERNEL, order);
+	first_page = __get_free_pages(GFP_KERNEL|__GFP_COMP, order);
 	if (first_page == 0UL)
 		return NULL;
 	memset((char *)first_page, 0, PAGE_SIZE << order);
sound/core/memalloc.c +2 -0
@@ -197,6 +197,7 @@ void *snd_malloc_pages(size_t size, gfp_
 
 	snd_assert(size > 0, return NULL);
 	snd_assert(gfp_flags != 0, return NULL);
+	gfp_flags |= __GFP_COMP;	/* compound page lets parts be mapped */
 	pg = get_order(size);
 	if ((res = (void *) __get_free_pages(gfp_flags, pg)) != NULL) {
 		mark_pages(virt_to_page(res), pg);
@@ -241,6 +242,7 @@ static void *snd_malloc_dev_pages(struct
 	snd_assert(dma != NULL, return NULL);
 	pg = get_order(size);
 	gfp_flags = GFP_KERNEL
+		| __GFP_COMP	/* compound page lets parts be mapped */
 		| __GFP_NORETRY /* don't trigger OOM-killer */
 		| __GFP_NOWARN; /* no stack trace print - this call is non-critical */
 	res = dma_alloc_coherent(dev, PAGE_SIZE << pg, dma, gfp_flags);
#1 lore raw
Quoted 5 lines · Hugh Dickins
  arch/sparc/kernel/ioport.c |    2 +-
  arch/sparc64/kernel/sbus.c |    2 +-
  sound/core/memalloc.c      |    2 ++
  3 files changed, 4 insertions(+), 2 deletions(-)

So with this, do you think everything is in place for a mainline merge?

-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc. Get Certified Today Register for a JBoss Training Course. Free Certification Exam for All Training Attendees Through End of 2005. For more info visit:
http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click

#2 lore raw
Quoted 8 lines · Andrew Morton
Quoted 5 lines · Hugh Dickins
  arch/sparc/kernel/ioport.c |    2 +-
  arch/sparc64/kernel/sbus.c |    2 +-
  sound/core/memalloc.c      |    2 ++
  3 files changed, 4 insertions(+), 2 deletions(-)

So with this, do you think everything is in place for a mainline merge?

Yes, I believe so: thanks.

Hugh

#3 lore raw
In reply to Hugh Dickins
Quoted 10 lines · Hugh Dickins

Earlier I unifdefed PageCompound, so that snd_pcm_mmap_control_nopage and others can give out a 0-order component of a higher-order page, which won't be mistakenly freed when zap_pte_range unmaps it. But many Bad page states reported a PG_reserved was freed after all: I had missed that we need to say __GFP_COMP to get compound page behaviour. Some of these higher-order pages are allocated by snd_malloc_pages, some by snd_malloc_dev_pages; or if SBUS, by sbus_alloc_consistent - but that has no gfp arg, so add __GFP_COMP into its sparc32/64 implementations. I'm still rather puzzled that DRM seems not to need a similar change.

-- wli