linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Andi Kleen <ak@suse.de>
To: Fawad Lateef <fawadlateef@gmail.com>
Cc: James Courtier-Dutton <James@superbug.demon.co.uk>, linux-mm@kvack.org
Subject: Re: Kernel tempory memory alloc
Date: Sun, 20 Nov 2005 00:54:35 +0100	[thread overview]
Message-ID: <200511200054.35906.ak@suse.de> (raw)
In-Reply-To: <1e62d1370511191057i5ab0b4b3ve3c8a2a3dcabe6fe@mail.gmail.com>

On Saturday 19 November 2005 19:57, Fawad Lateef wrote:
> On 11/19/05, James Courtier-Dutton <James@superbug.demon.co.uk> wrote:
> > The IOCTL will be a simple request/response type, so the memory
> > allocation will be for a very short time. Which is the correct memory
> > api to use when allocating short term temporary memory in the kernel.
>
> I mostly/vastly used and saw memory allocation API "kmalloc" for small
> memory allocations. And for short-term and fast memory allocation use
> GFP_ATOMIC flag with memory allocation functions!

No, that's not what GFP_ATOMIC is good for. Please don't spread misinformation 
like that which google will keep forever. GFP_ATOMIC is for allocating
for interrupt context or other contexts where you cannot sleep,
and is much less reliable than normal GFP_KERNEL.

> > Alternatively, is there a way to handle this by simply moving a page
> > from user space to kernel space and then back to user space again?
> > Thus reducing the amount of memcpy.
>
> I think memcpy is not a big-overhead as compare to temporary mapping a
> page from user space to kernel space and then unmapping it each time
> an ioctl is called, so you might try to constantly share a buffer
> between user/kernel space through which you can access data directly
> from both spaces (for mapping user page in kernel you can see
> get_user_pages) !

I don't think that's good advice. It depends on the exact circumstances
and the size of the data, but for reasonably sized data (> one page)
normally the copy should be more expensive.

Also there is no memcpy from user space of course.

-Andi

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

      reply	other threads:[~2005-11-19 23:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-19 12:45 James Courtier-Dutton
2005-11-19 18:57 ` Fawad Lateef
2005-11-19 23:54   ` Andi Kleen [this message]

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=200511200054.35906.ak@suse.de \
    --to=ak@suse.de \
    --cc=James@superbug.demon.co.uk \
    --cc=fawadlateef@gmail.com \
    --cc=linux-mm@kvack.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