Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp1707459lqz; Mon, 1 Apr 2024 14:50:58 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXzmUxatZiYwXXNZWyRTDS7manXhMJcHWVrgq/ZJvAFz06+jirvdARRTmYCygmTQG+cqLqatT0XM0LcyO4QFRQzkZY9niu2qN0EhamMfA== X-Google-Smtp-Source: AGHT+IHeZ7O80yB72U2Jgm7lqtNsEusin2LdOxcz1HvxemdV5jZ1qHCufF83wlB4SWATxCqHc/Ye X-Received: by 2002:a25:8145:0:b0:dcb:aa26:50f9 with SMTP id j5-20020a258145000000b00dcbaa2650f9mr8931372ybm.46.1712008257830; Mon, 01 Apr 2024 14:50:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712008257; cv=pass; d=google.com; s=arc-20160816; b=N+6qjLKTrgYyXFQycszl6MIGjDNBwDU8nqQ8g1xklZh0S9PGdNCCs1PyIhE6nJyajC bQsSfMvEitxMVwt0/TfTVojqdfho0v+GS/afl1YlrefmxoTVXNb5uWivlOstXRewAx9m PNSHt39+ZmF0q/GXdTQpYBXSHYAF9s6UsOtwreAaMQLrCv3PG5EHeaPHAameWCBK4Of5 rxSNTrDoaNsgL3QFb+LuHtNiyhdyJUY4rFKWeV8+wW7m3sOX30Bgmwsw0rYxnFL+bhc/ h6z28aPC0k0yqndnqQKIf7pNlAOmvNwElinF5V9pmvTYbVo6SZ/r48E3qWLTwYJJnlQ0 zVVQ== 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=XLIDZpDBHrtC9mQGuM4295zuVNtkbE3PLQnEnnfrBMA=; fh=SOVpwa0jPR2ApPrg+MFIOuVHqkSqbIS3c5cqWILdixQ=; b=IqIfiXrese0zjrO9tKjMupb2ZY4SF3LPRloYnI3cZXCR8YZghrilXpAoEHb3Q2mhGe 5AzI3LKucjjhFdbT/pftaosmeLhI//q4f3cRXT4gj3UeSpeQ6RAvZaskpoY2nBICSplW 1Dt0u/x4tbKs8o3PjWs+YHHlbvnstjF8Ejs7wE1fXAzi186uaUJ12ziIVHVvYeKUQZIg UpZXSgitdJmWQI8XiPtmuLBImDRjBhooiGWW3Mg5KyHWy3hDRYmgc0CeVMo8LfAEgPCh B56MKuXY+XnQi8ZF4/xESVzL4+8uCxcqKiVXhzHnbas/FADSV7vSY8hOxAXa9v4fD5bo M0AA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=xqJlfgFm; 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-127105-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-127105-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 x16-20020ae9e910000000b00789f31fb223si10655453qkf.356.2024.04.01.14.50.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Apr 2024 14:50:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-127105-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=xqJlfgFm; 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-127105-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-127105-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 80BC41C2138F for ; Mon, 1 Apr 2024 21:50:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5969055C26; Mon, 1 Apr 2024 21:50:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="xqJlfgFm" 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 F102B1C2E for ; Mon, 1 Apr 2024 21:50:46 +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=1712008248; cv=none; b=ArvkuH2Tjtgpk3uK0wZGYNHPCd5p0nRr3IrAK14vvsXv1wxGeJO+fuSBvyUdX0Ofu/rame4Qv/Gsx77UBsuc4jivKv8xMAUWkBB2EbezJKRlmw02AzFk6Y7X1F+SuNGPPRujpRjR6gACDsmaNvZ00GZX3ZqCqFn6nHWRpKxStNg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712008248; c=relaxed/simple; bh=LvCBtM2YQSeJABfcqD051PDiGGBI0pmlfrMCxzUoMmE=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=a8uVDqT9Eqq5zJiRdK/u0RHiQ1RDQTjH3oIbp+wW5I4KfS0ajlbqpG8Bm3TjxHg2KkvDMyOEEccMRW40fCLsnpJD1mULetmFq9c4BCRSRv+2aHFL9w6CcDua9z+A0cKZ0x0/WiJGJATaupzkZVxMPugbdcMP8qTTTdSUMgJayj0= 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=xqJlfgFm; 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-dc647f65573so7361530276.2 for ; Mon, 01 Apr 2024 14:50:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1712008246; x=1712613046; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=XLIDZpDBHrtC9mQGuM4295zuVNtkbE3PLQnEnnfrBMA=; b=xqJlfgFmw8EVSNp5ix6dcbeyrN7dLmOMFe9SHW+OycpRPRgMAHRgN2t5LerU4HRTdT KmTrH+Dk4u2rRCeuRD3GD/R/X6W3ZDBgF95+9kiqJ2I1ulsuINi0c55F0JSK7v0tHOHH 5fVHW8PZ4eTjTLqREeHKCeaxxS0GMHCwWtZZ7uCn+j5eCpwkm3Fln1UBQM/YOZrjUNap 89LDl067TluOt9qOfbERA1tzFi47zLt0YDEFJU7IY8+QjHQaO2D2X1+rxkjg5/4wV0Fz 0BEuUIgSpyjQ73z9thH5OhAUZrxiIFff8QaSdDFXTzxRvVuOjhyDGaxgB+5D/XxdXYzc H5lA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712008246; x=1712613046; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=XLIDZpDBHrtC9mQGuM4295zuVNtkbE3PLQnEnnfrBMA=; b=SZk151ccAGhPF8NJc3amZwHB+L2h5noq1xzvFynFlxGNapMdYHq+5NghFdDYKefXd5 1NChrfkasFgg8TU872LwloaAkJsGxEc5+5QghS39ijMSyiRqe4l2x2mZAWXszIkYPAfZ IXnelarjerOtMr+pBd7FMKthvlAR3vgrNLM5stA610a/zyS4bWYn4nURXpfHJniLTmkm t1LsYEswUCj0ZHae8br2F0sfxKc2nYIWgpF9zk+tVf7pGYrNX4znVxpGzz+eO3Lp9If4 Fyk3Jd8IbT1C4piocWyu6suM8UnVieEhdvskKtA0BTDRnHGgT0d/M0V7/IvtVQ7GXzCt m2UA== X-Forwarded-Encrypted: i=1; AJvYcCXtlfy+o+VoKVFBPGBkSoIJpI2AZafCJI4hNxccMR943+YUP5jk4/ALeM0Lx70w9rkNVwXFTSDzX3CHj/rNCyebpdfCWE1kHOGb66LE X-Gm-Message-State: AOJu0YxwoFkJZ+YRJxUD1FdGRHPew5r9WaKsNqqGOrw2Ef2CNbbYYJJk c3W/t969Bes2eemtlwP3KviJ9igxksweTXHZP8K/5ViJlKWdv+mNLdvt1SJPLVHzIIXtcc/vCnV 3rJj6bPELk1c2nGYslnJ0Tg== X-Received: from almasrymina.svl.corp.google.com ([2620:15c:2c4:200:b337:405b:46e7:9bd9]) (user=almasrymina job=sendgmr) by 2002:a05:6902:2503:b0:dc9:c54e:c5eb with SMTP id dt3-20020a056902250300b00dc9c54ec5ebmr3429870ybb.7.1712008246111; Mon, 01 Apr 2024 14:50:46 -0700 (PDT) Date: Mon, 1 Apr 2024 14:50:36 -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: <20240401215042.1877541-1-almasrymina@google.com> Subject: [PATCH net-next v3 0/3] Minor cleanups to skb frag ref/unref From: Mina Almasry To: netdev@vger.kernel.org, linux-kernel@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 , Steffen Klassert , Herbert Xu , David Ahern , Boris Pismenny , John Fastabend , Dragos Tatulea , Maxim Mikityanskiy , Sabrina Dubroca , Simon Horman , Yunsheng Lin , "=?UTF-8?q?Ahelenia=20Ziemia=C5=84ska?=" , Christophe JAILLET , David Howells , Florian Westphal , Aleksander Lobakin , Lorenzo Bianconi , Johannes Berg , Liang Chen Content-Type: text/plain; charset="UTF-8" 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/marvell/sky2.c | 2 +- drivers/net/ethernet/mellanox/mlx4/en_rx.c | 2 +- drivers/net/ethernet/sun/cassini.c | 4 +- drivers/net/veth.c | 2 +- include/linux/skbuff.h | 44 +++++++------- net/core/skbuff.c | 58 ++++++------------- net/ipv4/esp4.c | 2 +- net/ipv6/esp6.c | 2 +- net/tls/tls_device.c | 2 +- net/tls/tls_device_fallback.c | 2 +- net/tls/tls_strp.c | 2 +- 12 files changed, 54 insertions(+), 70 deletions(-) -- 2.44.0.478.gd926399ef9-goog