diff mbox series

[08/11] hypfs: avoid effectively open-coding xzalloc_array()

Message ID eecf9929-30ee-424d-a371-1462c04cd382@suse.com (mailing list archive)
State Superseded
Headers show
Series assorted replacement of x[mz]alloc_bytes() | expand

Commit Message

Jan Beulich April 8, 2021, 12:21 p.m. UTC
There is a difference in generated code: xzalloc_bytes() forces
SMP_CACHE_BYTES alignment. I think we not only don't need this here, but
actually don't want it.

To avoid the need to add a cast, do away with the only forward-declared
struct hypfs_dyndata.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

Comments

Juergen Gross April 8, 2021, 2:28 p.m. UTC | #1
On 08.04.21 14:21, Jan Beulich wrote:
> There is a difference in generated code: xzalloc_bytes() forces
> SMP_CACHE_BYTES alignment. I think we not only don't need this here, but
> actually don't want it.
> 
> To avoid the need to add a cast, do away with the only forward-declared
> struct hypfs_dyndata.
> 
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Reviewed-by: Juergen Gross <jgross@suse.com>


Juergen
diff mbox series

Patch

--- a/xen/common/hypfs.c
+++ b/xen/common/hypfs.c
@@ -72,7 +72,7 @@  enum hypfs_lock_state {
     hypfs_write_locked
 };
 static DEFINE_PER_CPU(enum hypfs_lock_state, hypfs_locked);
-static DEFINE_PER_CPU(struct hypfs_dyndata *, hypfs_dyndata);
+static DEFINE_PER_CPU(void *, hypfs_dyndata);
 
 static DEFINE_PER_CPU(const struct hypfs_entry *, hypfs_last_node_entered);
 
@@ -160,19 +160,19 @@  static void node_exit_all(void)
 void *hypfs_alloc_dyndata(unsigned long size)
 {
     unsigned int cpu = smp_processor_id();
-    struct hypfs_dyndata **dyndata = &per_cpu(hypfs_dyndata, cpu);
+    void **dyndata = &per_cpu(hypfs_dyndata, cpu);
 
     ASSERT(per_cpu(hypfs_locked, cpu) != hypfs_unlocked);
     ASSERT(*dyndata == NULL);
 
-    *dyndata = xzalloc_bytes(size);
+    *dyndata = xzalloc_array(unsigned char, size);
 
     return *dyndata;
 }
 
 void *hypfs_get_dyndata(void)
 {
-    struct hypfs_dyndata *dyndata = this_cpu(hypfs_dyndata);
+    void *dyndata = this_cpu(hypfs_dyndata);
 
     ASSERT(dyndata);
 
@@ -181,7 +181,7 @@  void *hypfs_get_dyndata(void)
 
 void hypfs_free_dyndata(void)
 {
-    struct hypfs_dyndata **dyndata = &this_cpu(hypfs_dyndata);
+    void **dyndata = &this_cpu(hypfs_dyndata);
 
     XFREE(*dyndata);
 }