Date: Wed, 12 Feb 2014 02:02:01 +0000 From: "Gumpula, Suresh" <Suresh.Gumpula@netapp.com> To: "freebsd-hackers@freebsd.org" <freebsd-hackers@freebsd.org> Subject: malloc(9) and its alignment Message-ID: <D29CB80EBA4DEA4D91181928AAF51538438EED0A@SACEXCMBX04-PRD.hq.netapp.com>
next in thread | raw e-mail | index | archive | help
Hi, It appears the malloc(9) returns 8 byte aligned ( UMA_ALIGN_PTR) pointers,= but in bus_dmamem_alloc we might end up checking for greater alignment if we take malloc(9) path instead contig_malloc. Can someone please confirm if malloc(9) returns different alignment pointer= s ? bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags, bus_dmamap_t *mapp) { /* * XXX: * (dmat->alignment < dmat->maxsize) is just a quick hack; the exac= t * alignment guarantees of malloc need to be nailed down, and the * code below should be rewritten to take that into account. * * In the meantime, we'll warn the user if malloc gets it wrong. */ if ((dmat->maxsize <=3D PAGE_SIZE) && (dmat->alignment < dmat->maxsize) && dmat->lowaddr >=3D ptoa((vm_paddr_t)Maxmem)) { *vaddr =3D malloc(dmat->maxsize, M_DEVBUF, mflags); } else { *vaddr =3D contigmalloc(dmat->maxsize, M_DEVBUF, mflags, 0ul, dmat->lowaddr, dmat->alignment? dmat->alignment : = 1ul, dmat->boundary); }=20 if (vtophys(*vaddr) & (dmat->alignment - 1)) { NETAPP_MUTED_PRINTF("bus_dmamem_alloc failed to align memor= y properly.\n"); Regards, Suresh
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?D29CB80EBA4DEA4D91181928AAF51538438EED0A>