From patchwork Tue Feb 11 14:58:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qinchuanyu X-Patchwork-Id: 3627521 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id AA712BF418 for ; Tue, 11 Feb 2014 14:59:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E045620165 for ; Tue, 11 Feb 2014 14:59:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 414462012B for ; Tue, 11 Feb 2014 14:59:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751064AbaBKO7H (ORCPT ); Tue, 11 Feb 2014 09:59:07 -0500 Received: from szxga03-in.huawei.com ([119.145.14.66]:26220 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750787AbaBKO7F (ORCPT ); Tue, 11 Feb 2014 09:59:05 -0500 Received: from 172.24.2.119 (EHLO szxeml207-edg.china.huawei.com) ([172.24.2.119]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id AKK26460; Tue, 11 Feb 2014 22:58:56 +0800 (CST) Received: from SZXEML420-HUB.china.huawei.com (10.82.67.159) by szxeml207-edg.china.huawei.com (172.24.2.56) with Microsoft SMTP Server (TLS) id 14.3.158.1; Tue, 11 Feb 2014 22:58:55 +0800 Received: from [127.0.0.1] (10.177.21.101) by szxeml420-hub.china.huawei.com (10.82.67.159) with Microsoft SMTP Server id 14.3.158.1; Tue, 11 Feb 2014 22:58:54 +0800 Message-ID: <52FA3AAC.2050003@huawei.com> Date: Tue, 11 Feb 2014 22:58:52 +0800 From: Qin Chuanyu User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.0.1 MIME-Version: 1.0 To: CC: "Michael S. Tsirkin" , , KVM list Subject: [PATCH] virtio: make udp more efficient by avoiding indirect desc X-Originating-IP: [10.177.21.101] X-CFilter-Loop: Reflected Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP udp packet use 2 buffers at least, one for vnet_hdr and one for skb->data. we could change the threshold from 2 to 3, so the udp packet which data buff only using single desc will gain from this. the guest would avoid from allocating memory dynamically. the host would avoid from translating indirect desc. Signed-off-by: Chuanyu Qin --- drivers/virtio/virtio_ring.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index 28b5338..88d008f 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c @@ -220,7 +220,7 @@ static inline int virtqueue_add(struct virtqueue *_vq, /* If the host supports indirect descriptor tables, and we have multiple * buffers, then go indirect. FIXME: tune this threshold */ - if (vq->indirect && total_sg > 1 && vq->vq.num_free) { + if (vq->indirect && total_sg > 2 && vq->vq.num_free) { head = vring_add_indirect(vq, sgs, next, total_sg, total_out, total_in, out_sgs, in_sgs, gfp);