From patchwork Mon Jul 23 23:11:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Raitto X-Patchwork-Id: 948149 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ewv5VK3T"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 41ZHLW6TYRz9s29 for ; Tue, 24 Jul 2018 09:11:47 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728357AbeGXAPP (ORCPT ); Mon, 23 Jul 2018 20:15:15 -0400 Received: from mail-pl0-f65.google.com ([209.85.160.65]:46209 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725907AbeGXAPP (ORCPT ); Mon, 23 Jul 2018 20:15:15 -0400 Received: by mail-pl0-f65.google.com with SMTP id t17-v6so846852ply.13 for ; Mon, 23 Jul 2018 16:11:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=OX32NYj6LddRpdJx5m5EtZvHvDlnauyS8+TI7pZtnw0=; b=ewv5VK3TFj30e4xnhpl9DDr/LGGlE3KvB1ZOAWI3nOcDMI0WzLywfDt9dBP4qFk/05 VTY4VMagms5AeRi+4MYJUlivSqXRWgdkj70cKiy2rVuH2+ObkzmCQd68v8CdoA2ZF9u4 gmRlLqVgKCrPSstw8QoqpG58UUmQVJZ/jY+/mFYd6wA2M9KhAeuYiDj2O4IX7sgYo2GN nFCObQ371etgpwm0J91S7BosfN6CTHXia1GORdNud4Exurpoes18xWblRjm59j3GFV/T RN0PFaHwVq4H7Mnt/sxDgeeBJCOxR7MXO1NgQjxj/GjCeQKJkOm8q5miiqj67Y5+N2ry HSvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=OX32NYj6LddRpdJx5m5EtZvHvDlnauyS8+TI7pZtnw0=; b=G8u/QPAwd7zTuHuvWlH48Q+rsROra/ktk882mywic3jkOsGLxQ/DzFn8naYUuqvTPz L4ypoWBdut3ycGLgdw3VZsqVkmyNxXOja7M1Ss223ehW5CfJ5YFYjHnZGX+Lw/dHLpOI vM0Wh+7fyDYJqnJwdEJRaz58iEJNY+bxcU912MGkgoXa4cgPYp7LSPzguMoFvDFwBcyJ zpeRzYR0AVpVi2qhuXgmuJsR/wIIESCWIJ92KxNBV9UrVJYSip9gqYVZ9B3pbT/kyoAx XE3YRJzCnibFaxIwQm+0OmuxQQ4WFIit30Ii0Lv+AwrfUUrCKfRXs8fJGPV63ec912WC RD4g== X-Gm-Message-State: AOUpUlHj+3rvlsu6zRWGQKF51kuNE58XsP9hxP2xiI8S2ZfOc0uRnFs8 o+B7yOOAnd+VHPX09oWyu4I= X-Google-Smtp-Source: AAOMgpc6/dhe0oP5QC1GYNs4LGShWyr7jY8EWL7NLmiM+eO/rpVbr2EQXIxZ6K96NyAED0gY58HfXw== X-Received: by 2002:a17:902:28a4:: with SMTP id f33-v6mr14457252plb.297.1532387504596; Mon, 23 Jul 2018 16:11:44 -0700 (PDT) Received: from caraitto-dev.sea.corp.google.com ([2620:0:1009:11:84ae:3ba4:ea4b:7d69]) by smtp.gmail.com with ESMTPSA id g5-v6sm12516926pgn.73.2018.07.23.16.11.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Jul 2018 16:11:43 -0700 (PDT) From: Caleb Raitto To: mst@redhat.com, jasowang@redhat.com, davem@davemloft.net, netdev@vger.kernel.org Cc: Caleb Raitto Subject: [PATCH net-next] virtio_net: force_napi_tx module param. Date: Mon, 23 Jul 2018 16:11:19 -0700 Message-Id: <20180723231119.142904-1-caleb.raitto@gmail.com> X-Mailer: git-send-email 2.18.0.233.g985f88cf7e-goog Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Caleb Raitto The driver disables tx napi if it's not certain that completions will be processed affine with tx service. Its heuristic doesn't account for some scenarios where it is, such as when the queue pair count matches the core but not hyperthread count. Allow userspace to override the heuristic. This is an alternative solution to that in the linked patch. That added more logic in the kernel for these cases, but the agreement was that this was better left to user control. Do not expand the existing napi_tx variable to a ternary value, because doing so can break user applications that expect boolean ('Y'/'N') instead of integer output. Add a new param instead. Link: https://patchwork.ozlabs.org/patch/725249/ Acked-by: Willem de Bruijn Acked-by: Jon Olson Signed-off-by: Caleb Raitto --- drivers/net/virtio_net.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 2ff08bc103a9..d9aca4e90d6b 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -39,10 +39,11 @@ static int napi_weight = NAPI_POLL_WEIGHT; module_param(napi_weight, int, 0444); -static bool csum = true, gso = true, napi_tx; +static bool csum = true, gso = true, napi_tx, force_napi_tx; module_param(csum, bool, 0444); module_param(gso, bool, 0444); module_param(napi_tx, bool, 0644); +module_param(force_napi_tx, bool, 0644); /* FIXME: MTU in config. */ #define GOOD_PACKET_LEN (ETH_HLEN + VLAN_HLEN + ETH_DATA_LEN) @@ -1201,7 +1202,7 @@ static void virtnet_napi_tx_enable(struct virtnet_info *vi, /* Tx napi touches cachelines on the cpu handling tx interrupts. Only * enable the feature if this is likely affine with the transmit path. */ - if (!vi->affinity_hint_set) { + if (!vi->affinity_hint_set && !force_napi_tx) { napi->weight = 0; return; } @@ -2646,7 +2647,7 @@ static int virtnet_alloc_queues(struct virtnet_info *vi) netif_napi_add(vi->dev, &vi->rq[i].napi, virtnet_poll, napi_weight); netif_tx_napi_add(vi->dev, &vi->sq[i].napi, virtnet_poll_tx, - napi_tx ? napi_weight : 0); + (napi_tx || force_napi_tx) ? napi_weight : 0); sg_init_table(vi->rq[i].sg, ARRAY_SIZE(vi->rq[i].sg)); ewma_pkt_len_init(&vi->rq[i].mrg_avg_pkt_len);