Received: by 2002:a05:6500:2018:b0:1fb:9675:f89d with SMTP id t24csp606995lqh; Fri, 31 May 2024 10:33:25 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUqiB7noxEI1plWfIGw2LhpxmPdWIUbxBIoclE8dRKhftCXy5feG6MH/nGU6/ipWmsouJCjpGtsPBXwuV4qICCZ6JlITFvks3vMgxNaxg== X-Google-Smtp-Source: AGHT+IEpwf9XJ8ISoCZLyLJt5VdesRB+pRRCsikJIeNd5z3DInP/h6Yu+pUKDLrmeA7T6k4omWQg X-Received: by 2002:a17:906:448:b0:a62:fcf7:8924 with SMTP id a640c23a62f3a-a6821982247mr165701066b.60.1717176804885; Fri, 31 May 2024 10:33:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717176804; cv=pass; d=google.com; s=arc-20160816; b=J06KYT8i2BmcRnQNE71QWjBguzYyVZXRBC+klphk60pvq8C7Cp3thie0iuTZW3hI0h +U1HtvyFNe+Qu74iYAJKubYSUjCa2zID1iI+1iQCZiE48+5Ssggx5lj+KkzhPsSVUpEd EMw5uJJuTkYnbMZ4srwaPhn7gBNok47vPq3TmJ2Zigr+srohd9aSAUGpcJOik1Bj2pmR Unubh7zkJTtE85cHWmaNoiIagP9wegWIoGnBxJ+KkY5vESp/iSd0/SlALlw6Lg6CwVTK trpCx+++AZI37X/ijoT9ZjETzpK/eppg1NXZmZiiA/u/WeqIs7pVLyOhiw/xX9pnitRO mp+Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=OMppGFFrT5MnAdCHtOHnnUXgbQ/hA3PsMnZtuj4qBMk=; fh=CM39zXn71gslRiZlSuMBPgzzxM2+490B6SJbYWFcyGY=; b=SFc0RF+w2c/A2fKJTkiMzGQN1fyJld2AQG5546uT0VUfHfqewFmHYpn89TLfqGA8fH 57RrODEHRcR1KYk5sdzo8r1m5XKQQ4dXlcbfGS6KrBqzq2I7x4uQmHbPWm/V+CJaSyNe UIJf6bnIqKW61IlUCwGdZXoZiboI78of1Eq0ae8R2NlsnXoXa1KI/qVLc+iKHGPem0Sy TOfpH9ceXs/TaFWgxR1jVJnA0z54QANmBxMoNWdUJaAJRXFoQITJyiZ/687vAN6QMWMl wczk57U9EZgXIZ7H94oGRLmODVN/2khfZ12pSvzeMc2p0R/nP0WipTZVk4CmIVyLmVEz VumA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=KRFkAU7s; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-197252-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-197252-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a67eaf65265si109880566b.812.2024.05.31.10.33.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 10:33:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-197252-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=KRFkAU7s; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-197252-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-197252-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id DC9981F264AA for ; Fri, 31 May 2024 17:33:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 83D6E17C23B; Fri, 31 May 2024 17:33:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="KRFkAU7s" Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.47]) (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 DBB5F80C1F for ; Fri, 31 May 2024 17:32:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717176779; cv=none; b=IB3odjOS9PEQx9c+cEAxwRm9z1840tk/chpIqLTlcTOoEDab/m6a2eC0VfSjsIOG7r/be47t7aYcw0KzCsbko5EOdsUrxZbjpH/qfinyfEwV0YCbQpJvC6N/JSskigUucSe25TKvHAt1JPAwGTb2eGm/uQVOgRF25bbP/HpkxFI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717176779; c=relaxed/simple; bh=Yjwu0m+erAt8XFKFMLD6Bnxw1BqoPUA8ibnGos7ynxI=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=gGqHTnzDQaVlAHzOLUSN4hbCFXi8QyVndiHK8RMe9NpFUsSnhdrM0tJ2VZ31q66YXW9cAHLDUjiYua/IXKbQx7+i0LRUdcAPbiHQN9fJxQyZ/oX7f28SmF6BsY5bWq1rq2sekuqw0h+ODjMxZ7LmdrTKTp7yNiFPryO7sl1vUjE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=KRFkAU7s; arc=none smtp.client-ip=209.85.208.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-ed1-f47.google.com with SMTP id 4fb4d7f45d1cf-57a22af919cso843a12.1 for ; Fri, 31 May 2024 10:32:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1717176776; x=1717781576; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=OMppGFFrT5MnAdCHtOHnnUXgbQ/hA3PsMnZtuj4qBMk=; b=KRFkAU7st43Cdiq4nVUn5JGa6MxYne7t9z/z4hoIkUhr4ERXBz6LctBHaW90cbNCYX m/qnrRnvDUof3V1psMG9Qfd0qGtlF2i/fqZHlsmQ9dazFEplzTrhAIPCXfMDMbz9eIHs 7TjQhHynZOqwxYcRt7OJU8fi2wA9XKLJUDC7YuiahiK27dYnEHW3OKZTMTFMb8VEiwCR HhQk7M0MTcvDGP7aQWNgKUcDqT55p5mstWMIyzO6h+oGzKjXvHQvhWerIEqI0Mow5TDg i027iyUVFrMg9oprSDjToQyTORLdxlYzG17kGJ3h9K54t1WSslEB8al8jl3Sp1xKexpl BqGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717176776; x=1717781576; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OMppGFFrT5MnAdCHtOHnnUXgbQ/hA3PsMnZtuj4qBMk=; b=VNO9HWqUPfCQmPzU+MWor96qxlrWEEFJS5GpUGVp09/kvNwBnKO/1dhpI3uP+GpDpv Fhf6G/lYBwbQY0ZhWb2VINNrF6YvlvjSGPFnOUH7APT3yU2Xhd24t/PQM14L8KY05kqg MYQyCvEMkFSm3RTY7OoWPz6T/9ciqgnDqryR+bOEKrHBvJxFRILW9AW3jj4jFjn7Qvms eN72/U79Nhk3ztjpiBmLAjvtqj/z/pJYxGMzfvNVtuT9YTwXZG3WhslCNRCQFLMz/cV7 oofjmiMx+vL71jHK+rQO7OfNRoJM4r3GJ5sTRLj2Qq8mqMjGRYo8lzDNItG1iQzXRPIr 6GDA== X-Forwarded-Encrypted: i=1; AJvYcCXLhPyIrwQlCC8CKh7K7fotyvMBGtzvYRPn5R8P4E7Jg9XhM53yAR7o7aQo7HrnSvm6N0dg6ZNb5dS9hbjZ0iGSkucaZfMTPiZASV2v X-Gm-Message-State: AOJu0YwhJ6dph7mYfP/g4Z94YZbAnFV/u/FCX6Eh2hyk81zQ3UY6Ivd2 ACSlzzLgSISbSYH7X1RANv61FkN0BtljZXsYCNQxU03VssO33V9JxQKl0zv/pKVM4nU3LskM6k3 6Sb1zw2ohxz4CpHqD4N/lL2uQeah4mTpYMP/1 X-Received: by 2002:a05:6402:682:b0:57a:3103:9372 with SMTP id 4fb4d7f45d1cf-57a37923832mr160622a12.7.1717176773754; Fri, 31 May 2024 10:32:53 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <9be3733eee16bb81a7e8e2e57ebcc008f95cae08.1717105215.git.yan@cloudflare.com> In-Reply-To: From: Eric Dumazet Date: Fri, 31 May 2024 19:32:40 +0200 Message-ID: Subject: Re: [RFC net-next 1/6] net: add kfree_skb_for_sk function To: Yan Zhai Cc: netdev@vger.kernel.org, "David S. Miller" , Jakub Kicinski , Paolo Abeni , Simon Horman , David Ahern , Abhishek Chauhan , Mina Almasry , Florian Westphal , Alexander Lobakin , David Howells , Jiri Pirko , Daniel Borkmann , Sebastian Andrzej Siewior , Lorenzo Bianconi , Pavel Begunkov , linux-kernel@vger.kernel.org, kernel-team@cloudflare.com, Jesper Dangaard Brouer Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, May 31, 2024 at 6:58=E2=80=AFPM Yan Zhai wrote= : > > Hi Eric, > > Thanks for the feedback. > > On Fri, May 31, 2024 at 1:51=E2=80=AFAM Eric Dumazet wrote: > > > > On Thu, May 30, 2024 at 11:46=E2=80=AFPM Yan Zhai = wrote: > > > > > > Implement a new kfree_skb_for_sk to replace kfree_skb_reason on a few > > > local receive path. The function accepts an extra receiving socket > > > argument, which will be set in skb->cb for kfree_skb/consume_skb > > > tracepoint consumption. With this extra bit of information, it will b= e > > > easier to attribute dropped packets to netns/containers and > > > sockets/services for performance and error monitoring purposes. > > > > This is a lot of code churn... > > > > I have to ask : Why not simply adding an sk parameter to an existing > > trace point ? > > > Modifying a signature of the current tracepoint seems like a breaking > change, that's why I was saving the context inside skb->cb, hoping to > not impact any existing programs watching this tracepoint. But > thinking it twice, it might not cause a problem if the signature > becomes: > > trace_kfree_skb(const struct sk_buff *skb, void *location, enum > skb_drop_reason reason, const struct sock *sk) > > As return values are usually not a thing for tracepoints, it is > probably still compatible. The cons is that the last "sk" still breaks > the integrity of naming. How about making a "kfree_skb_context" > internal struct and putting it as the last argument to "hide" the > naming confusion? > > > If this not possible, I would rather add new tracepoints, adding new cl= asses, > > because it will ease your debugging : > > > > When looking for TCP drops, simply use a tcp_event_sk_skb_reason instan= ce, > > and voila, no distractions caused by RAW/ICMP/ICMPv6/af_packet drops. > > > > DECLARE_EVENT_CLASS(tcp_event_sk_skb_reason, > > > > TP_PROTO(const struct sock *sk, const struct sk_buff *skb, enum > > skb_drop_reason reason), > > ... > > ); > > The alternative of adding another tracepoint could indeed work, we had > a few cases like that in the past, e.g. > > https://lore.kernel.org/lkml/20230711043453.64095-1-ivan@cloudflare.com/ > https://lore.kernel.org/netdev/20230707043923.35578-1-ivan@cloudflare.com= / > > But it does feel like a whack-a-mole thing. The problems are solvable > if we extend the kfree_skb tracepoint, so I would prefer to not add a > new tracepoint. Solvable with many future merge conflicts for stable teams. > > > > > Also, the name ( kfree_skb_for_sk) and order of parameters is confusing= . > > > > I always prefer this kind of ordering/names : > > > > void sk_skb_reason_drop( [struct net *net ] // not relevant here, but > > to expand the rationale > > struct sock *sk, struct sk_buff *skb, enum skb_drop_reaso= n reason) > > > > Looking at the name, we immediately see the parameter order. > > > > The consume one (no @reason there) would be called > > > > void sk_skb_consume(struct sock *sk, struct sk_buff *skb); > > I was intending to keep the "kfree_skb" prefix initially since it > would appear less surprising to kernel developers who used kfree_skb > and kfree_skb_reason. But your points do make good sense. How about > "kfree_sk_skb_reason" and "consume_sk_skb" here? > IMO kfree_skb() and consume_skb() were a wrong choice. We have to live with them. It should have been skb_free(), skb_consume(), skb_alloc(), to be consistent. Following (partial) list was much better: skb_add_rx_frag_netmem, skb_coalesce_rx_frag, skb_pp_cow_data, skb_cow_data_for_xdp, skb_dump, skb_tx_error, skb_morph, skb_zerocopy_iter_stream, skb_copy_ubufs= , skb_clone, skb_headers_offset_update, skb_copy_header, skb_copy, skb_realloc_headroom, skb_expand_head, skb_copy_expand, skb_put, skb_push, skb_pull, skb_pull_data, skb_trim, skb_copy_bits, skb_splice_bits, skb_send_sock_locked, skb_store_bits, skb_checksum, skb_copy_and_csum_bits, skb_zerocopy_headlen, skb_zerocopy, skb_copy_and_csum_dev, skb_dequeue, skb_dequeue_tail, skb_queue_purge_reason, skb_errqueue_purge, skb_queue_head, skb_queue_tail, skb_unlink, skb_append, skb_split, skb_prepare_seq_read, skb_seq_read, skb_abort_seq_read, skb_find_text, skb_append_pagefrags, skb_pull_rcsum, skb_segment_list, skb_segment, skb_to_sgvec, skb_to_sgvec_nomark, skb_cow_data, skb_clone_sk, skb_complete_tx_timestamp, skb_tstamp_tx, skb_complete_wifi_ack, skb_partial_csum_set, skb_checksum_setup, skb_checksum_trimmed, skb_try_coalesce, skb_scrub_packet, skb_vlan_untag, skb_ensure_writable, skb_ensure_writable_head_tail, skb_vlan_pop, skb_vlan_push, skb_eth_pop, skb_eth_push, skb_mpls_push, skb_mpls_pop, skb_mpls_update_lse, skb_mpls_dec_ttl, skb_condense, skb_ext_add, skb_splice_from_iter (just to make my point very very clear) Instead we have a myriad of functions with illogical parameter ordering vs their names. I see no reason to add more confusion for new helpers.