netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [net-next-2.6 PATCH 3/8] vxge: Align the memory only if it is misaligned.
@ 2010-03-29  8:09 Sreenivasa Honnur
  2010-03-29 23:59 ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Sreenivasa Honnur @ 2010-03-29  8:09 UTC (permalink / raw)
  To: davem; +Cc: netdev, support

- Align the memory only if it is misaligned.

Signed-off-by: Sreenivasa Honnur <sreenivasa.honnur@neterion.com>
Signed-off-by: Ramkrishna Vepa <ram.vepa@neterion.com>
---
diff -urpN patch2/drivers/net/vxge/vxge-config.h patch3/drivers/net/vxge/vxge-config.h
--- patch2/drivers/net/vxge/vxge-config.h	2010-03-19 16:08:43.000000000 +0530
+++ patch3/drivers/net/vxge/vxge-config.h	2010-03-22 12:15:04.000000000 +0530
@@ -1914,20 +1914,32 @@ static inline void *vxge_os_dma_malloc(s
 	gfp_t flags;
 	void *vaddr;
 	unsigned long misaligned = 0;
+	int realloc_flag = 0;
 	*p_dma_acch = *p_dmah = NULL;
 
 	if (in_interrupt())
 		flags = GFP_ATOMIC | GFP_DMA;
 	else
 		flags = GFP_KERNEL | GFP_DMA;
-
-	size += VXGE_CACHE_LINE_SIZE;
-
+realloc:
 	vaddr = kmalloc((size), flags);
 	if (vaddr == NULL)
 		return vaddr;
-	misaligned = (unsigned long)VXGE_ALIGN(*((u64 *)&vaddr),
+	misaligned = (unsigned long)VXGE_ALIGN((unsigned long)vaddr,
 				VXGE_CACHE_LINE_SIZE);
+	if (realloc_flag)
+		goto out;
+
+	if (misaligned) {
+		/* misaligned, free current one and try allocating
+		 * size + VXGE_CACHE_LINE_SIZE memory
+		 */
+		kfree((void *) vaddr);
+		size += VXGE_CACHE_LINE_SIZE;
+		realloc_flag = 1;
+		goto realloc;
+	}
+out:
 	*(unsigned long *)p_dma_acch = misaligned;
 	vaddr = (void *)((u8 *)vaddr + misaligned);
 	return vaddr;


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [net-next-2.6 PATCH 3/8] vxge: Align the memory only if it is misaligned.
  2010-03-29  8:09 [net-next-2.6 PATCH 3/8] vxge: Align the memory only if it is misaligned Sreenivasa Honnur
@ 2010-03-29 23:59 ` David Miller
  2010-03-30  0:04   ` Ramkrishna Vepa
  2010-04-01 22:05   ` Ramkrishna Vepa
  0 siblings, 2 replies; 4+ messages in thread
From: David Miller @ 2010-03-29 23:59 UTC (permalink / raw)
  To: Sreenivasa.Honnur; +Cc: netdev, support

From: Sreenivasa Honnur <Sreenivasa.Honnur@neterion.com>
Date: Mon, 29 Mar 2010 04:09:47 -0400 (EDT)

> - Align the memory only if it is misaligned.
> 
> Signed-off-by: Sreenivasa Honnur <sreenivasa.honnur@neterion.com>
> Signed-off-by: Ramkrishna Vepa <ram.vepa@neterion.com>

Applied, but this vxge_os_dma_malloc code is completely
unnecessary.

If you want to allocate 4K chunks and make sure they are at least 128
byte aligned, you can allocated pages (which are always PAGE_SIZE
aligned) and chop them up into the appropriate block size as needed.

This is exactly how drivers/net/niu.c handles this situation.

See drivers/net/niu.c:niu_rbr_add_page()

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [net-next-2.6 PATCH 3/8] vxge: Align the memory only if it is misaligned.
  2010-03-29 23:59 ` David Miller
@ 2010-03-30  0:04   ` Ramkrishna Vepa
  2010-04-01 22:05   ` Ramkrishna Vepa
  1 sibling, 0 replies; 4+ messages in thread
From: Ramkrishna Vepa @ 2010-03-30  0:04 UTC (permalink / raw)
  To: David Miller, Sreenivasa Honnur; +Cc: netdev, support

> From: Sreenivasa Honnur <Sreenivasa.Honnur@neterion.com>
> Date: Mon, 29 Mar 2010 04:09:47 -0400 (EDT)
> 
> > - Align the memory only if it is misaligned.
> >
> > Signed-off-by: Sreenivasa Honnur <sreenivasa.honnur@neterion.com>
> > Signed-off-by: Ramkrishna Vepa <ram.vepa@neterion.com>
> 
> Applied, but this vxge_os_dma_malloc code is completely
> unnecessary.
> 
> If you want to allocate 4K chunks and make sure they are at least 128
> byte aligned, you can allocated pages (which are always PAGE_SIZE
> aligned) and chop them up into the appropriate block size as needed.
> 
> This is exactly how drivers/net/niu.c handles this situation.
> 
> See drivers/net/niu.c:niu_rbr_add_page()
Thanks. We'll make this change.

Ram

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [net-next-2.6 PATCH 3/8] vxge: Align the memory only if it is misaligned.
  2010-03-29 23:59 ` David Miller
  2010-03-30  0:04   ` Ramkrishna Vepa
@ 2010-04-01 22:05   ` Ramkrishna Vepa
  1 sibling, 0 replies; 4+ messages in thread
From: Ramkrishna Vepa @ 2010-04-01 22:05 UTC (permalink / raw)
  To: David Miller, Sreenivasa Honnur; +Cc: netdev

> If you want to allocate 4K chunks and make sure they are at least 128
> byte aligned, you can allocated pages (which are always PAGE_SIZE
> aligned) and chop them up into the appropriate block size as needed.
> 
> This is exactly how drivers/net/niu.c handles this situation.
> 
> See drivers/net/niu.c:niu_rbr_add_page()
Thanks Dave! There's quite a bit of change required in the driver for
this. We'll submit the current set of patches we are working on and then
look into submitting this change.

Ram

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-04-01 22:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-29  8:09 [net-next-2.6 PATCH 3/8] vxge: Align the memory only if it is misaligned Sreenivasa Honnur
2010-03-29 23:59 ` David Miller
2010-03-30  0:04   ` Ramkrishna Vepa
2010-04-01 22:05   ` Ramkrishna Vepa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).