From patchwork Thu Sep 20 10:18:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "jianchao.wang" X-Patchwork-Id: 10607335 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A2C15157B for ; Thu, 20 Sep 2018 10:16:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 928032D011 for ; Thu, 20 Sep 2018 10:16:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 86BFA2D075; Thu, 20 Sep 2018 10:16:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 31EEC2D011 for ; Thu, 20 Sep 2018 10:16:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732041AbeITP7Y (ORCPT ); Thu, 20 Sep 2018 11:59:24 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:39808 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732386AbeITP7X (ORCPT ); Thu, 20 Sep 2018 11:59:23 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w8KAElB6101811; Thu, 20 Sep 2018 10:16:29 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2018-07-02; bh=k0YYcOTAshlZS+iJ74UVfkcpxEThRuemmV4FagmPDAU=; b=FQACT33o2G5Koi9kGq1HVWCL2f1ebf4nn63y9uHfM46bDvBTUgILwL7fb0hxzcXzqZZN CSSXRNtM6bIb/SFLO0SolEpEJm41lG2r450ypXCJ9UKi7reYqgHcnvxW5+3Tfy6ArA0g pMk7G3MEWgK5tpmPuyOW5cuRDREklbMBhMGNfGrKp992YBHw3mWF37iP8RVwKCqs1CF6 LaBn/h0liJrbnCZUeHOkUKyqDRGMA26DrtVom5ME5gFTkVdki311hnV9oOu+qnlO+QHK 4Kp47URrt3oTCCOYpQvnGlGH/5N98uIU3RhNBr0rJcht6Bk+sl6Mxl8zL6rS6j5eN4Dy vQ== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2130.oracle.com with ESMTP id 2mgsgu1udf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 Sep 2018 10:16:29 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w8KAGTBF021138 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 Sep 2018 10:16:29 GMT Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w8KAGSHJ005443; Thu, 20 Sep 2018 10:16:28 GMT Received: from will-ThinkCentre-M910s.cn.oracle.com (/10.182.70.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 20 Sep 2018 03:16:28 -0700 From: Jianchao Wang To: axboe@kernel.dk, tj@kernel.org, kent.overstreet@gmail.com, ming.lei@redhat.com, bart.vanassche@wdc.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 0/3] blk-mq: rework queue freeze and preempt-only Date: Thu, 20 Sep 2018 18:18:20 +0800 Message-Id: <1537438703-25217-1-git-send-email-jianchao.w.wang@oracle.com> X-Mailer: git-send-email 2.7.4 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9021 signatures=668707 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=677 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1809200105 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi all The current queue freeze depending on percpu_ref_kil/reinit has a limit that we have drain the requests before unfreeze the queue. Let's rework the queue freeze feature as following: 1. introduce __percpu_ref_get_many. It is same with original percpu_ref_get_many, but just need callers to provide sched rcu critical section. We will put the __percpu_ref_get_many and our own condition checking under rcu_read_lock_sched. With this new helper interface, we could save an extra rcu_read_lock_sched. 2. rework the blk_queue_enter as: rcu_read_lock_sched() if condition check true __percpu_ref_get_many(&q->q_usage_counter, 1) else goto wait rcu_read_unlock_sched() 3. use percpu_ref_switch_to_atomic/percpu to switch mode directly. Then we could unfreeze the queue w/o draining requests. In addition, preempt-only mode code could be simplified. Jianchao Wang (3) percpu_ref: add a new helper interface blk-core: rework the queue freeze block, scsi: rework the preempt only mode d16c830226a0ac15cb5947479030b block/blk-core.c | 58 ++++++++++++++++++++++++++-------------------------------- block/blk-mq-debugfs.c | 1 - block/blk-mq.c | 8 ++++++-- block/blk.h | 5 +++++ drivers/scsi/scsi_lib.c | 12 ++++-------- include/linux/blkdev.h | 5 ++--- include/linux/percpu-refcount.h | 23 +++++++++++++++++------ 7 files changed, 60 insertions(+), 52 deletions(-) Thanks Jianchao