public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Emmanuel Colbus <ecolbus@manux.info>
To: linux-kernel@vger.kernel.org
Subject: [RFC][10/11][MANUX] Suggestion : kmalloc()
Date: Tue, 15 Apr 2014 15:43:15 +0200	[thread overview]
Message-ID: <534D3773.5000708@manux.info> (raw)

Finally, since cloning the Linux kernel gave me some ideas, I would like
to give you a couple of suggestions of my own. Feel free to do what you
want with them.

First, I'm not sure whether this has been done or not, but I would like
to suggest you to mark your kernel memory allocator with gcc's malloc
attribute (and mark kfree() as taking void*, not const void*).

Yes, I know, it apparently doesn't corresponds with what the malloc
attribute's specification covers, since there are still pointers to the
returned memory area somewhere else in the kernel. However, I would like
to point out that this isn't relevant : in *any* malloc-like
implementation, there will be such pointers somewhere in the allocator.
What's important is whether they are such pointers *in the specific
compilation units from which the allocator is called*.

And since the allocator can't call itself (well, I'm not sure for the
Linux one, of course, but this happens to be true in mine), leaving
kmalloc in a separate file allows setting this attribute, which gives a
little speed boost to the code (that's what it did to my kernel when I
did it). That's because it allows the compiler to know that two areas
allocated with such a function *cannot* alias each other, which helps it
optimize the memory accesses to them.

                 reply	other threads:[~2014-04-15 14:00 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=534D3773.5000708@manux.info \
    --to=ecolbus@manux.info \
    --cc=linux-kernel@vger.kernel.org \
    /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