From patchwork Wed Apr 27 11:28:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 8955821 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 100169F441 for ; Wed, 27 Apr 2016 11:29:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3830220107 for ; Wed, 27 Apr 2016 11:29:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5CE82200F3 for ; Wed, 27 Apr 2016 11:29:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752561AbcD0L2n (ORCPT ); Wed, 27 Apr 2016 07:28:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52644 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751774AbcD0L2m (ORCPT ); Wed, 27 Apr 2016 07:28:42 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2888380084; Wed, 27 Apr 2016 11:28:41 +0000 (UTC) Received: from redhat.com (ovpn-116-123.ams2.redhat.com [10.36.116.123]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id u3RBScnY017845; Wed, 27 Apr 2016 07:28:39 -0400 Date: Wed, 27 Apr 2016 14:28:38 +0300 From: "Michael S. Tsirkin" To: Jason Wang Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org Subject: Re: [PATCH] vhost_net: stop polling socket during rx processing Message-ID: <20160427141317-mutt-send-email-mst@redhat.com> References: <1461656153-24074-1-git-send-email-jasowang@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1461656153-24074-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 On Tue, Apr 26, 2016 at 03:35:53AM -0400, Jason Wang wrote: > We don't stop polling socket during rx processing, this will lead > unnecessary wakeups from under layer net devices (E.g > sock_def_readable() form tun). Rx will be slowed down in this > way. This patch avoids this by stop polling socket during rx > processing. A small drawback is that this introduces some overheads in > light load case because of the extra start/stop polling, but single > netperf TCP_RR does not notice any change. In a super heavy load case, > e.g using pktgen to inject packet to guest, we get about ~17% > improvement on pps: > > before: ~1370000 pkt/s > after: ~1500000 pkt/s > > Signed-off-by: Jason Wang Acked-by: Michael S. Tsirkin There is one other possible enhancement: we actually have the wait queue lock taken in _wake_up, but we give it up only to take it again in the handler. It would be nicer to just remove the entry when we wake the vhost thread. Re-add it if required. I think that something like the below would give you the necessary API. Pls feel free to use it if you are going to implement a patch on top doing this - that's not a reason not to include this simple patch though. ---> wait: add API to drop a wait_queue_t entry from wake up handler A wake up handler might want to remove its own wait queue entry to avoid future wakeups. In particular, vhost has such a need. As wait queue lock is already taken, all we need is an API to remove the entry without wait_queue_head_t which isn't currently accessible to wake up handlers. Signed-off-by: Michael S. Tsirkin --- -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/include/linux/wait.h b/include/linux/wait.h index 27d7a0a..9c6604b 100644 --- a/include/linux/wait.h +++ b/include/linux/wait.h @@ -191,11 +191,17 @@ __add_wait_queue_tail_exclusive(wait_queue_head_t *q, wait_queue_t *wait) } static inline void -__remove_wait_queue(wait_queue_head_t *head, wait_queue_t *old) +__remove_wait_queue_entry(wait_queue_t *old) { list_del(&old->task_list); } +static inline void +__remove_wait_queue(wait_queue_head_t *head, wait_queue_t *old) +{ + __remove_wait_queue_entry(old); +} + typedef int wait_bit_action_f(struct wait_bit_key *, int mode); void __wake_up(wait_queue_head_t *q, unsigned int mode, int nr, void *key); void __wake_up_locked_key(wait_queue_head_t *q, unsigned int mode, void *key);