Re: [PATCH v3 13/18] x86/intel_rdt: Add mkdir to resctrl file system

From: Nilay Vaish
Date: Mon Oct 10 2016 - 13:53:40 EST


On 7 October 2016 at 21:45, Fenghua Yu <fenghua.yu@xxxxxxxxx> wrote:
> From: Fenghua Yu <fenghua.yu@xxxxxxxxx>
> diff --git a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c
> index 28df92e..efcbfe7 100644
> --- a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c
> +++ b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c
> @@ -36,6 +36,52 @@ struct kernfs_root *rdt_root;
> struct rdtgroup rdtgroup_default;
> LIST_HEAD(rdt_all_groups);
>
> +/*
> + * Trivial allocator for CLOSIDs. Since h/w only supports
> + * a small number, we can keep a bitmap of free CLOSIDs in
> + * a single integer.
> + */
> +static int closid_free_map;
> +
> +static void closid_init(void)
> +{
> + closid_free_map = BIT_MASK(rdt_max_closid) - 1;
> +
> + /* CLOSID 0 is always reserved for the default group */
> + closid_free_map &= ~1;
> +}
> +
> +int closid_alloc(void)
> +{
> + int closid = ffs(closid_free_map);
> +
> + if (closid == 0)
> + return -ENOSPC;
> + closid--;
> + closid_free_map &= ~(1 << closid);
> +
> + return closid;
> +}
> +
> +static void closid_free(int closid)
> +{
> + closid_free_map |= 1 << closid;
> +}
> +
> +static struct rdtgroup *rdtgroup_alloc(void)
> +{
> + struct rdtgroup *rdtgrp;
> +
> + rdtgrp = kzalloc(sizeof(*rdtgrp), GFP_KERNEL);
> +
> + return rdtgrp;
> +}
> +
> +static void rdtgroup_free(struct rdtgroup *rdtgroup)
> +{
> + kfree(rdtgroup);
> +}

Any reason why you defined the above two functions? Why not call
kzalloc() and kfree() directly?

--
Nilay