Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2284145ybl; Thu, 19 Dec 2019 11:00:31 -0800 (PST) X-Google-Smtp-Source: APXvYqyi8I4aqhmVppIcMTqyIaS9tXgtvtkF7hVx+v6r3R0BYVZ2DGqBDOd7P6DzUgyyQxS6oyEN X-Received: by 2002:a9d:7586:: with SMTP id s6mr10210489otk.342.1576782027013; Thu, 19 Dec 2019 11:00:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576782027; cv=none; d=google.com; s=arc-20160816; b=YLE4XkspuOK+g4pqaxDNwEnbRfnsTKc8ZmSCXSHBQHSng9vro6KTJQjgUFbfK872MK dIouWvsvsP8V7ArP4Oa50LuEYeNJOMIIxW2GD9H9UVVb8izp3AFYyZKPp97w7ZoQ9sq+ 62oC7umYLt0/M2lzOaItf5luETCuvTHye0rkLh861IyobiAvZifzO8G/rIugxD3YEVJx UXz7cd6T8hCNo3MolFaXQA1lK9syPXLbMpGC7c+FT9uvS60Oo/PH1HhmdGiV0qBLdniX RM6kavAQeBnskU/gPHG48qUVkbzkLv8z+y/iYOk1ZV6YoUS0JDp3frAwDziCSuiiNYJG PT5g== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=wYot2XmqYV2HsHNH/FFF0oX7NiM0k+eR7cnki//+t8Q=; b=x4dpsA28jKpuLAwNi59clBsJKj7oZH2fSO1NlpeT1wa3yIz7l+eKrAEiQhxQ3wAgq/ RQppzw4tvrXbvYjcNmphBdJ/6t+uBj+EOC1Ig34R0oSGM1+X3lkfsopDaoQcKTWtldfz BClM6Wfn1qoxM0KBCW7AOgiSdcbZJbMMlskd/6TYnESdgvv8GFiK1YY6ipnyzu9SHlG/ 0OIvljpqWUzOWp6poa+9BzMlGvIiollfHKY4SLNEBzu+ZoXhdVPs/za2PK3/6ymjG5V9 bZvsm72ybZCvUT4/rksegujQhMDGh7p2lKwECciscjewc4YyxjpmNaShmfBpNi8CZAO6 UehA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="RTwbj+t/"; 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 k7si2323133oib.115.2019.12.19.11.00.15; Thu, 19 Dec 2019 11:00:27 -0800 (PST) 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=@kernel.org header.s=default header.b="RTwbj+t/"; 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 S1730263AbfLSSy0 (ORCPT + 99 others); Thu, 19 Dec 2019 13:54:26 -0500 Received: from mail.kernel.org ([198.145.29.99]:49846 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730209AbfLSSyY (ORCPT ); Thu, 19 Dec 2019 13:54:24 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0FF89227BF; Thu, 19 Dec 2019 18:54:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576781663; bh=NDHlV/5kiS7r+Hm2Cfj1Jf69PpoWZ1Y7BukYPq+qrKU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RTwbj+t/UDqO7k+ta/pAT1Ko8RLFSm3rV1Guu00beu/9pUR269hST4b62wT9f18lS 4MeYE2XbuPXPCwZeZZZRtAif2LZdESavXthcPwKS/YgPE6Ht7nS5tRHQu+4KEALDEK OMYllSk7hEzgAznxk7avT+6sWke22QhvBaEe2j1s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Long Li , Steve French Subject: [PATCH 5.4 29/80] cifs: smbd: Only queue work for error recovery on memory registration Date: Thu, 19 Dec 2019 19:34:21 +0100 Message-Id: <20191219183103.776965717@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191219183031.278083125@linuxfoundation.org> References: <20191219183031.278083125@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Long Li commit c21ce58eab1eda4c66507897207e20c82e62a5ac upstream. It's not necessary to queue invalidated memory registration to work queue, as all we need to do is to unmap the SG and make it usable again. This can save CPU cycles in normal data paths as memory registration errors are rare and normally only happens during reconnection. Signed-off-by: Long Li Cc: stable@vger.kernel.org Signed-off-by: Steve French Signed-off-by: Greg Kroah-Hartman --- fs/cifs/smbdirect.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) --- a/fs/cifs/smbdirect.c +++ b/fs/cifs/smbdirect.c @@ -2269,12 +2269,7 @@ static void smbd_mr_recovery_work(struct int rc; list_for_each_entry(smbdirect_mr, &info->mr_list, list) { - if (smbdirect_mr->state == MR_INVALIDATED) - ib_dma_unmap_sg( - info->id->device, smbdirect_mr->sgl, - smbdirect_mr->sgl_count, - smbdirect_mr->dir); - else if (smbdirect_mr->state == MR_ERROR) { + if (smbdirect_mr->state == MR_ERROR) { /* recover this MR entry */ rc = ib_dereg_mr(smbdirect_mr->mr); @@ -2602,11 +2597,20 @@ int smbd_deregister_mr(struct smbd_mr *s */ smbdirect_mr->state = MR_INVALIDATED; - /* - * Schedule the work to do MR recovery for future I/Os - * MR recovery is slow and we don't want it to block the current I/O - */ - queue_work(info->workqueue, &info->mr_recovery_work); + if (smbdirect_mr->state == MR_INVALIDATED) { + ib_dma_unmap_sg( + info->id->device, smbdirect_mr->sgl, + smbdirect_mr->sgl_count, + smbdirect_mr->dir); + smbdirect_mr->state = MR_READY; + if (atomic_inc_return(&info->mr_ready_count) == 1) + wake_up_interruptible(&info->wait_mr); + } else + /* + * Schedule the work to do MR recovery for future I/Os MR + * recovery is slow and don't want it to block current I/O + */ + queue_work(info->workqueue, &info->mr_recovery_work); done: if (atomic_dec_and_test(&info->mr_used_count))