Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1210549pxa; Sat, 1 Aug 2020 23:00:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxgxYrk36WAduKnLNnOPQfXhr8aEOu1R+gk+/BXB560UuyJ9PX1N6iq22f9/zRQrGHey9JG X-Received: by 2002:a50:a40e:: with SMTP id u14mr1287522edb.36.1596348048350; Sat, 01 Aug 2020 23:00:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596348048; cv=none; d=google.com; s=arc-20160816; b=ancDVQ0re2NKfq/DMcKe45rUwE7UR08+T+3EsnA+auh/tJSfsPzZl9dvVzL333NxsH g0fAbwj0NjJn5z/WQtrxfaHari+N8vn34c8yUfzK1gyFpjohoP46/KhpnGPg+Qk7gBjh afx5NUXrwkJk37RCg1uiWtz+cgaZn7406NQ8liBienDDZBdrSPhHEC6C03jHCmDe692x VWWXRi7xMeR20L4cLakiFghf6dN1xBcUHVZnUdPex8g2wy9c95P67UmiojbyMnHM2Zpb /FaULmx/r9q2zBsYkytcJjJSlCn7+7lVAcJpQnctsJZa7XpJJ6aiwCFTyejCaCU8K1lK C5Cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=NnTpi+OJwE7W2db2nqpb7n9gs++FBm5/PS1t2KDF8u8=; b=LrnWC/lD57lyWLZsuJd/GY8mc3HhIMOqpaVfXRvixNWnhqiDiquD9JomkkAw2/ixjb JPbGTQ5aBStFaNZluF73haGi+2KfONqvPNAXXedy3qHMUNQSv74M8rMGeYwi73rIjy0z /faatWUy+gJACeiv8BTx/rqb3QZ9RxzJnUQi9qSVPa+u/xRZeVdmYrBGq/+LsoxdPa1C GnP/InOnGH9rUlzT4BpF+gSRuWIibn/m8+0asv7rDHtPYUKFPJJoUCZxY+8XJ/yiWXwU j6ZVIgL22N3dMZWY7q5+f5dxQ1DYcAMBoHylbhfeMccCt2IojTa7pdllYzKTIkYXn8c0 p2WA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i23si1447789edx.50.2020.08.01.23.00.26; Sat, 01 Aug 2020 23:00:48 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725973AbgHBF4s (ORCPT + 99 others); Sun, 2 Aug 2020 01:56:48 -0400 Received: from out30-57.freemail.mail.aliyun.com ([115.124.30.57]:56764 "EHLO out30-57.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725798AbgHBF4r (ORCPT ); Sun, 2 Aug 2020 01:56:47 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R611e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e07425;MF=wenan.mao@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0U4S29OA_1596347795; Received: from VM20200710-3.tbsite.net(mailfrom:wenan.mao@linux.alibaba.com fp:SMTPD_---0U4S29OA_1596347795) by smtp.aliyun-inc.com(127.0.0.1); Sun, 02 Aug 2020 13:56:44 +0800 From: Mao Wenan To: mst@redhat.com, jasowang@redhat.com Cc: virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Mao Wenan Subject: [PATCH -next v2] virtio_net: Avoid loop in virtnet_poll Date: Sun, 2 Aug 2020 13:56:33 +0800 Message-Id: <1596347793-55894-1-git-send-email-wenan.mao@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <20200802003818-mutt-send-email-mst@kernel.org> References: <20200802003818-mutt-send-email-mst@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The loop may exist if vq->broken is true, virtqueue_get_buf_ctx_packed or virtqueue_get_buf_ctx_split will return NULL, so virtnet_poll will reschedule napi to receive packet, it will lead cpu usage(si) to 100%. call trace as below: virtnet_poll virtnet_receive virtqueue_get_buf_ctx virtqueue_get_buf_ctx_packed virtqueue_get_buf_ctx_split virtqueue_napi_complete virtqueue_poll //return true virtqueue_napi_schedule //it will reschedule napi To fix this, return false if vq is broken in virtqueue_poll. Signed-off-by: Mao Wenan --- v1->v2: fix it in virtqueue_poll suggested by Michael S. Tsirkin drivers/virtio/virtio_ring.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index 58b96ba..4f7c73e 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c @@ -1960,6 +1960,9 @@ bool virtqueue_poll(struct virtqueue *_vq, unsigned last_used_idx) { struct vring_virtqueue *vq = to_vvq(_vq); + if (unlikely(vq->broken)) + return false; + virtio_mb(vq->weak_barriers); return vq->packed_ring ? virtqueue_poll_packed(_vq, last_used_idx) : virtqueue_poll_split(_vq, last_used_idx); -- 1.8.3.1