linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paul Moore <paul@paul-moore.com>
To: "이준일/연구원/MC연구소 BSP실 BSP6팀(junil0814.lee@lge.com)"
	<junil0814.lee@lge.com>
Cc: Stephen Smalley <sds@tycho.nsa.gov>,
	Eric Paris <eparis@parisplace.org>,
	James Morris <james.l.morris@oracle.com>,
	serge@hallyn.com, william.c.roberts@intel.com,
	adobriyan@gmail.com, akpm@linux-foundation.org,
	dledford@redhat.com, danielj@mellanox.com, mka@chromium.org,
	selinux@tycho.nsa.gov, linux-security-module@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] security: selinux: use kmem_cache for ebitmap
Date: Wed, 7 Jun 2017 09:50:24 -0400	[thread overview]
Message-ID: <CAHC9VhTU9fgZxfeyo_ViPcdEONxYaBxnMGCgM8yb35-52CBNtw@mail.gmail.com> (raw)
In-Reply-To: <872857aa-7587-79a9-cf31-4508eacdb3f7@lge.com>

On Tue, Jun 6, 2017 at 7:38 PM, 이준일/연구원/MC연구소 BSP실
BSP6팀(junil0814.lee@lge.com) <junil0814.lee@lge.com> wrote:
> Paul Moore wrote on 2017-06-06 오전 6:39:
>> On Mon, Jun 5, 2017 at 5:10 AM, Junil Lee <junil0814.lee@lge.com> wrote:
>>> The allocated size for each ebitmap_node is 192byte by kzalloc().
>>> Then, ebitmap_node size is fixed, so it's possible to use only 144byte
>>> for each object by kmem_cache_zalloc().
>>> It can reduce some dynamic allocation size.
>>>
>>> Signed-off-by: Junil Lee <junil0814.lee@lge.com>
>>> ---
>>> security/selinux/ss/ebitmap.c | 24 +++++++++++++++++++-----
>>> security/selinux/ss/ebitmap.h | 3 +++
>>> security/selinux/ss/services.c | 4 ++++
>>> 3 files changed, 26 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/security/selinux/ss/ebitmap.c
>> b/security/selinux/ss/ebitmap.c
>>> index 9db4709a..076c96f 100644
>>> --- a/security/selinux/ss/ebitmap.c
>>> +++ b/security/selinux/ss/ebitmap.c
>>> @@ -24,6 +24,8 @@
>>>
>>> #define BITS_PER_U64 (sizeof(u64) * 8)
>>>
>>> +static struct kmem_cache *ebitmap_node_cachep;
>>> +
>>> int ebitmap_cmp(struct ebitmap *e1, struct ebitmap *e2)
>>> {
>>> struct ebitmap_node *n1, *n2;
>>> @@ -54,7 +56,7 @@ int ebitmap_cpy(struct ebitmap *dst, struct ebitmap
>> *src)
>>> n = src->node;
>>> prev = NULL;
>>> while (n) {
>>> - new = kzalloc(sizeof(*new), GFP_ATOMIC);
>>> + new = kmem_cache_zalloc(ebitmap_node_cachep, GFP_ATOMIC);
>>> if (!new) {
>>> ebitmap_destroy(dst);
>>> return -ENOMEM;
>>> @@ -162,7 +164,7 @@ int ebitmap_netlbl_import(struct ebitmap *ebmap,
>>> if (e_iter == NULL ||
>>> offset >= e_iter->startbit + EBITMAP_SIZE) {
>>> e_prev = e_iter;
>>> - e_iter = kzalloc(sizeof(*e_iter), GFP_ATOMIC);
>>> + e_iter = kmem_cache_zalloc(ebitmap_node_cachep, GFP_ATOMIC);
>>> if (e_iter == NULL)
>>> goto netlbl_import_failure;
>>> e_iter->startbit = offset - (offset % EBITMAP_SIZE);
>>> @@ -299,7 +301,7 @@ int ebitmap_set_bit(struct ebitmap *e, unsigned
>> long bit, int value)
>>> if (!value)
>>> return 0;
>>>
>>> - new = kzalloc(sizeof(*new), GFP_ATOMIC);
>>> + new = kmem_cache_zalloc(ebitmap_node_cachep, GFP_ATOMIC);
>>> if (!new)
>>> return -ENOMEM;
>>
>> I believe there is a kfree() in ebitmap_set_bit() that also needs to
>> be converted.
>>
>
> Thanks for your advice Paul.
> reattach patch v2.

Please submit patches inline, just as you did for your original
posting.  It make it easier to review and apply.

Thanks.

-- 
paul moore
www.paul-moore.com

  parent reply	other threads:[~2017-06-07 13:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-05  9:10 [PATCH] security: selinux: use kmem_cache for ebitmap Junil Lee
2017-06-05 21:39 ` Paul Moore
     [not found]   ` <872857aa-7587-79a9-cf31-4508eacdb3f7@lge.com>
2017-06-07 13:50     ` Paul Moore [this message]
2017-06-08  4:18 Junil Lee
2017-06-09 20:16 ` Paul Moore
2017-06-12  2:16   ` Junil Lee

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAHC9VhTU9fgZxfeyo_ViPcdEONxYaBxnMGCgM8yb35-52CBNtw@mail.gmail.com \
    --to=paul@paul-moore.com \
    --cc=adobriyan@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=danielj@mellanox.com \
    --cc=dledford@redhat.com \
    --cc=eparis@parisplace.org \
    --cc=james.l.morris@oracle.com \
    --cc=junil0814.lee@lge.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=mka@chromium.org \
    --cc=sds@tycho.nsa.gov \
    --cc=selinux@tycho.nsa.gov \
    --cc=serge@hallyn.com \
    --cc=william.c.roberts@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).