Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1221388pxa; Sat, 1 Aug 2020 23:26:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3zC9yWXpgBvRtcZd13CRJcmythpZ5kqQMRpftonJnr7r+m5gu9aY/xdc6fpSleQN86Rgv X-Received: by 2002:a17:906:840c:: with SMTP id n12mr10869065ejx.246.1596349606085; Sat, 01 Aug 2020 23:26:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596349606; cv=none; d=google.com; s=arc-20160816; b=Yyelx+edDLeSIteWOw/K36SZWkfWB+S7M71GYg/V4dWgiBP7Rhuu17REcrsJYrvBhh NGA/Lnt9hqcRv613vMgKanyGBuodfPhRyCqozqSZbe08H1aItIn7Gc27jEHqUNrU1fo4 kvWgLfLG5b13Vi1fMloB8QIWlBo2XAIO623MgXqH16ISDgGB9AZ2YyUWg1YmVEZd9Jtr FkAZfGRRb0ofPWe0VxswNN9tMmgZppgUXerVcpXf0GoSIyhY+wQiNNO2RRLLtFJ0dhLK PaXaGk6GpUxxet0W1Z3+ZI9BLawsbd9FIKV1alXrW41lCCC8d6mcIrCdxkERan9KqdTd pZUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=S6OYCdbGW3vcu3y+tw3bsh0JBnWwiCW5p61nwH6OSdk=; b=uBAiCeDJxmb6Fz6DYIPdy2tZn3/uz/W3m8jpiv4Ee3A8tTVhjQXCuja8Xl6syZhl84 dsI/JrnTZQKjG+pP4yqP0LUiDDFsRc8k4w/ogTb56Oz/YAt2uuxQ6L1P6C+84/fEpuNz Y91kBcihYyM1NVVPHAgVNM1nbxV3NC4O4gKwDHdPv+yMe++lWpZswUbkV9x3n6RX5Jsv 8rYaxe9flSlwzXxoHX/gx5N+Xf+VI/2cfE+pgs9mDNKn3FPsHBkbWF8C2vn+1WZHKQlT 8weKr3Me2IJjmCCAh/4F4yQ5OSMAvwD2KIY5kZvQc1O4QE0jlGygO7iVDbSIFgYbhYwV 7ayA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Q/XP8a2T"; 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 h8si8328171ejd.623.2020.08.01.23.26.07; Sat, 01 Aug 2020 23:26:46 -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="Q/XP8a2T"; 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 S1725882AbgHBGZv (ORCPT + 99 others); Sun, 2 Aug 2020 02:25:51 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:43708 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725823AbgHBGZv (ORCPT ); Sun, 2 Aug 2020 02:25:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596349549; 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=S6OYCdbGW3vcu3y+tw3bsh0JBnWwiCW5p61nwH6OSdk=; b=Q/XP8a2T99FM3ItA1jY9At27hJM5likCSB7In+3kCCjIblwiiHTtUYPDkNyDkU8KSCdfqw tWVDnSxZwR5dvizcJwStq2JRvagJrevSlpLW/2A6yUQ5qLuYMOf4Am7Xy5J4xnMif57nmC yPW6x8R8BQZ3Y+dNEui2joeLnpeJQ6Q= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-391-5WKU_gxoP_61H7iCsJI9EA-1; Sun, 02 Aug 2020 02:25:47 -0400 X-MC-Unique: 5WKU_gxoP_61H7iCsJI9EA-1 Received: by mail-wr1-f70.google.com with SMTP id z12so10358815wrl.16 for ; Sat, 01 Aug 2020 23:25:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=S6OYCdbGW3vcu3y+tw3bsh0JBnWwiCW5p61nwH6OSdk=; b=gLOiBfgPxeA0Nbx7ieF8cupm7Y2E5Ib9KsU9iA0RT+Z4g8AOWjuSMPTyMeQvOMWqrz Ls2x2GFgkArR0yPhzuklZ8N5G9Km9KylW9TwEIc5cYOsLR9aBiS9SLpUY3R3I02/fKiP ZLCq+4olZdutlf3DTwxmNglK5+xUElkbhceROo+wZeMP7LXne1wkooqtC95zIQ9zC8sd J0zcmZ8QhjCrjZJSNvqD1T1iP8aFuIiKglHthpfgsjxz9yWPOGEy2pObG3f7LMbPwjZV bvn83P0K/iv+g0RWHC3NzBFYdgx8z1IEft5l4eDGQvCBGlY4KI6QOvUq+rkTEohi6c2C LwDA== X-Gm-Message-State: AOAM5305tBgv9xGhQN8u/a/+J24/FBSYnQ4x64voOOrO0LFZV+sSUXC8 pNnO0D3fyaJ6trOF/4Rd6jFg9dcX3BdB088yvpNoStaB30vccBi7n6nvdkcF/kOdMlcWRkanilo Y76vTzBcpLZZ/quK0QmJ7gswq X-Received: by 2002:a7b:c154:: with SMTP id z20mr11102332wmi.118.1596349545808; Sat, 01 Aug 2020 23:25:45 -0700 (PDT) X-Received: by 2002:a7b:c154:: with SMTP id z20mr11102318wmi.118.1596349545515; Sat, 01 Aug 2020 23:25:45 -0700 (PDT) Received: from redhat.com (bzq-79-179-105-63.red.bezeqint.net. [79.179.105.63]) by smtp.gmail.com with ESMTPSA id 68sm19668139wra.39.2020.08.01.23.25.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Aug 2020 23:25:44 -0700 (PDT) Date: Sun, 2 Aug 2020 02:25:42 -0400 From: "Michael S. Tsirkin" To: Mao Wenan Cc: jasowang@redhat.com, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH -next v2] virtio_net: Avoid loop in virtnet_poll Message-ID: <20200802022521-mutt-send-email-mst@kernel.org> References: <20200802003818-mutt-send-email-mst@kernel.org> <1596347793-55894-1-git-send-email-wenan.mao@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1596347793-55894-1-git-send-email-wenan.mao@linux.alibaba.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Aug 02, 2020 at 01:56:33PM +0800, Mao Wenan wrote: > 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 Looks good: Acked-by: Michael S. Tsirkin > --- > 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