* [Xen-devel] [PATCH] AMD/IOMMU: Clean up the allocation helpers
@ 2020-02-11 11:27 Andrew Cooper
2020-02-11 11:54 ` Durrant, Paul
2020-02-12 9:28 ` Jan Beulich
0 siblings, 2 replies; 3+ messages in thread
From: Andrew Cooper @ 2020-02-11 11:27 UTC (permalink / raw)
To: Xen-devel; +Cc: Andrew Cooper, Wei Liu, Jan Beulich, Roger Pau Monné
Conform to style, drop unnecessary local variables, and avoid opencoding
clear_domain_page().
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Wei Liu <wl@xen.org>
CC: Roger Pau Monné <roger.pau@citrix.com>
Avoiding opencoding clear_domain_page() drops a surprising quantity of code.
add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-269 (-269)
Function old new delta
amd_iommu_alloc_root.part 167 116 -51
iommu_pde_from_dfn 1061 955 -106
amd_iommu_quarantine_init 694 582 -112
Total: Before=3019031, After=3018762, chg -0.01%
---
xen/drivers/passthrough/amd/iommu.h | 26 ++++++++++----------------
1 file changed, 10 insertions(+), 16 deletions(-)
diff --git a/xen/drivers/passthrough/amd/iommu.h b/xen/drivers/passthrough/amd/iommu.h
index 1abfdc685a..16af40b8cd 100644
--- a/xen/drivers/passthrough/amd/iommu.h
+++ b/xen/drivers/passthrough/amd/iommu.h
@@ -341,34 +341,28 @@ static inline unsigned long region_to_pages(unsigned long addr, unsigned long si
return (PAGE_ALIGN(addr + size) - (addr & PAGE_MASK)) >> PAGE_SHIFT;
}
-static inline struct page_info* alloc_amd_iommu_pgtable(void)
+static inline struct page_info *alloc_amd_iommu_pgtable(void)
{
- struct page_info *pg;
- void *vaddr;
-
- pg = alloc_domheap_page(NULL, 0);
- if ( pg == NULL )
- return 0;
- vaddr = __map_domain_page(pg);
- memset(vaddr, 0, PAGE_SIZE);
- unmap_domain_page(vaddr);
+ struct page_info *pg = alloc_domheap_page(NULL, 0);
+
+ if ( pg )
+ clear_domain_page(page_to_mfn(pg));
+
return pg;
}
static inline void free_amd_iommu_pgtable(struct page_info *pg)
{
- if ( pg != 0 )
+ if ( pg )
free_domheap_page(pg);
}
-static inline void* __alloc_amd_iommu_tables(int order)
+static inline void *__alloc_amd_iommu_tables(unsigned int order)
{
- void *buf;
- buf = alloc_xenheap_pages(order, 0);
- return buf;
+ return alloc_xenheap_pages(order, 0);
}
-static inline void __free_amd_iommu_tables(void *table, int order)
+static inline void __free_amd_iommu_tables(void *table, unsigned int order)
{
free_xenheap_pages(table, order);
}
--
2.11.0
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Xen-devel] [PATCH] AMD/IOMMU: Clean up the allocation helpers
2020-02-11 11:27 [Xen-devel] [PATCH] AMD/IOMMU: Clean up the allocation helpers Andrew Cooper
@ 2020-02-11 11:54 ` Durrant, Paul
2020-02-12 9:28 ` Jan Beulich
1 sibling, 0 replies; 3+ messages in thread
From: Durrant, Paul @ 2020-02-11 11:54 UTC (permalink / raw)
To: Andrew Cooper, Xen-devel; +Cc: Jan Beulich, Wei Liu, Roger Pau Monné
> -----Original Message-----
> From: Xen-devel <xen-devel-bounces@lists.xenproject.org> On Behalf Of
> Andrew Cooper
> Sent: 11 February 2020 12:27
> To: Xen-devel <xen-devel@lists.xenproject.org>
> Cc: Andrew Cooper <andrew.cooper3@citrix.com>; Wei Liu <wl@xen.org>; Jan
> Beulich <JBeulich@suse.com>; Roger Pau Monné <roger.pau@citrix.com>
> Subject: [Xen-devel] [PATCH] AMD/IOMMU: Clean up the allocation helpers
>
> Conform to style, drop unnecessary local variables, and avoid opencoding
> clear_domain_page().
>
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Paul Durrant <pdurrant@amazon.com>
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Xen-devel] [PATCH] AMD/IOMMU: Clean up the allocation helpers
2020-02-11 11:27 [Xen-devel] [PATCH] AMD/IOMMU: Clean up the allocation helpers Andrew Cooper
2020-02-11 11:54 ` Durrant, Paul
@ 2020-02-12 9:28 ` Jan Beulich
1 sibling, 0 replies; 3+ messages in thread
From: Jan Beulich @ 2020-02-12 9:28 UTC (permalink / raw)
To: Andrew Cooper; +Cc: Xen-devel, Wei Liu, Roger Pau Monné
On 11.02.2020 12:27, Andrew Cooper wrote:
> Conform to style, drop unnecessary local variables, and avoid opencoding
> clear_domain_page().
>
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-02-12 9:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-11 11:27 [Xen-devel] [PATCH] AMD/IOMMU: Clean up the allocation helpers Andrew Cooper
2020-02-11 11:54 ` Durrant, Paul
2020-02-12 9:28 ` Jan Beulich
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).