public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Al Viro <viro@ZenIV.linux.org.uk>
To: NeilBrown <neilb@suse.de>
Cc: Tejun Heo <tj@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] kernfs: use stack-buf for small writes.
Date: Wed, 24 Sep 2014 20:17:27 +0100	[thread overview]
Message-ID: <20140924191727.GG7996@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20140923140633.35efbe7a@notabene.brown>

On Tue, Sep 23, 2014 at 02:06:33PM +1000, NeilBrown wrote:
> 
> For a write <= 128 characters, don't use kmalloc.
> 
> mdmon, part of mdadm, will sometimes need to write
> to a sysfs file in order to allow writes to the array
> to continue.  This is important to support RAID metadata
> types that the kernel doesn't know about.
> 
> It is important that this write doesn't block on
> memory allocation.  The safest way to ensure that is to
> use an on-stack buffer.

Is it, now?  What happens if caller of write(2) loses CPU and gets
the page it's writing from swapped out, just as it's getting to
issuing the actual syscall?  copy_from_user() will fault and cause
memory allocation for you...

> Writes are always small, typically less than 10 characters.

Translation: "but my userland code uses it _that_ way; surely, nobody
would do anything else..."

  parent reply	other threads:[~2014-09-24 19:17 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-23  4:06 [PATCH] kernfs: use stack-buf for small writes NeilBrown
2014-09-23  4:12 ` Tejun Heo
2014-09-23  4:18 ` Tejun Heo
2014-09-23  4:46   ` NeilBrown
2014-09-23  4:55     ` Tejun Heo
2014-09-23  5:40       ` NeilBrown
2014-09-23  5:51         ` Tejun Heo
2014-09-23  6:11           ` NeilBrown
2014-09-23  6:15             ` Tejun Heo
2014-09-24 19:17 ` Al Viro [this message]
2014-09-24 23:58   ` NeilBrown

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=20140924191727.GG7996@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=neilb@suse.de \
    --cc=tj@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