From: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
To: andi@firstfloor.org
Cc: konishi.ryusuke@lab.ntt.co.jp, akpm@linux-foundation.org,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH mmotm 1/5] nilfs2: fix problems of memory allocation in ioctl
Date: Sat, 13 Dec 2008 17:29:15 +0900 (JST) [thread overview]
Message-ID: <20081213.172915.31069043.ryusuke@osrg.net> (raw)
In-Reply-To: <20081212202411.GK25779@one.firstfloor.org>
On Fri, 12 Dec 2008 21:24:11 +0100, Andi Kleen <andi@firstfloor.org> wrote:
> > In the current interface, each data item is copied twice: one is to
> > the allocated memory from user space (via copy_from_user), and another
>
> For such large copies it is better to use multiple smaller (e.g. 4K)
> copy user, that gives better real time preempt latencies. Each cfu has a
> cond_resched(), but only one, not multiple times in the inner loop.
For the function in question, the buffer memory can be divided into a
smaller size (at least to 4K bytes) since the buffer is repeatedly
used for small objects, where the copy_from_user (and a copy_to_user)
is only once in each cycle.
So, just reducing the allocation size of the buffer seems good; it is
likely able to avoid both large preempt latencies and large memory
allocation, which also can leave off the use of vmalloc.
> > is to on-memory structures or to buffers/pages from the allocated
> > memory.
>
> It depends how performance critical it is.
>
> One way for example is to grab the user pages using get_user_pages()
> and then reference those pages directly using kmap().
> But you would be at the mercy of the user process not modifying in
> parallel then. Normally it is safer to work from copies in kernel
> space to avoid races. As long as it doesn't happen too often a few
> copies are also usually not a problem. I wouldn't worry about them
> unless you see them prominently in profiler logs.
>
> -Andi
I got it. If need arises, then I'll recall get_user_pages(). At
present, there is likely no need to do like that.
Thank you for the informative advises.
With regards,
Ryusuke
next prev parent reply other threads:[~2008-12-13 8:29 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-12 5:16 [PATCH mmotm 0/5] nilfs2 filesystem updates Ryusuke Konishi
2008-12-12 5:16 ` [PATCH mmotm 1/5] nilfs2: fix problems of memory allocation in ioctl Ryusuke Konishi
2008-12-12 5:16 ` [PATCH mmotm 2/5] nilfs2: cleanup nilfs_clear_inode Ryusuke Konishi
2008-12-12 5:16 ` [PATCH mmotm 3/5] nilfs2: avoid double error caused by nilfs_transaction_end Ryusuke Konishi
2008-12-12 5:17 ` [PATCH mmotm 4/5] nilfs2: insert explanations in gcinode file Ryusuke Konishi
2008-12-12 5:17 ` [PATCH mmotm 5/5] nilfs2: add maintainer Ryusuke Konishi
2008-12-12 7:50 ` [PATCH mmotm 3/5] nilfs2: avoid double error caused by nilfs_transaction_end Pekka Enberg
2008-12-12 13:47 ` [PATCH mmotm 1/5] nilfs2: fix problems of memory allocation in ioctl Andi Kleen
2008-12-12 18:48 ` Ryusuke Konishi
2008-12-12 20:24 ` Andi Kleen
2008-12-13 8:29 ` Ryusuke Konishi [this message]
2008-12-14 12:08 ` Ryusuke Konishi
2008-12-14 15:13 ` Andi Kleen
2008-12-15 6:58 ` Ryusuke Konishi
2008-12-15 10:17 ` Andi Kleen
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=20081213.172915.31069043.ryusuke@osrg.net \
--to=konishi.ryusuke@lab.ntt.co.jp \
--cc=akpm@linux-foundation.org \
--cc=andi@firstfloor.org \
--cc=linux-fsdevel@vger.kernel.org \
--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
all inboxes | Powered by JetHome®