x86/intel_rdt: Switch to bitmap_zalloc()
authorAndy Shevchenko <[email protected]>
Thu, 30 Aug 2018 11:50:39 +0000 (14:50 +0300)
committerThomas Gleixner <[email protected]>
Wed, 3 Oct 2018 19:53:49 +0000 (21:53 +0200)
Switch to bitmap_zalloc() to show clearly what is allocated. Besides that
it returns a pointer of bitmap type instead of opaque void *.

Signed-off-by: Andy Shevchenko <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
Acked-by: Fenghua Yu <[email protected]>
Cc: "H. Peter Anvin" <[email protected]>
Link: https://lkml.kernel.org/r/[email protected]
arch/x86/kernel/cpu/intel_rdt.c

index abb71ac704433cea9f2eca68b8f3ed60566c22da..1214f3f7ec6d31963920e3645f7c6ab28f958d0b 100644 (file)
@@ -485,9 +485,7 @@ static int domain_setup_mon_state(struct rdt_resource *r, struct rdt_domain *d)
        size_t tsize;
 
        if (is_llc_occupancy_enabled()) {
-               d->rmid_busy_llc = kcalloc(BITS_TO_LONGS(r->num_rmid),
-                                          sizeof(unsigned long),
-                                          GFP_KERNEL);
+               d->rmid_busy_llc = bitmap_zalloc(r->num_rmid, GFP_KERNEL);
                if (!d->rmid_busy_llc)
                        return -ENOMEM;
                INIT_DELAYED_WORK(&d->cqm_limbo, cqm_handle_limbo);
@@ -496,7 +494,7 @@ static int domain_setup_mon_state(struct rdt_resource *r, struct rdt_domain *d)
                tsize = sizeof(*d->mbm_total);
                d->mbm_total = kcalloc(r->num_rmid, tsize, GFP_KERNEL);
                if (!d->mbm_total) {
-                       kfree(d->rmid_busy_llc);
+                       bitmap_free(d->rmid_busy_llc);
                        return -ENOMEM;
                }
        }
@@ -504,7 +502,7 @@ static int domain_setup_mon_state(struct rdt_resource *r, struct rdt_domain *d)
                tsize = sizeof(*d->mbm_local);
                d->mbm_local = kcalloc(r->num_rmid, tsize, GFP_KERNEL);
                if (!d->mbm_local) {
-                       kfree(d->rmid_busy_llc);
+                       bitmap_free(d->rmid_busy_llc);
                        kfree(d->mbm_total);
                        return -ENOMEM;
                }
@@ -612,7 +610,7 @@ static void domain_remove_cpu(int cpu, struct rdt_resource *r)
 
                kfree(d->ctrl_val);
                kfree(d->mbps_val);
-               kfree(d->rmid_busy_llc);
+               bitmap_free(d->rmid_busy_llc);
                kfree(d->mbm_total);
                kfree(d->mbm_local);
                kfree(d);