Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1423506lqe; Mon, 8 Apr 2024 08:30:17 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV8eoGJF3sV4q+3/jq9vbh9k+/+spuXdnm4skyE7fmDKc0Tb+R00xkbEhTKufK0XnvXHNJUI+Z3L4JoY3KRXlPtOPWcqKZXN8F0j/0Zzg== X-Google-Smtp-Source: AGHT+IHOFvrIGW7s35dTwBbY0uJfyG/2NRnInjR4CxgrF6Wn0medtDmLreLR3C8tGCnTBAHn0dY+ X-Received: by 2002:a05:6359:4197:b0:17c:b53:98dc with SMTP id ki23-20020a056359419700b0017c0b5398dcmr10213489rwc.18.1712590216968; Mon, 08 Apr 2024 08:30:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712590216; cv=pass; d=google.com; s=arc-20160816; b=rF4+mjgu2aFE4BLbzapv54wgCMLuLDi8WS1lV2qkVY51rSc+71T2jaaM+hDnFQkwCD dgCXuUEwsMN7GMx++ZMPHJsFGD5B/WuC472Z3WQakUhxbDdMgtse10YH36oj1w9iNvHK edkpp8d1+AkrQQm2BAwQ+gLV4xK70Zrxjpo7RgfhUo8ryAnF0B5KszWG7woVUcelD5BY K5aD+s42jQ3qHsDEcLlppb2zpGhlGLV8xRPupfI+VcoV7UzCy8IzD40SyYdaewuQheTk o6eg/kW7bVV366W7Dqo18QmKoMCrl+wTXQQzeNwaSuAduSmzCSFQYEb0YXjPFh9far5O IaSg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:dkim-signature; bh=lRVgpIf9CTXoaaWbx3Q2b02belw9uoH1ZpMonmX2m4M=; fh=h52BRGorrk8BS4kPJbFiQhhf2K+AG9T6UEpKut5hmkY=; b=PrM87WmTBoKN1lLrCgiAoAUxMW8+F+dSwd5JxxUpRavR2ChguEXR5NmLKs4q5dOzTQ K54qIGJwmr/51V14K/+ocgeEb5gzneLy/QY9B9O9QDNTItZpxv0zEswUWervAtqab4Af JZqRaxSAEKW13xBI9m7yekxTHglE/u+3/huqJkl8YveFmRRjRnw9rSjF2cJczpR+I/XY zVC7lmIFqTUOP8OMFW9RnqcMjmDWUSlH1nrI/OLe2ECwaKPffuGDUMJkoyrYjnnn5whw WVztAelum2lwrqVbVeGyyX9vQGPFfL6g+Pe35mbi51y1tcE5fppE9EwkIWVfNeXvvq2K J2NA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Cm6BhEZN; arc=pass (i=1 spf=pass spfdomain=flex--almasrymina.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-135601-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-135601-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id j20-20020a63cf14000000b005dc071d13c7si6490598pgg.273.2024.04.08.08.30.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 08:30:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-135601-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Cm6BhEZN; arc=pass (i=1 spf=pass spfdomain=flex--almasrymina.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-135601-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-135601-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 6BC64284C42 for ; Mon, 8 Apr 2024 15:30:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DFA00140E46; Mon, 8 Apr 2024 15:30:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Cm6BhEZN" Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (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 70392140396 for ; Mon, 8 Apr 2024 15:30:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712590206; cv=none; b=YhFR8j/R8hWmAnDU+QVV/tu/TXu7BAQcbtgKqS3htR7TnkZUr4Qq7Jdr9dVnZI5j2n5gCppknPF5SY2yu/y09YJmjp96hixDngv7qbU6eRmMBGytW90Vq00ubCSDnz6Vc/8CWXA/C/ZR5utkiTr8IkrFSlsnqTqPdNLrOu1crxE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712590206; c=relaxed/simple; bh=6L0lKI5+1hOR7QHLw/0Q/vUSD9qNXRR1VfCBE+a/MS4=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=YbcBFbiXvzJEq922GjYk1CZHPm2HnOiMLnGGz+7W2IHFa1OIV8o6UjLeYH6DJW89yjemX6W2xvTBAn2N+nsBZlMR1wSzj696mArTZjOZbne29AY5U+siq6aA9zAK3QZXDeSxdUicLVDM1d/1oxBK7tjp+c1LY0mQk5rjwvXlLDg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--almasrymina.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Cm6BhEZN; arc=none smtp.client-ip=209.85.219.202 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=flex--almasrymina.bounces.google.com Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dc64f63d768so7689473276.2 for ; Mon, 08 Apr 2024 08:30:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1712590203; x=1713195003; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=lRVgpIf9CTXoaaWbx3Q2b02belw9uoH1ZpMonmX2m4M=; b=Cm6BhEZNkP9eUEjT34QZExfVIX/cYnDIM6sqyD3hmRNk+LO3Reyo2gosUWi52y6U6e I7uJ6bTqGaXvH0Z5somRF2wJlL3w22+HaQigz7pGjzEYCIsSdjjd0Olz+Ee0osyhjBsO 91dAY2drU8UWieH45PCvBSKhIWs3fwhMVY22Pt2X0t58tvzCj8ye8R90gxzh8H0lF5/p TrYLDUeZoS3RODorw+pNz2Q9jupJvn1owkv4ht4TFULyHsv9Cp2jGklGIhJYi1Rj8JTm 80vm3WnE9VTbiKeIVLNuAZ/KfimPed3IhZ+eKONcGA1MrPaZlk+beiFoUPLbDehBxsz+ ipgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712590203; x=1713195003; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=lRVgpIf9CTXoaaWbx3Q2b02belw9uoH1ZpMonmX2m4M=; b=FWlWY3bYKaAaF0BN2v5NMj+9c8fH+/fBYhd+H2NeJcyCFgQvyCX4C21gD72Hnb/QgU n/HDraXX5vri1LaekatMGWpfS0L0Q+NersQ322z6qobYnhgpihPK8riKMEvlNVSiBA+U 6lJ2X06BKzWB/NzdRfxA4G7JXwRmicfIeAzA7wbpxkeqdYZV9zEmq9P+dNMdW1NaZmO9 N2gg8GRFAD5Q85v2wxnSKztNbnI75ZE0A3w6GnQ/ZAO1r7Z6ewG9An5JKLtUkxTEcHao z7PiU6/jiL20wBvHGNDVv20cn1ca97sJfK8s9xcgjLiDujZLjl4c0yvPJnDANIbVwLXi pyCg== X-Forwarded-Encrypted: i=1; AJvYcCUEXRFY9IC9s/IclsiiYOHDNX2WvqZ03LwylfKdAr7ws+Juc6nrgnq1OlcxtA0V64vbhr4Dv6DSJYLAvB/PpMCMoADfgQp4MtH8/Va6 X-Gm-Message-State: AOJu0YzQ6hS9KQqynOga5haodvt3On+c6HRYTUR9i0ewHYi/MYF9i0kS hB5J9KmTaXc2wZZqQcGbqFMwQ5Co1WkfR8W6e0rMSpzXOhaAOkU+UtMj1DBmGxydDzgyjvlRRmM 4O37NdMIYSThrfo26HPfT7A== X-Received: from almasrymina.svl.corp.google.com ([2620:15c:2c4:200:ca23:d62d:de32:7c93]) (user=almasrymina job=sendgmr) by 2002:a25:8712:0:b0:dca:33b8:38d7 with SMTP id a18-20020a258712000000b00dca33b838d7mr2596614ybl.11.1712590203429; Mon, 08 Apr 2024 08:30:03 -0700 (PDT) Date: Mon, 8 Apr 2024 08:29:55 -0700 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.44.0.478.gd926399ef9-goog Message-ID: <20240408153000.2152844-1-almasrymina@google.com> Subject: [PATCH net-next v5 0/3] Minor cleanups to skb frag ref/unref From: Mina Almasry To: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Mina Almasry , Ayush Sawal , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jesper Dangaard Brouer , Ilias Apalodimas , Steffen Klassert , Herbert Xu , David Ahern , Boris Pismenny , John Fastabend , Dragos Tatulea Content-Type: text/plain; charset="UTF-8" v5: - Applied feedback from Eric to inline napi_pp_get_page(). - Applied Reviewed-By's. v4: - Rebased to net-next. - Clarified skb_shift() code change in commit message. - Use skb->pp_recycle in a couple of places where I previously hardcoded 'false'. v3: - Fixed patchwork build errors/warnings from patch-by-patch modallconfig build v2: - Removed RFC tag. - Rebased on net-next after the merge window opening. - Added 1 patch at the beginning, "net: make napi_frag_unref reuse skb_page_unref" because a recent patch introduced some code duplication that can also be improved. - Addressed feedback from Dragos & Yunsheng. - Added Dragos's Reviewed-by. This series is largely motivated by a recent discussion where there was some confusion on how to properly ref/unref pp pages vs non pp pages: https://lore.kernel.org/netdev/CAHS8izOoO-EovwMwAm9tLYetwikNPxC0FKyVGu1TPJWSz4bGoA@mail.gmail.com/T/#t There is some subtely there because pp uses page->pp_ref_count for refcounting, while non-pp uses get_page()/put_page() for ref counting. Getting the refcounting pairs wrong can lead to kernel crash. Additionally currently it may not be obvious to skb users unaware of page pool internals how to properly acquire a ref on a pp frag. It requires checking of skb->pp_recycle & is_pp_page() to make the correct calls and may require some handling at the call site aware of arguable pp internals. This series is a minor refactor with a couple of goals: 1. skb users should be able to ref/unref a frag using [__]skb_frag_[un]ref() functions without needing to understand pp concepts and pp_ref_count vs get/put_page() differences. 2. reference counting functions should have a mirror opposite. I.e. there should be a foo_unref() to every foo_ref() with a mirror opposite implementation (as much as possible). This is RFC to collect feedback if this change is desirable, but also so that I don't race with the fix for the issue Dragos is seeing for his crash. https://lore.kernel.org/lkml/CAHS8izN436pn3SndrzsCyhmqvJHLyxgCeDpWXA4r1ANt3RCDLQ@mail.gmail.com/T/ Cc: Dragos Tatulea Mina Almasry (3): net: make napi_frag_unref reuse skb_page_unref net: mirror skb frag ref/unref helpers net: remove napi_frag_unref .../chelsio/inline_crypto/ch_ktls/chcr_ktls.c | 2 +- drivers/net/ethernet/sun/cassini.c | 4 +- drivers/net/veth.c | 2 +- include/linux/skbuff.h | 60 +++++++++++++------ include/net/page_pool/helpers.h | 5 -- net/core/skbuff.c | 48 ++------------- net/ipv4/esp4.c | 2 +- net/ipv6/esp6.c | 2 +- net/tls/tls_device_fallback.c | 2 +- 9 files changed, 54 insertions(+), 73 deletions(-) -- 2.44.0.478.gd926399ef9-goog