提交 1e22166c 编写于 作者: K Kyle McMartin 提交者: Kyle McMartin

parisc: unify CCIO_COLLECT_STATS implementation

Make it behave in the same manner as SBA_COLLECT_STATS, further
clean ups pending.
上级 dae2cdf3
...@@ -66,15 +66,8 @@ ...@@ -66,15 +66,8 @@
#undef DEBUG_CCIO_RUN_SG #undef DEBUG_CCIO_RUN_SG
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
/* /* depends on proc fs support. But costs CPU performance. */
* CCIO_SEARCH_TIME can help measure how fast the bitmap search is. #undef CCIO_COLLECT_STATS
* impacts performance though - ditch it if you don't use it.
*/
#define CCIO_SEARCH_TIME
#undef CCIO_MAP_STATS
#else
#undef CCIO_SEARCH_TIME
#undef CCIO_MAP_STATS
#endif #endif
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
...@@ -239,12 +232,10 @@ struct ioc { ...@@ -239,12 +232,10 @@ struct ioc {
u32 res_size; /* size of resource map in bytes */ u32 res_size; /* size of resource map in bytes */
spinlock_t res_lock; spinlock_t res_lock;
#ifdef CCIO_SEARCH_TIME #ifdef CCIO_COLLECT_STATS
#define CCIO_SEARCH_SAMPLE 0x100 #define CCIO_SEARCH_SAMPLE 0x100
unsigned long avg_search[CCIO_SEARCH_SAMPLE]; unsigned long avg_search[CCIO_SEARCH_SAMPLE];
unsigned long avg_idx; /* current index into avg_search */ unsigned long avg_idx; /* current index into avg_search */
#endif
#ifdef CCIO_MAP_STATS
unsigned long used_pages; unsigned long used_pages;
unsigned long msingle_calls; unsigned long msingle_calls;
unsigned long msingle_pages; unsigned long msingle_pages;
...@@ -351,7 +342,7 @@ ccio_alloc_range(struct ioc *ioc, struct device *dev, size_t size) ...@@ -351,7 +342,7 @@ ccio_alloc_range(struct ioc *ioc, struct device *dev, size_t size)
unsigned int pages_needed = size >> IOVP_SHIFT; unsigned int pages_needed = size >> IOVP_SHIFT;
unsigned int res_idx; unsigned int res_idx;
unsigned long boundary_size; unsigned long boundary_size;
#ifdef CCIO_SEARCH_TIME #ifdef CCIO_COLLECT_STATS
unsigned long cr_start = mfctl(16); unsigned long cr_start = mfctl(16);
#endif #endif
...@@ -406,7 +397,7 @@ ccio_alloc_range(struct ioc *ioc, struct device *dev, size_t size) ...@@ -406,7 +397,7 @@ ccio_alloc_range(struct ioc *ioc, struct device *dev, size_t size)
DBG_RES("%s() res_idx %d res_hint: %d\n", DBG_RES("%s() res_idx %d res_hint: %d\n",
__func__, res_idx, ioc->res_hint); __func__, res_idx, ioc->res_hint);
#ifdef CCIO_SEARCH_TIME #ifdef CCIO_COLLECT_STATS
{ {
unsigned long cr_end = mfctl(16); unsigned long cr_end = mfctl(16);
unsigned long tmp = cr_end - cr_start; unsigned long tmp = cr_end - cr_start;
...@@ -416,7 +407,7 @@ ccio_alloc_range(struct ioc *ioc, struct device *dev, size_t size) ...@@ -416,7 +407,7 @@ ccio_alloc_range(struct ioc *ioc, struct device *dev, size_t size)
ioc->avg_search[ioc->avg_idx++] = cr_start; ioc->avg_search[ioc->avg_idx++] = cr_start;
ioc->avg_idx &= CCIO_SEARCH_SAMPLE - 1; ioc->avg_idx &= CCIO_SEARCH_SAMPLE - 1;
#endif #endif
#ifdef CCIO_MAP_STATS #ifdef CCIO_COLLECT_STATS
ioc->used_pages += pages_needed; ioc->used_pages += pages_needed;
#endif #endif
/* /*
...@@ -452,7 +443,7 @@ ccio_free_range(struct ioc *ioc, dma_addr_t iova, unsigned long pages_mapped) ...@@ -452,7 +443,7 @@ ccio_free_range(struct ioc *ioc, dma_addr_t iova, unsigned long pages_mapped)
DBG_RES("%s(): res_idx: %d pages_mapped %d\n", DBG_RES("%s(): res_idx: %d pages_mapped %d\n",
__func__, res_idx, pages_mapped); __func__, res_idx, pages_mapped);
#ifdef CCIO_MAP_STATS #ifdef CCIO_COLLECT_STATS
ioc->used_pages -= pages_mapped; ioc->used_pages -= pages_mapped;
#endif #endif
...@@ -764,7 +755,7 @@ ccio_map_single(struct device *dev, void *addr, size_t size, ...@@ -764,7 +755,7 @@ ccio_map_single(struct device *dev, void *addr, size_t size,
size = ALIGN(size + offset, IOVP_SIZE); size = ALIGN(size + offset, IOVP_SIZE);
spin_lock_irqsave(&ioc->res_lock, flags); spin_lock_irqsave(&ioc->res_lock, flags);
#ifdef CCIO_MAP_STATS #ifdef CCIO_COLLECT_STATS
ioc->msingle_calls++; ioc->msingle_calls++;
ioc->msingle_pages += size >> IOVP_SHIFT; ioc->msingle_pages += size >> IOVP_SHIFT;
#endif #endif
...@@ -828,7 +819,7 @@ ccio_unmap_single(struct device *dev, dma_addr_t iova, size_t size, ...@@ -828,7 +819,7 @@ ccio_unmap_single(struct device *dev, dma_addr_t iova, size_t size,
spin_lock_irqsave(&ioc->res_lock, flags); spin_lock_irqsave(&ioc->res_lock, flags);
#ifdef CCIO_MAP_STATS #ifdef CCIO_COLLECT_STATS
ioc->usingle_calls++; ioc->usingle_calls++;
ioc->usingle_pages += size >> IOVP_SHIFT; ioc->usingle_pages += size >> IOVP_SHIFT;
#endif #endif
...@@ -894,7 +885,7 @@ ccio_free_consistent(struct device *dev, size_t size, void *cpu_addr, ...@@ -894,7 +885,7 @@ ccio_free_consistent(struct device *dev, size_t size, void *cpu_addr,
*/ */
#define PIDE_FLAG 0x80000000UL #define PIDE_FLAG 0x80000000UL
#ifdef CCIO_MAP_STATS #ifdef CCIO_COLLECT_STATS
#define IOMMU_MAP_STATS #define IOMMU_MAP_STATS
#endif #endif
#include "iommu-helpers.h" #include "iommu-helpers.h"
...@@ -938,7 +929,7 @@ ccio_map_sg(struct device *dev, struct scatterlist *sglist, int nents, ...@@ -938,7 +929,7 @@ ccio_map_sg(struct device *dev, struct scatterlist *sglist, int nents,
spin_lock_irqsave(&ioc->res_lock, flags); spin_lock_irqsave(&ioc->res_lock, flags);
#ifdef CCIO_MAP_STATS #ifdef CCIO_COLLECT_STATS
ioc->msg_calls++; ioc->msg_calls++;
#endif #endif
...@@ -997,13 +988,13 @@ ccio_unmap_sg(struct device *dev, struct scatterlist *sglist, int nents, ...@@ -997,13 +988,13 @@ ccio_unmap_sg(struct device *dev, struct scatterlist *sglist, int nents,
DBG_RUN_SG("%s() START %d entries, %08lx,%x\n", DBG_RUN_SG("%s() START %d entries, %08lx,%x\n",
__func__, nents, sg_virt_addr(sglist), sglist->length); __func__, nents, sg_virt_addr(sglist), sglist->length);
#ifdef CCIO_MAP_STATS #ifdef CCIO_COLLECT_STATS
ioc->usg_calls++; ioc->usg_calls++;
#endif #endif
while(sg_dma_len(sglist) && nents--) { while(sg_dma_len(sglist) && nents--) {
#ifdef CCIO_MAP_STATS #ifdef CCIO_COLLECT_STATS
ioc->usg_pages += sg_dma_len(sglist) >> PAGE_SHIFT; ioc->usg_pages += sg_dma_len(sglist) >> PAGE_SHIFT;
#endif #endif
ccio_unmap_single(dev, sg_dma_address(sglist), ccio_unmap_single(dev, sg_dma_address(sglist),
...@@ -1048,7 +1039,7 @@ static int ccio_proc_info(struct seq_file *m, void *p) ...@@ -1048,7 +1039,7 @@ static int ccio_proc_info(struct seq_file *m, void *p)
len += seq_printf(m, "IO PDIR size : %d bytes (%d entries)\n", len += seq_printf(m, "IO PDIR size : %d bytes (%d entries)\n",
total_pages * 8, total_pages); total_pages * 8, total_pages);
#ifdef CCIO_MAP_STATS #ifdef CCIO_COLLECT_STATS
len += seq_printf(m, "IO PDIR entries : %ld free %ld used (%d%%)\n", len += seq_printf(m, "IO PDIR entries : %ld free %ld used (%d%%)\n",
total_pages - ioc->used_pages, ioc->used_pages, total_pages - ioc->used_pages, ioc->used_pages,
(int)(ioc->used_pages * 100 / total_pages)); (int)(ioc->used_pages * 100 / total_pages));
...@@ -1057,7 +1048,7 @@ static int ccio_proc_info(struct seq_file *m, void *p) ...@@ -1057,7 +1048,7 @@ static int ccio_proc_info(struct seq_file *m, void *p)
len += seq_printf(m, "Resource bitmap : %d bytes (%d pages)\n", len += seq_printf(m, "Resource bitmap : %d bytes (%d pages)\n",
ioc->res_size, total_pages); ioc->res_size, total_pages);
#ifdef CCIO_SEARCH_TIME #ifdef CCIO_COLLECT_STATS
min = max = ioc->avg_search[0]; min = max = ioc->avg_search[0];
for(j = 0; j < CCIO_SEARCH_SAMPLE; ++j) { for(j = 0; j < CCIO_SEARCH_SAMPLE; ++j) {
avg += ioc->avg_search[j]; avg += ioc->avg_search[j];
...@@ -1070,7 +1061,7 @@ static int ccio_proc_info(struct seq_file *m, void *p) ...@@ -1070,7 +1061,7 @@ static int ccio_proc_info(struct seq_file *m, void *p)
len += seq_printf(m, " Bitmap search : %ld/%ld/%ld (min/avg/max CPU Cycles)\n", len += seq_printf(m, " Bitmap search : %ld/%ld/%ld (min/avg/max CPU Cycles)\n",
min, avg, max); min, avg, max);
#endif #endif
#ifdef CCIO_MAP_STATS #ifdef CCIO_COLLECT_STATS
len += seq_printf(m, "pci_map_single(): %8ld calls %8ld pages (avg %d/1000)\n", len += seq_printf(m, "pci_map_single(): %8ld calls %8ld pages (avg %d/1000)\n",
ioc->msingle_calls, ioc->msingle_pages, ioc->msingle_calls, ioc->msingle_pages,
(int)((ioc->msingle_pages * 1000)/ioc->msingle_calls)); (int)((ioc->msingle_pages * 1000)/ioc->msingle_calls));
...@@ -1088,7 +1079,7 @@ static int ccio_proc_info(struct seq_file *m, void *p) ...@@ -1088,7 +1079,7 @@ static int ccio_proc_info(struct seq_file *m, void *p)
len += seq_printf(m, "pci_unmap_sg() : %8ld calls %8ld pages (avg %d/1000)\n\n\n", len += seq_printf(m, "pci_unmap_sg() : %8ld calls %8ld pages (avg %d/1000)\n\n\n",
ioc->usg_calls, ioc->usg_pages, ioc->usg_calls, ioc->usg_pages,
(int)((ioc->usg_pages * 1000)/ioc->usg_calls)); (int)((ioc->usg_pages * 1000)/ioc->usg_calls));
#endif /* CCIO_MAP_STATS */ #endif /* CCIO_COLLECT_STATS */
ioc = ioc->next; ioc = ioc->next;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册