From patchwork Mon Mar 4 18:38:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13580999 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ed1-f41.google.com (mail-ed1-f41.google.com [209.85.208.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3489B78698; Mon, 4 Mar 2024 18:38:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709577530; cv=none; b=PqLRCtP9qbPV7ay63POguJORqRX2ZxyDEHgoTm47hvXWb7GTsu/w/8YhZx/uYLmmbn138RnOeeh4p35IW9d47FYw0RFTZgd8P2iQpe0c2jsffD4/bsTcpBOe7j9ALJXC0lAQMlWSXvJSo3BSoPDaTj0h32Ea6CNu318nhP4bKKw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709577530; c=relaxed/simple; bh=+juVcYk4qeGIcuSKSQA26jTcPanFQBQTHQWtjYPzxQM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=H8ETk0RozXbSBtTGdk6pIVUQNs4Ymd/aXwd53u6BSKpluyiSMNu4NeE2heZYFTPCZSK1Io6Ocyv13Te3E7iH1lc/g5bTL1FSZ9bG24tu4zPThkqKfTNKDMZSQ+F+1bHUjMWU3qn2UR0nhbxjKou2b3PXW31BLowLrV6z1t1ObhU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.208.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-f41.google.com with SMTP id 4fb4d7f45d1cf-564372fb762so6308666a12.0; Mon, 04 Mar 2024 10:38:48 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709577527; x=1710182327; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=3tpuyayzAPkavhecbPCeBqxZM5Q9OhC9n++6ENUjv9s=; b=w31KqUKVXA20UF2ClFMa3f1Wh5oD5X9LNZIwSkFjTtB/z81yTI7k1X4uvdeBSZGor2 WLQ9wgmQ7c/uqx/LxVGJUBRJ6AK9KUQcT4qOSMEttzvx+vqi4kAs3dQQ39uorqnqYAWE reeqpeOtHnLjTqrF/EnuXHzau/ggjItI68JAzi6T9u8hCKyKbWWhxOkpvIYxIgsz1zM4 Zfotc6775W0IZVJvnwAK5q5ng6ikAgL1x0C5/xdb5ePRdu2LE4ftrvGh2qckBDhn76zL JKRZ9mk0c5LOa6+/ErBeZ62Mvgc1krp0v6f87DLEP5YHquYC7B4Y8rxPB2cyA0xyvaFq ajKw== X-Forwarded-Encrypted: i=1; AJvYcCVG2z96ERs7WkW2g5fuiA/7uNJynvRTfM2jfcRSMZBxteLXxh9Nqo+rOuTdDdyZhBh+5Q23sN6gTjxL4+bfcf+QIGI9h5MfjOrkm/Fo X-Gm-Message-State: AOJu0YygjtWjNhDmxyejZKabVH06UiW4wJok8bYd/j/h4BUAL4G4TDxM LVYkcgTcwTg+s8//AtmBGRNTG8TxRXlky6ponKgdHhxn+dmiSPIquuNL/P6e X-Google-Smtp-Source: AGHT+IH/N9zYpKg0OzMCx98jQwubycWmSZwlvoEFO/oPP5exY9QTBwAxb4AYOKyv/bSzSlcYagJpDw== X-Received: by 2002:a05:6402:2032:b0:567:5d76:6ea2 with SMTP id ay18-20020a056402203200b005675d766ea2mr2193697edb.39.1709577527328; Mon, 04 Mar 2024 10:38:47 -0800 (PST) Received: from localhost (fwdproxy-lla-003.fbsv.net. [2a03:2880:30ff:3::face:b00c]) by smtp.gmail.com with ESMTPSA id ev16-20020a056402541000b0055d333a0584sm4927405edb.72.2024.03.04.10.38.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 10:38:46 -0800 (PST) From: Breno Leitao To: kuba@kernel.org, davem@davemloft.net, pabeni@redhat.com, edumazet@google.com, Willem de Bruijn , Jason Wang Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, horms@kernel.org, dsahern@kernel.org Subject: [PATCH net-next 1/2] net: tuntap: Leverage core stats allocator Date: Mon, 4 Mar 2024 10:38:07 -0800 Message-ID: <20240304183810.1474883-1-leitao@debian.org> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org With commit 34d21de99cea9 ("net: Move {l,t,d}stats allocation to core and convert veth & vrf"), stats allocation could be done on net core instead of in this driver. With this new approach, the driver doesn't have to bother with error handling (allocation failure checking, making sure free happens in the right spot, etc). This is core responsibility now. Remove the allocation in the tun/tap driver and leverage the network core allocation instead. Signed-off-by: Breno Leitao Reviewed-by: Willem de Bruijn --- drivers/net/tun.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/drivers/net/tun.c b/drivers/net/tun.c index be37235af55d..6c594a3c2c37 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -977,20 +977,15 @@ static int tun_net_init(struct net_device *dev) struct ifreq *ifr = tun->ifr; int err; - dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats); - if (!dev->tstats) - return -ENOMEM; - spin_lock_init(&tun->lock); err = security_tun_dev_alloc_security(&tun->security); - if (err < 0) { - free_percpu(dev->tstats); + if (err < 0) return err; - } tun_flow_init(tun); + dev->pcpu_stat_type = NETDEV_PCPU_STAT_TSTATS; dev->hw_features = NETIF_F_SG | NETIF_F_FRAGLIST | TUN_USER_FEATURES | NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_STAG_TX; @@ -1008,7 +1003,6 @@ static int tun_net_init(struct net_device *dev) if (err < 0) { tun_flow_uninit(tun); security_tun_dev_free_security(tun->security); - free_percpu(dev->tstats); return err; } return 0; @@ -2317,7 +2311,6 @@ static void tun_free_netdev(struct net_device *dev) BUG_ON(!(list_empty(&tun->disabled))); - free_percpu(dev->tstats); tun_flow_uninit(tun); security_tun_dev_free_security(tun->security); __tun_set_ebpf(tun, &tun->steering_prog, NULL); From patchwork Mon Mar 4 18:38:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13581000 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D268B78B4A; Mon, 4 Mar 2024 18:38:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709577532; cv=none; b=BQylPT6B/OiFrx1gWfQa6tTj+m0E3x8+kVu9ghc/Se5TD+rnTl3fApG3F+AVIA/BpPTwNuaY7gl8XxrhE8BLd9pz5KmizDDZknJQKmD+RkvbKjKnUJJmNUEs5h6YslwSmkTsNZVu5ZJbNYLquQ4IstYxwxEBJ4ebMMtV5UPmqmI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709577532; c=relaxed/simple; bh=G3E1d+84x8xXVqhy+1WXOgtV5Tf07lUnzqrmHl07wKI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=S/LvCyNE8mCo0CMJXh75SEB+R+pccr3vKwt9esJTx9+PNr6DDMdkGH24lzYky3KfnlfDeBz3tIkNih8RF71f3+Y5uLacpG/DSIO9uISTX3TRXPQ1fDq3o/7AjLfFPGKmjoc4NmhRdxz36s+Y5Qdk7CHX6qwjRTBMXgaNT1Clcpg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.218.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-f44.google.com with SMTP id a640c23a62f3a-a2f22bfb4e6so789868466b.0; Mon, 04 Mar 2024 10:38:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709577529; x=1710182329; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Fnoi1H+j4clEhXj1HIttNv5q1C/92NCaQWwcE97Vd+Y=; b=kOy+SvuE/2SshULcfMdUOO5YKPOmtGdAfqBUbyQKcqfiP5pWwH+/b908aSs/val+0E iQLZLL3c6R9jo2pv10fvJWn60WasDmtqokT0N03im4GwPeQxjncAcyjmVsfjkQgABrDI imAZUOrGSeOU0y2YssK0mzcMcpSkjTYi9hh0NXl7+1uQCBqA2HVVq4+XyDVHN1VYK0RO V2VemY4Mdb8Uvwm1tJlK0tBWRkzq72AiMkqfx+BVWOALYDRkMwXXkfHRoX74WgdrB2Vo 41isCIJiKLDb1w0DSF6GTDV444XK+PHW+m/RbrdwCSUDyukm45wBEdWhU15YcvLWla38 4eSg== X-Forwarded-Encrypted: i=1; AJvYcCUJ305vgFsrrW8rOuBEiDmYgbaUA8qtV3DygxHNQmLAr/jsPYfsdntrMGgiuN62G+MkZqkWygVnhLEkqmYfY/wMEBdwpleAt04BIf7R X-Gm-Message-State: AOJu0YxFTFABzkTAACxrzjBrY7q21EsDDbuljFTB9BROvn1ojArt940g OUl3upSAm8TeZDiJVFyO1g3zfwwIUQxKj9whBDM2NFK3SKjcmokr X-Google-Smtp-Source: AGHT+IEjDKoxs7M4FkK6BsyvwavYoCjPmPWQ55cq7nluhEoUfuXQXBx1OfwbtCY9VBKuh4doC+3shw== X-Received: by 2002:a17:906:cc93:b0:a43:3f37:4d94 with SMTP id oq19-20020a170906cc9300b00a433f374d94mr6649732ejb.16.1709577529141; Mon, 04 Mar 2024 10:38:49 -0800 (PST) Received: from localhost (fwdproxy-lla-119.fbsv.net. [2a03:2880:30ff:77::face:b00c]) by smtp.gmail.com with ESMTPSA id tb25-20020a1709078b9900b00a4557115465sm1285404ejc.13.2024.03.04.10.38.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 10:38:48 -0800 (PST) From: Breno Leitao To: kuba@kernel.org, davem@davemloft.net, pabeni@redhat.com, edumazet@google.com, Willem de Bruijn , Jason Wang Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, horms@kernel.org, dsahern@kernel.org Subject: [PATCH net-next 2/2] net: tap: Remove generic .ndo_get_stats64 Date: Mon, 4 Mar 2024 10:38:08 -0800 Message-ID: <20240304183810.1474883-2-leitao@debian.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240304183810.1474883-1-leitao@debian.org> References: <20240304183810.1474883-1-leitao@debian.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Commit 3e2f544dd8a33 ("net: get stats64 if device if driver is configured") moved the callback to dev_get_tstats64() to net core, so, unless the driver is doing some custom stats collection, it does not need to set .ndo_get_stats64. Since this driver is now relying in NETDEV_PCPU_STAT_TSTATS, then, it doesn't need to set the dev_get_tstats64() generic .ndo_get_stats64 function pointer. Signed-off-by: Breno Leitao Reviewed-by: Willem de Bruijn --- drivers/net/tun.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 6c594a3c2c37..8d258e263f54 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -1338,7 +1338,6 @@ static const struct net_device_ops tap_netdev_ops = { .ndo_select_queue = tun_select_queue, .ndo_features_check = passthru_features_check, .ndo_set_rx_headroom = tun_set_headroom, - .ndo_get_stats64 = dev_get_tstats64, .ndo_bpf = tun_xdp, .ndo_xdp_xmit = tun_xdp_xmit, .ndo_change_carrier = tun_net_change_carrier,