Re: 4k mbuf alignment on intel?
site_archiver@lists.apple.com Delivered-To: darwin-kernel@lists.apple.com -josh On Oct 20, 2006, at 5:54 PM, Terry Lambert wrote: On Oct 20, 2006, at 10:55 AM, Andrew Gallatin wrote: 4KB mbufs has been always been aligned on 4KB boundaries on ppc. Is it true on Intel? If this is not true, how does one allocate one's own external storage in the face of the mbuf kpi? -- Terry Thanks, Drew _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-kernel mailing list (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-kernel/site_archiver%40lists.a... This email sent to site_archiver@lists.apple.com It is not possible to maintain your own buffer list and use M_EXT.. There is no way to do this using the KPI. If you absolutely need this, file a bug report and it may be considered for some future release. I'm trying to track down some weird mbuf corruption problems with my driver on mac pros, without any access to mac pro hardware. One thing that came to my mind is that I currently assume 4k mbufs as returned by mbuf_allocpacket(..4096..) are aligned on a 4k physical address boundary. If the hardware attempts a DMA across a 4K boundary, it will wrap around and scribble over the first part of the page, so this might explain the mbuf corruption. Sorry, the answer is not that easy, so you're probably going to have to chase it down; the underlying primitive is vm_allocate_page () from kernel_memory_allocate(), so it's all page aligned for this usage. You could check this relatively easily at runtime by ANDing the returned address with 0x00000fff and making sure it's 0, which I recommend if you want to reassure yourself that that's the case; however, I think you are going to have to look elsewhere for your problem. It's possible to maintain your own buffer list and use M_EXT; there are several drivers that do this internally, if they have a limited ability to address memory (e.g. if they don't implement all of the address lines, don't hook them all up, or are over a bus that doesn't support it (e.g. using a 32 bit device on a machine with more than 4G of memory, where the DMA target would be above the 4G physical memory boundary). I'm not sure if there are any public examples of drivers using this, but it's possible to do. In general, though, you will end up taking an extra copy (e.g. for pull up) if you end up triggering that code path, so you should avoid this unless you don't really have a choice in the matter. If you need to do this, FreeBSD does it exactly this same way as well (e.g. that's how "sendfile" works in FreeBSD, and I believe there are some network drivers over there that use it because of bus limits, too). _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-kernel mailing list (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-kernel/tlambert% 40apple.com This email sent to tlambert@apple.com _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-kernel mailing list (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-kernel/jgraessley% 40apple.com This email sent to jgraessley@apple.com smime.p7s
participants (1)
-
Josh Graessley