Skip to content

Commit 2fa0076

Browse files
TGSPrafaeljw
authored andcommitted
powercap: intel_rapl: Optimize rp->domains memory allocation
In the memory allocation of rp->domains in rapl_detect_domains(), there is an additional memory of struct rapl_domain allocated, optimize the code here to save sizeof(struct rapl_domain) bytes of memory. Test in Intel NUC (i5-1135G7). Signed-off-by: xiongxin <xiongxin@kylinos.cn> Tested-by: xiongxin <xiongxin@kylinos.cn> Reviewed-by: Srinivas Pandruvada<srinivas.pandruvada@linux.intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 3e767d6 commit 2fa0076

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/powercap/intel_rapl_common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1485,7 +1485,7 @@ static int rapl_detect_domains(struct rapl_package *rp)
14851485
}
14861486
pr_debug("found %d domains on %s\n", rp->nr_domains, rp->name);
14871487

1488-
rp->domains = kcalloc(rp->nr_domains + 1, sizeof(struct rapl_domain),
1488+
rp->domains = kcalloc(rp->nr_domains, sizeof(struct rapl_domain),
14891489
GFP_KERNEL);
14901490
if (!rp->domains)
14911491
return -ENOMEM;

0 commit comments

Comments
 (0)