Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp28919501rwd; Wed, 5 Jul 2023 04:51:15 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5FFCUyQVuqVy7MmQ1rGm8whWdhNz25OSFkl+VJvFv8yuSrnRjiOsB13qQLOVsRHlV9voa9 X-Received: by 2002:a05:6830:1315:b0:6b7:47c4:b64b with SMTP id p21-20020a056830131500b006b747c4b64bmr13659785otq.25.1688557875055; Wed, 05 Jul 2023 04:51:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688557875; cv=none; d=google.com; s=arc-20160816; b=pWP0oDBLb/Z586FEiqQqu8HWGUNDxZ3tovHTySF0tYZxWWI1UUduRux+27GE10V3j8 nu75Z2NnIOS7DX2EQJwXJJt3MFA+uDzRwRHokQznclqXArw2WijqewQknYIZDAbvBQYN 5xv+TS4wMlJh5pKXm4vwrgSJkbqLdUaGLbxxwVcMQs/tdznO80gPMJYvzpcIFY2w0QG8 BuXSPLnZXCFRyd5rDOG4Pn6F34kckxH/hoOd+8aPB0vOf+6n6JE/RntvX/WPYRDnKyuq m5WH+IliqFGnW/wBVw/lkAFHAB7Ch28dFal/2d25XFk2RXCTqZxBKoLEvyeMd2vvKplV tK1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=qsSjD1XIc1/jKyhDNjcqV8yyQFT6uszClHQCkBLneM8=; fh=S1rZK6DPg0mAED4KjNm0cP4EEY87q6FXHFEeosELg0E=; b=bISVF2IQ/H6tQ6wfjqr/J0ejeD16yvMw1Vi16EK+B+c3tBs9ubcezJZiF/y0RZ3nlG QGMkDBGgPX0hDBOvbjX54ZC3yMGzqMjS6bgD1ibhKzib8XV1FeJ/NFRhD/RAuqcVsiOT 8aYQ7KQuwL1jf40yCOKtCw4Q5pMMhX25U3BRaf8O3peqQfH3qin+APD5pQ6HzPnFzUKH g5L8vOBqgUA8pkseEIGRrQ1RkkHQruOygMwIi1YAeXAwGV0U3U6Q/UtP7bhk9V+D+tSl D8JN3nlhJGDrQhV7jsCxP3RuxwPRmw9VJE+wzEGJxdHYqD0mw5uy7BkPeoV7pCaGk1/M GV+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=BnF9ZFzb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 71-20020a63024a000000b0055acbe61853si20714234pgc.430.2023.07.05.04.50.52; Wed, 05 Jul 2023 04:51:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=BnF9ZFzb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S231693AbjGELqW (ORCPT + 99 others); Wed, 5 Jul 2023 07:46:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231514AbjGELqV (ORCPT ); Wed, 5 Jul 2023 07:46:21 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A57461736 for ; Wed, 5 Jul 2023 04:45:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688557511; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=qsSjD1XIc1/jKyhDNjcqV8yyQFT6uszClHQCkBLneM8=; b=BnF9ZFzbevN1mqHtczbQePgHRQW/McbuzdvHyCP/vnx3WNOj3WLi1PFXWkNOr/VOvA1u0A l+vv76ORV0Z+gUXly7Bf2YDykrhIoRdWQ9wyTISyebldFqD9oOGtRhBsVlWaW0fBNnAHu7 XyUrzhKj3iSdadT0HfyrEB8Cs/f2Xv0= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-671-_b8qkYa1MdyJVekOnvtR3A-1; Wed, 05 Jul 2023 07:45:10 -0400 X-MC-Unique: _b8qkYa1MdyJVekOnvtR3A-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EA7BE1C08DAA; Wed, 5 Jul 2023 11:45:09 +0000 (UTC) Received: from max-t490s.redhat.com (unknown [10.39.208.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id BA6E140C6CCD; Wed, 5 Jul 2023 11:45:07 +0000 (UTC) From: Maxime Coquelin To: xieyongji@bytedance.com, jasowang@redhat.com, mst@redhat.com, david.marchand@redhat.com, lulu@redhat.com Cc: linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, xuanzhuo@linux.alibaba.com, eperezma@redhat.com, Maxime Coquelin Subject: [PATCH] vduse: Use proper spinlock for IRQ injection Date: Wed, 5 Jul 2023 13:45:05 +0200 Message-ID: <20230705114505.63274-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The IRQ injection work used spin_lock_irq() to protect the scheduling of the softirq, but spin_lock_bh() should be used. With spin_lock_irq(), we noticed delay of more than 6 seconds between the time a NAPI polling work is scheduled and the time it is executed. Fixes: c8a6153b6c59 ("vduse: Introduce VDUSE - vDPA Device in Userspace") Cc: xieyongji@bytedance.com Suggested-by: Jason Wang Signed-off-by: Maxime Coquelin --- drivers/vdpa/vdpa_user/vduse_dev.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vduse_dev.c index dc38ed21319d..df7869537ef1 100644 --- a/drivers/vdpa/vdpa_user/vduse_dev.c +++ b/drivers/vdpa/vdpa_user/vduse_dev.c @@ -935,10 +935,10 @@ static void vduse_dev_irq_inject(struct work_struct *work) { struct vduse_dev *dev = container_of(work, struct vduse_dev, inject); - spin_lock_irq(&dev->irq_lock); + spin_lock_bh(&dev->irq_lock); if (dev->config_cb.callback) dev->config_cb.callback(dev->config_cb.private); - spin_unlock_irq(&dev->irq_lock); + spin_unlock_bh(&dev->irq_lock); } static void vduse_vq_irq_inject(struct work_struct *work) @@ -946,10 +946,10 @@ static void vduse_vq_irq_inject(struct work_struct *work) struct vduse_virtqueue *vq = container_of(work, struct vduse_virtqueue, inject); - spin_lock_irq(&vq->irq_lock); + spin_lock_bh(&vq->irq_lock); if (vq->ready && vq->cb.callback) vq->cb.callback(vq->cb.private); - spin_unlock_irq(&vq->irq_lock); + spin_unlock_bh(&vq->irq_lock); } static bool vduse_vq_signal_irqfd(struct vduse_virtqueue *vq) -- 2.41.0