Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp56238lqh; Wed, 27 Mar 2024 14:45:45 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUmqGUewm/2R/21Vf5x6cJmhK1HAk6PeRJW38KXIRu8Ts9NH3jGRYhzYnZRNjKEeIHLk1feLGGzD8DWoaLVpwezNBbeitcGl968VGg/9w== X-Google-Smtp-Source: AGHT+IHzyyGxtanPrRc2NoiCTUyQfexbE23wNCrPuxEEFmYFbxYYktk3XOVYAkXyNDtrYSbua0iu X-Received: by 2002:a17:906:1398:b0:a4e:c35:c54c with SMTP id f24-20020a170906139800b00a4e0c35c54cmr508418ejc.3.1711575945757; Wed, 27 Mar 2024 14:45:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711575945; cv=pass; d=google.com; s=arc-20160816; b=cDfE2sH37lqvBmhkz2zgn2sUYoP0/f4hy24YNDxs1TmEB4KQqP8S2pbVsOL4P+I1Dw WRJPL03kTEC1/ZTnPHPKU6LTZOVNBq/kHS/4x/LDhKxnHUaj5rkG8qNgMc/nrWISBj19 QTmI9QaDsVfiJ6KXYYlf85qO6CyQgWbutTj+xiNdIvlWbc061FvK7xfbLF0mrjRClVBe qUN+dsRRrs+Vn1kUQEoEUhLqEOB5eTR6+wH+gODLF47ntUbNvRi4lpaFRBcoJ4+V4S0p DG2TLKttm82QmGcewHmJjd4u62VrXaxPJA2rUlcR0w5CX7YpCcbhY7o7x9B4YMv5AxI+ 7Msg== 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=CKh/si12loPcjkl/bjouIbxS+vyvkdZDxqEpH33Vuvs=; fh=iIVbEf0Tl40TZlaqM7HTx00wFhr9V+XU3Qfgjv7rFyQ=; b=RM4ZGODkzLCFwLp/KrGgUjbYYSIrwaZHezNnLjXgfKNi4okLbsJa753pSAoaVxFddx qFFP6cWadIE9fKYhplTb8tMNRBHhUjO6A4EnWs2ziVDIGQiE9g+5H39vuX1c/qfdGyHi aBV6AZ3dmAc1ne+uE/DkFJKSC1Xz+vLg2HlLBg/kZU2J/f3ayYETdzVHMFJTmP5CQ6aM SApQ5WbJGh/3g73FmsocTnRaLXQNFTxMH3LawP2mJzFb0g08jTFYCmgbhCV2axk3QqC8 HEkADRLdUfZwlLOvvxph963T7UczhkJeMz2fI0OFex5eZ1e1Zs1Sh8yF5CMSfOcz26Cp jU7w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=SdR68CvE; 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-122048-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-122048-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 k17-20020a17090666d100b00a4a3ca59dcasi2892803ejp.958.2024.03.27.14.45.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 14:45:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-122048-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=SdR68CvE; 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-122048-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-122048-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 52E5D1F2F6B9 for ; Wed, 27 Mar 2024 21:45:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ACA1C153829; Wed, 27 Mar 2024 21:45:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="SdR68CvE" Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (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 3F69614C5BE for ; Wed, 27 Mar 2024 21:45:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711575929; cv=none; b=HIRfESUFoWLAp/gWg7LYisCW+82DB+Mf0tCqoFXIWqEbK7V1gM/rgjj8yRCZEL2RrXs/BcLHkM8HLW4UkflfVRvehUWzFpBZ5YyAKxCIAuPNx4My9SeDW9rw1MiDJAKH5vsmjuCnA1Jki2I2cAt9V6/C3P6zYDbx4iFB/yE0GQY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711575929; c=relaxed/simple; bh=lTnVetYvVWg5DjyVBudKOtPcgTtVueyB5BYBsAsl91Q=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=LmO/pRKJHVab20EG3ukUcZ+4mSd9AKeoRjb377DHic0e8MaGVCphMH5q4/q95/8dEaXJVjMgWosuEpzcvvkWqTI0bGg7J/pEYfz8ojDHjocVyTcA09+Ks/dxZlevmdsZdqKlMHI+h1uGZfwGnKVh3S5BMIVsKqi89Q3xADuBaOI= 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=SdR68CvE; arc=none smtp.client-ip=209.85.128.201 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-f201.google.com with SMTP id 00721157ae682-60a08eb0956so4762407b3.3 for ; Wed, 27 Mar 2024 14:45:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1711575927; x=1712180727; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=CKh/si12loPcjkl/bjouIbxS+vyvkdZDxqEpH33Vuvs=; b=SdR68CvEpuBEsx2TIE0nQmQ0u5KH1ZB5jWHON47nBAdvzzx6a7S353k1NDA3eKnsz5 MHTp6gPdPLJLmF9KWv1oxhHoJdiU9OSmkOUtVzJ7VgUoiVSLXW1zTGFfLeZdGpnE3HjZ Bkv28ee42yrZoMrydEOqUbmWrqVsU8WX4YAZvup4rNd8uzMzVWF40y+0MDrpHrljErxP LxnfH8nS9GAJ/88KNBeD0P/tZh1cdclhcFaOR8A9QCCCWsi02Ca1ogIgHJCPbgjWYY05 KnRLYrUzHycOHOgnHqyqoHfJu8GPw4Wc8v2pAfmo4HHVxksJvu+S4NvX01do8bl32WAl NXlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711575927; x=1712180727; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=CKh/si12loPcjkl/bjouIbxS+vyvkdZDxqEpH33Vuvs=; b=mAze0XmsdqLztqcZEmSJBjjIXGY95Xnp9oeOo1FB6XnY7fDUWdlG+UxyJnbdIREzS+ ObM3/LHi/szky7T4Ia9w9GhgeLLbXq6W07Y49RS5rsfj1uWCYWlytIOt5ToSQzb6SD6y RE1ugaZlpKELHkeml6he/G/KGf2UIkdWYWc8C8Y2hJbH9yy0gAwsrMMr1WksWCMjitlA PmidoaBxeRvh8OdNG1AAmUycw/StD2Be+r5PMiKr9UIkPyZrHOrFysyREePfhau3hhq6 x7yGW0/JbMkWxVgKhBihGBSQPBlffehMiZb3i24Dj0au3FXqIKgiZ/0QZkr9KgxYUiT/ l4qA== X-Forwarded-Encrypted: i=1; AJvYcCUlRfSJN3C+Gk5Byyqbv2BiYQckuHrdncN8qZv8u8BCo9PYtAoWIvnjay5aQg6jRbZ3WPPLnoXrOiCJHjV+8i5koAUQo2vUxyZhjiaX X-Gm-Message-State: AOJu0YwHi4mk4bzosr3GV5aTypjGls3ydSLgE4gGdPNQeuCtBWKSM3nm hbwNgK0Wi0z4UkCgeoC4GmeBimVSd1eh1ObVCGwMw8JtnLC6AA9cCXqwQotonQm6+9Ct0k5vMk0 A+tzcUqdvXfe6x+tTMkHKFA== X-Received: from almasrymina.svl.corp.google.com ([2620:15c:2c4:200:b757:6e7b:2156:cabc]) (user=almasrymina job=sendgmr) by 2002:a81:834c:0:b0:60c:ca9c:7d10 with SMTP id t73-20020a81834c000000b0060cca9c7d10mr184265ywf.2.1711575927326; Wed, 27 Mar 2024 14:45:27 -0700 (PDT) Date: Wed, 27 Mar 2024 14:45:18 -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.396.g6e790dbe36-goog Message-ID: <20240327214523.2182174-1-almasrymina@google.com> Subject: [PATCH net-next v2 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 Content-Type: text/plain; charset="UTF-8" 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 +- 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_strp.c | 2 +- 10 files changed, 52 insertions(+), 68 deletions(-) -- 2.44.0.396.g6e790dbe36-goog