Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp4771186imm; Tue, 21 Aug 2018 00:16:03 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxtQoMacMM82WYhItPZOeF0q3SJs36kC3w0856T9XrcocmmjP3RhngUN3U7GWk6481g+MUP X-Received: by 2002:a17:902:6a83:: with SMTP id n3-v6mr48333205plk.246.1534835763023; Tue, 21 Aug 2018 00:16:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534835762; cv=none; d=google.com; s=arc-20160816; b=q+LF89YDo1t4ZdM1bWUOm0iUAp6t3wKoVbfwKjbpGhctwt4XUTaY8fdGKX00+/tVnB Oei2M5FcBJWFA9URIcektCwe5uyXr7IxLotbhV0IivgUgrEcp+A0yLz71fKlTNJL+SfN X+ndV6CtgctQaK/JHXrQTCokHbR/Z76V5VUj8Un75qcfsysuICq+Eqj+GTBHff6QSDxG ETf5ifV3uT2ZwfE4Vb5skdx70mK5f5tGr2VJedlq2sTtNy2qAaPzc2PfLeGddmyxeGqG IkFx+iKQqAPa2C9b3YER1Cep6dopdfD1DWahFm1M4Ns51zvLPdm9xh3S/o0Nq15Nchp+ pLUQ== 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=6TIaqKH6ViEFixweGPApxgoBo5j5hF7eaXg01YuXG9Q=; b=pBdcwXuEU1OL46mB5t5h6KiEATbgmaeAQsU1CZ5c37h/J2TH5CwXXVvJSPGTxTPtX4 r4mG3n6f+bEylx4QhQULoeSf/il6ba0dqIrsxVI6/3NAd04XCWcXbpQmiHMgPlPPg1Qm g4gV1R8QSQyv+HTvvzAgbTH95u1v7bU+TSp+DiHPhM/xS+u8PdLEy+9fU9iwqcvqEJjn pZe9inuQGYtjnCFVPAbypHNuqDRQEaSgWScPjN6HYC7hs3aE+frs5iUQ/7Z/P7NacgwC 3YZC4Fg39k+7jBNBmo4tQcV3OkbAEfEO7wkatPN8jawjXQuX82prbUIROxfJ6fFDObLm crEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=vVWXyvNX; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m13-v6si11247031pgk.251.2018.08.21.00.15.46; Tue, 21 Aug 2018 00:16:02 -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=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=vVWXyvNX; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726761AbeHUKc2 (ORCPT + 99 others); Tue, 21 Aug 2018 06:32:28 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:44290 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726315AbeHUKc2 (ORCPT ); Tue, 21 Aug 2018 06:32:28 -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 w7L78xGx070774; Tue, 21 Aug 2018 07:13:27 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=6TIaqKH6ViEFixweGPApxgoBo5j5hF7eaXg01YuXG9Q=; b=vVWXyvNX0CW4ZcXIA2nITyUi++sbswhy5X5Jj2PXMOVX5rIPlNwoL+9kxwyc0uudolJZ DYGdSEDmgFpHZtooggzOCS+ZIcBMq+nvPe3yVYD19O80tcaGfXPUOenIvGniJDqiVOz+ Uk0w4VCGtlTm6AANspXre1z1agNEG3/x0gmrjfESRqkG8SibKNyTro0Mw88CUrCqjHZE 5TUMg/abxjYZNnoPm/ukzwSfTtZDM5uxsvZ/2+euPxf3r1q9iUoiS6BuSaySHqVLFG4X pYwxaAlTx3VugEYkH7ZR5Um64MKPsHoLrQZRSooFdq4lZqau0j97EevBgeGN6vuabxr9 3Q== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2kxavtjjwy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 21 Aug 2018 07:13:27 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w7L7DPg7029950 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 21 Aug 2018 07:13:26 GMT Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w7L7DOfE014463; Tue, 21 Aug 2018 07:13:25 GMT Received: from will-ThinkCentre-M910s.cn.oracle.com (/10.182.70.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 21 Aug 2018 00:13:24 -0700 From: Jianchao Wang To: axboe@kernel.dk Cc: tom.leiming@gmail.com, bart.vanassche@wdc.com, keith.busch@linux.intel.com, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH V4 0/2] fixes for the updating nr_hw_queues Date: Tue, 21 Aug 2018 15:15:02 +0800 Message-Id: <1534835704-3607-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=8991 signatures=668707 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=892 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1808210076 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jens Two fixes for updating nr_hw_queues. The first patch fixes the following scenario: io scheduler (kyber) depends on the mapping between ctx and hctx. When update nr_hw_queues, io scheduler's init_hctx will be invoked before the mapping is adapted correctly, this would cause panic in kyber. The second patch fixes the following scenario: part_in_flight/rw will invoke blk_mq_in_flight/rw to account the inflight requests. It will access the queue_hw_ctx and nr_hw_queues w/o any protection. When updating nr_hw_queues and blk_mq_in_flight /rw occur concurrently, panic comes up. V4: - remove the elv_type in request_queue and introduce blk_mq_qe_pair to cache the elevator_type associated with one request_queue. And add two new helper interfaces blk_mq_elv_switch_none/back to carry out the elevator_type caching and switching work. - Add Ming's Reviewd-by on 2nd patch and remove it from 1st patch due to the reworking. - comment modification. V3: - move the rcu and q_usage_counter checking into blk_mq_queue_tag_busy_iter as suggestion of Ming. - Add more comment about the __module_get in 1st patch. - Add Ming's Reviewd-by on 1st patch. V2: - remove blk_mq_sched_init/exit_hctx in patch 1. - use q_usage_counter instead of adding new member suggested by Ming in patch 2. - comment modification. block/blk-mq-sched.c | 44 -------------------------------------------- block/blk-mq-sched.h | 5 ----- block/blk-mq-tag.c | 14 +++++++++++++- block/blk-mq.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------- block/blk.h | 2 ++ block/elevator.c | 20 ++++++++++++-------- 6 files changed, 115 insertions(+), 66 deletions(-) Thanks Jianchao