From patchwork Tue Jan 23 22:17:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mina Almasry X-Patchwork-Id: 13528208 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 080584403 for ; Tue, 23 Jan 2024 22:17:54 +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=1706048276; cv=none; b=lmRoco6QSdkZSdTEdPMv8IgdpJoZ6N2WL/Rz33Efg1YuYwbm4BQPb6HRSAS4QENvOx7Zjg7WIp0HvoLQ7An1pm+uKwgk5/jUsduuCyE2gX+fvy2lMnNM9qEFGzczOuAJYynPL7SJafk6Q372tXocOI8bRCUCh5HfS+PxxOfcl4k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706048276; c=relaxed/simple; bh=fibjmZmjuKKnvDk9ji89uzWTcVwU0i34NoX/+yPgrZo=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=Px6N1kpCmPojoHWx6HlaAp89DVysFCgWMhZ2Nxl/5WxIvjFnOlR7qBWvxvPDT81m2zdAZVrqpu+tuqLNylKUPr0peMW/o45Zn1xIX8K+OFR28JTjRixbpKf98vVv+GFeTNf2TOxXft5NGYbiGq2zFV9tYAY6ldEDZ/KyntxT7nc= 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=pVi0EGWV; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="pVi0EGWV" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-5ffa9b3659cso60635987b3.1 for ; Tue, 23 Jan 2024 14:17:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706048274; x=1706653074; 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=Rw4CHX/yPrA/zwMzsyij6NhlGhkx7uxmvUtdcUBOHDo=; b=pVi0EGWVKAiMg4QifRSF9wDldXJDvetCa8yjgDZY2JmyHqYpNMv2C48uYFn0QazU1e EXExto98Wh9sqFZZvdwLGQHDZjVjLn6JCNtNXiltaJXPjmdp5PPpTg1vwltmWKPZgcjz zlrXo2gA6BZCSQexK76mcwZ9jUrmUgjhwJyXOxj/mrkALfXW432J9wZbc8CuCFph/S3N nKeCPwbvW87OT8tip47OacWC08C8/U9+zhaYF01ctDUdy1yAVW0KOcqMVYKP+ywFEHAP qWpjJWZwaU/Mz8Ed/brk9xd5GQ7JxNuelmwrrBLorYFkn/Fldw3p6G5uFVDDtWgbCdvo Wiqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706048274; x=1706653074; 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=Rw4CHX/yPrA/zwMzsyij6NhlGhkx7uxmvUtdcUBOHDo=; b=O7Z0X/V5OjN3p5WiyIl9pgOZ3i55pLgIR1nTeN2p1Y3uSYcoL6EMPUyR6pbjbJjLQd awpTC9t+1aStT0F+Gzhk9bMMn5z2gZwC6wjqqi/0gKT2YmEh41DgP3v59gYa3NCzBKx2 yDiXNnIjOLfeXRxR13Kdqijb5PEguKK3oyG5EQfNkWzNLdUO1I1y9/GSkv99e521Cua5 P9SePZGkVUTFmaS8X0yBUI/3bCSHBKXvO3QKCK+6XBTFWLu4Z1ip8oonqfwxIy7tCQAI rTGP2ZrUq/1z8BYY6bGhYCz2MKx6KrEK6ilyW8Jk7CBpLfmeVlYtVwaHSo/3XgCkndpx QVwQ== X-Gm-Message-State: AOJu0Yy/s9BvpyX912CIVybj6mlDlmtXFjXylYlzCtYAFD3/RVbVwDOi I+bCx88tUbRrZotcEgFaw7KlpE2d7WYEx9ck2OBL4zz7eZT7LzYwSJEU7Vou8cAzv/Omlc0smaY kWgRv4J61/5KCtMdP9jQe5w== X-Google-Smtp-Source: AGHT+IGzQOEeslPfrOE3siORTL3t/RQ7QXEdr7ChXI3GBke/z5IxA/wuJR/uFV3oftguGvZUfhRfx5oFoHb+uespPw== X-Received: from almasrymina.svl.corp.google.com ([2620:15c:2c4:200:3608:aa16:52d:3594]) (user=almasrymina job=sendgmr) by 2002:a81:9242:0:b0:5fc:316d:a366 with SMTP id j63-20020a819242000000b005fc316da366mr3066711ywg.4.1706048274064; Tue, 23 Jan 2024 14:17:54 -0800 (PST) Date: Tue, 23 Jan 2024 14:17:44 -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.429.g432eaa2c6b-goog Message-ID: <20240123221749.793069-1-almasrymina@google.com> Subject: [PATCH net-next v6 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 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 | 90 +++++++++++++++++++++++++++++------------- include/net/netmem.h | 41 +++++++++++++++++++ net/core/skbuff.c | 40 ++++++++++++++++--- net/kcm/kcmsock.c | 9 ++++- 4 files changed, 145 insertions(+), 35 deletions(-) create mode 100644 include/net/netmem.h