public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* pci_map_sg() does not coalesce adjacent physical memory? x86
@ 2008-11-17 21:54 Leon Woestenberg
  2008-11-18  3:15 ` Andrew Morton
  0 siblings, 1 reply; 11+ messages in thread
From: Leon Woestenberg @ 2008-11-17 21:54 UTC (permalink / raw)
  To: LKML

Hello,

pci_map_sg() does not coalesce the scattergather list for me on x86.
Is this expected? Documentation mentions that coalescing is typically
done by pci_map_sg().

Manually traversing scatterlists that describe large user space
allocations I found that on my system 25% reduction of list length can
be achieved.


static int sgm_map_to_table(struct sg_mapping_t *sgm)
{
        int i, j = 0;
        dma_addr_t addr = sg_dma_address(&sgm->sgl[0]);
        unsigned int len = sg_dma_len(&sgm->sgl[0]);
        dma_addr_t cont_addr = addr;
        unsigned int cont_len = len;
        for (i = 0; i < sgm->mapped_pages - 1; i++) {
                dma_addr_t next = sg_dma_address(&sgm->sgl[i + 1]);
                len = sg_dma_len(&sgm->sgl[i]);
                printk(KERN_DEBUG "%04d: addr=0x%08x length=0x%08x\n",
i, addr, len);
                /* page i + 1 is non-contiguous with page i? */
                if (next != addr + len) {
                        /* TODO create entry here (we could overwrite i) */
                        printk(KERN_DEBUG "%4d: cont_addr=0x%08x
cont_len=0x%08x\n",
                                j++, cont_addr, cont_len);
                        cont_addr = next;
                        cont_len = 0;
                }
                /* add page i + 1 to current contiguous block */
                cont_len += len;
                /* goto page i + 1 */
                addr = next;
        }
        /* TODO create entry here  (we could overwrite i) */
        printk(KERN_DEBUG "%04d: addr=0x%08x length=0x%08x\n", i, addr, len);
        printk(KERN_DEBUG "%4d: cont_addr=0x%08x length=0x%08x\n",
j++, cont_addr, cont_len);
}

Regards,
-- 
Leon

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

end of thread, other threads:[~2008-11-19 10:06 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-17 21:54 pci_map_sg() does not coalesce adjacent physical memory? x86 Leon Woestenberg
2008-11-18  3:15 ` Andrew Morton
2008-11-18  5:21   ` James Bottomley
2008-11-18  9:37     ` Leon Woestenberg
2008-11-19  5:19   ` FUJITA Tomonori
2008-11-19  6:22     ` Leon Woestenberg
2008-11-19  6:58       ` FUJITA Tomonori
2008-11-19  7:05         ` FUJITA Tomonori
2008-11-19  7:58         ` FUJITA Tomonori
2008-11-19  9:45           ` Leon Woestenberg
2008-11-19 10:05             ` Tejun Heo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox