Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp56212imm; Mon, 21 May 2018 02:06:47 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrac1FD9ITY95nn5n5pV1tNa2sKo4CRblz57RU0F701GHeWnNq3ISY1OhFp3O0gaRZvTTMO X-Received: by 2002:a17:902:bd46:: with SMTP id b6-v6mr19653817plx.170.1526893607583; Mon, 21 May 2018 02:06:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526893607; cv=none; d=google.com; s=arc-20160816; b=nhkHVbggoZqr/rUA4RDIXpJtcRYE5KCb9hiB8v0KCnAPAr91Qojve0Q/IlHyyYEbxT ENQ+zvgZ5lk+0Yd/bVPm6a1ZrmVHvw/pbUySmD9M05KQXog3HNuNGlAMPbanpoE0I1aU mKWjUBcgoznuRZaLDLvgty4ou8XZGMgQ1SF7waVafka5wHLmqUA1Tcczc9NjuxHB/rMG mHHEyRBuyYx2PZ58Dmt8e8eG1XdHr2h3FEjW7qly6n3dqBi7ZejNtNG+1JGUXQCDTEfv DCwp3RG8/8uhzSL+A/WDzYRiKMmjiG+VyNrTiebzFvLcdGH1ie+wRw4bl34z9/QEk5kt Np6g== 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:arc-authentication-results; bh=fP0C0SLR7MTDu0BBnhQvYnFtR02hhD1hvIdaGeekpD8=; b=egZDFYKibuJam8vAaI3FpJcY635XK/9rmxKK+nGVLZA9T7NSi/Duu/Kz2CdSciqrIH Z5UtmlIa21j3CUFor056AiCNRXiQAgpVGOqYaULhPkJ6HPI1sYooZWWVcaTYJAycu4bn bEqR0BJInUEaAZFjgcHDm3L2qPwFjO6w0p/Zh6SHqaJ++Jydap/keoPGyU3v3Q6x/Tmp cs+q+DwSRcPnLTEHWn/Pq0QXJvWsjHLZ7X+qBAmt+Rnj8xjNHYAG3wjyqmaIwe7O6xoJ Hwpvv0j0WVzvdj9q/hZEWuSKbWs8TdfU0yh6ZkGTo6okwgg71F5R9/HM5hgdZAI2rE8R dpUQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u8-v6si10883130pgv.277.2018.05.21.02.06.33; Mon, 21 May 2018 02:06:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752718AbeEUJFW (ORCPT + 99 others); Mon, 21 May 2018 05:05:22 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:54680 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752670AbeEUJFP (ORCPT ); Mon, 21 May 2018 05:05:15 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9C96E400E9A7; Mon, 21 May 2018 09:05:14 +0000 (UTC) Received: from jason-ThinkPad-T450s.redhat.com (ovpn-12-30.pek2.redhat.com [10.72.12.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9C04F4AF1; Mon, 21 May 2018 09:05:11 +0000 (UTC) From: Jason Wang To: mst@redhat.com, jasowang@redhat.com Cc: kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH net-next 08/12] tuntap: tweak on the path of non-xdp case in tun_build_skb() Date: Mon, 21 May 2018 17:04:29 +0800 Message-Id: <1526893473-20128-9-git-send-email-jasowang@redhat.com> In-Reply-To: <1526893473-20128-1-git-send-email-jasowang@redhat.com> References: <1526893473-20128-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Mon, 21 May 2018 09:05:14 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Mon, 21 May 2018 09:05:14 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'jasowang@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If we're sure not to go native XDP, there's no need for several things like touching preemption counter and rcu stuffs. Signed-off-by: Jason Wang --- drivers/net/tun.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/net/tun.c b/drivers/net/tun.c index f6e0f96..ed04291 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -1645,10 +1645,12 @@ static struct sk_buff *tun_build_skb(struct tun_struct *tun, * of xdp_prog above, this should be rare and for simplicity * we do XDP on skb in case the headroom is not enough. */ - if (hdr->gso_type || !xdp_prog) + if (hdr->gso_type || !xdp_prog) { *skb_xdp = 1; - else - *skb_xdp = 0; + goto build; + } + + *skb_xdp = 0; preempt_disable(); rcu_read_lock(); @@ -1695,6 +1697,7 @@ static struct sk_buff *tun_build_skb(struct tun_struct *tun, rcu_read_unlock(); preempt_enable(); +build: skb = build_skb(buf, buflen); if (!skb) { skb = ERR_PTR(-ENOMEM); -- 2.7.4