Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp4809495imm; Fri, 18 May 2018 11:01:11 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqNmMCLOYzOzwgQv30q7lXuoDUE/1NzfoHr9AThwZY7WytrC0h0KgAETEi9jwcIwJB7Cllh X-Received: by 2002:a63:8f43:: with SMTP id r3-v6mr8280966pgn.10.1526666471324; Fri, 18 May 2018 11:01:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526666471; cv=none; d=google.com; s=arc-20160816; b=KYj+9/fFQB7f4mtFsvR0UGawFHjUBNhRcGQiHXxTZ4b752K1hR5YNqFK4EGnMTndMO B5NkmTjCFB1W9J8/dEXhII9C+AK8MKeM2eW1uIJ/Y+kxpxM4vdqdKCB4cQ0+sUFvscxX JHt81hMlK2JfPOIrMfC9L98GEaW9OEJJPICP4in3KXl9ga1mmbpxEdy2rXWCRNjuDqIv +iSOw4TNOxZyUhZkRC2+NAfH3rJbm1OU+qbsye1m40hBwirWYcvf9FSGQBEMKf8+z/0G cxeAfqa92GfaJZIXEsHxvVF45oWQRFxEnmHRP7JfLJPQBO9Gs73uHE+AzyumO7QxGX2P am9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=/ZLvThhw4/fPHx60zBYhgwajiRpKPEXr6m+LjxcpLcc=; b=yP6b/cVBbfKMMQAt8F3gHwKYfVl1G1CNosOL+RHLAA1ncuOcvJfZXaQMlvUIp2LitA 4FBcy76nGNUHgPANLNbNrKQzKQ2MjIaXX/sYSHC2k0kYbA3u3VMnlCf704EtyNsUa6XR eCCLx9dcafIOseJIhcAIv0L6XYkIRM0mJD459fGdIiLydeezYBWtB/BClQrUEkEYDqpW NMBINXDH3M6YabRwCCPbQJBoDN8bWF2R9UuHWdRJsr12CHyc4sIVO4VlUVmIKiqYINRz 8gCYbUDIR1vkIlhhYmSbX6H9dgcD0SG/3k2UJvBw6wwaQhqFWfQZjw8m0ZGuAS+nyRnS 91HQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=I0jkBoUM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y188-v6si6469471pgb.61.2018.05.18.11.00.55; Fri, 18 May 2018 11:01:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=I0jkBoUM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751851AbeERSAJ (ORCPT + 99 others); Fri, 18 May 2018 14:00:09 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:57928 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750957AbeERSAH (ORCPT ); Fri, 18 May 2018 14:00:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1526666408; x=1558202408; h=from:to:cc:subject:date:message-id; bh=j2Z9S65dYhxzCM0Q3+b8fsVkkuQntWl8CSvysJ0K6EU=; b=I0jkBoUMMh9Omn8CePhPyPQawONIru6o0puTuRkhzHOyKHpnBYwTdLmt GawhLftBY5eKVXEaLyr69/OHkKRdSCBQBS5uNxuvJmGhZnkDMGCeXjzM5 3hbSpSvzsd0InVlr7CG/hWB+qkFB5l7skaVLo3VK3fxGPexXxp5c/PXqp NrSg/piT8/IzdLG6MD682V05+EjlCA/vtVhsLiMKKLNNlBYKG06oATtvU O+eVmLs/n7HwmWTvmAVAg7MMHAFfSZXgzlYRMjZ2KnBA/H/BB0SzUFUi1 y1M6qj/KRj6MoIJxdYuzcDXxVguajn5VJin5Y73lO6Az+mJvx7d2Gcu4c w==; X-IronPort-AV: E=Sophos;i="5.49,415,1520870400"; d="scan'208";a="78647829" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 19 May 2018 02:00:08 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP; 18 May 2018 10:51:08 -0700 Received: from thinkpad-bart.sdcorp.global.sandisk.com ([10.111.70.1]) by uls-op-cesaip01.wdc.com with ESMTP; 18 May 2018 11:00:06 -0700 From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Christoph Hellwig , Bart Van Assche Subject: [PATCH v11 0/2] blk-mq: Rework blk-mq timeout handling again Date: Fri, 18 May 2018 11:00:04 -0700 Message-Id: <20180518180006.24389-1-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.16.3 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Jens, This patch series reworks blk-mq timeout handling by introducing a state machine per request. Please consider this patch series for inclusion in the upstream kernel. Bart. Changes compared to v10: - In patch 1/2, added "default y if 64BIT" to the "config ARCH_HAVE_CMPXCHG64" entry in arch/Kconfig. Left out the "select ARCH_HAVE_CMPXCHG64" statements that became superfluous due to this change (alpha, arm64, powerpc and s390). - Also in patch 1/2, only select ARCH_HAVE_CMPXCHG64 if X86_CMPXCHG64 has been selected. - In patch 2/2, moved blk_mq_change_rq_state() from blk-mq.h to blk-mq.c. - Added a comment header above __blk_mq_requeue_request() and blk_mq_requeue_request(). - Documented the MQ_RQ_* state transitions in block/blk-mq.h. - Left out the fourth argument of blk_mq_rq_set_deadline(). Changes compared to v9: - Addressed multiple comments related to patch 1/2: added CONFIG_ARCH_HAVE_CMPXCHG64 for riscv, modified features/locking/cmpxchg64/arch-support.txt as requested and made the order of the symbols in the arch/*/Kconfig alphabetical where possible. Changes compared to v8: - Split into two patches. - Moved the spin_lock_init() call from blk_mq_rq_ctx_init() into blk_mq_init_request(). - Fixed the deadline set by blk_add_timer(). - Surrounded the das_lock member with #ifndef CONFIG_ARCH_HAVE_CMPXCHG64 / #endif. Changes compared to v7: - Fixed the generation number mechanism. Note: with this patch applied the behavior of the block layer does not depend on the generation number. - Added more 32-bit architectures to the list of architectures on which cmpxchg64() should not be used. Changes compared to v6: - Used a union instead of bit manipulations to store multiple values into a single 64-bit field. - Reduced the size of the timeout field from 64 to 32 bits. - Made sure that the block layer still builds with this patch applied for the sh and mips architectures. - Fixed two sparse warnings that were introduced by this patch in the WRITE_ONCE() calls. Changes compared to v5: - Restored the synchronize_rcu() call between marking a request for timeout handling and the actual timeout handling to avoid that timeout handling starts while .queue_rq() is still in progress if the timeout is very short. - Only use cmpxchg() if another context could attempt to change the request state concurrently. Use WRITE_ONCE() otherwise. Changes compared to v4: - Addressed multiple review comments from Christoph. The most important are that atomic_long_cmpxchg() has been changed into cmpxchg() and also that there is now a nice and clean split between the legacy and blk-mq versions of blk_add_timer(). - Changed the patch name and modified the patch description because there is disagreement about whether or not the v4.16 blk-mq core can complete a single request twice. Kept the "Cc: stable" tag because of https://bugzilla.kernel.org/show_bug.cgi?id=199077. Changes compared to v3 (see also https://www.mail-archive.com/linux-block@vger.kernel.org/msg20073.html): - Removed the spinlock again that was introduced to protect the request state. v4 uses atomic_long_cmpxchg() instead. - Split __deadline into two variables - one for the legacy block layer and one for blk-mq. Changes compared to v2 (https://www.mail-archive.com/linux-block@vger.kernel.org/msg18338.html): - Rebased and retested on top of kernel v4.16. Changes compared to v1 (https://www.mail-archive.com/linux-block@vger.kernel.org/msg18089.html): - Removed the gstate and aborted_gstate members of struct request and used the __deadline member to encode both the generation and state information. Bart Van Assche (2): arch/*: Add CONFIG_ARCH_HAVE_CMPXCHG64 blk-mq: Rework blk-mq timeout handling again .../features/locking/cmpxchg64/arch-support.txt | 33 +++ arch/Kconfig | 4 + arch/arm/Kconfig | 1 + arch/ia64/Kconfig | 1 + arch/m68k/Kconfig | 1 + arch/mips/Kconfig | 1 + arch/parisc/Kconfig | 1 + arch/riscv/Kconfig | 1 + arch/sparc/Kconfig | 1 + arch/x86/Kconfig | 1 + arch/xtensa/Kconfig | 1 + block/blk-core.c | 6 - block/blk-mq-debugfs.c | 1 - block/blk-mq.c | 238 ++++++++++----------- block/blk-mq.h | 64 +++--- block/blk-timeout.c | 133 ++++++++---- block/blk.h | 11 +- include/linux/blkdev.h | 47 ++-- 18 files changed, 308 insertions(+), 238 deletions(-) create mode 100644 Documentation/features/locking/cmpxchg64/arch-support.txt -- 2.16.3