[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 05/11] x86/oprofile: avoid effectively open-coding xmalloc_array()



There is a difference in generated code: xmalloc_bytes() forces
SMP_CACHE_BYTES alignment. I think we not only don't need this here, but
actually don't want it.

While at it also use XFREE() instead of open-coding it and change loop
induction variable types.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>

--- a/xen/arch/x86/oprofile/nmi_int.c
+++ b/xen/arch/x86/oprofile/nmi_int.c
@@ -142,30 +142,29 @@ static void nmi_save_registers(void * du
 
 static void free_msrs(void)
 {
-       int i;
+       unsigned int i;
+
        for (i = 0; i < nr_cpu_ids; ++i) {
-               xfree(cpu_msrs[i].counters);
-               cpu_msrs[i].counters = NULL;
-               xfree(cpu_msrs[i].controls);
-               cpu_msrs[i].controls = NULL;
+               XFREE(cpu_msrs[i].counters);
+               XFREE(cpu_msrs[i].controls);
        }
 }
 
 
 static int allocate_msrs(void)
 {
+       unsigned int i;
        int success = 1;
-       size_t controls_size = sizeof(struct op_msr) * model->num_controls;
-       size_t counters_size = sizeof(struct op_msr) * model->num_counters;
 
-       int i;
        for_each_online_cpu (i) {
-               cpu_msrs[i].counters = xmalloc_bytes(counters_size);
+               cpu_msrs[i].counters = xmalloc_array(struct op_msr,
+                                                    model->num_counters);
                if (!cpu_msrs[i].counters) {
                        success = 0;
                        break;
                }
-               cpu_msrs[i].controls = xmalloc_bytes(controls_size);
+               cpu_msrs[i].controls = xmalloc_array(struct op_msr,
+                                                    model->num_controls);
                if (!cpu_msrs[i].controls) {
                        success = 0;
                        break;




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.