[Xen-devel] [PATCH 3/5] arm/gnttab: Implement stub helpers as static inlines

Andrew Cooper posted 5 patches 6 years, 7 months ago
[Xen-devel] [PATCH 3/5] arm/gnttab: Implement stub helpers as static inlines
Posted by Andrew Cooper 6 years, 7 months ago
It is inefficient to call into a different translation unit for a stub
function, when a static inline will work fine.  Replace an open-coded
printk_once() while moving it.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien.grall@arm.com>
---
 xen/arch/arm/mm.c                 | 16 ----------------
 xen/include/asm-arm/grant_table.h | 17 +++++++++++++++--
 2 files changed, 15 insertions(+), 18 deletions(-)

diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
index 35dc1f7..44258ad 100644
--- a/xen/arch/arm/mm.c
+++ b/xen/arch/arm/mm.c
@@ -41,7 +41,6 @@
 #include <xen/sizes.h>
 #include <xen/libfdt/libfdt.h>
 
-#include <asm/guest_atomics.h>
 #include <asm/setup.h>
 
 /* Override macros from asm/page.h to make them work with mfn_t */
@@ -1532,21 +1531,6 @@ void put_page_type(struct page_info *page)
     return;
 }
 
-void gnttab_clear_flag(struct domain *d, unsigned long nr, uint16_t *addr)
-{
-    guest_clear_mask16(d, BIT(nr, UL), addr);
-}
-
-void gnttab_mark_dirty(struct domain *d, mfn_t mfn)
-{
-    /* XXX: mark dirty */
-    static int warning;
-    if (!warning) {
-        gdprintk(XENLOG_WARNING, "gnttab_mark_dirty not implemented yet\n");
-        warning = 1;
-    }
-}
-
 int create_grant_host_mapping(unsigned long addr, mfn_t frame,
                               unsigned int flags, unsigned int cache_flags)
 {
diff --git a/xen/include/asm-arm/grant_table.h b/xen/include/asm-arm/grant_table.h
index 1ed0aef..b0d673b 100644
--- a/xen/include/asm-arm/grant_table.h
+++ b/xen/include/asm-arm/grant_table.h
@@ -6,6 +6,8 @@
 #include <xen/pfn.h>
 #include <xen/sched.h>
 
+#include <asm/guest_atomics.h>
+
 #define INITIAL_NR_GRANT_FRAMES 1U
 #define GNTTAB_MAX_VERSION 1
 
@@ -14,13 +16,24 @@ struct grant_table_arch {
     gfn_t *status_gfn;
 };
 
-void gnttab_clear_flag(struct domain *d, unsigned long nr, uint16_t *addr);
+static inline void gnttab_clear_flag(struct domain *d,
+                                     unsigned long nr, uint16_t *addr)
+{
+    guest_clear_mask16(d, BIT(nr, UL), addr);
+}
+
+static inline void gnttab_mark_dirty(struct domain *d, mfn_t mfn)
+{
+#ifndef NDEBUG
+    printk_once(XENLOG_G_WARNING "gnttab_mark_dirty not implemented yet\n");
+#endif
+}
+
 int create_grant_host_mapping(unsigned long gpaddr, mfn_t mfn,
                               unsigned int flags, unsigned int cache_flags);
 #define gnttab_host_mapping_get_page_type(ro, ld, rd) (0)
 int replace_grant_host_mapping(unsigned long gpaddr, mfn_t mfn,
                                unsigned long new_gpaddr, unsigned int flags);
-void gnttab_mark_dirty(struct domain *d, mfn_t mfn);
 #define gnttab_release_host_mappings(domain) 1
 
 /*
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH 3/5] arm/gnttab: Implement stub helpers as static inlines
Posted by Julien Grall 6 years, 7 months ago
Hi Andrew,

On 6/21/19 10:36 AM, Andrew Cooper wrote:
> It is inefficient to call into a different translation unit for a stub
> function, when a static inline will work fine.  Replace an open-coded
> printk_once() while moving it.
> 
> No functional change.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

Acked-by: Julien Grall <julien.grall@arm.com>

Cheers,

> ---
> CC: Stefano Stabellini <sstabellini@kernel.org>
> CC: Julien Grall <julien.grall@arm.com>
> ---
>   xen/arch/arm/mm.c                 | 16 ----------------
>   xen/include/asm-arm/grant_table.h | 17 +++++++++++++++--
>   2 files changed, 15 insertions(+), 18 deletions(-)
> 
> diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
> index 35dc1f7..44258ad 100644
> --- a/xen/arch/arm/mm.c
> +++ b/xen/arch/arm/mm.c
> @@ -41,7 +41,6 @@
>   #include <xen/sizes.h>
>   #include <xen/libfdt/libfdt.h>
>   
> -#include <asm/guest_atomics.h>
>   #include <asm/setup.h>
>   
>   /* Override macros from asm/page.h to make them work with mfn_t */
> @@ -1532,21 +1531,6 @@ void put_page_type(struct page_info *page)
>       return;
>   }
>   
> -void gnttab_clear_flag(struct domain *d, unsigned long nr, uint16_t *addr)
> -{
> -    guest_clear_mask16(d, BIT(nr, UL), addr);
> -}
> -
> -void gnttab_mark_dirty(struct domain *d, mfn_t mfn)
> -{
> -    /* XXX: mark dirty */
> -    static int warning;
> -    if (!warning) {
> -        gdprintk(XENLOG_WARNING, "gnttab_mark_dirty not implemented yet\n");
> -        warning = 1;
> -    }
> -}
> -
>   int create_grant_host_mapping(unsigned long addr, mfn_t frame,
>                                 unsigned int flags, unsigned int cache_flags)
>   {
> diff --git a/xen/include/asm-arm/grant_table.h b/xen/include/asm-arm/grant_table.h
> index 1ed0aef..b0d673b 100644
> --- a/xen/include/asm-arm/grant_table.h
> +++ b/xen/include/asm-arm/grant_table.h
> @@ -6,6 +6,8 @@
>   #include <xen/pfn.h>
>   #include <xen/sched.h>
>   
> +#include <asm/guest_atomics.h>
> +
>   #define INITIAL_NR_GRANT_FRAMES 1U
>   #define GNTTAB_MAX_VERSION 1
>   
> @@ -14,13 +16,24 @@ struct grant_table_arch {
>       gfn_t *status_gfn;
>   };
>   
> -void gnttab_clear_flag(struct domain *d, unsigned long nr, uint16_t *addr);
> +static inline void gnttab_clear_flag(struct domain *d,
> +                                     unsigned long nr, uint16_t *addr)
> +{
> +    guest_clear_mask16(d, BIT(nr, UL), addr);
> +}
> +
> +static inline void gnttab_mark_dirty(struct domain *d, mfn_t mfn)
> +{
> +#ifndef NDEBUG
> +    printk_once(XENLOG_G_WARNING "gnttab_mark_dirty not implemented yet\n");
> +#endif
> +}
> +
>   int create_grant_host_mapping(unsigned long gpaddr, mfn_t mfn,
>                                 unsigned int flags, unsigned int cache_flags);
>   #define gnttab_host_mapping_get_page_type(ro, ld, rd) (0)
>   int replace_grant_host_mapping(unsigned long gpaddr, mfn_t mfn,
>                                  unsigned long new_gpaddr, unsigned int flags);
> -void gnttab_mark_dirty(struct domain *d, mfn_t mfn);
>   #define gnttab_release_host_mappings(domain) 1
>   
>   /*
> 

-- 
Julien Grall

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
[Xen-devel] Ping: [PATCH 3/5] arm/gnttab: Implement stub helpers as static inlines
Posted by Andrew Cooper 6 years, 7 months ago
On 21/06/2019 10:36, Andrew Cooper wrote:
> It is inefficient to call into a different translation unit for a stub
> function, when a static inline will work fine.  Replace an open-coded
> printk_once() while moving it.
>
> No functional change.
>
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> ---
> CC: Stefano Stabellini <sstabellini@kernel.org>
> CC: Julien Grall <julien.grall@arm.com>
> ---
>  xen/arch/arm/mm.c                 | 16 ----------------
>  xen/include/asm-arm/grant_table.h | 17 +++++++++++++++--
>  2 files changed, 15 insertions(+), 18 deletions(-)
>
> diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
> index 35dc1f7..44258ad 100644
> --- a/xen/arch/arm/mm.c
> +++ b/xen/arch/arm/mm.c
> @@ -41,7 +41,6 @@
>  #include <xen/sizes.h>
>  #include <xen/libfdt/libfdt.h>
>  
> -#include <asm/guest_atomics.h>
>  #include <asm/setup.h>
>  
>  /* Override macros from asm/page.h to make them work with mfn_t */
> @@ -1532,21 +1531,6 @@ void put_page_type(struct page_info *page)
>      return;
>  }
>  
> -void gnttab_clear_flag(struct domain *d, unsigned long nr, uint16_t *addr)
> -{
> -    guest_clear_mask16(d, BIT(nr, UL), addr);
> -}
> -
> -void gnttab_mark_dirty(struct domain *d, mfn_t mfn)
> -{
> -    /* XXX: mark dirty */
> -    static int warning;
> -    if (!warning) {
> -        gdprintk(XENLOG_WARNING, "gnttab_mark_dirty not implemented yet\n");
> -        warning = 1;
> -    }
> -}
> -
>  int create_grant_host_mapping(unsigned long addr, mfn_t frame,
>                                unsigned int flags, unsigned int cache_flags)
>  {
> diff --git a/xen/include/asm-arm/grant_table.h b/xen/include/asm-arm/grant_table.h
> index 1ed0aef..b0d673b 100644
> --- a/xen/include/asm-arm/grant_table.h
> +++ b/xen/include/asm-arm/grant_table.h
> @@ -6,6 +6,8 @@
>  #include <xen/pfn.h>
>  #include <xen/sched.h>
>  
> +#include <asm/guest_atomics.h>
> +
>  #define INITIAL_NR_GRANT_FRAMES 1U
>  #define GNTTAB_MAX_VERSION 1
>  
> @@ -14,13 +16,24 @@ struct grant_table_arch {
>      gfn_t *status_gfn;
>  };
>  
> -void gnttab_clear_flag(struct domain *d, unsigned long nr, uint16_t *addr);
> +static inline void gnttab_clear_flag(struct domain *d,
> +                                     unsigned long nr, uint16_t *addr)
> +{
> +    guest_clear_mask16(d, BIT(nr, UL), addr);
> +}
> +
> +static inline void gnttab_mark_dirty(struct domain *d, mfn_t mfn)
> +{
> +#ifndef NDEBUG
> +    printk_once(XENLOG_G_WARNING "gnttab_mark_dirty not implemented yet\n");
> +#endif
> +}
> +
>  int create_grant_host_mapping(unsigned long gpaddr, mfn_t mfn,
>                                unsigned int flags, unsigned int cache_flags);
>  #define gnttab_host_mapping_get_page_type(ro, ld, rd) (0)
>  int replace_grant_host_mapping(unsigned long gpaddr, mfn_t mfn,
>                                 unsigned long new_gpaddr, unsigned int flags);
> -void gnttab_mark_dirty(struct domain *d, mfn_t mfn);
>  #define gnttab_release_host_mappings(domain) 1
>  
>  /*


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel