Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2121128ybb; Thu, 26 Mar 2020 22:33:59 -0700 (PDT) X-Google-Smtp-Source: ADFU+vt843cSaaYk7PPxd++CTjYk4cqGATHRzj1aLEgrd4SVG00u26yAaJbO4gdq07FWAoLUCkvK X-Received: by 2002:a05:6830:1aee:: with SMTP id c14mr8849332otd.141.1585287239501; Thu, 26 Mar 2020 22:33:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585287239; cv=none; d=google.com; s=arc-20160816; b=F6r8glnltq2QEAH8l1cDYeZgd4As8ruDXF48uiAMytnYOnwccD631Z9t4vdFP11AvJ aO0qqvXadWmJ/t+suSvC1WCauJQKesPvcdpolOnQWrSGzshty0tESACoKZqFnbMx7uKZ WWyNQm4gxYb/t0AltFeL8x73am6eYQFB/8cVaxGnjnvb/yQZnYu33Sf5OXJj7Gq3ZBKp czI0v0cYM+D2jPkby7frE0O7ivcmRFqs7pORIGCFAXSiPZYfGjvC3qvHUVCkCXo3/CDg OtsynqUkRIWrlfnLjJsLvtxtS7o1J98ceq/SFkeXmLPcaVyTR5UK+c4ZNqNi86PdCime EZvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:reply-to:message-id:date:subject:cc:to :from:dkim-signature:dkim-filter; bh=p8YGRod+AoZSOG+yxhDi9CuAIYPiAdJpgka/fXNPphE=; b=geCCEbBxccbFvYCYplvEzVwtQ5+17kIwliHdE3XxF+IYtldgzkyLNpOYHIxGrc20Dv b1XhEZFdFBcqLla4x948G6k9+qGl5ORBecDf7XoIP8SZjWfyTPh7c+aOFbFD7s1ZxVYl 9WQ5wZrWpLHZ/DnDQxfYniJxMdgqCqnMv0TX283ZZQsuRrzZ4MCqKyxU7qSbMHk3lW+v p+ZvP2vvA0Vyl/rFbGhOMKy/2dnto731SvafykYeGQ3dTg06ItTZWzxNbdjMHKVqi3z5 TDDJCC9nbBspz6C21WLk/w6cGILhAOz7ciQ9YnT1mznwMFcdjYp/tf2KmNS/1v2iVWE7 3KTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxonhyperv.com header.s=default header.b=Pw7xdQOg; 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=linuxonhyperv.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k10si2015035otr.174.2020.03.26.22.33.46; Thu, 26 Mar 2020 22:33:59 -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=@linuxonhyperv.com header.s=default header.b=Pw7xdQOg; 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=linuxonhyperv.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726333AbgC0FdR (ORCPT + 99 others); Fri, 27 Mar 2020 01:33:17 -0400 Received: from linux.microsoft.com ([13.77.154.182]:38140 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725956AbgC0FdQ (ORCPT ); Fri, 27 Mar 2020 01:33:16 -0400 Received: by linux.microsoft.com (Postfix, from userid 1004) id 4D4D220B4737; Thu, 26 Mar 2020 22:33:15 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 4D4D220B4737 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxonhyperv.com; s=default; t=1585287195; bh=p8YGRod+AoZSOG+yxhDi9CuAIYPiAdJpgka/fXNPphE=; h=From:To:Cc:Subject:Date:Reply-To:From; b=Pw7xdQOgpEi/d7fkjjLUDr9c3giKGLWFJXVjlaWVukxdgRRM5roPWEdwwKWq22+FU QwkOue/d53Gs8nZtihhHrTZmzEB0UDl7P1b0EsLiEC1vn+76G0rAKlHgrgR3/jRE27 dqDVJgkbwrpu/fGAG6nZT93ZUIpmrhxwdtEPzQlc= From: longli@linuxonhyperv.com To: Steve French , linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-kernel@vger.kernel.org Cc: Long Li Subject: [PATCH] cifs: smbd: Check and extend sender credits in interrupt context Date: Thu, 26 Mar 2020 22:33:01 -0700 Message-Id: <1585287181-35333-1-git-send-email-longli@linuxonhyperv.com> X-Mailer: git-send-email 1.8.3.1 Reply-To: longli@microsoft.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Long Li When a RDMA packet is received and server is extending send credits, we should check and unblock senders immediately in IRQ context. Doing it in a worker queue causes unnecessary delay and doesn't save much CPU on the receive path. Signed-off-by: Long Li --- fs/cifs/smbdirect.c | 38 +++++++++++++++----------------------- fs/cifs/smbdirect.h | 1 - 2 files changed, 15 insertions(+), 24 deletions(-) diff --git a/fs/cifs/smbdirect.c b/fs/cifs/smbdirect.c index a6ae29b3c4e7..8da43a500686 100644 --- a/fs/cifs/smbdirect.c +++ b/fs/cifs/smbdirect.c @@ -459,25 +459,6 @@ static void smbd_post_send_credits(struct work_struct *work) check_and_send_immediate(info); } -static void smbd_recv_done_work(struct work_struct *work) -{ - struct smbd_connection *info = - container_of(work, struct smbd_connection, recv_done_work); - - /* - * We may have new send credits granted from remote peer - * If any sender is blcoked on lack of credets, unblock it - */ - if (atomic_read(&info->send_credits)) - wake_up_interruptible(&info->wait_send_queue); - - /* - * Check if we need to send something to remote peer to - * grant more credits or respond to KEEP_ALIVE packet - */ - check_and_send_immediate(info); -} - /* Called from softirq, when recv is done */ static void recv_done(struct ib_cq *cq, struct ib_wc *wc) { @@ -546,8 +527,15 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc) atomic_dec(&info->receive_credits); info->receive_credit_target = le16_to_cpu(data_transfer->credits_requested); - atomic_add(le16_to_cpu(data_transfer->credits_granted), - &info->send_credits); + if (le16_to_cpu(data_transfer->credits_granted)) { + atomic_add(le16_to_cpu(data_transfer->credits_granted), + &info->send_credits); + /* + * We have new send credits granted from remote peer + * If any sender is waiting for credits, unblock it + */ + wake_up_interruptible(&info->wait_send_queue); + } log_incoming(INFO, "data flags %d data_offset %d " "data_length %d remaining_data_length %d\n", @@ -563,7 +551,12 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc) info->keep_alive_requested = KEEP_ALIVE_PENDING; } - queue_work(info->workqueue, &info->recv_done_work); + /* + * Check if we need to send something to remote peer to + * grant more credits or respond to KEEP_ALIVE packet + */ + check_and_send_immediate(info); + return; default: @@ -1762,7 +1755,6 @@ static struct smbd_connection *_smbd_get_connection( atomic_set(&info->send_payload_pending, 0); INIT_WORK(&info->disconnect_work, smbd_disconnect_rdma_work); - INIT_WORK(&info->recv_done_work, smbd_recv_done_work); INIT_WORK(&info->post_send_credits_work, smbd_post_send_credits); info->new_credits_offered = 0; spin_lock_init(&info->lock_new_credits_offered); diff --git a/fs/cifs/smbdirect.h b/fs/cifs/smbdirect.h index 6ff880a1e186..8ede915f2b24 100644 --- a/fs/cifs/smbdirect.h +++ b/fs/cifs/smbdirect.h @@ -67,7 +67,6 @@ struct smbd_connection { bool negotiate_done; struct work_struct disconnect_work; - struct work_struct recv_done_work; struct work_struct post_send_credits_work; spinlock_t lock_new_credits_offered; -- 2.17.1