Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp6616166rdb; Fri, 15 Dec 2023 03:59:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IG6iN55inkLddAcFWgoaimm1hHP58DVyELMl4S2Z1i34RkHnzO8INpDMPHsIF5IeVysg35p X-Received: by 2002:a05:622a:347:b0:425:4043:5f2b with SMTP id r7-20020a05622a034700b0042540435f2bmr16206037qtw.105.1702641556959; Fri, 15 Dec 2023 03:59:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702641556; cv=none; d=google.com; s=arc-20160816; b=YmcgF3C0aYqOwtd7cdRpL9xBdXXKVWKs2TNTW19ncyiGG/q7wFHnuwgs3klM43Am2+ l40LqBVBex8Bp6SppqJBIq5QVTO7fFaZf2ptPyPnmmT4VkGAmXdp/prXUQlankC/tOIr 1YtFYBDqsf/EWOd+wLktYs+K0m1NX8T3HyeP4DNFbtHURtqCvRNJz5LsrRPoAJnzS+7d EU49uJxnAJ52r5Tmlinr7sc6x+6wZt13mrQOzHno64nXNGCDgtX7IwwiT7mXk9L/O51N Symk7TrqzlBIFyLfd7AnFdQssIP5Oem+RWPm2kRhBEnUIlgkj/aj4E+vtcigwknYr5OB V0WA== ARC-Message-Signature: i=1; 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=C1qp2ImWnMh4HgY4sW8WfO4bMs2GBayiF7ZjfjZdpiw=; fh=xZiulu+bKXguaEns1I7J5eOx79NUGfw5B9pYJMKr3AY=; b=igm/mTR1lZPAIU8lgdfW7yP63Io3IrA6JqwI33RUHcmLgPfRCxLUaMVoyoChDQ1+Jb ZXIHEbR1nOuNrG4v3OQqy/rMJQaqGckMQUrMWz1NMkSq/lXJmVwUufL+vfw1g6oc9J+Y zWTQYXCwKBQJ16A1ldAgC56agQp86TcCkTrScB3nuTn0DZK4UdQjnVCXkbLh5n7fngtC j7EmhbmFky2IqwVBLdSv5ikxFst6niuqAgJY40lldem5de6jEgrnQqzP1+RSOHcOsm9C NTrGimWfhH5sFWVgbrKrGOss5qxCqC/mZJl6rkbg6Av41rYc4deVXlHTXtgVftIz1wSC a/Yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=p+w9946q; spf=pass (google.com: domain of linux-kernel+bounces-886-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-886-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id q11-20020a05622a030b00b00425f0a73de7si6054057qtw.472.2023.12.15.03.59.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 03:59:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-886-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=p+w9946q; spf=pass (google.com: domain of linux-kernel+bounces-886-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-886-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id B57381C233C5 for ; Fri, 15 Dec 2023 11:59:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 092E628E0D; Fri, 15 Dec 2023 11:59:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="p+w9946q" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) (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 152B52C863 for ; Fri, 15 Dec 2023 11:58:56 +0000 (UTC) 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-f175.google.com with SMTP id 38308e7fff4ca-2c9f62fca3bso6756381fa.0 for ; Fri, 15 Dec 2023 03:58:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1702641535; x=1703246335; 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=C1qp2ImWnMh4HgY4sW8WfO4bMs2GBayiF7ZjfjZdpiw=; b=p+w9946q/3ZlhkzbnVGJfjAlX/lsClJYLssspdAvvLBZKbbgdlq2l5ACeviaEr2KSI DBwY+uVUiR+gdoIFc3PYGC6mx2VT1kRy/TYa8vlpl25+I6NMZ09ZGUDLuD++uTb1TrKR Lp6AVitoDdDOO/Yf+LP9CbPvLaJJ/mtjo3R7ETarM06eMSGdcvm5/7JTlYwIkxiSZw+4 ouWUIRqpJfPsxSzEnMgom/WJfchSrjuI7q4F+M6o1wm56jWY5Nt8/p23kfFSrW0XQFmp NQtC2qaVVcltEG47j2eLICIwIOEhQU8GG8r2FEF4S0QQBLM4xTFoaBntTccf22vM9p+X DVdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702641535; x=1703246335; 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=C1qp2ImWnMh4HgY4sW8WfO4bMs2GBayiF7ZjfjZdpiw=; b=Mhzpiv5GjRM9WnynwnwZ4JdQbs/m1O+8SYQ++IksWAdZW9p0mB5iIpDUhnyE/FDzAs m8Yczx1Cl/gRYGqu608eNEwJhXVQTL9u4UAGP6D4d5myrRCklDoM/Kn00C/tTf3noMEu 6d9Y8q4ftbqOU22Cz+GZlYAmFjvM4l6xdoz8WokovD2S21ILxuRlCsgYCpVRWyu1aRWZ axG/gwmPeQ+NAzAMMArKc52Jos2d+UxMz30MxWmdLPJlOEotQVDF7opucEKaLv3RBp/7 1Xs+tA+fE2e12zTqItO1b90Yy+OlNfLj8MwLbxGW0zU0FTBEOsElzYJ34QoXqKpYvEm3 LliA== X-Gm-Message-State: AOJu0YzeABcrIA87yIFCKYJoRLOjL11WGKNprtXTn3jmTMqY5tnN20PU xZVS85DyjTdI5q58wvuMPgeS78lfuklbBe+//fApvw== X-Received: by 2002:a05:651c:160a:b0:2cc:1f04:9dd0 with SMTP id f10-20020a05651c160a00b002cc1f049dd0mr6855697ljq.6.1702641535121; Fri, 15 Dec 2023 03:58:55 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231215073119.543560-1-ilias.apalodimas@linaro.org> <6fddeb22-0906-e04c-3a84-7836bef9ffa2@huawei.com> In-Reply-To: <6fddeb22-0906-e04c-3a84-7836bef9ffa2@huawei.com> From: Ilias Apalodimas Date: Fri, 15 Dec 2023 13:58:19 +0200 Message-ID: Subject: Re: [PATCH net-next] page_pool: Rename frag_users to frag_cnt To: Yunsheng Lin Cc: netdev@vger.kernel.org, Jesper Dangaard Brouer , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Hi Yunsheng, On Fri, 15 Dec 2023 at 13:10, Yunsheng Lin wrote: > > On 2023/12/15 15:31, Ilias Apalodimas wrote: > > Since [0] got merged, it's clear that 'pp_ref_count' is used to track > > the number of users for each page. On struct_page though we have > > a member called 'frag_users'. Despite of what the name suggests this is > > not the number of users. It instead represents the number of fragments of > > the current page. When we have a single page this is set to one. When we > > split the page this is set to the actual number of frags and later used > > in page_pool_drain_frag() to infer the real number of users. > > > > So let's rename it to something that matches the description above > > > > [0] > > Link: https://lore.kernel.org/netdev/20231212044614.42733-2-liangchen.linux@gmail.com/ > > Signed-off-by: Ilias Apalodimas > > --- > > include/net/page_pool.h | 2 +- > > net/core/page_pool.c | 8 ++++---- > > 2 files changed, 5 insertions(+), 5 deletions(-) > > > > diff --git a/include/net/page_pool.h b/include/net/page_pool.h > > index 813c93499f20..957cd84bb3f4 100644 > > --- a/include/net/page_pool.h > > +++ b/include/net/page_pool.h > > @@ -158,7 +158,7 @@ struct page_pool { > > u32 pages_state_hold_cnt; > > unsigned int frag_offset; > > struct page *frag_page; > > - long frag_users; > > + long frag_cnt; > > I would rename it to something like refcnt_bais to mirror the pagecnt_bias > in struct page_frag_cache. Sure > > > > > #ifdef CONFIG_PAGE_POOL_STATS > > /* these stats are incremented while in softirq context */ > > diff --git a/net/core/page_pool.c b/net/core/page_pool.c > > index 9b203d8660e4..19a56a52ac8f 100644 > > --- a/net/core/page_pool.c > > +++ b/net/core/page_pool.c > > @@ -659,7 +659,7 @@ EXPORT_SYMBOL(page_pool_put_page_bulk); > > static struct page *page_pool_drain_frag(struct page_pool *pool, > > struct page *page) > > { > > - long drain_count = BIAS_MAX - pool->frag_users; > > + long drain_count = BIAS_MAX - pool->frag_cnt; > > drain_count = pool->refcnt_bais; I think this is a typo right? This still remains long drain_count = BIAS_MAX - pool->refcnt_bias; > > or > > remove it and use pool->refcnt_bais directly. I don't see any reason for inverting the logic. The bias is the number of refs that should be accounted for during allocation. I'll just stick with the rename > > > > > /* Some user is still using the page frag */ > > if (likely(page_pool_defrag_page(page, drain_count))) > > @@ -678,7 +678,7 @@ static struct page *page_pool_drain_frag(struct page_pool *pool, > > > > static void page_pool_free_frag(struct page_pool *pool) > > { > > - long drain_count = BIAS_MAX - pool->frag_users; > > + long drain_count = BIAS_MAX - pool->frag_cnt; > > Same here. > > > struct page *page = pool->frag_page; > > > > pool->frag_page = NULL; > > @@ -721,14 +721,14 @@ struct page *page_pool_alloc_frag(struct page_pool *pool, > > pool->frag_page = page; > > > > frag_reset: > > - pool->frag_users = 1; > > + pool->frag_cnt = 1; > > pool->refcnt_bais = BIAS_MAX - 1; > > > *offset = 0; > > pool->frag_offset = size; > > page_pool_fragment_page(page, BIAS_MAX); > > return page; > > } > > > > - pool->frag_users++; > > + pool->frag_cnt++; > > pool->refcnt_bais--; > > > pool->frag_offset = *offset + size; > > alloc_stat_inc(pool, fast); > > return page; > > -- > > 2.37.2 > > > > . > > Thanks /Ilias