mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Goswin von Brederlow <brederlo@informatik.uni-tuebingen.de>
To: Nick Piggin <nickpiggin@yahoo.com.au>
Cc: Bernd Schubert <bs@q-leap.de>,
	Randy Dunlap <randy.dunlap@oracle.com>,
	linux-kernel@vger.kernel.org,
	"J. Bruce Fields" <bfields@fieldses.org>,
	brian@clusterfs.com,
	Goswin von Brederlow <brederlo@informatik.uni-tuebingen.de>
Subject: Re: patch: improve generic_file_buffered_write() (2nd try 1/2)
Date: Fri, 07 Sep 2007 22:01:08 +0200	[thread overview]
Message-ID: <87odgeckjf.fsf@informatik.uni-tuebingen.de> (raw)
In-Reply-To: <200709081415.54211.nickpiggin@yahoo.com.au> (Nick Piggin's message of "Sat, 8 Sep 2007 14:15:53 +1000")

Nick Piggin <nickpiggin@yahoo.com.au> writes:

> On Thursday 06 September 2007 03:41, Bernd Schubert wrote:
> Minor nit: when resubmitting a patch, you should include everything
> (ie. the full changelog of problem statement and fix description) in a
> single mail. It's just a bit easier...

Will do next time.

> So I believe the problem is that for a multi-segment iovec, we currently
> prepare_write/commit_write once for each segment, right? We do this

It is more complex.

Currently a __grab_cache_page, a_ops->prepare_write,
filemap_copy_from_user[_iovec] and a_ops->commit_write is done
whenever we hit

  a) a page boundary
  b) a segment boundary

Those two cases don't have to, and from the stats basically never,
coincide. For NFSd this means we do this TWICE per segment and TWICE
per page.

> because there is a nasty deadlock in the VM (copy_from_user being
> called with a page locked), and copying multiple segs dramatically
> increases the chances that one of these copies will cause a page fault
> and thus potentially deadlock.

What actually locks the page? Is it __grab_cache_page or
a_ops->prepare_write?

Note that the patch does not change the number of copy_from_user calls
being made nor does it change their arguments. If we need 2 (or more)
segments to fill a page we still do 2 seperate calls to
filemap_copy_from_user_iovec, both only spanning (part of) one
segment.

What the patch changes is the number of copy_from_user calls between
__grab_cache_page and a_ops->commit_write.

Copying a full PAGE_SIZE bytes from multiple segments in one go would
be a further improvement if that is possible.

> The fix you have I don't think can work because a filesystem must be
> notified of the modification _before_ it has happened. (If I understand
> correctly, you are skipping the prepare_write potentially until after
> some data is copied?).

Yes. We changed the order of copy_from_user calls and
a_ops->prepare_write by mistake. We will rectify that and do the
prepare_write for the full page (when possible) before copying the
data into the page.

> Anyway, there are fixes for this deadlock in Andrew's -mm tree, but
> also a workaround for the NFSD problem in git commit 29dbb3fc. Did
> you try a later kernel to see if it is fixed there?

Later than 2.6.23-rc5?

> Thanks,
> Nick

MfG
        Goswin

  reply	other threads:[~2007-09-07 20:35 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-05 13:45 patch: improve generic_file_buffered_write() Bernd Schubert
2007-09-05 15:35 ` Randy Dunlap
2007-09-05 17:41   ` patch: improve generic_file_buffered_write() (2nd try 1/2) Bernd Schubert
2007-09-05 17:49     ` patch: improve generic_file_buffered_write() (2nd try 2/2) Bernd Schubert
2007-09-08  4:15     ` patch: improve generic_file_buffered_write() (2nd try 1/2) Nick Piggin
2007-09-07 20:01       ` Goswin von Brederlow [this message]
2007-09-08  6:28         ` Nick Piggin
2007-09-07 21:12           ` Goswin von Brederlow
2007-09-08  7:25             ` Nick Piggin
2007-09-08  7:31               ` Nick Piggin
2007-09-08  9:43                 ` Goswin von Brederlow
2007-09-07 20:12                   ` Nick Piggin
2007-09-07 21:00       ` Goswin von Brederlow
2007-09-08  7:14         ` Nick Piggin

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=87odgeckjf.fsf@informatik.uni-tuebingen.de \
    --to=brederlo@informatik.uni-tuebingen.de \
    --cc=bfields@fieldses.org \
    --cc=brian@clusterfs.com \
    --cc=bs@q-leap.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nickpiggin@yahoo.com.au \
    --cc=randy.dunlap@oracle.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

all inboxes | Powered by JetHome®