linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steve French <smfltc@us.ibm.com>
To: linux-fsdevel@vger.kernel.org
Subject: filesystem behavior when low on memory and PF_MEMALLOC
Date: 27 Apr 2004 11:20:53 -0500	[thread overview]
Message-ID: <1083082853.13165.15.camel@stevef95.austin.ibm.com> (raw)

Does PF_MEMALLOC have a similar effect to setting SLAB_NOFS and
equivalent on memory allocations? and prevent memory allocations in
critical code paths from blocking?

Sergey Vlasov recently made a good suggestion about fixing a problem
with very large file copy hangs via the use of the PF_MEMALLOC.

He noted that shrink_caches can cause writepage (cifs_writepage in my
case) to be invoked to write out dirty pages - but writepage needs to
allocate memory both explicitly (for each the 4.5K cifs write buffer)
and implicitly as a result of using the sockets API (sock_sendmsg can
allocate memory) but this presumably can block.  In addition the cifs
demultiplex thread needs to get an acknowledgement from the server to
before waking up the writepage thread - but the demultiplex thread can
allocate memory in some cases.

His suggested solution was to add the PF_MEMALLOC flag to the
current->flags for the demultiplex thread, which makes sense and seems
similar to what XFS and a few other filesystems do in some of their
daemons.   What was harder to evaluate though was how to fix the context
of the process doing writepage - is it ok to temporarily set PF_MEMALLOC
on entry to a filesystems writepage and writepages routines? Or would
this be redundant since the linux/mm code should already be doing this
in all low memory paths in the calling function? Is it ok to clear the
flag - always clearing PF_MEMALLOC on exit from cifs_writepage (and
eventually cifs_writepages when that is added).  The alternative is to
set SLAB_NOFS and equivalent on memory allocations on all calls in cifs
on behalf of writepages which would probably be ok but would hit more
code and make the codepaths trickier (figuring out if an smb buffer
allocation e.g. came from writepage).  My initial observations was that
there is a significant performance hit setting SLAB_NOFS on all cifs
buffer allocations (although I think that this is what at least one
other filesystem basically does) - it seems like overkill when writepage
(and possibly prepare_write/commit_write) are the ones that matter for
performance during low memory situations as pages are being freed.


             reply	other threads:[~2004-04-27 16:21 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-04-27 16:20 Steve French [this message]
2004-04-27 19:09 ` filesystem behavior when low on memory and PF_MEMALLOC Bryan Henderson
2004-04-27 20:29   ` filesystem signal handling Steve French
2004-04-28 15:14     ` David Woodhouse
2004-04-28 17:05       ` Trond Myklebust
2004-04-28 17:14         ` David Woodhouse
2004-04-28 17:32           ` Trond Myklebust
2004-04-28 19:28             ` Jamie Lokier
2004-04-28 19:43               ` Trond Myklebust
2004-04-28 19:47                 ` Jamie Lokier
2004-04-28 20:31                   ` Trond Myklebust
2004-04-29  2:18               ` David Woodhouse
2004-04-29  2:53                 ` Trond Myklebust
2004-04-29  6:41                   ` David Woodhouse
2004-04-29 17:41                     ` Bryan Henderson
2004-04-28 21:46       ` Bryan Henderson
2004-04-29  2:34         ` David Woodhouse

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=1083082853.13165.15.camel@stevef95.austin.ibm.com \
    --to=smfltc@us.ibm.com \
    --cc=linux-fsdevel@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;
as well as URLs for NNTP newsgroup(s).