From: akpm@linux-foundation.org Subject: [folded-merged] zram-delete-zram_init_device-fix.patch removed from -mm tree Date: Mon, 07 Apr 2014 15:12:32 -0700 Message-ID: <534322d0.wraRY9P0Qi7DJwOb%akpm@linux-foundation.org> Reply-To: linux-kernel@vger.kernel.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Return-path: Received: from mail.linuxfoundation.org ([140.211.169.12]:39964 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755314AbaDGWMd (ORCPT ); Mon, 7 Apr 2014 18:12:33 -0400 Sender: mm-commits-owner@vger.kernel.org List-Id: mm-commits@vger.kernel.org To: mm-commits@vger.kernel.org, sergey.senozhatsky@gmail.com, sasha.levin@oracle.com, minchan@kernel.org Subject: [folded-merged] zram-delete-zram_init_device-fix.patch removed from -mm tree To: minchan@kernel.org,sasha.levin@oracle.com,sergey.senozhatsky@gmail.com,mm-commits@vger.kernel.org From: akpm@linux-foundation.org Date: Mon, 07 Apr 2014 15:12:32 -0700 The patch titled Subject: zram: prevent lockdep spew of init_lock has been removed from the -mm tree. Its filename was zram-delete-zram_init_device-fix.patch This patch was dropped because it was folded into zram-delete-zram_init_device.patch ------------------------------------------------------ From: Minchan Kim Subject: zram: prevent lockdep spew of init_lock Sasha reported following below lockdep spew of zram. It was introduced by [1] in recent linux-next but it's false positive because zram_meta_alloc with down_write(init_lock) couldn't be called during zram is working as swap device so we could annotate the lock. But I don't think it's worthy because it would make greate lockdep less effective. Instead, move zram_meta_alloc out of the lock as good old day so we could do unnecessary allocation/free of zram_meta for initialied device as Sergey claimed in [1] but it wouldn't be common and be harmful if someone might do it. Rather than, I'd like to respect lockdep which is great tool to prevent upcoming subtle bugs. [1] zram: delete zram_init_device [ 2655.365684] ================================= [ 2655.368278] [ INFO: inconsistent lock state ] [ 2655.370163] 3.14.0-rc4-next-20140226-sasha-00013-g082bdac-dirty #4 Tainted: G W [ 2655.371972] --------------------------------- [ 2655.371972] inconsistent {RECLAIM_FS-ON-W} -> {IN-RECLAIM_FS-R} usage. [ 2655.371972] kswapd30/5352 [HC0[0]:SC0[0]:HE1:SE1] takes: [ 2655.371972] (&zram->init_lock){+++++-}, at: [] zram_make_request+0x2a/0xc0 [ 2655.371972] {RECLAIM_FS-ON-W} state was registered at: [ 2655.371972] [] mark_held_locks+0x6c/0x90 [ 2655.371972] [] lockdep_trace_alloc+0xfd/0x140 [ 2655.371972] [] kmem_cache_alloc_trace+0x32/0x2e0 [ 2655.371972] [] zram_meta_alloc+0x20/0x150 [ 2655.371972] [] disksize_store+0x8e/0xf0 [ 2655.371972] [] dev_attr_store+0x1b/0x20 [ 2655.371972] [] sysfs_kf_write+0x4a/0x60 [ 2655.371972] [] kernfs_fop_write+0x110/0x190 [ 2655.371972] [] vfs_write+0xe3/0x1d0 [ 2655.371972] [] SyS_write+0x5d/0xa0 [ 2655.371972] [] tracesys+0xdd/0xe2 [ 2655.371972] irq event stamp: 10207 [ 2655.371972] hardirqs last enabled at (10207): [] throtl_update_dispatch_stats+0x15d/0x1a0 [ 2655.371972] hardirqs last disabled at (10206): [] throtl_update_dispatch_stats+0xa4/0x1a0 [ 2655.371972] softirqs last enabled at (10172): [] __do_softirq+0x447/0x4f0 [ 2655.371972] softirqs last disabled at (10165): [] irq_exit+0x83/0x160 [ 2655.371972] [ 2655.371972] other info that might help us debug this: [ 2655.371972] Possible unsafe locking scenario: [ 2655.371972] [ 2655.371972] CPU0 [ 2655.371972] ---- [ 2655.371972] lock(&zram->init_lock); [ 2655.371972] [ 2655.371972] lock(&zram->init_lock); [ 2655.371972] [ 2655.371972] *** DEADLOCK *** [ 2655.371972] [ 2655.371972] no locks held by kswapd30/5352. [ 2655.371972] [ 2655.371972] stack backtrace: [ 2655.371972] CPU: 78 PID: 5352 Comm: kswapd30 Tainted: G W 3.14.0-rc4-next-20140226-sasha-00013-g082bdac-dirty #4 [ 2655.371972] ffff880636f98cc0 ffff880636f8d3f8 ffffffff843882e5 0000000000000000 [ 2655.371972] ffff880636f98000 ffff880636f8d458 ffffffff811a09f7 0000000000000000 [ 2655.371972] 0000000000000001 ffff880600000001 ffffffff876c2060 0000000000000009 [ 2655.371972] Call Trace: [ 2655.371972] [] dump_stack+0x52/0x7f [ 2655.371972] [] print_usage_bug+0x1a7/0x1e0 [ 2655.371972] [] ? print_usage_bug+0x1e0/0x1e0 [ 2655.371972] [] mark_lock_irq+0xd9/0x2a0 [ 2655.371972] [] mark_lock+0x128/0x210 [ 2655.371972] [] mark_irqflags+0x144/0x170 [ 2655.371972] [] __lock_acquire+0x2de/0x5a0 [ 2655.371972] [] lock_acquire+0x182/0x1d0 [ 2655.371972] [] ? zram_make_request+0x2a/0xc0 [ 2655.371972] [] down_read+0x47/0xa0 [ 2655.371972] [] ? zram_make_request+0x2a/0xc0 [ 2655.371972] [] ? preempt_count_add+0x96/0xc0 [ 2655.371972] [] zram_make_request+0x2a/0xc0 [ 2655.371972] [] generic_make_request+0xb6/0x110 [ 2655.371972] [] submit_bio+0x148/0x170 [ 2655.371972] [] ? test_set_page_writeback+0x24e/0x2a0 [ 2655.371972] [] __swap_writepage+0x1fc/0x220 [ 2655.371972] [] ? _raw_spin_unlock+0x30/0x50 [ 2655.371972] [] ? page_swapcount+0x4e/0x60 [ 2655.371972] [] swap_writepage+0x72/0x80 [ 2655.371972] [] pageout+0x167/0x2e0 [ 2655.371972] [] shrink_page_list+0x4f4/0x7c0 [ 2655.371972] [] shrink_inactive_list+0x31c/0x570 [ 2655.371972] [] ? shrink_active_list+0x30b/0x320 [ 2655.371972] [] shrink_lruvec+0x124/0x300 [ 2655.371972] [] ? sched_clock+0x1d/0x30 [ 2655.371972] [] shrink_zone+0x8e/0x1d0 [ 2655.371972] [] kswapd_shrink_zone+0xf1/0x1b0 [ 2655.371972] [] balance_pgdat+0x363/0x540 [ 2655.371972] [] ? finish_wait+0x70/0x90 [ 2655.371972] [] kswapd+0x2eb/0x350 [ 2655.371972] [] ? ftrace_raw_event_mm_vmscan_writepage+0x180/0x180 [ 2655.371972] [] kthread+0x105/0x110 [ 2655.371972] [] ? __lock_release+0x1e2/0x200 [ 2655.371972] [] ? set_kthreadd_affinity+0x30/0x30 [ 2655.371972] [] ret_from_fork+0x7c/0xb0 [ 2655.371972] [] ? set_kthreadd_affinity+0x30/0x30 Signed-off-by: Minchan Kim Reported-by: Sasha Levin Cc: Sergey Senozhatsky Signed-off-by: Andrew Morton --- drivers/block/zram/zram_drv.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff -puN drivers/block/zram/zram_drv.c~zram-delete-zram_init_device-fix drivers/block/zram/zram_drv.c --- a/drivers/block/zram/zram_drv.c~zram-delete-zram_init_device-fix +++ a/drivers/block/zram/zram_drv.c @@ -537,26 +537,27 @@ static ssize_t disksize_store(struct dev struct device_attribute *attr, const char *buf, size_t len) { u64 disksize; + struct zram_meta *meta; struct zram *zram = dev_to_zram(dev); disksize = memparse(buf, NULL); if (!disksize) return -EINVAL; + disksize = PAGE_ALIGN(disksize); + meta = zram_meta_alloc(disksize); + if (!meta) + return -ENOMEM; + down_write(&zram->init_lock); if (init_done(zram)) { + zram_meta_free(meta); up_write(&zram->init_lock); pr_info("Cannot change disksize for initialized device\n"); return -EBUSY; } - disksize = PAGE_ALIGN(disksize); - zram->meta = zram_meta_alloc(disksize); - if (!zram->meta) { - up_write(&zram->init_lock); - return -ENOMEM; - } - + zram->meta = meta; zram->disksize = disksize; set_capacity(zram->disk, zram->disksize >> SECTOR_SHIFT); up_write(&zram->init_lock); _ Patches currently in -mm which might be from minchan@kernel.org are origin.patch mm-vmallocc-enhance-vm_map_ram-comment.patch zram-drop-init_done-struct-zram-member.patch zram-do-not-pass-rw-argument-to-__zram_make_request.patch zram-remove-good-and-bad-compress-stats.patch zram-use-atomic64_t-for-all-zram-stats.patch zram-remove-zram-stats-code-duplication.patch zram-report-failed-read-and-write-stats.patch zram-drop-not-used-table-count-member.patch zram-move-zram-size-warning-to-documentation.patch zram-document-failed_reads-failed_writes-stats.patch zram-delete-zram_init_device.patch zram-introduce-compressing-backend-abstraction.patch zram-use-zcomp-compressing-backends.patch zram-use-zcomp-compressing-backends-fix.patch zram-factor-out-single-stream-compression.patch zram-add-multi-stream-functionality.patch zram-add-set_max_streams-knob.patch zram-make-compression-algorithm-selection-possible.patch zram-add-lz4-algorithm-backend.patch zram-move-comp-allocation-out-of-init_lock.patch zram-return-error-valued-pointer-from-zcomp_create.patch zram-return-error-valued-pointer-from-zcomp_create-fix.patch zram-propagate-error-to-user.patch zram-propagate-error-to-user-fix.patch zram-propagate-error-to-user-fix-2.patch zram-use-scnprintf-in-attrs-show-methods.patch zram-support-req_discard.patch zram-support-req_discard-v4.patch zram-support-req_discard-v4-fix.patch mm-zswap-fix-trivial-typo-and-arrange-indentation.patch mm-zswap-update-zsmalloc-in-comment-to-zbud.patch mm-zswap-support-multiple-swap-devices.patch