From patchwork Wed Feb 14 22:34:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mina Almasry X-Patchwork-Id: 20401 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b825:b0:106:860b:bbdd with SMTP id da37csp25230dyb; Wed, 14 Feb 2024 14:38:11 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUbwTc/uHfWS9sbSpcPoI1I/nVdg66Ja/nnwXK2CSKSQz8JRRAECD9DzzrA5W9sxOZdcS/hHwXrQ4ilj53PHJ8Ry5Sj+w== X-Google-Smtp-Source: AGHT+IFqaF4ZsgB92pS8uDrXUkJN/6yIjqNP3JTKzpo9sMHK5P8isMC+aAHuFkaEsKRGUlE1Bb8b X-Received: by 2002:a05:6a21:1583:b0:19e:a19f:f4de with SMTP id nr3-20020a056a21158300b0019ea19ff4demr226408pzb.41.1707950291699; Wed, 14 Feb 2024 14:38:11 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707950291; cv=pass; d=google.com; s=arc-20160816; b=HhkdYkdRaLNwB9PG3Uyb2q6f4EVwzWHDi2I05QmnQ1V0nV8t+rW0ZI7ShwVJD8lNdg DTg6/1DiLLb0Qh6wLpryMVU+MIfnDjeNyJdSfXA7Psp3l62camPv6Xub5zpkURqwuexk gTMAuUbdwtN4v9j+xyBci3sC4YpCwS41Ct7FnW13bFfoyKp3uyNUxkz3TgJGYO9GseIo 1R5Rhzn3l7Wvn5gyM28hR4U6ZN+d6SLWIKRr6bXpebjEZexFK65ScFqzSd8n+YNufXBA JtlPUEds39OC5A1GMEkueTu6OzS+s7T/C5LjF7X1MfLmMJwoh6eMqFx5X0yfNY3xleyO yGCA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:from:subject:message-id :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :date:dkim-signature; bh=0cbBOEAdMKtHU21rqPFfqL7h7M//5Xm4Ynv7hO4s8OY=; fh=3zG4NHuhPxuhQ6Shw7Nt9BiRVbWd7elghbVYpfpS9LI=; b=dhoNOSIMTrLE/GqjO4q58IxBUcrso2Oy0SVDJiRo04+G4wnSNSPZX7OB79uLjPj8jn dKj01UxxJ/yY3GhXmKuD/lO3/YVR1+nU+cHDbXp5DQ1Hlz1upOU2Hj+BefRCQd14rqJr YakzzE6az8I651tNcCbVlXqyS3ZrxjbqD5mlKED8yq92ebZ2T5VfT/NA1HFbn7HMudj8 jw1EYLUNncIn03ekUq25+hflci90p1sY7We3k0gNskWuNSwj7y3qUQ/9xyfrcyEJoGwB tUk5Bhbj739RYXKiagIRcrs2Vl1rOaMiEXobE8FMqIoK8M4vZ0JelVDetZDz5YRCRMfx 8YYA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=PORiuqgN; 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-66056-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66056-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id m8-20020a17090a34c800b00296f787e17bsi7602pjf.102.2024.02.14.14.38.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 14:38:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-66056-ouuuleilei=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=PORiuqgN; 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-66056-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66056-ouuuleilei=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 3FEEA28F3F7 for ; Wed, 14 Feb 2024 22:36:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 46AED145355; Wed, 14 Feb 2024 22:34:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="PORiuqgN" 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 A2EC326291 for ; Wed, 14 Feb 2024 22:34:08 +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=1707950051; cv=none; b=mJnecn0RVB4h2TjedeieaVU3lGwZAoEcOGXIMSHzfhx6W/sOLWJiev0Oa4b9NKOIUgvs9gXnPVoKQSXYY9mF+hXEKya61cujWTc1X4rGcPP1iOsCg2ytThTr0NUDBdu6gCG0D5OTuY3FQVkJ0NqAoRxuOURCnWOW3DV3P3jcWNM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707950051; c=relaxed/simple; bh=92FzybQ0k/QQSRZIXOZq2u6SesnBUJmYVfIEOiul8QU=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=FZBPfw1Etzcrpq63+w6T6WlpdvkKGoKCIe6x5pTbW4HIMOnk5Hs9NhLl+5/uQuQ3Cx9O3BcFDk2tCBP0Lurx77DLRwbZZj46t4+vCdta2Lg8KYVT/wziktg+GJ4eb1ZTitfEkSR5EjpB5okznbMKC0sLZOUXYtVrbVM9pnHli5A= 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=PORiuqgN; 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-607838c0800so15841147b3.1 for ; Wed, 14 Feb 2024 14:34:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1707950047; x=1708554847; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:from:subject:message-id :mime-version:date:from:to:cc:subject:date:message-id:reply-to; bh=0cbBOEAdMKtHU21rqPFfqL7h7M//5Xm4Ynv7hO4s8OY=; b=PORiuqgN3YpORj0iB3mss/O3GREJn/8JAup3hW5Ar1YheIU/lKh6mQ4OdrfdIcWtCW r+x4SicyAcNiJwRhONgr6/uw5A4DU+5AaublgXqc1j5WlNnLZk6/adCh4X7BuFKJuhh9 Z5uaBJoRTXMycgh51i9+agg1/wZpW107E+qdHe/yStmrpQcaCJCtuiJpaIw/bKLYeE/q 5RsPS1d7OvwL4n8tGbaEwOf6ruyLiU167CD1bShhTSPESbTiPC0KNH9Vjl8qQBKj/QPb F+vx7brNzdjiGYM1YS9fDYSaJbasHtxlOgZRz363XnORSmNRHA3ci80kMDSWEw7TPdAl UmtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707950047; x=1708554847; h=content-transfer-encoding:cc:to:from:subject:message-id :mime-version:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=0cbBOEAdMKtHU21rqPFfqL7h7M//5Xm4Ynv7hO4s8OY=; b=U+QpLlPQ4SjUkEQrLQfQ/4MpUM9zJjnI38fBzBpY/z8e4gFYfoeDTVFHqUS6Xyba8t 9ADoJk1sJrIxKxqdScI8s6e+7jR0qOlHBvdl4P9pEKZc8mzlSDv448spO1mYnzejs8n2 MlCAVm7hJ026AgrvvDUZHy/n9FUrhJ+Jf/BWwKbNz8fhhw+x4MIswozA2OwE8E4rb/Sd wDfGrpdupEIIDO/yA4a5crmdyJUzHLEtMYXVS683tFy1XW7fOYoxUUsxVK9eqnyfX1br ZnXzZ0+q3Bdd2YUhc6lfbcC2LKJCMj6WmCi5mSWQ6l4t0SIjQbU0W9QV/PbThADIm16H +q7g== X-Gm-Message-State: AOJu0YyUlkxPq3nXqE+oPAkRKaYXvqvd+XpOwbxxqgacwjjdVCqxMg5y EQBWUTlAUCKmilffPND088+Q3P5LQ0ob2gfx3iVZPpFgdcG8WiD3+LUs2qqL7dzmefuFfg2MKEI TyN95JK8EFpoNQP4e9QqzOPPJxRjc/i0I+PyPo2THQQrYYYxjuEbFiuHz5RyA17OrGxLyJ/yco1 3ZTqjPBrc8raD9ehwhOzjP5hBLjqu5M51XTcYgGfyEKjaAS0OS8o2bBq243z4hn4oRLzs= X-Received: from almasrymina.svl.corp.google.com ([2620:15c:2c4:200:e4bb:b13c:bc16:afe5]) (user=almasrymina job=sendgmr) by 2002:a05:6902:f0d:b0:dc6:deca:8122 with SMTP id et13-20020a0569020f0d00b00dc6deca8122mr588946ybb.5.1707950047502; Wed, 14 Feb 2024 14:34:07 -0800 (PST) Date: Wed, 14 Feb 2024 14:34:01 -0800 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.43.0.687.g38aa6559b0-goog Message-ID: <20240214223405.1972973-1-almasrymina@google.com> Subject: [PATCH net-next v8 0/2] Abstract page from net stack From: Mina Almasry To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: Mina Almasry , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jason Gunthorpe , " =?utf-8?q?Christian_K=C3=B6nig?= " , Shakeel Butt , Yunsheng Lin , Willem de Bruijn X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790915685124742365 X-GMAIL-MSGID: 1790915685124742365 Changes in v8: - Moved back skb_add_rx_frag_netmem to .c file (Paolo). - Applied Paolo's Acked-by. ----------- Changes in v7; - Addressed comments from Paolo. - Moved skb_add_rx_frag* to header file. - Moved kcmsock.c check. ----------- Changes in v6: - Non-RFC as net-next opened. - static_assert skb_frag_t compatibility with bio_vec. ----------- Changes in RFC v5: - RFC due to merge window - Changed netmem to __bitwise unsigned long. ----------- Changes in v4: - Forked off the trivial fixes to skb_frag_t field access to their own patches and changed this to RFC that depends on these fixes: https://lore.kernel.org/netdev/20240102205905.793738-1-almasrymina@google.com/T/#u https://lore.kernel.org/netdev/20240102205959.794513-1-almasrymina@google.com/T/#u - Use an empty struct for netmem instead of void* __bitwise as that's not a correct use of __bitwise. ----------- Changes in v3: - Replaced the struct netmem union with an opaque netmem_ref type. - Added func docs to the netmem helpers and type. - Renamed the skb_frag_t fields since it's no longer a bio_vec ----------- Changes in v2: - Reverted changes to the page_pool. The page pool now retains the same API, so that we don't have to touch many existing drivers. The devmem TCP series will include the changes to the page pool. - Addressed comments. This series is a prerequisite to the devmem TCP series. For a full snapshot of the code which includes these changes, feel free to check: https://github.com/mina/linux/commits/tcpdevmem-rfcv5/ ----------- Currently these components in the net stack use the struct page directly: 1. Drivers. 2. Page pool. 3. skb_frag_t. To add support for new (non struct page) memory types to the net stack, we must first abstract the current memory type. Originally the plan was to reuse struct page* for the new memory types, and to set the LSB on the page* to indicate it's not really a page. However, for safe compiler type checking we need to introduce a new type. struct netmem is introduced to abstract the underlying memory type. Currently it's a no-op abstraction that is always a struct page underneath. In parallel there is an undergoing effort to add support for devmem to the net stack: https://lore.kernel.org/netdev/20231208005250.2910004-1-almasrymina@google.com/ Cc: Jason Gunthorpe Cc: Christian König Cc: Shakeel Butt Cc: Yunsheng Lin Cc: Willem de Bruijn Mina Almasry (2): net: introduce abstraction for network memory net: add netmem to skb_frag_t include/linux/skbuff.h | 100 +++++++++++++++++++++++++++++------------ include/net/netmem.h | 41 +++++++++++++++++ net/core/skbuff.c | 34 +++++++++++--- net/kcm/kcmsock.c | 7 +-- 4 files changed, 143 insertions(+), 39 deletions(-) create mode 100644 include/net/netmem.h