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: 13509389 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 DF047168A6 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="QTq0Bdpo" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dbdb5c2b1beso12636533276.0 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=wY8ZI/oAJ3M4owsD/Qd2Tx3j9FCP9OlBtHoEYCcWnk6feSlX2lJXa87zmmjlHqcnb6 fcXzQT5WRo8MQexZP+MmQnkQ2yHTmzPRm2hb8AYt9C4ND2HjBK0WdD/Mhy0fuFaK9xar u1mzWNtUgo3yes7IZrCAc5i/3wek04p2o9apZ9Nhq/nmsxv2CLZ1PMDqsYNhlTL+8AcS h7Ej9D3oK8j2P1zr/vhD+XZCYgsyTBecla7BhyfF/+vQIHCcKQsPM19KZtoOZ9ofcQ0O TbGgGs2xttKR94Mgxsp4VtKbC1CTqrrto+dm9p7j67aeIOsgkNR8RqZ2KhxGu5pAkPgF i9Rg== X-Gm-Message-State: AOJu0YyG4CJKX3mVNEFw3GqzakuSz9/e4pHJmB+sUJGvPG+1QuE6nVan tkfyE4d9fue2a31K6z6HOw74S0NmhPlrXZ94W4/C+wwh X-Google-Smtp-Source: AGHT+IHi1x1vNvCy7nh5qrPZXCz13gCpMzojuxdWNRARprBd5bnr1TBEGPjAqihkEYX2n51UbHfc4n0C/Tpy/M+g4g== 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: netdev@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-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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