From nobody Sun Nov 24 02:37:35 2024 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 AF362217F47 for ; Thu, 7 Nov 2024 21:23:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731014598; cv=none; b=GzHh358bPbBiOcPvcYmShnbxcPgu9kSaWKDKVmfP6Oufnb4S8Mn22riBwMtmukSgaNgfv3p+7CeE2EDJrfe6DZ0aMye5RqtXpRjxHzt6p+P4bTSzz1bbOY9GRiAHuCuJkdzJ5zpkzf3JbG0xSJmdobQAom288/FVyZdbGo2w0Bo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731014598; c=relaxed/simple; bh=zU771VywMfhHaMQg5hypX6J21hCCKxI+7oDPusRKQbo=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=NMQWYN0RPjxLuNvFOYYdRuJQV8peh9UfX6RmhL+W7X/dBGVskun+XTWYApY/jiOUeeBXQ7lGvw+YBMf0raW/koqrNRTkK4p34oySAPVV2eOviPtOolTo1jm2hFtQYOrakn5EXyNEE51927Pv2aD+qcPZn+3oVfo2nsQfLAUesac= 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=kEXhEdqJ; arc=none smtp.client-ip=209.85.219.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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="kEXhEdqJ" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e2954ada861so2552738276.3 for ; Thu, 07 Nov 2024 13:23:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1731014596; x=1731619396; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=HAZq9oy6Bl8obMNqEnRNBAotywvY9gCvI9My8ktbfNI=; b=kEXhEdqJaNPGNjReXtFogjSarfC5FImDYl44aTYtzxhYAS3b+GVDfrIceX+XpmHISZ AHFm4DCvPvvizFe2JSttuygckm9bAFZ/Zdb7nxKBm9ElExcFMtI7DIVi68p7nmbl14JG GjvdgS59x5S9A0ny6DOfsqt6c0WwehYQMQdHcAyG458DkeEF/VOgZIBHAXCCcO1wSGYV RnCo5ZGhwRI1cKQb/Tv6AKUKvzghVsUD0+YZ4Bp7ufBLUFdX1GaOFQnnoCen9J0+kjvu h1lSsLCe5jcXTU9xA8x6JWMFJrwRh3FrtMHA3BGLK1a7AgzpHYrDOxWgiFjEwzXGDRI3 NAGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731014596; x=1731619396; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=HAZq9oy6Bl8obMNqEnRNBAotywvY9gCvI9My8ktbfNI=; b=o3JjGpeolwHvhO49b7jG2Nl6i//vAKy1DccNOs0yDJ8oY01tJLokOMRuXQp2GCH+HI febCxI9m3pUefLxsoDLGiXnOnn3a5/8m1Ya126iRkkh985r+Cm5/X/fIRFw6Q3xMcEWm Wwt8tMaRkjIYnIOmtbK0zYV3wvvOwPpSaw3uJAEtkiIX4okY6hukp2QaRJAKRCaTI8C+ BXt+FQc/+tyDnAXuLr/uprGKky2eI/KleASPTqTecZA05GnO7r2O10CmUstjJJqTEfsz ge9a8TL+sHvjroO7FKcCD+KTNNvXCwWfoUyZj4qfjFCkOuIPhlDPuExh2hmxZvkByUa5 18Bg== X-Forwarded-Encrypted: i=1; AJvYcCXMGhqo6vXkeyfqlzvIHkbDQIuvGT4b10DN4W6Gl0pL/XZSskYXBy9AWJhSJ3NqjbXvmliVT9XW0Yo9oPQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yxmvow6S0HBrnStXXdhtspLeKjtv5Hv2IWobZRoJ+EUaYmfFsoY w7PdhROeOUbxEgQu4Ucf4sLr/Ka8baaefDBPOOyHpjk3pzZMmmhXOMlyqvROtbSnhF2IcOJnP0r /+zz662ty6UCb6IZ9SXm38Q== X-Google-Smtp-Source: AGHT+IFpZz3joBko2XoXlKijEWXBVEsSKlDAhkhOb9gDzyhStaeTOBcZzdF/pwUDd8RiQ/Qt/WPqhvbOJCOQ6hJZQQ== X-Received: from almasrymina.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:4bc5]) (user=almasrymina job=sendgmr) by 2002:a25:3302:0:b0:e28:e4a7:3206 with SMTP id 3f1490d57ef6-e337f8e44f5mr795276.8.1731014595774; Thu, 07 Nov 2024 13:23:15 -0800 (PST) Date: Thu, 7 Nov 2024 21:23:05 +0000 In-Reply-To: <20241107212309.3097362-1-almasrymina@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241107212309.3097362-1-almasrymina@google.com> X-Mailer: git-send-email 2.47.0.277.g8800431eea-goog Message-ID: <20241107212309.3097362-2-almasrymina@google.com> Subject: [PATCH net-next v2 1/5] net: page_pool: rename page_pool_alloc_netmem to *_netmems From: Mina Almasry To: netdev@vger.kernel.org, Jakub Kicinski , Mina Almasry , Pavel Begunkov , Willem de Bruijn , Kaiyuan Zhang , Samiullah Khawaja , linux-kernel@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Paolo Abeni , Simon Horman , Jesper Dangaard Brouer , Ilias Apalodimas Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" page_pool_alloc_netmem (without an s) was the mirror of page_pool_alloc_pages (with an s), which was confusing. Rename to page_pool_alloc_netmems so it's the mirror of page_pool_alloc_pages. Signed-off-by: Mina Almasry Acked-by: Stanislav Fomichev --- include/net/page_pool/types.h | 2 +- net/core/page_pool.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/net/page_pool/types.h b/include/net/page_pool/types.h index c022c410abe3..8f564fe9eb9a 100644 --- a/include/net/page_pool/types.h +++ b/include/net/page_pool/types.h @@ -242,7 +242,7 @@ struct page_pool { }; =20 struct page *page_pool_alloc_pages(struct page_pool *pool, gfp_t gfp); -netmem_ref page_pool_alloc_netmem(struct page_pool *pool, gfp_t gfp); +netmem_ref page_pool_alloc_netmems(struct page_pool *pool, gfp_t gfp); struct page *page_pool_alloc_frag(struct page_pool *pool, unsigned int *of= fset, unsigned int size, gfp_t gfp); netmem_ref page_pool_alloc_frag_netmem(struct page_pool *pool, diff --git a/net/core/page_pool.c b/net/core/page_pool.c index a813d30d2135..77de79c1933b 100644 --- a/net/core/page_pool.c +++ b/net/core/page_pool.c @@ -574,7 +574,7 @@ static noinline netmem_ref __page_pool_alloc_pages_slow= (struct page_pool *pool, /* For using page_pool replace: alloc_pages() API calls, but provide * synchronization guarantee for allocation side. */ -netmem_ref page_pool_alloc_netmem(struct page_pool *pool, gfp_t gfp) +netmem_ref page_pool_alloc_netmems(struct page_pool *pool, gfp_t gfp) { netmem_ref netmem; =20 @@ -590,11 +590,11 @@ netmem_ref page_pool_alloc_netmem(struct page_pool *p= ool, gfp_t gfp) netmem =3D __page_pool_alloc_pages_slow(pool, gfp); return netmem; } -EXPORT_SYMBOL(page_pool_alloc_netmem); +EXPORT_SYMBOL(page_pool_alloc_netmems); =20 struct page *page_pool_alloc_pages(struct page_pool *pool, gfp_t gfp) { - return netmem_to_page(page_pool_alloc_netmem(pool, gfp)); + return netmem_to_page(page_pool_alloc_netmems(pool, gfp)); } EXPORT_SYMBOL(page_pool_alloc_pages); ALLOW_ERROR_INJECTION(page_pool_alloc_pages, NULL); @@ -956,7 +956,7 @@ netmem_ref page_pool_alloc_frag_netmem(struct page_pool= *pool, } =20 if (!netmem) { - netmem =3D page_pool_alloc_netmem(pool, gfp); + netmem =3D page_pool_alloc_netmems(pool, gfp); if (unlikely(!netmem)) { pool->frag_page =3D 0; return 0; --=20 2.47.0.277.g8800431eea-goog From nobody Sun Nov 24 02:37:35 2024 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 6E5FC2185B3 for ; Thu, 7 Nov 2024 21:23:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731014599; cv=none; b=gcGOkpEBGjhaCk8+1GPYWRH6c7RoL3nxZTDeONKxh15MVvqMfZoPP7kkcwh46fotAd6bQXj95937zpRVefw1BbTY2DUCmUNcYfhCmeSCymxUOZ3Kz/8ff9cXiKyqHpuV4XwYw2MaBQQ94FHY1he9DuhJDiwdLj46BWLjEhJj6Xk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731014599; c=relaxed/simple; bh=MvJ6yPQOrI6wahZADxfSEp4jdMsiVlhVUJM/vAV2fS4=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=rYF+0kKn8wZxs1OF0s8MY8Jepp5qlwHzZLTupUWlNnuWhPDX3f+Hy8Jp968+saacdFqI2uXZZNHVCowJbjjcveAhR8lACcLJtaN3sYf5hpGdxinfq5n+J8gcJdYFFKyMhpIz/F4M8E1z+pcUlWcrqk8Sme6XxO6JWevxWlqGD38= 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=VvvZHTSc; arc=none smtp.client-ip=209.85.219.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="VvvZHTSc" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e33152c8225so3078235276.0 for ; Thu, 07 Nov 2024 13:23:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1731014597; x=1731619397; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=J83wfJiF0JQ+3oVDQ8yXRG5SdUbkoDbY+HbVcbuh1Lg=; b=VvvZHTScGjBhZdgsuFEa93EhYKmmQxRdWkoHnY328/p+Ll5mw+hP1n1OxjoILI82XN o3oaxBgILqZ4HJXJ8xh6E8e+a7Ypg/QqIO5YrhNwUQqZEKRQwF0qY7ZriSSwajZAkgIf KsUyt+Yaw1gRffdhVO+xkhS1PpUz8M/h0uect80zoz+LiiLcUe0UIyibCu0gfegDPw8c ISiTFd2I7rgWQyXVN7v0GIlcInJ4f2ueJL/LFNklTlppHhosoinG5cg0rbjU9sVhdlXA hvGZlbObGURLjMpWSyst+pA1QQBR4lS1+z3lrT7N1f66r/Ey/phKRbCW/uh7nyJnJj6F TEYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731014597; x=1731619397; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=J83wfJiF0JQ+3oVDQ8yXRG5SdUbkoDbY+HbVcbuh1Lg=; b=dSl1qgIdbg7FfATcerX7KrYi/bqBkag4iFrcMCr9u7qqI0+T7H4+U4cV1RA7n6LiDD loJRscXYk0CZPGImPf7nAc5wipuTTZcAxWNQ6F1qzW9hfg1XfxT+BbZpjulBJW/l/soh 8kMgQWMudyKkI5Z7gNZ42J584fhLMBztgcQoyzSkAmf7S1n3ypKVMbpveJmEXL6ZeCxz Rvxs9Rlz2g8MkBHFVBajF1R795DiV7Ab14R6bbXnO+P8f5LumXZ+rIluMsGiNQW1de72 4o6lUiTR6fGz34SQT6x59mL3NVoRUKkS9e3GwoTdY/P77iWGniPudqLO2UqStUSgkyoQ 326g== X-Forwarded-Encrypted: i=1; AJvYcCUoQrOiXW0hEGeEkgMDAIWzJqaYCor8L3FizusabZD3O0jsTrwLM9Pm0wIonKY7RQwWTqgVf/lNQPQwZYE=@vger.kernel.org X-Gm-Message-State: AOJu0Yw2dXFGfweD+I5prPtsSJPA89ko9hJ232xR/OypSbpYXdwI4LaW ne63IYkPkNoZ2mfZ/BCnsFUv6gaTofggIL1Zw8377z27dqztri8nS+xBRzv4FH8PTnzYisQNEPt UeFT5VMna6mJeS2AbprUwmA== X-Google-Smtp-Source: AGHT+IF6z/QPQ1XLZAvWGreuIWIzXwrgafM/eQRgTmOxVD278ef+a/phPaMZMGyLfa6rqPGjMSbh4Q8VmdUVJC+pTw== X-Received: from almasrymina.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:4bc5]) (user=almasrymina job=sendgmr) by 2002:a25:a249:0:b0:e28:e510:6ab1 with SMTP id 3f1490d57ef6-e337f8faff5mr344276.8.1731014597352; Thu, 07 Nov 2024 13:23:17 -0800 (PST) Date: Thu, 7 Nov 2024 21:23:06 +0000 In-Reply-To: <20241107212309.3097362-1-almasrymina@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241107212309.3097362-1-almasrymina@google.com> X-Mailer: git-send-email 2.47.0.277.g8800431eea-goog Message-ID: <20241107212309.3097362-3-almasrymina@google.com> Subject: [PATCH net-next v2 2/5] net: page_pool: create page_pool_alloc_netmem From: Mina Almasry To: netdev@vger.kernel.org, Jakub Kicinski , Mina Almasry , Pavel Begunkov , Willem de Bruijn , Kaiyuan Zhang , Samiullah Khawaja , linux-kernel@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Paolo Abeni , Simon Horman , Jesper Dangaard Brouer , Ilias Apalodimas Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Create page_pool_alloc_netmem to be the mirror of page_pool_alloc. This enables drivers that want currently use page_pool_alloc to transition to netmem by converting the call sites to page_pool_alloc_netmem. Signed-off-by: Mina Almasry Acked-by: Stanislav Fomichev --- include/net/page_pool/helpers.h | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/include/net/page_pool/helpers.h b/include/net/page_pool/helper= s.h index 793e6fd78bc5..8e548ff3044c 100644 --- a/include/net/page_pool/helpers.h +++ b/include/net/page_pool/helpers.h @@ -116,22 +116,22 @@ static inline struct page *page_pool_dev_alloc_frag(s= truct page_pool *pool, return page_pool_alloc_frag(pool, offset, size, gfp); } =20 -static inline struct page *page_pool_alloc(struct page_pool *pool, - unsigned int *offset, - unsigned int *size, gfp_t gfp) +static inline netmem_ref page_pool_alloc_netmem(struct page_pool *pool, + unsigned int *offset, + unsigned int *size, gfp_t gfp) { unsigned int max_size =3D PAGE_SIZE << pool->p.order; - struct page *page; + netmem_ref netmem; =20 if ((*size << 1) > max_size) { *size =3D max_size; *offset =3D 0; - return page_pool_alloc_pages(pool, gfp); + return page_pool_alloc_netmems(pool, gfp); } =20 - page =3D page_pool_alloc_frag(pool, offset, *size, gfp); - if (unlikely(!page)) - return NULL; + netmem =3D page_pool_alloc_frag_netmem(pool, offset, *size, gfp); + if (unlikely(!netmem)) + return 0; =20 /* There is very likely not enough space for another fragment, so append * the remaining size to the current fragment to avoid truesize @@ -142,7 +142,14 @@ static inline struct page *page_pool_alloc(struct page= _pool *pool, pool->frag_offset =3D max_size; } =20 - return page; + return netmem; +} + +static inline struct page *page_pool_alloc(struct page_pool *pool, + unsigned int *offset, + unsigned int *size, gfp_t gfp) +{ + return netmem_to_page(page_pool_alloc_netmem(pool, offset, size, gfp)); } =20 /** --=20 2.47.0.277.g8800431eea-goog From nobody Sun Nov 24 02:37:35 2024 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 1FB17218D74 for ; Thu, 7 Nov 2024 21:23:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731014601; cv=none; b=C7o2vQB01p9ffbj0M78NZBoBmAVpGr6qBG+4faDLre6HmsnrPMmijBJd4eD+va1p8xjqtABvQbNB0wQyr+ItYdTvPlPvWWlU5dd6VXw3rtMcgAnwaGtvswtyz665MJBKRp81VHgEozGwj0Wko2+mdGrF2RByXj+cDKlzlvzazQY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731014601; c=relaxed/simple; bh=ps8g7aS9YWdHiljpOSe0iIE7Rn7tIj0JNhfoyBSlYao=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=j0o9Gwz+OOP1pQY67ROKURbgJaZidW69+L49qzmUI8kuxS5ULALYiYbWghCGVOqzC/EO8Di3lvkXIJkylfOrMk8PTN+eqIYWPrpMIkKOzGFJshGhV/zvR8+1A26a9LosLVgQ27huqw9RmoSlv91N29x3cL8IGkh8kWpJDzsvMuI= 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=w3Iu36X/; arc=none smtp.client-ip=209.85.219.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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="w3Iu36X/" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e3314237b86so2533342276.1 for ; Thu, 07 Nov 2024 13:23:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1731014599; x=1731619399; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=x+st140tRnSi1hqWlJmll4Lhmo3xu0I4VHUB3oVubp4=; b=w3Iu36X/yN/uxVBPCA0bVFgUHHngQwmlQbGeDD5IQUWdRRQwbPr9u7EERMWBkTjcrU czdE26k7JQmthwf5YdeYXKccOoYarRNkLO+dvgyzye8aJFEUZu8+xH7/o7ujiY7ZYE6o +sb4WeqZ8xo0Xjcp24l5F6oh4TdYWJi9xNBtbJG3UCw41HQQAggUbsggMULH08IzqB1p /5ISuwFpbzX7lOe2DasET+M8J1FRQIubFA4/rY2I5Cq20LeDJ7OEJreTEng8IOFH9OT9 dZlhEzOXZ2Wb2Y82FPh7tRoeIlTcWHQRPxI5iTkldRF7HCZj86QEccWnMR27mzlQ55Oz Nakg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731014599; x=1731619399; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=x+st140tRnSi1hqWlJmll4Lhmo3xu0I4VHUB3oVubp4=; b=Xi8rZyhWC1sUqtnjtVuf2HuajFCxg3U44c898EEp9HXJclqcMKcHXd7HsT+qKwwV1Q X5QciRBxizx+hkPh9wCaSShGTFT8SRq8voZLFc/bZS9hIEHDmBoSRHj3czCKckXyHWo5 GX2QzQbvzZ5Gbigee6RQHUr8x2mHZRyaiRL68jS2SpA1YDRXadgC7/WQ2M7QbXK5p29o UxSN7X74Up9+8ZJPbfyWOD1MRlexKd/Eq05r43hz4fdS4ATEqSJs0NaGf87otes8WIpO G3PKySN6KZtl2605z1Ky+CR+PHFwUzav8hUgzSsQAEeb7tf0kS/TTZeVuz2AL78fievf aapg== X-Forwarded-Encrypted: i=1; AJvYcCUEdc0VPTv1SwB1b7REX+HSqufYpZOWYyHIhGuflaIESpOlmxubl+uo3ZZlVuXInba7HAwCu7g0MDJMMfg=@vger.kernel.org X-Gm-Message-State: AOJu0YwgojiIWcqcYNwLstxHHg3ezd8bz/MdfnUxLfhbX4HlJjkaTlXy l9uA2mSF6sJxKdQBxstU8lViKNq+S+jNTHDOnoznOyQjZzB39xsIu0KZG0L43HINqt8SfoWTHif sGXvbPksi4kTSkg5XCkR54g== X-Google-Smtp-Source: AGHT+IFgLUXTW1oofpX7j+3fjQdPt6Z3JBpPD3P1QknlqjCzkBELvb4f5iD7diwTeje1LMy4ccv21eNPv4d6rFfFOw== X-Received: from almasrymina.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:4bc5]) (user=almasrymina job=sendgmr) by 2002:a25:dc4a:0:b0:e25:5cb1:77d8 with SMTP id 3f1490d57ef6-e337f8ed8bbmr319276.6.1731014599186; Thu, 07 Nov 2024 13:23:19 -0800 (PST) Date: Thu, 7 Nov 2024 21:23:07 +0000 In-Reply-To: <20241107212309.3097362-1-almasrymina@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241107212309.3097362-1-almasrymina@google.com> X-Mailer: git-send-email 2.47.0.277.g8800431eea-goog Message-ID: <20241107212309.3097362-4-almasrymina@google.com> Subject: [PATCH net-next v2 3/5] page_pool: Set `dma_sync` to false for devmem memory provider From: Mina Almasry To: netdev@vger.kernel.org, Jakub Kicinski , Mina Almasry , Pavel Begunkov , Willem de Bruijn , Kaiyuan Zhang , Samiullah Khawaja , linux-kernel@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Paolo Abeni , Simon Horman , Jesper Dangaard Brouer , Ilias Apalodimas , Jason Gunthorpe Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Samiullah Khawaja Move the `dma_map` and `dma_sync` checks to `page_pool_init` to make them generic. Set dma_sync to false for devmem memory provider because the dma_sync APIs should not be used for dma_buf backed devmem memory provider. Cc: Jason Gunthorpe Signed-off-by: Samiullah Khawaja Signed-off-by: Mina Almasry Acked-by: Stanislav Fomichev --- net/core/devmem.c | 9 ++++----- net/core/page_pool.c | 3 +++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/net/core/devmem.c b/net/core/devmem.c index 11b91c12ee11..826d0b00159f 100644 --- a/net/core/devmem.c +++ b/net/core/devmem.c @@ -331,11 +331,10 @@ int mp_dmabuf_devmem_init(struct page_pool *pool) if (!binding) return -EINVAL; =20 - if (!pool->dma_map) - return -EOPNOTSUPP; - - if (pool->dma_sync) - return -EOPNOTSUPP; + /* dma-buf dma addresses should not be used with + * dma_sync_for_cpu/device. Force disable dma_sync. + */ + pool->dma_sync =3D false; =20 if (pool->p.order !=3D 0) return -E2BIG; diff --git a/net/core/page_pool.c b/net/core/page_pool.c index 77de79c1933b..528dd4d18eab 100644 --- a/net/core/page_pool.c +++ b/net/core/page_pool.c @@ -287,6 +287,9 @@ static int page_pool_init(struct page_pool *pool, } =20 if (pool->mp_priv) { + if (!pool->dma_map || !pool->dma_sync) + return -EOPNOTSUPP; + err =3D mp_dmabuf_devmem_init(pool); if (err) { pr_warn("%s() mem-provider init failed %d\n", __func__, --=20 2.47.0.277.g8800431eea-goog From nobody Sun Nov 24 02:37:35 2024 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 CEF142194A2 for ; Thu, 7 Nov 2024 21:23:21 +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=1731014603; cv=none; b=SimdDYSClgu2rg47KgWClEudUphXEf6E61KaXWEAU0xQnEmrc56z486qNSVzqAd/DaxBJHHkyz7tcSbIp05oaTgmy4lifm4tWKxOFTT8wssezC+XJveBUYJGITPHmrUjxozevwfm9cO4FUUzNIfHfvYb5pJiQhO/YqLToTn/LUI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731014603; c=relaxed/simple; bh=m8IdxZqUwMqRC2HMh2bTKic9Iv2zEBl6lcyJNuEk5WE=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=uLGmPDC209MswOuQQ19LqgCNTfMmREH7fhl6rxDa9Az3jt9ThhnY0xaAs55UCZ88US2v/52gxdXSoq12Mm920az7b9E0/hs2YX07qvBRSDP6+0XB6ITSH56Vi1klNWwgQfRW/juMNTM9cA2o0OrpO5UuYDaqGcGHlTAd2BKFiII= 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=DRtMRll6; 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="DRtMRll6" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6ea8a5e862eso18644807b3.0 for ; Thu, 07 Nov 2024 13:23:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1731014601; x=1731619401; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Aiw631cVYF88tA3jMsDP51zKCtA5BveE1WXlRhKkO9c=; b=DRtMRll6XcMEv0/zWo3jzBOx4/oJy3DMVJmP3QOnigu9qvYLzwkZihnV8bhc07ow84 2bupM3LBeBYtnus26kQQsCXM1KIvr7gXpuox6P/QkIrsxO6kDyW4SyuHYzctK5OEqe0r W0gH9yV8zPrifwEy1xD9W66CVtoxgTBqy0VtwqzfCFU4YUIWxw9lFR7jv/gAcgqwas9U j2YjCgLJyj1p2ZXIOII8QiaMKhW/xux/G8zn7UGmLF22Fm2iX4FmzFy3z+588iPJGPCc nS+YouO37ru0efKXTL+iAM8BFHnlVUqUMZa7avMV19b5Nmen7FJaqsugGsLvJA8/ioTZ l0+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731014601; x=1731619401; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Aiw631cVYF88tA3jMsDP51zKCtA5BveE1WXlRhKkO9c=; b=XK3sDoiGk8gGOU/5cL7YX0l8HbsZf1gRvs1830tctHpGl86rIyETU0D+KXLHjjkPax M+e4yPPb/qIu+EaeA+KxfG8GruAC4dAWoYlPJP9CuOC0ClPzpIPzQSoH1DN1rxiDbhpe iXLGMkiFvKI36fIMg9MU45JOyKJ+L3qTYcyOv2F2j/G0E8UCXIaXayLqVbo+sf5cmpQ6 EnbMIOmVJO0H2dyTObsnaZG4saDOchJVCJuSHaPBesY3vzYlRQ5tECSfH4ZM/lX6gMs7 /msetDazV+3YAGN7Mc4K6VZnFSIolLQsj9mHozzbJhvsmegNGqQXid5IPvASrDkkbzBp yRjg== X-Forwarded-Encrypted: i=1; AJvYcCXdpQF4gH10I6JkD/3OGil8RXbGZ2uunu6A16b4wdrjiIzbgdBDhABSIATmCxPPcao/Eep1Hw8boVag+N0=@vger.kernel.org X-Gm-Message-State: AOJu0YwP6HqXLdj7p6vE1+L3s5o6LiEyCiD983/3TKHbJ9xmc3zOvjO9 6jXuDMXKsQJ1aXlHj56v5PvxLE17LOxXL9cVwFNiDlaBewXzmAHDv0hNtKgYBo2bp8l7iSHH0+y biqvwd7YZzZcg1WndMkl2ug== X-Google-Smtp-Source: AGHT+IFcD/DvotfYM+pVSvbUUM61OCX/CMwJjo9lQAnn7vXUnCYSFqjVZ5LnQgBS3mPiwUW32kp2i4JkBRuWazqvLw== X-Received: from almasrymina.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:4bc5]) (user=almasrymina job=sendgmr) by 2002:a0d:e545:0:b0:6dd:bb6e:ec89 with SMTP id 00721157ae682-6eade40bbf7mr39597b3.2.1731014600825; Thu, 07 Nov 2024 13:23:20 -0800 (PST) Date: Thu, 7 Nov 2024 21:23:08 +0000 In-Reply-To: <20241107212309.3097362-1-almasrymina@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241107212309.3097362-1-almasrymina@google.com> X-Mailer: git-send-email 2.47.0.277.g8800431eea-goog Message-ID: <20241107212309.3097362-5-almasrymina@google.com> Subject: [PATCH net-next v2 4/5] page_pool: disable sync for cpu for dmabuf memory provider From: Mina Almasry To: netdev@vger.kernel.org, Jakub Kicinski , Mina Almasry , Pavel Begunkov , Willem de Bruijn , Kaiyuan Zhang , Samiullah Khawaja , linux-kernel@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Paolo Abeni , Simon Horman , Jesper Dangaard Brouer , Ilias Apalodimas , Jason Gunthorpe Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" dmabuf dma-addresses should not be dma_sync'd for CPU/device. Typically its the driver responsibility to dma_sync for CPU, but the driver should not dma_sync for CPU if the netmem is actually coming from a dmabuf memory provider. The page_pool already exposes a helper for dma_sync_for_cpu: page_pool_dma_sync_for_cpu. Upgrade this existing helper to handle netmem, and have it skip dma_sync if the memory is from a dmabuf memory provider. Drivers should migrate to using this helper when adding support for netmem. Cc: Jason Gunthorpe Signed-off-by: Mina Almasry --- include/net/page_pool/helpers.h | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/include/net/page_pool/helpers.h b/include/net/page_pool/helper= s.h index 8e548ff3044c..ad4fed4a791c 100644 --- a/include/net/page_pool/helpers.h +++ b/include/net/page_pool/helpers.h @@ -429,9 +429,10 @@ static inline dma_addr_t page_pool_get_dma_addr(const = struct page *page) } =20 /** - * page_pool_dma_sync_for_cpu - sync Rx page for CPU after it's written by= HW + * page_pool_dma_sync_netmem_for_cpu - sync Rx page for CPU after it's wri= tten + * by HW * @pool: &page_pool the @page belongs to - * @page: page to sync + * @netmem: netmem to sync * @offset: offset from page start to "hard" start if using PP frags * @dma_sync_size: size of the data written to the page * @@ -440,16 +441,28 @@ static inline dma_addr_t page_pool_get_dma_addr(const= struct page *page) * Note that this version performs DMA sync unconditionally, even if the * associated PP doesn't perform sync-for-device. */ -static inline void page_pool_dma_sync_for_cpu(const struct page_pool *pool, - const struct page *page, - u32 offset, u32 dma_sync_size) +static inline void +page_pool_dma_sync_netmem_for_cpu(const struct page_pool *pool, + const netmem_ref netmem, u32 offset, + u32 dma_sync_size) { + if (pool->mp_priv) + return; + dma_sync_single_range_for_cpu(pool->p.dev, - page_pool_get_dma_addr(page), + page_pool_get_dma_addr_netmem(netmem), offset + pool->p.offset, dma_sync_size, page_pool_get_dma_dir(pool)); } =20 +static inline void page_pool_dma_sync_for_cpu(const struct page_pool *pool, + struct page *page, u32 offset, + u32 dma_sync_size) +{ + page_pool_dma_sync_netmem_for_cpu(pool, page_to_netmem(page), offset, + dma_sync_size); +} + static inline bool page_pool_put(struct page_pool *pool) { return refcount_dec_and_test(&pool->user_cnt); --=20 2.47.0.277.g8800431eea-goog From nobody Sun Nov 24 02:37:35 2024 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 78A88219CA7 for ; Thu, 7 Nov 2024 21:23:23 +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=1731014604; cv=none; b=OIadBprgvRyu1SqoFp2olnUxqjAILG1Sn96Z/pWnIj/HSn61/PKmYUkJShRvoG6Dj6b2smIulPmCz1yH15nK39j8edLYhGeVLgyBfey7tMMg2AYAQ1xRYhJ9PSDl+c1rvUvcQVF+c07QgO3gSZfDffCE14VTwYQFmZfbfR7IzOQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731014604; c=relaxed/simple; bh=hiLF67ZB3WMU8hX4LaHsXxF0Pkp+AKd2y1OkKzs23ts=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=IKVKHHSViq30T/LToPVZfOv+95BoYiVkoW6zDBLHaVBFXv2vjWIaLrYQs6bEov/stKsIHpchNhc3HNEChgMbagOnXeK/N6FKoYjYe0xD22/EWsfEAV/Pcj5kvVSqRgFB3CTfFBzzxVHQQMX+dIHhWxXDydhUeM9oCgcMkZx7b+4= 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=iAUL81ln; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="iAUL81ln" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6ea8794f354so27175857b3.2 for ; Thu, 07 Nov 2024 13:23:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1731014602; x=1731619402; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=6k+P4diOLJqi5qBWB1cI5BvWrqmmxwXAHcITy5id4XU=; b=iAUL81ln8pM5B/FpetkpXP7yfwpV3Haj3NMDZKBKfsNes4br2SmhJcnBuV33kxVdq6 PAb9/at7Bj1ODme+aUzxyztWdOmT0JE2GgLhYIiZFmiHqp2Btq6wFcMuKD2/n2D7krXO 5RCrKEfyOjiB6Y0xw6NT5t2GIsSJF913G/iAvhOl9jMSahkmz3UXynFnit0GfEigNz5/ Alvmov51R5qLT2fu7TKBwZzPkxaL6zYJdjYqpgV4mn4TOWrZ4DCTx7TlRRjBNMnDCZ4g OUhk2tVlmdfkBdO9MwZNE8VLUHNzVuFeYjqUKxw8p79YADGOkCyuk0y34tqhf3HCpp0P Tclw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731014602; x=1731619402; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=6k+P4diOLJqi5qBWB1cI5BvWrqmmxwXAHcITy5id4XU=; b=kwEh/RV+DGTTwpLB8PagVV7yzWOXmMPV7Rg54qWqXXVHV6/8Hu9lHu+yvQKk1FWXus TJWcyYGQxojux0Y7zc1+HTytvkn6j2vuYamSmElxTz7tgQCcVqFlVeP5MHfxffJmdfZ9 Z695145vV7AERXAj0qN6TWof/2nzCdeEu4OkNq62HN32poCawCmhoVlgMmx2CXmff15Y u2TpzMdrxjySl7bzAuMxACl52yUuiz1bcnX18q0bZLWjG16OAQzqGivves2k3dQ0at3R oS0uI1EEXO5Re7YHT8rTo3Ho9qfRCZmnt2Lgtra4T2C4ipbmjjvKsOKHJQEbOLjjz37n CIrw== X-Forwarded-Encrypted: i=1; AJvYcCWq7s4UEX8YQFoOj12hzTaAK5WjzpxS71wp1p1y13Hi/VO3YbALmCwpq+3e/bl3JR0ZIrXvV7GLoOC44hY=@vger.kernel.org X-Gm-Message-State: AOJu0YwqVukhrG2B8Mh+vfn/kaEYsIMt88OTTFl21YMcjyNyanwGZCRv DEQ2ELYFNbo++qqR5+ZhLai/4ZNhENgUPe1ysogvMd4isKI4qVOE78RJcT7r/epzsA49Kio7BJk dLmk4Socy1Qk20bNoj7RX2g== X-Google-Smtp-Source: AGHT+IF7xrqtzpYezRtSKaHI3uuKF4iJovh+7+L3DoGZk9NlkYM7SwDne1PSukpRNI4o5wYpQPfuw2lzr3HDcb/9AQ== X-Received: from almasrymina.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:4bc5]) (user=almasrymina job=sendgmr) by 2002:a0d:f4c5:0:b0:6e3:2693:ca6b with SMTP id 00721157ae682-6eaddd64226mr13067b3.2.1731014602472; Thu, 07 Nov 2024 13:23:22 -0800 (PST) Date: Thu, 7 Nov 2024 21:23:09 +0000 In-Reply-To: <20241107212309.3097362-1-almasrymina@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241107212309.3097362-1-almasrymina@google.com> X-Mailer: git-send-email 2.47.0.277.g8800431eea-goog Message-ID: <20241107212309.3097362-6-almasrymina@google.com> Subject: [PATCH net-next v2 5/5] netmem: add netmem_prefetch From: Mina Almasry To: netdev@vger.kernel.org, Jakub Kicinski , Mina Almasry , Pavel Begunkov , Willem de Bruijn , Kaiyuan Zhang , Samiullah Khawaja , linux-kernel@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Paolo Abeni , Simon Horman , Jesper Dangaard Brouer , Ilias Apalodimas Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" prefect(page) is a common thing to be called from drivers. Add netmem_prefetch that can be called on generic netmem. Skips the prefetch for net_iovs. Signed-off-by: Mina Almasry Acked-by: Stanislav Fomichev --- include/net/netmem.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/net/netmem.h b/include/net/netmem.h index 8a6e20be4b9d..923c47147aa8 100644 --- a/include/net/netmem.h +++ b/include/net/netmem.h @@ -171,4 +171,11 @@ static inline unsigned long netmem_get_dma_addr(netmem= _ref netmem) return __netmem_clear_lsb(netmem)->dma_addr; } =20 +static inline void netmem_prefetch(netmem_ref netmem) +{ + if (netmem_is_net_iov(netmem)) + return; + + prefetch(netmem_to_page(netmem)); +} #endif /* _NET_NETMEM_H */ --=20 2.47.0.277.g8800431eea-goog