Re: [PATCH 03/10] x86: add initialization code for DMA-API debugging

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Ingo Molnar
Date: Friday, November 21, 2008 - 10:43 am

* Joerg Roedel <joerg.roedel@amd.com> wrote:


some more generic comments about the data structure: it's main purpose 
is to provide a mapping based on (dev,addr). There's little if any 
cross-entry interaction - same-address+same-dev DMA is checked.

1)

the hash:

+ 	return (entry->dev_addr >> HASH_FN_SHIFT) & HASH_FN_MASK;

should mix in entry->dev as well - that way we get not just per 
address but per device hash space separation as well.

2)

HASH_FN_SHIFT is 1MB chunks right now - that's probably fine in 
practice albeit perhaps a bit too small. There's seldom any coherency 
between the physical addresses of DMA - we rarely have any real 
(performance-relevant) physical co-location of DMA addresses beyond 4K 
granularity. So using 1MB chunking here will discard a good deal of 
random low bits we should be hashing on.

3)

And the most scalable locking would be per hash bucket locking - no 
global lock is needed. The bucket hash heads should probably be 
cacheline sized - so we'd get one lock per bucket.

This way if there's irq+DMA traffic on one CPU from one device into 
one range of memory, and irq+DMA traffic on another CPU to another 
device, they will map to two different hash buckets.

4)

Plus it might be an option to make hash lookup lockless as well: 
depending on the DMA flux we can get a lot of lookups, and taking the 
bucket lock can be avoided, if you use RCU-safe list ops and drive the 
refilling of the free entries pool from RCU.

	Ingo
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 0/10] DMA-API debugging facility, Joerg Roedel, (Fri Nov 21, 9:26 am)
[PATCH 06/10] x86: add check code for map/unmap_sg code, Joerg Roedel, (Fri Nov 21, 9:26 am)
[PATCH 08/10] x86: add checks for sync_single* code, Joerg Roedel, (Fri Nov 21, 9:26 am)
[PATCH 10/10] x86: add checks for sync_sg* code, Joerg Roedel, (Fri Nov 21, 9:26 am)
Re: [PATCH 0/10] DMA-API debugging facility, Ingo Molnar, (Fri Nov 21, 9:37 am)
Re: [PATCH 0/10] DMA-API debugging facility, Joerg Roedel, (Fri Nov 21, 9:40 am)
Re: [PATCH 0/10] DMA-API debugging facility, Joerg Roedel, (Fri Nov 21, 9:52 am)
Re: [PATCH 0/10] DMA-API debugging facility, David Woodhouse, (Fri Nov 21, 9:54 am)
Re: [PATCH 0/10] DMA-API debugging facility, Joerg Roedel, (Fri Nov 21, 9:57 am)
Re: [PATCH 10/10] x86: add checks for sync_sg* code, Ingo Molnar, (Fri Nov 21, 9:59 am)
Re: [PATCH 0/10] DMA-API debugging facility, Ingo Molnar, (Fri Nov 21, 10:03 am)
Re: [PATCH 0/10] DMA-API debugging facility, David Woodhouse, (Fri Nov 21, 10:06 am)
Re: [PATCH 0/10] DMA-API debugging facility, Ingo Molnar, (Fri Nov 21, 10:18 am)
Re: [PATCH 0/10] DMA-API debugging facility, Joerg Roedel, (Fri Nov 21, 10:20 am)
Re: [PATCH 0/10] DMA-API debugging facility, David Woodhouse, (Fri Nov 21, 10:22 am)
Re: [PATCH 0/10] DMA-API debugging facility, David Woodhouse, (Fri Nov 21, 10:24 am)
Re: [PATCH 0/10] DMA-API debugging facility, Joerg Roedel, (Fri Nov 21, 10:27 am)
Re: [PATCH 03/10] x86: add initialization code for DMA-API ..., Ingo Molnar, (Fri Nov 21, 10:43 am)
Re: [PATCH 0/10] DMA-API debugging facility, Ingo Molnar, (Fri Nov 21, 10:45 am)
Re: [PATCH 0/10] DMA-API debugging facility, FUJITA Tomonori, (Fri Nov 21, 8:27 pm)
Re: [PATCH 0/10] DMA-API debugging facility, FUJITA Tomonori, (Fri Nov 21, 8:27 pm)
Re: [PATCH 0/10] DMA-API debugging facility, Joerg Roedel, (Sat Nov 22, 2:29 am)
Re: [PATCH 0/10] DMA-API debugging facility, Joerg Roedel, (Sat Nov 22, 2:33 am)
Re: [PATCH 0/10] DMA-API debugging facility, FUJITA Tomonori, (Sat Nov 22, 3:16 am)