From nobody Sun Nov 24 05:46:00 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