From patchwork Tue Nov 17 07:19:33 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: KOSAKI Motohiro X-Patchwork-Id: 38583 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 49916B7B61 for ; Tue, 17 Nov 2009 18:21:45 +1100 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1NAILt-0007vT-5M; Tue, 17 Nov 2009 07:19:49 +0000 Received: from fgwmail5.fujitsu.co.jp ([192.51.44.35]) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1NAILj-0007te-Eb for linux-mtd@lists.infradead.org; Tue, 17 Nov 2009 07:19:44 +0000 Received: from m1.gw.fujitsu.co.jp ([10.0.50.71]) by fgwmail5.fujitsu.co.jp (Fujitsu Gateway) with ESMTP id nAH7JcaL027277 for (envelope-from kosaki.motohiro@jp.fujitsu.com); Tue, 17 Nov 2009 16:19:38 +0900 Received: from smail (m1 [127.0.0.1]) by outgoing.m1.gw.fujitsu.co.jp (Postfix) with ESMTP id 1A2CB45DE4F for ; Tue, 17 Nov 2009 16:19:38 +0900 (JST) Received: from s1.gw.fujitsu.co.jp (s1.gw.fujitsu.co.jp [10.0.50.91]) by m1.gw.fujitsu.co.jp (Postfix) with ESMTP id ED46245DE4E for ; Tue, 17 Nov 2009 16:19:37 +0900 (JST) Received: from s1.gw.fujitsu.co.jp (localhost.localdomain [127.0.0.1]) by s1.gw.fujitsu.co.jp (Postfix) with ESMTP id D3E48E38002 for ; Tue, 17 Nov 2009 16:19:37 +0900 (JST) Received: from m105.s.css.fujitsu.com (m105.s.css.fujitsu.com [10.249.87.105]) by s1.gw.fujitsu.co.jp (Postfix) with ESMTP id 8BB9BE38003 for ; Tue, 17 Nov 2009 16:19:34 +0900 (JST) Received: from m105.css.fujitsu.com (m105 [127.0.0.1]) by m105.s.css.fujitsu.com (Postfix) with ESMTP id 438D05D800B; Tue, 17 Nov 2009 16:19:34 +0900 (JST) Received: from [127.0.0.1] (unknown [10.124.100.179]) by m105.s.css.fujitsu.com (Postfix) with ESMTP id A823E5D8003; Tue, 17 Nov 2009 16:19:33 +0900 (JST) X-SecurityPolicyCheck-FJ: OK by FujitsuOutboundMailChecker v1.3.1 Received: from KOSANOTE2[10.124.100.179] by KOSANOTE2 (FujitsuOutboundMailChecker v1.3.1/9992[10.124.100.179]); Tue, 17 Nov 2009 16:19:35 +0900 (JST) From: KOSAKI Motohiro To: LKML Subject: [PATCH 4/7] nandsim: Don't use PF_MEMALLOC In-Reply-To: <20091117161551.3DD4.A69D9226@jp.fujitsu.com> References: <20091117161551.3DD4.A69D9226@jp.fujitsu.com> Message-Id: <20091117161843.3DE0.A69D9226@jp.fujitsu.com> MIME-Version: 1.0 X-Mailer: Becky! ver. 2.50.07 [ja] Date: Tue, 17 Nov 2009 16:19:33 +0900 (JST) X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20091117_021939_966548_6F341F34 X-CRM114-Status: UNSURE ( 9.52 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.2.5 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- _SUMMARY_ Cc: Artem Bityutskiy , David Woodhouse , linux-mm , linux-mtd@lists.infradead.org, kosaki.motohiro@jp.fujitsu.com, Andrew Morton X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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 Cc: Artem Bityutskiy Cc: linux-mtd@lists.infradead.org Signed-off-by: KOSAKI Motohiro --- 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;