Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754004Ab2KUIhb (ORCPT ); Wed, 21 Nov 2012 03:37:31 -0500 Received: from LGEMRELSE1Q.lge.com ([156.147.1.111]:61361 "EHLO LGEMRELSE1Q.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751698Ab2KUIh3 (ORCPT ); Wed, 21 Nov 2012 03:37:29 -0500 X-AuditID: 9c93016f-b7b42ae000004383-04-50ac92c69af9 Date: Wed, 21 Nov 2012 17:37:37 +0900 From: Minchan Kim To: Nitin Gupta Cc: Seth Jennings , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Pekka Enberg , Konrad Rzeszutek Wilk , Dan Magenheimer , Andrew Morton , Greg Kroah-Hartman Subject: Lockdep complain for zram Message-ID: <20121121083737.GB5121@bbox> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Brightmail-Tracker: AAAAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 7534 Lines: 137 Hi alls, Today, I saw below complain of lockdep. As a matter of fact, I knew it long time ago but forgot that. The reason lockdep complains is that now zram uses GFP_KERNEL in reclaim path(ex, __zram_make_request) :( I can fix it via replacing GFP_KERNEL with GFP_NOIO. But more big problem is vzalloc in zram_init_device which calls GFP_KERNEL. Of course, I can change it with __vmalloc which can receive gfp_t. But still we have a problem. Althoug __vmalloc can handle gfp_t, it calls allocation of GFP_KERNEL. That's why I sent the patch. https://lkml.org/lkml/2012/4/23/77 Since then, I forgot it, saw the bug today and poped the question again. Yes. Fundamental problem is utter crap API vmalloc. If we can fix it, everyone would be happy. But life isn't simple like seeing my thread of the patch. So next option is to move zram_init_device into setting disksize time. But it makes unnecessary metadata waste until zram is used really(That's why Nitin move zram_init_device from disksize setting time to make_request) and it makes user should set the disksize before using, which are behavior change. I would like to clean up this issue before promoting because it might change usage behavior. Do you have any idea? ============ 8< ============== [ 335.772277] ================================= [ 335.772615] [ INFO: inconsistent lock state ] [ 335.772955] 3.7.0-rc6 #162 Tainted: G C [ 335.773320] --------------------------------- [ 335.773663] inconsistent {RECLAIM_FS-ON-W} -> {IN-RECLAIM_FS-R} usage. [ 335.774170] kswapd0/23 [HC0[0]:SC0[0]:HE1:SE1] takes: [ 335.774564] (&zram->init_lock){+++++-}, at: [] zram_make_request+0x4a/0x260 [zram] [ 335.775321] {RECLAIM_FS-ON-W} state was registered at: [ 335.775716] [] mark_held_locks+0x82/0x130 [ 335.776009] [] lockdep_trace_alloc+0x67/0xc0 [ 335.776009] [] __alloc_pages_nodemask+0x94/0xa00 [ 335.776009] [] alloc_pages_current+0xb6/0x120 [ 335.776009] [] __get_free_pages+0x14/0x50 [ 335.776009] [] kmalloc_order_trace+0x3f/0xf0 [ 335.776009] [] zram_init_device+0x7b/0x220 [zram] [ 335.776009] [] zram_make_request+0x24a/0x260 [zram] [ 335.776009] [] generic_make_request+0xca/0x100 [ 335.776009] [] submit_bio+0x7b/0x160 [ 335.776009] [] submit_bh+0xf2/0x120 [ 335.776009] [] block_read_full_page+0x235/0x3a0 [ 335.776009] [] blkdev_readpage+0x18/0x20 [ 335.776009] [] __do_page_cache_readahead+0x2c7/0x2d0 [ 335.776009] [] force_page_cache_readahead+0x79/0xb0 [ 335.776009] [] page_cache_sync_readahead+0x43/0x50 [ 335.776009] [] generic_file_aio_read+0x4f0/0x760 [ 335.776009] [] blkdev_aio_read+0xbb/0xf0 [ 335.776009] [] do_sync_read+0xa3/0xe0 [ 335.776009] [] vfs_read+0xb0/0x180 [ 335.776009] [] sys_read+0x52/0xa0 [ 335.776009] [] system_call_fastpath+0x16/0x1b [ 335.776009] irq event stamp: 97589 [ 335.776009] hardirqs last enabled at (97589): [] throtl_update_dispatch_stats+0x94/0xf0 [ 335.776009] hardirqs last disabled at (97588): [] throtl_update_dispatch_stats+0x4d/0xf0 [ 335.776009] softirqs last enabled at (67416): [] __do_softirq+0x139/0x280 [ 335.776009] softirqs last disabled at (67395): [] call_softirq+0x1c/0x30 [ 335.776009] [ 335.776009] other info that might help us debug this: [ 335.776009] Possible unsafe locking scenario: [ 335.776009] [ 335.776009] CPU0 [ 335.776009] ---- [ 335.776009] lock(&zram->init_lock); [ 335.776009] [ 335.776009] lock(&zram->init_lock); [ 335.776009] [ 335.776009] *** DEADLOCK *** [ 335.776009] [ 335.776009] no locks held by kswapd0/23. [ 335.776009] [ 335.776009] stack backtrace: [ 335.776009] Pid: 23, comm: kswapd0 Tainted: G C 3.7.0-rc6 #162 [ 335.776009] Call Trace: [ 335.776009] [] print_usage_bug+0x1f5/0x206 [ 335.776009] [] ? save_stack_trace+0x2f/0x50 [ 335.776009] [] mark_lock+0x295/0x2f0 [ 335.776009] [] ? print_irq_inversion_bug.part.37+0x1f0/0x1f0 [ 335.776009] [] ? blk_throtl_bio+0x88/0x630 [ 335.776009] [] __lock_acquire+0x564/0x1c00 [ 335.776009] [] ? trace_hardirqs_on_caller+0x105/0x190 [ 335.776009] [] ? blk_throtl_bio+0x3c2/0x630 [ 335.776009] [] ? blk_throtl_bio+0x88/0x630 [ 335.776009] [] ? create_task_io_context+0xdc/0x150 [ 335.776009] [] ? create_task_io_context+0xdc/0x150 [ 335.776009] [] ? zram_make_request+0x4a/0x260 [zram] [ 335.776009] [] lock_acquire+0x85/0x130 [ 335.776009] [] ? zram_make_request+0x4a/0x260 [zram] [ 335.776009] [] down_read+0x4c/0x61 [ 335.776009] [] ? zram_make_request+0x4a/0x260 [zram] [ 335.776009] [] ? generic_make_request_checks+0x222/0x420 [ 335.776009] [] ? test_set_page_writeback+0x6e/0x1a0 [ 335.776009] [] zram_make_request+0x4a/0x260 [zram] [ 335.776009] [] generic_make_request+0xca/0x100 [ 335.776009] [] submit_bio+0x7b/0x160 [ 335.776009] [] ? account_page_writeback+0x13/0x20 [ 335.776009] [] ? test_set_page_writeback+0xf5/0x1a0 [ 335.776009] [] swap_writepage+0x1b9/0x240 [ 335.776009] [] ? __swap_duplicate+0x65/0x170 [ 335.776009] [] ? shmem_writepage+0x17a/0x2f0 [ 335.776009] [] ? shmem_writepage+0x17a/0x2f0 [ 335.776009] [] ? __mutex_unlock_slowpath+0xd1/0x160 [ 335.776009] [] ? trace_hardirqs_on_caller+0x105/0x190 [ 335.776009] [] ? trace_hardirqs_on+0xd/0x10 [ 335.776009] [] shmem_writepage+0x1b5/0x2f0 [ 335.776009] [] shrink_page_list+0x516/0x9a0 [ 335.776009] [] ? __activate_page+0x150/0x150 [ 335.776009] [] shrink_inactive_list+0x1f7/0x3f0 [ 335.776009] [] shrink_lruvec+0x435/0x540 [ 335.776009] [] ? __init_waitqueue_head+0x60/0x60 [ 335.776009] [] kswapd+0x703/0xc80 [ 335.776009] [] ? _raw_spin_unlock_irq+0x30/0x50 [ 335.776009] [] ? __init_waitqueue_head+0x60/0x60 [ 335.776009] [] ? try_to_free_pages+0x6f0/0x6f0 [ 335.776009] [] kthread+0xea/0xf0 [ 335.776009] [] ? flush_kthread_work+0x1a0/0x1a0 [ 335.776009] [] ret_from_fork+0x7c/0xb0 [ 335.776009] [] ? flush_kthread_work+0x1a0/0x1a0 -- Kind regards, Minchan Kim -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/