Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp223731img; Wed, 20 Mar 2019 18:33:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqx8RTjs/lLWnj3d+YWaNlI8UGKaLKKazaOcuZygaK+eWWQXVY5c4iSZNcwqtV8RfUhQ78XX X-Received: by 2002:a63:561f:: with SMTP id k31mr958880pgb.319.1553132006326; Wed, 20 Mar 2019 18:33:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553132006; cv=none; d=google.com; s=arc-20160816; b=EBWqZP6GhV2VGb8lMHXfT00ftorzJczy7yu6fJ3INHXbUfYVTR8rVWXen8DHbQxwzh SqT66uRlQexpAmvKCVRa+UTZrWI/wdPz9W0XTzHIRoVH6DJCtK30gh1V/T0I9JmOLppY cr+hdm3SEjvRLwq+m4Pail0E+v2OhnVSFuFGYjKZiHbICEbTx3jqy9JwaAKX+kdDW6x9 jE91QdZEgDBprQborjI1skx4vSOKBoD5OlgO8NvnWeMDyQNC6yefQi1NuTzXHbs6bgfF 9d5lq4upEVFVNLMVASCCbxWO0VRS78SOe7rJUAjLfTNQsjgWsyUjjqWoSuFaKuFquz92 SAuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=tHqaXZAUo6StWTKwDVBLWpvAhmFJGq957ch/0cuFhIc=; b=xTrv1Bbl8aSKCmFedzFBClWAHnBPplwHnlTQErrKavM55UdUB14RcoHZBkcjWqtDzC q0nd7FCVP0AE3eRHYJaSRxZSviAI/ATPfkGHpuDYwPooO5wJRz6w+tN1ezv0y1r7lzDZ 2AgFgfMIEM9hFwgiV/+4KiZXBzyLp9iKK2geWkJj5pkSm+djec+977Ds7Dd0CYbiAQr4 wLxO3Bbx40u8n/klyBHoPhB5o7TuVsfi7CfoCfS9qwuWbrKUzHmXHKex0tORq/Uim+UC I9q+RcknxYn3d5+3szJ7xmM4yB7nbSMIzHG9fCRgDG1wvbJOdJSQZlCy5Fho3fA6DP4A o4iQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b="sDTBq/Sx"; 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 d30si3418625pld.82.2019.03.20.18.33.11; Wed, 20 Mar 2019 18:33:26 -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="sDTBq/Sx"; 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 S1727638AbfCUBbL (ORCPT + 99 others); Wed, 20 Mar 2019 21:31:11 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:60842 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726753AbfCUBbL (ORCPT ); Wed, 20 Mar 2019 21:31:11 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x2L1NbbX014048; Thu, 21 Mar 2019 01:30:49 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=tHqaXZAUo6StWTKwDVBLWpvAhmFJGq957ch/0cuFhIc=; b=sDTBq/SxzOO3LKORzHmbieurenqD7aky+gYKqalj7CRJ9YmHYWF9h30PPSjavJcTfoBS aD9eN7Nm0RHiCBAQgNtEmU28/otcLl9LvKcglMdA8oghnni4G50Mj97IkxVpRCWe24lE ChD3G4Vxf5rZ9d1croNQ4dLLzUE78i1u2NxZwPdtuS4XSoPcDJ908188wJ41C9yVdTJw rM8/JBL62SscIebLrx+HUZt50S/R1eanEEHre78///T/PJEA+Yn6gCnbcNXFTfaGiaAN SWcZoAqGwErwI48yhpASZmjnXi0xoFVnNtKqGUIRY/lJDYWQ5vJwKOqufTDQwfq+jE6/ xg== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2130.oracle.com with ESMTP id 2r8pnex5vy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 Mar 2019 01:30:49 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x2L1Umb5013151 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 Mar 2019 01:30:48 GMT Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x2L1UlDH020203; Thu, 21 Mar 2019 01:30:47 GMT Received: from [10.182.71.8] (/10.182.71.8) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 20 Mar 2019 18:30:47 -0700 Subject: Re: [PATCH 2/8] blk-mq: change the method of iterating busy tags of a request_queue To: Sagi Grimberg , axboe@kernel.dk Cc: hch@lst.de, jthumshirn@suse.de, hare@suse.de, josef@toxicpanda.com, bvanassche@acm.org, keith.busch@intel.com, jsmart2021@gmail.com, linux-block@vger.kernel.org, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org References: <1552640264-26101-1-git-send-email-jianchao.w.wang@oracle.com> <1552640264-26101-3-git-send-email-jianchao.w.wang@oracle.com> From: "jianchao.wang" Message-ID: Date: Thu, 21 Mar 2019 09:33:58 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9201 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1903210008 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Sagi Thanks for your kindly response. On 3/21/19 2:52 AM, Sagi Grimberg wrote: > > > On 3/15/19 1:57 AM, Jianchao Wang wrote: >> tags->rqs[] will not been cleaned when free driver tag and there >> is a window between get driver tag and write tags->rqs[], so we >> may see stale rq in tags->rqs[] which may have been freed, as >> following case, >> blk_mq_get_request         blk_mq_queue_tag_busy_iter >>    -> blk_mq_get_tag >>                               -> bt_for_each >>                                 -> bt_iter >>                                   -> rq = taags->rqs[] >>                                   -> rq->q >>    -> blk_mq_rq_ctx_init >>      -> data->hctx->tags->rqs[rq->tag] = rq; >> >> To fix this, the blk_mq_queue_tag_busy_iter is changed in this >> patch to use tags->static_rqs[] instead of tags->rqs[]. We have >> to identify whether there is a io scheduler attached to decide >> to use hctx->tags or hctx->sched_tags. And we will try to get a >> non-zero q_usage_counter before that, so it is safe to access >> them. Add 'inflight' parameter to determine to iterate in-flight >> requests or just busy tags. A correction here is that >> part_in_flight should count the busy tags instead of rqs that >> have got driver tags. > > IMO, instead of this parameter, add a wrapper like > blk_mq_queue_tag_inflight_iter() or keep the parameter out until > we actually have a user that calls it for busy and not inflight. Using a wrapper instead of exporting the parameter to user is indeed better. I will change it in next version. When the 'inflight' parameter is true, we iterate the inflight requests, otherwise, we iterate the all the busy requests no matter they are in-flight or not. The latter would be useful for part_in_flight. Currently, we only account the requests with driver tags, it is inconsistent for the io-scheduler and non-io-scheduler case. > > Other than that, I think that iterating over static_rqs is a good > solution to the problem described. > Sincerely Jianchao