Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2260598pxb; Thu, 28 Oct 2021 20:17:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJweBu3p0Zqha2CZWBy5XNOpE0dURSjJkHSt6ySoOgV5Hfx3CdBlix7UEA6rfaKy/AHVTHVD X-Received: by 2002:a17:907:9694:: with SMTP id hd20mr10173553ejc.508.1635477465873; Thu, 28 Oct 2021 20:17:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635477465; cv=none; d=google.com; s=arc-20160816; b=rzRjqnTST6AUQMab5NDOtPPMoH9cKtx1vjv8plfx5CQHOVEgKX8phW4pYXSjZH7Cbn UdSRmwJkLfDDw0Zr8ZWTvZ+We5DmaS+zBRc4Zy4H0FIo/LUC0NJE0/oab6ilXSofSLH3 oFPAKNXIj6EAOxvxm8nx3D674P+mQC7+z3095hRCmDrWAV72zn9yGDB6oAyQHCuSd0xh hgAdo5cipNMQv5DrMvlUso5Ycv/Nw05AXhYWMF3/nqqGoGyqgAXKwdHglW2dpDL4w0C0 oeAw5wbPhszEDM+BIFe55VD8VUCOCka3PEJwGgyhvNMKNmMkSB0vGv1DyxESE4P5rSjx vZlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=3pYzmXHRuJS5a4JTUR2VzeH599pTh8w8NKmslhTSrbs=; b=TXk0si0UZJKXZ3r4sjVn+xNhAuOQS+MFEQxhXoxxM3E5+wz+Ljr++HW4PyLDnN/hhO z4nIvT7yXim/1f5aCghPb85bW2Yvm6PMfdFmyvPc91seDEDhR/li36frZ2YD9BKmK/UG EFZRNfjXx8prHwSgY9muhofbT5IPCok4SiksqOVh1Ek6Dp6q8bgeEVkQYcrwp2BqFNlF YjP1U0jwYycHGZDb0Bo3/iP0DZCmA/izvNNT9TPC1aouJxz3+flN1NkUkVpWYIlalwQX LYP59uA7LdvtWl7KoA6Q+IuSD5rg6qlyhjv6Wa9pfNeK4XAIsFSyQN39CgiOCmzMFWk9 K1bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=HHegkJw4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c14si7417175ede.420.2021.10.28.20.17.21; Thu, 28 Oct 2021 20:17:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=HHegkJw4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231629AbhJ2DSE (ORCPT + 99 others); Thu, 28 Oct 2021 23:18:04 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:24399 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231584AbhJ2DSD (ORCPT ); Thu, 28 Oct 2021 23:18:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635477335; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=3pYzmXHRuJS5a4JTUR2VzeH599pTh8w8NKmslhTSrbs=; b=HHegkJw46wucSIuhMlABN7N9urs8r95iqhKJi5lwmVTmCvWfR3XRprC8ilfPr6cs+tXxEQ A5ldyiDWMIa/MIoxj2jgqv+4AmP1piePOrZernw7O9SVs5RSPol8fjYJtavBnthj2jTjxq iI/vAHyObtmpHxCTO8lqb1Hd/UxFVuA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-421-S-hPaw3BN8ygbqkn2yGlNg-1; Thu, 28 Oct 2021 23:15:30 -0400 X-MC-Unique: S-hPaw3BN8ygbqkn2yGlNg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5A2A7802682; Fri, 29 Oct 2021 03:15:28 +0000 (UTC) Received: from T590 (ovpn-8-17.pek2.redhat.com [10.72.8.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 36C2060843; Fri, 29 Oct 2021 03:15:04 +0000 (UTC) Date: Fri, 29 Oct 2021 11:14:59 +0800 From: Ming Lei To: Daejun Park Cc: ALIM AKHTAR , "avri.altman@wdc.com" , "jejb@linux.ibm.com" , "martin.petersen@oracle.com" , "huobean@gmail.com" , "bvanassche@acm.org" , Keoseong Park , "linux-scsi@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] scsi: ufs: Fix proper API to send HPB pre-request Message-ID: References: <20211027223619epcms2p60bbc74c9ba9757c58709a99acd0892ff@epcms2p6> <20211029015015epcms2p3a46e0779e43ab84c00388d99abf3b867@epcms2p3> <20211029025012epcms2p429d940cb32f5f31a2ac3fe395538a755@epcms2p4> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211029025012epcms2p429d940cb32f5f31a2ac3fe395538a755@epcms2p4> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 29, 2021 at 11:50:12AM +0900, Daejun Park wrote: > > On Fri, Oct 29, 2021 at 10:50:15AM +0900, Daejun Park wrote: > > > > On Thu, Oct 28, 2021 at 07:36:19AM +0900, Daejun Park wrote: > > > > > This patch addresses the issue of using the wrong API to create a > > > > > pre_request for HPB READ. > > > > > HPB READ candidate that require a pre-request will try to allocate a > > > > > pre-request only during request_timeout_ms (default: 0). Otherwise, it is > > > > > > > > Can you explain about 'only during request_timeout_ms'? > > > > > > > > From the following code in ufshpb_prep(), the pre-request is allocated > > > > for each READ IO in case of (!ufshpb_is_legacy(hba) && ufshpb_is_required_wb(hpb, > > > > transfer_len)). > > > > > > > > if (!ufshpb_is_legacy(hba) && > > > > ufshpb_is_required_wb(hpb, transfer_len)) { > > > > err = ufshpb_issue_pre_req(hpb, cmd, &read_id); > > > > > > > > > passed as normal READ, so deadlock problem can be resolved. > > > > > > > > > > Signed-off-by: Daejun Park > > > > > --- > > > > > drivers/scsi/ufs/ufshpb.c | 11 +++++------ > > > > > drivers/scsi/ufs/ufshpb.h | 1 + > > > > > 2 files changed, 6 insertions(+), 6 deletions(-) > > > > > > > > > > diff --git a/drivers/scsi/ufs/ufshpb.c b/drivers/scsi/ufs/ufshpb.c > > > > > index 02fb51ae8b25..3117bd47d762 100644 > > > > > --- a/drivers/scsi/ufs/ufshpb.c > > > > > +++ b/drivers/scsi/ufs/ufshpb.c > > > > > @@ -548,8 +548,7 @@ static int ufshpb_execute_pre_req(struct ufshpb_lu *hpb, struct scsi_cmnd *cmd, > > > > > read_id); > > > > > rq->cmd_len = scsi_command_size(rq->cmd); > > > > > > > > > > - if (blk_insert_cloned_request(q, req) != BLK_STS_OK) > > > > > - return -EAGAIN; > > > > > + blk_execute_rq_nowait(NULL, req, true, ufshpb_pre_req_compl_fn); > > > > > > > > Be care with above change, blk_insert_cloned_request() allocates > > > > driver tag and issues the request to LLD directly, then returns the > > > > result. If anything fails in the code path, -EAGAIN is returned. > > > > > > > > But blk_execute_rq_nowait() simply queued the request in block layer, > > > > and run hw queue. It doesn't allocate driver tag, and doesn't issue it > > > > to LLD. > > > > > > > > So ufshpb_execute_pre_req() may think the pre-request is issued to LLD > > > > successfully, but actually not, maybe never. What will happen after the > > > > READ IO is issued to device, but the pre-request(write buffer) isn't > > > > sent to device? > > > > > > In that case, the HPB READ cannot get benefit from pre-request. But it is not > > > common case. > > > > OK, so the device will ignore the pre-request if it isn't received in > > time, not sure it is common or not, since blk_execute_rq_nowait() > > doesn't provide any feedback. Here looks blk_insert_cloned_request() > > is better. > > Yor're right. > > > > > > > > Can you explain how this change solves the deadlock? > > > > > > The deadlock is happen when the READ waiting allocation of pre-request. But > > > the timeout code makes to stop waiting after given time later. > > > > If you mean blk-mq timeout code will be triggered, I think it won't. > > Meantime, LLD may see nothing to timeout too. > > I mean timeout of the HPB code. Please refer following code: > > if (!ufshpb_is_legacy(hba) && > ufshpb_is_required_wb(hpb, transfer_len)) { > err = ufshpb_issue_pre_req(hpb, cmd, &read_id); > if (err) { > unsigned long timeout; > > timeout = cmd->jiffies_at_alloc + msecs_to_jiffies( > hpb->params.requeue_timeout_ms); > > if (time_before(jiffies, timeout)) > return -EAGAIN; > > hpb->stats.miss_cnt++; > return 0; > } > } > > Although the return value of ufshpb_issue_pre_req() is -EAGAIN, the code > ignores the return value and issues READ not HPB READ. OK, got it, this way should avoid the deadlock. But just be curious why you change hpb->throttle_pre_req to 4, seems it isn't necessary for avoiding the deadlock? Thanks, Ming