Skip to content

Commit 5848dc5

Browse files
committed
dma-debug: remove debug_dma_assert_idle() function
This remoes the code from the COW path to call debug_dma_assert_idle(), which was added many years ago. Google shows that it hasn't caught anything in the 6+ years we've had it apart from a false positive, and Hugh just noticed how it had a very unfortunate spinlock serialization in the COW path. He fixed that issue the previous commit (a85ffd5: "dma-debug: fix debug_dma_assert_idle(), use rcu_read_lock()"), but let's see if anybody even notices when we remove this function entirely. NOTE! We keep the dma tracking infrastructure that was added by the commit that introduced it. Partly to make it easier to resurrect this debug code if we ever deside to, and partly because that tracking by pfn and offset looks quite reasonable. The problem with this debug code was simply that it was expensive and didn't seem worth it, not that it was wrong per se. Acked-by: Dan Williams <[email protected]> Acked-by: Christoph Hellwig <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent a85ffd5 commit 5848dc5

File tree

4 files changed

+1
-58
lines changed

4 files changed

+1
-58
lines changed

include/linux/dma-debug.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ extern void debug_dma_sync_sg_for_device(struct device *dev,
6767

6868
extern void debug_dma_dump_mappings(struct device *dev);
6969

70-
extern void debug_dma_assert_idle(struct page *page);
71-
7270
#else /* CONFIG_DMA_API_DEBUG */
7371

7472
static inline void dma_debug_add_bus(struct bus_type *bus)
@@ -157,10 +155,6 @@ static inline void debug_dma_dump_mappings(struct device *dev)
157155
{
158156
}
159157

160-
static inline void debug_dma_assert_idle(struct page *page)
161-
{
162-
}
163-
164158
#endif /* CONFIG_DMA_API_DEBUG */
165159

166160
#endif /* __DMA_DEBUG_H */

kernel/dma/Kconfig

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,6 @@ config DMA_API_DEBUG
186186
drivers like double-freeing of DMA mappings or freeing mappings that
187187
were never allocated.
188188

189-
This also attempts to catch cases where a page owned by DMA is
190-
accessed by the cpu in a way that could cause data corruption. For
191-
example, this enables cow_user_page() to check that the source page is
192-
not undergoing DMA.
193-
194189
This option causes a performance degradation. Use only if you want to
195190
debug device drivers and dma interactions.
196191

kernel/dma/debug.c

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -448,9 +448,6 @@ void debug_dma_dump_mappings(struct device *dev)
448448
* dma_active_cacheline entry to track per event. dma_map_sg(), on the
449449
* other hand, consumes a single dma_debug_entry, but inserts 'nents'
450450
* entries into the tree.
451-
*
452-
* At any time debug_dma_assert_idle() can be called to trigger a
453-
* warning if any cachelines in the given page are in the active set.
454451
*/
455452
static RADIX_TREE(dma_active_cacheline, GFP_NOWAIT);
456453
static DEFINE_SPINLOCK(radix_lock);
@@ -497,10 +494,7 @@ static void active_cacheline_inc_overlap(phys_addr_t cln)
497494
overlap = active_cacheline_set_overlap(cln, ++overlap);
498495

499496
/* If we overflowed the overlap counter then we're potentially
500-
* leaking dma-mappings. Otherwise, if maps and unmaps are
501-
* balanced then this overflow may cause false negatives in
502-
* debug_dma_assert_idle() as the cacheline may be marked idle
503-
* prematurely.
497+
* leaking dma-mappings.
504498
*/
505499
WARN_ONCE(overlap > ACTIVE_CACHELINE_MAX_OVERLAP,
506500
pr_fmt("exceeded %d overlapping mappings of cacheline %pa\n"),
@@ -555,44 +549,6 @@ static void active_cacheline_remove(struct dma_debug_entry *entry)
555549
spin_unlock_irqrestore(&radix_lock, flags);
556550
}
557551

558-
/**
559-
* debug_dma_assert_idle() - assert that a page is not undergoing dma
560-
* @page: page to lookup in the dma_active_cacheline tree
561-
*
562-
* Place a call to this routine in cases where the cpu touching the page
563-
* before the dma completes (page is dma_unmapped) will lead to data
564-
* corruption.
565-
*/
566-
void debug_dma_assert_idle(struct page *page)
567-
{
568-
struct dma_debug_entry *entry;
569-
unsigned long pfn;
570-
phys_addr_t cln;
571-
572-
if (dma_debug_disabled())
573-
return;
574-
575-
if (!page)
576-
return;
577-
578-
pfn = page_to_pfn(page);
579-
cln = (phys_addr_t) pfn << CACHELINE_PER_PAGE_SHIFT;
580-
581-
rcu_read_lock();
582-
if (!radix_tree_gang_lookup(&dma_active_cacheline, (void **) &entry,
583-
cln, 1) || entry->pfn != pfn)
584-
entry = NULL;
585-
rcu_read_unlock();
586-
587-
if (!entry)
588-
return;
589-
590-
cln = to_cacheline_number(entry);
591-
err_printk(entry->dev, entry,
592-
"cpu touching an active dma mapped cacheline [cln=%pa]\n",
593-
&cln);
594-
}
595-
596552
/*
597553
* Wrapper function for adding an entry to the hash.
598554
* This function takes care of locking itself.

mm/memory.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2411,8 +2411,6 @@ static inline bool cow_user_page(struct page *dst, struct page *src,
24112411
struct mm_struct *mm = vma->vm_mm;
24122412
unsigned long addr = vmf->address;
24132413

2414-
debug_dma_assert_idle(src);
2415-
24162414
if (likely(src)) {
24172415
copy_user_highpage(dst, src, addr, vma);
24182416
return true;

0 commit comments

Comments
 (0)