Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753357AbcJJRxZ (ORCPT ); Mon, 10 Oct 2016 13:53:25 -0400 Received: from mail-it0-f65.google.com ([209.85.214.65]:33172 "EHLO mail-it0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752993AbcJJRxS (ORCPT ); Mon, 10 Oct 2016 13:53:18 -0400 MIME-Version: 1.0 In-Reply-To: <1475894763-64683-14-git-send-email-fenghua.yu@intel.com> References: <1475894763-64683-1-git-send-email-fenghua.yu@intel.com> <1475894763-64683-14-git-send-email-fenghua.yu@intel.com> From: Nilay Vaish Date: Mon, 10 Oct 2016 12:51:57 -0500 Message-ID: Subject: Re: [PATCH v3 13/18] x86/intel_rdt: Add mkdir to resctrl file system To: Fenghua Yu Cc: Thomas Gleixner , "H. Peter Anvin" , Ingo Molnar , Tony Luck , Peter Zijlstra , Stephane Eranian , Borislav Petkov , Dave Hansen , Shaohua Li , David Carrillo-Cisneros , Ravi V Shankar , Sai Prakhya , Vikas Shivappa , linux-kernel , x86 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1591 Lines: 61 On 7 October 2016 at 21:45, Fenghua Yu wrote: > From: Fenghua Yu > 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