From patchwork Wed Dec 20 21:44:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mina Almasry X-Patchwork-Id: 18387 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp45385dyi; Wed, 20 Dec 2023 14:24:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IFSodpcrDrq/5Ue9OLBTemUuaROc1QlvJZNntUbSJOGtMolG0HOrNMKFIOBVFcTwv3Gub/e X-Received: by 2002:a05:6a00:1245:b0:6d9:6081:600f with SMTP id u5-20020a056a00124500b006d96081600fmr1256032pfi.35.1703111054384; Wed, 20 Dec 2023 14:24:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703111054; cv=none; d=google.com; s=arc-20160816; b=qNUvuA4Zh0kVbixRZOnBxzoXMAjFxTmFXY+K7fJKTPkMBDK5U0p0owPnIQcgaP1/OU jS3333yW18GsFTyNIzfx6jB5udphOcK1v8YUksI+E4aYO/d2eVuAmxwLo73f7cYUGWLl FmEwOIxykJrlNNcazKKXllg9x+XdGOV4ljeAdc7BDwQAVywIiC9ESyHs6JzM3RQRl4hj 0A4O+dKF7aFyHtp1HmXmIzv0Tar5xaAlI9GpCniAMs/xALVLUHFhnv4MX3EFqBfKNB63 YZHN5qfkM8J4kYmXDnU1CBKHk5+aXLFIZLcVRVtBuGKWZJa3O3Y+yGBratygAlof5tkW Qk4A== 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=o2KyAbQGeXRxX9Kez0BA+ghL8Ur6r9y2yNTe+BsOa4w=; fh=JlPK37Up5EiBiZMpR+3rbUHDZrxBspzZ+EmMm14SzR0=; b=nPHNkoxcDyJ9TkAUxzKfyE2MtfmsICQmGC3GVmT6m2vKHoUZIlLjkoBQbDttABq9IG QWNul8JthXW1TG9mTCYTgrgwUcqsAXdckSb6yQW3B5iWCiI25HBxBXSGsCpJLR5sZEbO lqvrR0zIbHoXV5kIXzlQn+u059DMP2iRPtsXqiaAmTeihC1Lhz5hon7j6RLo9wIb/n7R DN700ubJMUw2494dmLwfsykL3wdkr57NvC5cvO4A/KN9FcbuYFpGtvmq2GJzZCkk0WVh cOkF5qmmZDtktxQ5EK8H+8A3h4FljD3+jkzQ9fafesRMEZTrYEp3jJ1Nhp9aHogpVDv4 kCkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ylE54Etx; spf=pass (google.com: domain of linux-kernel+bounces-7476-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7476-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 z42-20020a056a001daa00b006d9646f7204si407739pfw.69.2023.12.20.14.24.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 14:24:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-7476-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=ylE54Etx; spf=pass (google.com: domain of linux-kernel+bounces-7476-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7476-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 7E1F328A593 for ; Wed, 20 Dec 2023 21:45:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D82634AF86; Wed, 20 Dec 2023 21:45:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ylE54Etx" X-Original-To: linux-kernel@vger.kernel.org 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 C326D48CEB for ; Wed, 20 Dec 2023 21:45:09 +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-f202.google.com with SMTP id 3f1490d57ef6-dbdb14f811cso205465276.1 for ; Wed, 20 Dec 2023 13:45:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1703108709; x=1703713509; 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=o2KyAbQGeXRxX9Kez0BA+ghL8Ur6r9y2yNTe+BsOa4w=; b=ylE54Etx8BXE5psiF7ctW3HBPCDMW0D+N4DEmZIBtD22CfaIgfh/K0DdxlJ/frTm+R JKoeTuSC54FgencyVysRW1MVNLlGAqpuF3XpuNgMeykX6Fi5tQsigpikWx02zCKv8Abf Ql8G5HDWnICRZPU1/pFrt1Pw6D+QpyUzYCMvDWXIOGvy1En6LHyK7FCffZQIeUFyCnY+ 07c5B6AgEgot/4nQ5NmDFs4NfwdMYPB79AZMecP6Y2y0F4aZvXGUfw0qsMY6FsDgUhz8 krxmiTHqqwWjrm8bFaSwRru0Kisnmbd/Ofy0SM1ISA1+ye3oFXcFb7/GmS0MEuzyFYnL QTJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703108709; x=1703713509; 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=o2KyAbQGeXRxX9Kez0BA+ghL8Ur6r9y2yNTe+BsOa4w=; b=RlXe0zuhxPYMQMhdQTUxs49GkV2/8scCj/ucASK3resbpA9RRt9DlfCJOICidmL06V R4u8SNQzkZhyxbYzVzg8cQAmMM0dp4w4DlKgIS+mNka80LV2t2ns3AJCsF3brQTvLz4f IFsOLtnkUT1nZBSiNetAizicBkJ43OB5a2yof4yMiDDX1WpteZO71+Ay1wTyShq4lwad bzAjzv7qQxpR9j0TvmnepDH61R1K96Vtublpgq/iumErpuTqkhBlN2lV+RdxWjIbaDGO SnyddTdd2UXuK+wQY2uRhzhvMPoZheVCe75DPNJhHN+Axde9PxLYbe0VOGU/tqB3lvKI wUJA== X-Gm-Message-State: AOJu0YwztTojIfQOEiU4+6xxOU+uaQMb/HKID9JSF1Szu6A0OPPJ21TI UQO2vQshpG/oZr/siGjJyyMZ/KydKSBUayMx8ld1zzoRf4jmEQx0G/SJ1mHKL9iaZFPGOu0Ukqy Ro3TEAsc9GaNaQrbskkIiB+2XkGWLR4panKdflne+MMhEZuqePn3XkpXKlk1PZg9TRgmHLg/60C irzQN80wc= X-Received: from almasrymina.svl.corp.google.com ([2620:15c:2c4:200:13cc:a33:a435:3fe9]) (user=almasrymina job=sendgmr) by 2002:a25:8701:0:b0:dbd:bce2:82f9 with SMTP id a1-20020a258701000000b00dbdbce282f9mr157856ybl.10.1703108708803; Wed, 20 Dec 2023 13:45:08 -0800 (PST) Date: Wed, 20 Dec 2023 13:44:59 -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: <20231220214505.2303297-1-almasrymina@google.com> Subject: [PATCH net-next v3 0/3] Abstract page from net stack From: Mina Almasry To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, kvm@vger.kernel.org, virtualization@lists.linux.dev Cc: Mina Almasry , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Stefan Hajnoczi , Stefano Garzarella , David Howells , 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: 1785841376997974491 X-GMAIL-MSGID: 1785841376997974491 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 (3): vsock/virtio: use skb_frag_*() helpers net: introduce abstraction for network memory net: add netmem_ref to skb_frag_t include/linux/skbuff.h | 92 ++++++++++++++++++++++---------- include/net/netmem.h | 41 ++++++++++++++ net/core/skbuff.c | 22 +++++--- net/kcm/kcmsock.c | 10 +++- net/vmw_vsock/virtio_transport.c | 6 +-- 5 files changed, 133 insertions(+), 38 deletions(-) create mode 100644 include/net/netmem.h