From patchwork Tue Jan 2 21:27:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mina Almasry X-Patchwork-Id: 18652 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp4691699dyb; Tue, 2 Jan 2024 13:27:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IGc2G81/8T1BTc5Hs1zhccmdf/+VE7eXPWf4ofAbXUa91yLf9aA37YP4ZnlccGTUWt8OpKN X-Received: by 2002:a05:600c:510d:b0:40d:3b17:1e93 with SMTP id o13-20020a05600c510d00b0040d3b171e93mr9108299wms.24.1704230865212; Tue, 02 Jan 2024 13:27:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704230865; cv=none; d=google.com; s=arc-20160816; b=ieEhl8AJcZsoqzvkPnDglCrcxQoE3SDKp8XwyhU0X//V8T5om8/UFu4avsyu3xU9iq 7rRDJ1ljG0EdUng0XevdfB3PJvO/wxKIoZDoesCS7nmx7E6wCxaykGfoSAENsMZk4Xiw hSWZO8Vk7FjEFMzvcAExWc8D8fan2zTva4gfYjIpOpMBX9yR9Ume2Iw2r0iC9UswdySV 368Q7+zAFBTCjgGMoUae4OqSTBwxXf42v12qNdIIH1mxsTPFxxQ0HaF4u+vT1nsgo4xE 2z8fJvYuW9fK3W0Ttcxa9WNNniwl4UPEt2BT2kT7DsvNckOZOyW4RDFmu1r3U20HG/JU OLUQ== ARC-Message-Signature: i=1; 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=b9mb89vCm3BKTU0DU+/TGy4Hk6L4CQ4i3DlNwc7INoo=; fh=3zG4NHuhPxuhQ6Shw7Nt9BiRVbWd7elghbVYpfpS9LI=; b=AHZnh+BvJmDtJm+yDLA3wSFqaKKM4bbnonfgtfVkV4jaPLvecS4vilxM97ssgBiF3U F8FHYhO/inZ5aUbw4pM5Ek7Go3AtX+Zx00XERGcjyxWmQ5upJo0tw5t1Obopl3JvlCxI EIkGS1uIYN2cnyDlA1A9A8E4Uiote0dX6SFtOZC5w4XWCA6sOJnI4fIjmrMBem9FV03i tOvTer4n+BVb5sX4c8sQBI8FKNXdEOb8FL5/4N3OxjyC8NaEqqD+JkfA3qRb7fdtTuuE DxrfX6oIg5iA4JvYu/I6qKg8uPTmBN2xXlma7wjY6LBDXE5ww3P4NX044Km2pmpzJekI 0aHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=QTq0Bdpo; spf=pass (google.com: domain of linux-kernel+bounces-14856-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14856-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id v4-20020a170906564400b00a232d09762csi10292341ejr.11.2024.01.02.13.27.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 13:27:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-14856-ouuuleilei=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=QTq0Bdpo; spf=pass (google.com: domain of linux-kernel+bounces-14856-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14856-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 am.mirrors.kernel.org (Postfix) with ESMTPS id CD8081F235C4 for ; Tue, 2 Jan 2024 21:27:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 13B4D168D8; Tue, 2 Jan 2024 21:27:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="QTq0Bdpo" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.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 141E8168A7 for ; Tue, 2 Jan 2024 21:27:19 +0000 (UTC) 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-f201.google.com with SMTP id 3f1490d57ef6-dbd7389572dso12612444276.1 for ; Tue, 02 Jan 2024 13:27:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1704230839; x=1704835639; 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=b9mb89vCm3BKTU0DU+/TGy4Hk6L4CQ4i3DlNwc7INoo=; b=QTq0Bdpo60Ekqq2oYrLPhrRJXYQNZ4E2Yt6/noM/M+HB+sNtRh7ignNo9Cy3hIlekX mIWrMX9TIu+lqVnTmg2Ar22FQs/81LYhG5wd3I12E1oGKPsAOg9B3RaNoyj6dZBV2xNR cQbm94zUt6LPqNquQWih+umpryX8HK1QvDZ84f/pvZAMSc9ieZAoIJV5g2vEwfQ1fMu1 Rtcuw6Z0fdR2Vyp7B+yxYkSmNetKobhTvewX+uqHyAs8Y4Vaij4LMnQHi5GDrRidkOBX GYkERIWBo6qnB8Lzxqz3qU7Req5wRfw3hhhfTTYDc/n6emJWdCrFXAMm0PR/rDhVX9Lw /kUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704230839; x=1704835639; 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=b9mb89vCm3BKTU0DU+/TGy4Hk6L4CQ4i3DlNwc7INoo=; b=MPqSG2QaNuvY0JqbtiKNQQzUqL0Shj0q6K1c14DpAunS+sj3sGeg0nxudbFTdARGi/ doc04hwOHLuNtoR4iP7tNSk/y7xxRsV3hWj/8n4+BR0HMYmfbM81IgWHWYnqhiCxfixp U7ZpI2k5dCSh4Bp7dpj5gEiolYKk72qHTdsHERz4aonFtPuiXIwLrAWc+stcGH8W15cx H/Q5c7XtxcWwYT8ID3kw7EbjD2SUQZ2VdGfQBVPvKKTZRpTWJFaGcm3XIysBG2k7jhsE VaRGnvtiMdHgYYipzhX/U/IArYbu7D+xzu6vOCxbr3q77gJThoktbXoFh3JxGcCan+aM uhSg== X-Gm-Message-State: AOJu0Yxx0DivGLD4fLampE5Y1+TYThwpOtj6ZW/mv8Uck5aEgqJTCJb5 29bIxzPDVihZALX1IxsRR4+DP/FxJJnCEslvM7TVIy0QxMDZZsIrv7YZpTvAZRXTXV6VH3Zz2XC KpZpsuMsaNmOzL2r6sReQHvmf3fwfNt96bInWPjM05A96kBS7nHDO965i4t1oHEZxgBjN8vih8K PS7AXOwaEZ7Qk17A== X-Received: from almasrymina.svl.corp.google.com ([2620:15c:2c4:200:9a04:c262:c978:d762]) (user=almasrymina job=sendgmr) by 2002:a25:8181:0:b0:dbd:2c5a:6c53 with SMTP id p1-20020a258181000000b00dbd2c5a6c53mr21581ybk.6.1704230838915; Tue, 02 Jan 2024 13:27:18 -0800 (PST) Date: Tue, 2 Jan 2024 13:27:13 -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.472.g3155946c3a-goog Message-ID: <20240102212716.810731-1-almasrymina@google.com> Subject: [RFC PATCH net-next v4 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: 1787015583833096215 X-GMAIL-MSGID: 1787015583833096215 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 | 92 +++++++++++++++++++++++++++++------------- include/net/netmem.h | 41 +++++++++++++++++++ net/core/skbuff.c | 22 +++++++--- net/kcm/kcmsock.c | 9 ++++- 4 files changed, 129 insertions(+), 35 deletions(-) create mode 100644 include/net/netmem.h