Received: by 2002:ab2:4a89:0:b0:1f4:a8b6:6e69 with SMTP id w9csp344238lqj; Wed, 10 Apr 2024 12:05:56 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU7RanWhAQjv2oJB1qtDEHmT+cHFVbiYLpRurNjzFy6301YPddA1kyyiAXMFVgy1gA8jzFrBfJEUyE248bjn6YW7eFkAypaRawWXcX45Q== X-Google-Smtp-Source: AGHT+IF/9hwDYO7jBQCW0JUEX7upwvOnsM84AxtBrrj1Tq/3pbC4IoXb3RWvGTNcT8+VaMG1afWS X-Received: by 2002:a05:6102:32d1:b0:47a:22cb:cf27 with SMTP id o17-20020a05610232d100b0047a22cbcf27mr655629vss.3.1712775956460; Wed, 10 Apr 2024 12:05:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712775956; cv=pass; d=google.com; s=arc-20160816; b=svgYm3MHP4S32RP+am5N8Wy/VeVdAimjYdZQNyK44xpvKp4d5FYJVqpdtNiKDaRaY/ vIxydIVoKu5irEc30MLpG7dPtJKa6tueFd3Czk95P7bxjmNDr9tzpIbG7uCUt7pQ23bp 9syshe0pNk6xvSbJat6DAKFr8z6esKhTy5WXpgqnM91vqIo+OPnZV6eWpPsF/6n9MWlP 6HIneHI1NarmOi+zXuhce+dK0ISIVr/otemEFn8tyDO/U6bnfzJiZlQcc3uq5JbQTrB4 nvV3QAtZ4nDSilN88i/eQOhSY4kYIl8h7pMB2Hw8rqEmPy2vzXD/Cx6mzvrk4O4oFhL8 7oSQ== 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=NUsqaY3FlD+Zy5gL3/6y26rsQKtdUSDBl6T6cUgvwGY=; fh=ja8DoAg2gvQ63hE5c3emsmyllHFchGvyu1popbW+rTo=; b=IlGLDa8s9UlxMSoHuevaZ6ocDNkYwP/D6SRtg03Gd6ismApOSC/XdtojCu2t85C4Nm P+9vF/HkyYw3jDdQs+V97CN/3x4RBOoyhQ0ajxtp3HkfEo9VHA6XlWsnobp7uTc1dc9W lDG+NwfLZnmMiXJwKJ7MeDxbLUGZi8QQWwl375IqhhSR3EN5ocQGZUfRcdOXPnKgxKxv fpeM/lK239bGBBDkV+il0v7B+YHJ3//0f/L7yb77woV6FHFVUPgMgAZ1ovGdb+s0MtPt CsQ+azxIL+FS451fILfqQweT/UpCzdbmekYyHOTZsVr1mPJVf3L/tkuWC/be3HP7KhLg c2wg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=x+VEU+E5; 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-139240-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139240-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id q11-20020a056102126b00b00479c187b4fdsi1541365vsg.767.2024.04.10.12.05.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 12:05:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-139240-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=x+VEU+E5; 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-139240-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139240-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 047951C22983 for ; Wed, 10 Apr 2024 19:05:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 47460181BAE; Wed, 10 Apr 2024 19:05:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="x+VEU+E5" Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.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 D1D62180A89 for ; Wed, 10 Apr 2024 19:05:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712775912; cv=none; b=gNoSIjNCpOWuSfng4mg36tkJ67CM19CgGzaaQEw9b2YzcY+Tie1oyPwW73q6YQeW51xPrOBxazx/UcG418XvH6k+0f6pNGoYT1wdRaIdIsR5LcxskOUofU4H7jEc3yyZabYfVgQqF+d2ybRDdikhFJoJ8CSM/sUQ8xI/gIvZnq4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712775912; c=relaxed/simple; bh=fmONSPwwncQRNVe6gLdC7y2dFGVtjszuSrUkmPvCfMc=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=tHZh0gnO2XdczMnuqWn1NXAOW6BH4vZPwuAtMJ4u2V9r3AXXn3R8XIOXfjXsrDW/RU03FvFjSre4yjZ0i0wVE6sJUXZMpExgyu37YdEKPgc/grq3Pk2iEkCSCAIL60w7seUosqFfLJL3fCpFaWEOzAjGvOxBOfszCC4nF7JkJj8= 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=x+VEU+E5; arc=none smtp.client-ip=209.85.128.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-yw1-f202.google.com with SMTP id 00721157ae682-615372710c4so114032147b3.1 for ; Wed, 10 Apr 2024 12:05:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1712775909; x=1713380709; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=NUsqaY3FlD+Zy5gL3/6y26rsQKtdUSDBl6T6cUgvwGY=; b=x+VEU+E5c4GbDaPYaNdZcxDOslPEALGSRJLuem9mUjVeMcSNBLP3ASaxZPQqQ5XUQZ GZMXRyCkhx2ZoxxyRLPMKrCqPZ+3yvuZEPa5AUd/6FJ8/yzq1XcF4hnROHBlxlK7Vgcx 2pyZa2zNev3R91omeeXv2aO0gV3B/NJBobuMHBIRA1cVejh4jjPsHoitvpHL3Zd/40WE 8JXRx0qZSqdCyEyWcppCQJYcHhwxeQ66pzqYrqYfjyIhXJ7KWt3JYnWgKWiEzv/g1wpN 95gbBhqfIKateV6/hlTY1IgJOxtlJjoG83yPoufIOVhEi2xSPNNRakvoMC/x0k8EFMCl OBYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712775909; x=1713380709; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=NUsqaY3FlD+Zy5gL3/6y26rsQKtdUSDBl6T6cUgvwGY=; b=a9oBHDvqNx3kF9ygoYIyQ6QF+VgxO/a/S+fw32aACdZsTr2L89AxPFS5Jfx1tif+C5 FL8IK4HKvi339MiC+C588SoVxhq2hliFybJXqfcZpZ9unQ1eBpeCo2KOV4LNC3qhW2kM drZPAERnkyI85/AnS5HqWDq67kYCPcboFrWrmLXqEvi6y+EF8k6zvDLFLn/kfANOWvUa jAE8/bLE67JJe166tkfdXGhsF0rMpRTmZB6BV2p1Ox0q9Sv8zVxO1Wzu6f2XCDcWEjn0 9Km8TJIUXrRk+6ekXkC5mh+RDFbr+vCJz2SVkf5W3svON2/IvbtlUil3XalVl1G19ljM 00mw== X-Gm-Message-State: AOJu0YzeAzDhPQ0eJ4xevUvL0507QvpXmMRYM3FvBVk0AIc5CVSgYL5O +IfdftFyc2UrMtAu+3CjEkynYRyqYz387dut2uviHMzHYzVKzMSwiiMyKP+LaZdMaSaQsMJI7Lu b+YD9nywt3zZx57zJi7acPOlqVk+TVmd49+YrhIdmI8LkeLbqauNwPv8NLnbAzjNzfePY2McOfq qjLs3mLxeGBgk3t4CyvBqNervbztQnuNpB68sAQdLIyYfwzsjn5KoE3S9QfVJORgWr2YA= X-Received: from almasrymina.svl.corp.google.com ([2620:15c:2c4:200:21f0:1a3a:493e:cf21]) (user=almasrymina job=sendgmr) by 2002:a5b:34e:0:b0:dc7:4af0:8c6c with SMTP id q14-20020a5b034e000000b00dc74af08c6cmr344899ybp.6.1712775908813; Wed, 10 Apr 2024 12:05:08 -0700 (PDT) Date: Wed, 10 Apr 2024 12:05:00 -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: <20240410190505.1225848-1-almasrymina@google.com> Subject: [PATCH net-next v6 0/2] Minor cleanups to skb frag ref/unref From: Mina Almasry To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-rdma@vger.kernel.org Cc: Mina Almasry , Ayush Sawal , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Mirko Lindner , Stephen Hemminger , Tariq Toukan , Wei Liu , Paul Durrant , Steffen Klassert , Herbert Xu , David Ahern , Boris Pismenny , John Fastabend , Dragos Tatulea Content-Type: text/plain; charset="UTF-8" v6: - Rebased on top of net-next; dropped the merged patches. - Move skb ref helpers to a new header file. (Jakub). 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 (2): net: move skb ref helpers to new header net: mirror skb frag ref/unref helpers .../chelsio/inline_crypto/ch_ktls/chcr_ktls.c | 3 +- drivers/net/ethernet/marvell/sky2.c | 1 + drivers/net/ethernet/mellanox/mlx4/en_rx.c | 1 + drivers/net/ethernet/sun/cassini.c | 5 +- drivers/net/veth.c | 3 +- drivers/net/xen-netback/netback.c | 1 + include/linux/skbuff.h | 63 ----------- include/linux/skbuff_ref.h | 106 ++++++++++++++++++ net/core/gro.c | 1 + net/core/skbuff.c | 47 +------- net/ipv4/esp4.c | 1 + net/ipv4/tcp_output.c | 1 + net/ipv6/esp6.c | 1 + net/tls/tls_device.c | 1 + net/tls/tls_device_fallback.c | 3 +- net/tls/tls_strp.c | 1 + 16 files changed, 129 insertions(+), 110 deletions(-) create mode 100644 include/linux/skbuff_ref.h -- 2.44.0.478.gd926399ef9-goog