Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933768AbbBISKh (ORCPT ); Mon, 9 Feb 2015 13:10:37 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33755 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932870AbbBISKg (ORCPT ); Mon, 9 Feb 2015 13:10:36 -0500 Date: Mon, 9 Feb 2015 13:10:04 -0500 (EST) From: Mikulas Patocka X-X-Sender: mpatocka@file01.intranet.prod.int.rdu2.redhat.com To: Ingo Molnar , Peter Zijlstra , Jens Axboe , Neil Brown cc: Zdenek Kabelac , Heinz Mauelshagen , "Alasdair G. Kergon" , dm-devel@redhat.com, linux-kernel@vger.kernel.org Subject: [PATCH] sched: call blk_schedule_flush_plug from io_schedule Message-ID: User-Agent: Alpine 2.02 (LRH 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4319 Lines: 97 The function raid10_unplug tests the "from_schedule" variable. If the variable is true, it offloads queued bios to a thread. If the variable is false, it submits queued bios directly. The function io_schedule calls blk_flush_plug, that calls blk_flush_plug_list with "from_schedule" set to false. Consequently, raid10_unplug tries to submit the bios directly when being called from io_schedule, and that results in this warning. Fix the bug by calling blk_schedule_flush_plug instead of blk_flush_plug from io_schedule. WARNING: CPU: 0 PID: 2876 at kernel/sched/core.c:7326 __might_sleep+0xae/0xc0() md: using maximum available idle IO bandwidth (but not more than 200000 KB/sec) for resync. do not call blocking ops when !TASK_RUNNING; state=2 set at [] do_blockdev_direct_IO+0x11a0/0x2e50 Modules linked in: loop dm_raid raid456 async_raid6_recov async_memcpy async_pq async_xor async_tx raid1 raid10 xor raid6_pq nfsv4 nfs nfsd auth_rpcgss oid_registry nfs_acl lockd grace sunrpc autofs4 fuse dm_crypt md_mod uhci_hcd ehci_hcd usbcore i2c_piix4 serio_raw i2c_core virtio_net usb_common floppy pvpanic evdev sym53c8xx dm_mirror dm_region_hash dm_log dm_mod md: using 128k window, over a total of 1024k. CPU: 0 PID: 2876 Comm: lvm Not tainted 3.19.0-rc7-00195-gd4cecd5 #7 Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011 ffffffff819e4eba ffff88003c493818 ffffffff8163975d 0000000000000007 ffff88003c493868 ffff88003c493858 ffffffff810587ba 00000000001d4280 ffffffffa013b2b4 00000000000002e9 0000000000000000 ffff88003a8be010 Call Trace: [] dump_stack+0x4f/0x7b [] warn_slowpath_common+0x8a/0xc0 [] warn_slowpath_fmt+0x46/0x50 [] ? __lock_acquire+0x411/0x1d10 [] ? do_blockdev_direct_IO+0x11a0/0x2e50 [] ? do_blockdev_direct_IO+0x11a0/0x2e50 [] __might_sleep+0xae/0xc0 [] md_super_wait+0x26/0x90 [md_mod] [] bitmap_unplug+0x193/0x1a0 [md_mod] [] ? __delayacct_blkio_start+0x23/0x30 [] raid10_unplug+0xe0/0x160 [raid10] [] blk_flush_plug_list+0xaa/0x250 [] ? trace_hardirqs_on+0xd/0x10 [] io_schedule+0x82/0x150 [] do_blockdev_direct_IO+0x11ca/0x2e50 [] ? sched_clock_local+0x25/0x90 [] ? I_BDEV+0x10/0x10 [] __blockdev_direct_IO+0x4c/0x50 [] ? I_BDEV+0x10/0x10 [] blkdev_direct_IO+0x4e/0x50 [] ? I_BDEV+0x10/0x10 [] generic_file_direct_write+0xb5/0x190 [] __generic_file_write_iter+0x2e5/0x390 [] blkdev_write_iter+0x2f/0xa0 [] new_sync_write+0x81/0xb0 [] vfs_write+0xba/0x1f0 [] SyS_write+0x49/0xb0 [] sysenter_dispatch+0x7/0x1f [] ? trace_hardirqs_on_thunk+0x3a/0x3f ---[ end trace 28ea2673fb871796 ]--- Signed-off-by: Mikulas Patocka Reported-by: Zdenek Kabelac Cc: stable@vger.kernel.org # 2.6.39+ --- kernel/sched/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) Index: linux-2.6/kernel/sched/core.c =================================================================== --- linux-2.6.orig/kernel/sched/core.c 2015-02-09 11:35:35.169156491 +0100 +++ linux-2.6/kernel/sched/core.c 2015-02-09 12:11:35.140557980 +0100 @@ -4397,7 +4397,7 @@ void __sched io_schedule(void) delayacct_blkio_start(); atomic_inc(&rq->nr_iowait); - blk_flush_plug(current); + blk_schedule_flush_plug(current); current->in_iowait = 1; schedule(); current->in_iowait = 0; @@ -4413,7 +4413,7 @@ long __sched io_schedule_timeout(long ti delayacct_blkio_start(); atomic_inc(&rq->nr_iowait); - blk_flush_plug(current); + blk_schedule_flush_plug(current); current->in_iowait = 1; ret = schedule_timeout(timeout); current->in_iowait = 0; -- 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/