From: Adrian Hunter <adrian.hunter@nokia.com>
To: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: "Bityutskiy Artem (Nokia-D/Helsinki)"
<Artem.Bityutskiy@nokia.com>, LKML <linux-kernel@vger.kernel.org>,
linux-mm <linux-mm@kvack.org>,
Andrew Morton <akpm@linux-foundation.org>,
David Woodhouse <David.Woodhouse@intel.com>,
"linux-mtd@lists.infradead.org" <linux-mtd@lists.infradead.org>
Subject: Re: [PATCH 4/7] nandsim: Don't use PF_MEMALLOC
Date: Mon, 23 Nov 2009 22:01:55 +0200 [thread overview]
Message-ID: <4B0AEA33.3010306@nokia.com> (raw)
In-Reply-To: <1258988417.18407.44.camel@localhost>
Bityutskiy Artem (Nokia-D/Helsinki) wrote:
> On Tue, 2009-11-17 at 16:19 +0900, KOSAKI Motohiro wrote:
>> Non MM subsystem must not use PF_MEMALLOC. Memory reclaim need few
>> memory, anyone must not prevent it. Otherwise the system cause
>> mysterious hang-up and/or OOM Killer invokation.
>>
>> Cc: David Woodhouse <David.Woodhouse@intel.com>
>> Cc: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
>> Cc: linux-mtd@lists.infradead.org
>> Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
>> ---
>> drivers/mtd/nand/nandsim.c | 22 ++--------------------
>> 1 files changed, 2 insertions(+), 20 deletions(-)
>>
>> diff --git a/drivers/mtd/nand/nandsim.c b/drivers/mtd/nand/nandsim.c
>> index cd0711b..97a8bbb 100644
>> --- a/drivers/mtd/nand/nandsim.c
>> +++ b/drivers/mtd/nand/nandsim.c
>> @@ -1322,34 +1322,18 @@ static int get_pages(struct nandsim *ns, struct file *file, size_t count, loff_t
>> return 0;
>> }
>>
>> -static int set_memalloc(void)
>> -{
>> - if (current->flags & PF_MEMALLOC)
>> - return 0;
>> - current->flags |= PF_MEMALLOC;
>> - return 1;
>> -}
>> -
>> -static void clear_memalloc(int memalloc)
>> -{
>> - if (memalloc)
>> - current->flags &= ~PF_MEMALLOC;
>> -}
>> -
>> static ssize_t read_file(struct nandsim *ns, struct file *file, void *buf, size_t count, loff_t *pos)
>> {
>> mm_segment_t old_fs;
>> ssize_t tx;
>> - int err, memalloc;
>> + int err;
>>
>> err = get_pages(ns, file, count, *pos);
>> if (err)
>> return err;
>> old_fs = get_fs();
>> set_fs(get_ds());
>> - memalloc = set_memalloc();
>> tx = vfs_read(file, (char __user *)buf, count, pos);
>> - clear_memalloc(memalloc);
>> set_fs(old_fs);
>> put_pages(ns);
>> return tx;
>> @@ -1359,16 +1343,14 @@ static ssize_t write_file(struct nandsim *ns, struct file *file, void *buf, size
>> {
>> mm_segment_t old_fs;
>> ssize_t tx;
>> - int err, memalloc;
>> + int err;
>>
>> err = get_pages(ns, file, count, *pos);
>> if (err)
>> return err;
>> old_fs = get_fs();
>> set_fs(get_ds());
>> - memalloc = set_memalloc();
>> tx = vfs_write(file, (char __user *)buf, count, pos);
>> - clear_memalloc(memalloc);
>> set_fs(old_fs);
>> put_pages(ns);
>> return tx;PF_MEMALLOC,
>
> I vaguely remember Adrian (CCed) did this on purpose. This is for the
> case when nandsim emulates NAND flash on top of a file. So there are 2
> file-systems involved: one sits on top of nandsim (e.g. UBIFS) and the
> other owns the file which nandsim uses (e.g., ext3).
>
> And I really cannot remember off the top of my head why he needed
> PF_MEMALLOC, but I think Adrian wanted to prevent the direct reclaim
> path to re-enter, say UBIFS, and cause deadlock. But I'd thing that all
> the allocations in vfs_read()/vfs_write() should be GFP_NOFS, so that
> should not be a probelm?
>
Yes it needs PF_MEMALLOC to prevent deadlock because there can be a
file system on top of nandsim which, in this case, is on top of another
file system.
I do not see how mempools will help here.
Please offer an alternative solution.
--
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>
next prev parent reply other threads:[~2009-11-23 20:02 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-17 7:16 [PATCH 0/7] Kill PF_MEMALLOC abuse KOSAKI Motohiro
2009-11-17 7:17 ` [PATCH 1/7] dm: use __GFP_HIGH instead PF_MEMALLOC KOSAKI Motohiro
2009-11-17 13:15 ` Alasdair G Kergon
2009-11-18 6:17 ` KOSAKI Motohiro
2009-11-17 7:17 ` [PATCH 2/7] mmc: Don't use PF_MEMALLOC KOSAKI Motohiro
2009-11-17 10:29 ` Alan Cox
2009-11-17 10:32 ` Minchan Kim
2009-11-17 10:38 ` Oliver Neukum
2009-11-17 11:58 ` KOSAKI Motohiro
2009-11-17 12:51 ` Minchan Kim
2009-11-17 20:47 ` Peter Zijlstra
2009-11-18 0:01 ` Minchan Kim
2009-11-18 9:56 ` Peter Zijlstra
2009-11-18 10:31 ` Minchan Kim
2009-11-18 10:54 ` Peter Zijlstra
2009-11-18 11:15 ` Minchan Kim
2009-11-17 7:18 ` [PATCH 3/7] mtd: " KOSAKI Motohiro
2009-11-17 7:19 ` [PATCH 4/7] nandsim: " KOSAKI Motohiro
2009-11-23 15:00 ` Artem Bityutskiy
2009-11-23 20:01 ` Adrian Hunter [this message]
2009-11-24 10:46 ` KOSAKI Motohiro
2009-11-24 11:56 ` Adrian Hunter
2009-11-25 0:42 ` KOSAKI Motohiro
2009-11-25 7:13 ` Adrian Hunter
2009-11-25 7:18 ` KOSAKI Motohiro
2009-11-17 7:21 ` [PATCH 5/7] Revert "Intel IOMMU: Avoid memory allocation failures in dma map api calls" KOSAKI Motohiro
2009-11-17 7:22 ` [PATCH 6/7] cifs: Don't use PF_MEMALLOC KOSAKI Motohiro
2009-11-17 7:32 ` [PATCH] Mark cifs mailing list as "moderated as non-subscribers" KOSAKI Motohiro
2009-11-17 12:47 ` [PATCH 6/7] cifs: Don't use PF_MEMALLOC Jeff Layton
2009-11-17 16:40 ` Steve French
2009-11-18 6:31 ` KOSAKI Motohiro
2009-11-17 7:23 ` [PATCH 7/7] xfs: " KOSAKI Motohiro
2009-11-17 22:11 ` Dave Chinner
2009-11-18 8:56 ` KOSAKI Motohiro
2009-11-18 22:16 ` Dave Chinner
2009-11-17 8:07 ` [PATCH 0/7] Kill PF_MEMALLOC abuse David Rientjes
2009-11-17 8:33 ` KOSAKI Motohiro
2009-11-17 8:36 ` David Rientjes
2009-11-17 20:56 ` Peter Zijlstra
2009-11-18 5:55 ` KOSAKI Motohiro
2009-11-17 10:15 ` Christoph Hellwig
2009-11-17 10:24 ` KOSAKI Motohiro
2009-11-17 10:27 ` Christoph Hellwig
2009-11-17 12:24 ` KOSAKI Motohiro
2009-11-17 12:47 ` Christoph Hellwig
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=4B0AEA33.3010306@nokia.com \
--to=adrian.hunter@nokia.com \
--cc=Artem.Bityutskiy@nokia.com \
--cc=David.Woodhouse@intel.com \
--cc=akpm@linux-foundation.org \
--cc=kosaki.motohiro@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-mtd@lists.infradead.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