Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

intel-iommu: Speed up map routines by using cached domain ASAP

We did before, in the end -- but it was at the bottom of a long stack of
functions. Add an inline wrapper get_valid_domain_for_dev() which will
use the cached one _first_ and only make the out-of-line call if it's
not already set.

This takes the average time taken for a 1-page intel_map_sg() from 5961
cycles to 4812 cycles on my Lenovo x200s test box -- a modest 20%.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>

+13 -2
+13 -2
drivers/pci/intel-iommu.c
··· 2455 2455 return iova; 2456 2456 } 2457 2457 2458 - static struct dmar_domain * 2459 - get_valid_domain_for_dev(struct pci_dev *pdev) 2458 + static struct dmar_domain *__get_valid_domain_for_dev(struct pci_dev *pdev) 2460 2459 { 2461 2460 struct dmar_domain *domain; 2462 2461 int ret; ··· 2481 2482 } 2482 2483 2483 2484 return domain; 2485 + } 2486 + 2487 + static inline struct dmar_domain *get_valid_domain_for_dev(struct pci_dev *dev) 2488 + { 2489 + struct device_domain_info *info; 2490 + 2491 + /* No lock here, assumes no domain exit in normal case */ 2492 + info = dev->dev.archdata.iommu; 2493 + if (likely(info)) 2494 + return info->domain; 2495 + 2496 + return __get_valid_domain_for_dev(dev); 2484 2497 } 2485 2498 2486 2499 static int iommu_dummy(struct pci_dev *pdev)