Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp259790lql; Mon, 11 Mar 2024 01:32:49 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXcNyJ/q9Yn+adm/R1aROKE8Ji5CxLW9GSYDkXhAQip0a9hYUW9nD+ZlurFBRNkPupGXAJtaQE/VjdhaZ7Li36Nr2zGj3HBOkOTjHaKfQ== X-Google-Smtp-Source: AGHT+IFw10720Tj03om6ZgVXeHnbwC3atyJFFXKbJIZhFLvB1ZnsluBMtnH5opr4QefG6EIjwv97 X-Received: by 2002:a50:a45b:0:b0:568:3067:5191 with SMTP id v27-20020a50a45b000000b0056830675191mr3478207edb.38.1710145969612; Mon, 11 Mar 2024 01:32:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710145969; cv=pass; d=google.com; s=arc-20160816; b=BR9+Ghlt1xGQdV7eOxpT0eCaGF7zB9H1hjwLsGlBwoKKo7W9dXvT6MaK/BgfEZN0Mn vQ+A4HNnakxXFFyYRDTR8fYPdBsKfWOJpXgRuR++cBuc8eThJpVPyWc7JOrIrO1H+MLt /HLgUyJbJTXGlqi8wmB+Nmtng0JcEaJHFI5eRw2+dzXwUo5VV8v0f+UaQwDFBD7yVPHQ 4Hy2RxvQNb626XCeeTGvyjWLtEaUpn7a+FKBsgFIvSAT3kYHhAwbgO9ce/6P36o+JLVo S6vo6fb9AaqjiYwQ6HRMHSko/IfYdspsWfiWq/LRdjkMArvL00B1zSlFDbQiqzZtPqtN LtmA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=S9r+vNYj9kj35H0PtwD9InlJXv44xx/+vmqGYDjLPXw=; fh=UBmajoj4i+p0OyRDdOfl2TSNt3ClgdVBxe6oQtyLkaE=; b=CUJuxdjNwI3IGxL3fr32J12Nfe5GTH+G8pZqQEQ94F0RFEHvnEtx7BAS0qoQL9PDWp jHzLTuLcFZNtYRURdLtTsEA1jK8NkIBeEiauB75p5Lov/iQ7FXSow2b6/Xy4QSeLZi9h 1tz6SZU4iZ8jl6UFMZunnL129gxmuk4GoRgSrbKH8ziWqkRiiIlawkObAvqYU70KOIat ezhVSpNgMHUS7lCqSUssUGqTgYHWPApDxLJ9SXXP9zOf3nwqkV51SI8hUTEMsQI/RqC0 0X2m6pi5aBd7P2bijvA3nuMvFutuTIuSsNdoLcBlJ5gvIwFBGIx3doySw+pEtYsI74sx iZPA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fN5OYbT1; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-98541-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-98541-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id eb9-20020a0564020d0900b0056837b58623si2410808edb.237.2024.03.11.01.32.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 01:32:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-98541-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fN5OYbT1; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-98541-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-98541-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 5A2811F218E9 for ; Mon, 11 Mar 2024 08:32:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 16AC0125BF; Mon, 11 Mar 2024 08:32:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="fN5OYbT1" Received: from mail-lj1-f179.google.com (mail-lj1-f179.google.com [209.85.208.179]) (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 CBB1512E48 for ; Mon, 11 Mar 2024 08:32:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710145955; cv=none; b=u25X6yGDufXvE6zUYIK2v3MeHciprBIuCt5C8+MLP5AblO8DtVpGFaFKdo+vfXxaEB2ig1Mr1/OlzjCVNNJlPWJyZW7NI53OsiQtDDcYSa02PihA0xtknyUuDDYlDsbCDZenoiJzpY7Vx+GNIbNwS03noW/C9gH21Outz8SVlyM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710145955; c=relaxed/simple; bh=x5ec069Py/OgCXIu9yohHAJ93X7AijwmWNVCPg8q9bU=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=QvQzak4+WlZOTg6kb80to4I6j1DnlIdbm5rxDsxC58XNovjSSd++Z1I4UUfktcTJJWFAXl/wgb4JT+N59Oaf4o7g8KZjT8U7BVDmXyGZYRHArIqfuS4Mq+ZMADQ65l8odqQeGv2Hdng0lqjZH/ZC8Bd65x5Kt5/mnpAHds6IKrE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=fN5OYbT1; arc=none smtp.client-ip=209.85.208.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-lj1-f179.google.com with SMTP id 38308e7fff4ca-2d4360ab3daso15928781fa.3 for ; Mon, 11 Mar 2024 01:32:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710145951; x=1710750751; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=S9r+vNYj9kj35H0PtwD9InlJXv44xx/+vmqGYDjLPXw=; b=fN5OYbT19nj8YvWmtMtEkGvub/qGgxBlrnn0RHbULDYYnLHgDX53s6Uo3kS2kSNdI6 bsU0XZwpN3OpXpX8uv3d72TjVZ4fh/5+SO6clj4Ll4A3FKulr55jFhfaxaogm7VdkPa2 NNsTYkl/69XkgSv9MmmX3mnq9LCPNd5UvoZebcpWbZVCkbK4gFoEwXCbPer0fLFliuk0 TVMMlbdq3Ne1mc9lAZEjz+yqevhGU9QfXfL8xhVwDszU4Nv0X2BV6Get0JeLKdmh1R/Y 6I6HbJwlcXJRljYAh6tV7imEp7KWqw0YfzwXkMWyH5/8CEkXIDTr5AKPca7TUzfoT615 HaEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710145951; x=1710750751; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=S9r+vNYj9kj35H0PtwD9InlJXv44xx/+vmqGYDjLPXw=; b=JcY0y7gmmrJClX5HX2Qei94s9KvtYpquJY8TeqMP2QO70oMYbB9i+Omh8QX70uTLYH TzDVTW7/zVy7vf1hUMOlrPaHlipJQ7Y8L90kNdtaNCDRLDb88vnFozgXlMoi1kJhJy/s JlwypT8opCQ5MTdgi9AVSGdEXfnjq/P11WhW6GC6Rpk9rni/sOjVZ9QaOQpJpul+HBUZ 3bp1Fw8Fg8qmTeTWzbwdlh87Tyn96XpDL7M9b/EPmRVxij2RA2+Iz+G5h3dIbZ9w5aC4 9mssDoghv1GT/9GXxg6u2AEAn1cgRtI1JyblJEy8Pb4pdFKtPluXChrQdcgEvOt9xrsQ vHVw== X-Forwarded-Encrypted: i=1; AJvYcCVI7xBx68BW5oetREbj5RvYjx1FOpsXuHThV5fGXKTu51y4ucavdhzkthLcvZniAq5y2jD703x/4oPss0Kcc31mK5DJ30lKW4dlNZmr X-Gm-Message-State: AOJu0YzSv8Nj9ipMQnsBFV4jYefZIozPdCslKQqwul6Ud7u5SDvTkP3y Zd8jxXROrqOZOa22q4vnXnkC705TotVV9BYji7NNtwrYkmlmEuctFRC7dJSZ4Xcw2zJn4uoPEqG +vc4h9mTHLua51ecfIzG4eycmYLZnh0qcVlboeQ== X-Received: by 2002:a05:651c:14f:b0:2d2:abf0:1c0d with SMTP id c15-20020a05651c014f00b002d2abf01c0dmr3451548ljd.47.1710145950789; Mon, 11 Mar 2024 01:32:30 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240308204500.1112858-1-almasrymina@google.com> In-Reply-To: <20240308204500.1112858-1-almasrymina@google.com> From: Ilias Apalodimas Date: Mon, 11 Mar 2024 10:31:54 +0200 Message-ID: Subject: Re: [PATCH net-next v1] net: page_pool: factor out page_pool recycle check To: Mina Almasry Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jesper Dangaard Brouer , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Yunsheng Lin Content-Type: text/plain; charset="UTF-8" On Fri, 8 Mar 2024 at 22:45, Mina Almasry wrote: > > The check is duplicated in 2 places, factor it out into a common helper. > > Signed-off-by: Mina Almasry > Reviewed-by: Yunsheng Lin > --- > net/core/page_pool.c | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) > > diff --git a/net/core/page_pool.c b/net/core/page_pool.c > index d706fe5548df..dd364d738c00 100644 > --- a/net/core/page_pool.c > +++ b/net/core/page_pool.c > @@ -657,6 +657,11 @@ static bool page_pool_recycle_in_cache(struct page *page, > return true; > } > > +static bool __page_pool_page_can_be_recycled(const struct page *page) > +{ > + return page_ref_count(page) == 1 && !page_is_pfmemalloc(page); > +} > + > /* If the page refcnt == 1, this will try to recycle the page. > * if PP_FLAG_DMA_SYNC_DEV is set, we'll try to sync the DMA area for > * the configured size min(dma_sync_size, pool->max_len). > @@ -678,7 +683,7 @@ __page_pool_put_page(struct page_pool *pool, struct page *page, > * page is NOT reusable when allocated when system is under > * some pressure. (page_is_pfmemalloc) > */ > - if (likely(page_ref_count(page) == 1 && !page_is_pfmemalloc(page))) { > + if (likely(__page_pool_page_can_be_recycled(page))) { > /* Read barrier done in page_ref_count / READ_ONCE */ > > if (pool->p.flags & PP_FLAG_DMA_SYNC_DEV) > @@ -793,7 +798,7 @@ static struct page *page_pool_drain_frag(struct page_pool *pool, > if (likely(page_pool_unref_page(page, drain_count))) > return NULL; > > - if (page_ref_count(page) == 1 && !page_is_pfmemalloc(page)) { > + if (__page_pool_page_can_be_recycled(page)) { > if (pool->p.flags & PP_FLAG_DMA_SYNC_DEV) > page_pool_dma_sync_for_device(pool, page, -1); > > -- > 2.44.0.278.ge034bb2e1d-goog > Reviewed-by: Ilias Apalodimas