Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3201048pxb; Sun, 31 Jan 2021 07:38:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJwziJL1gXOBJRO+NgR0pZgMiVEk1w74v5OZWMIP+HU5Mof2Yhp0dGDo6eParzw3vqcp9Q3e X-Received: by 2002:a17:906:1c0c:: with SMTP id k12mr13897935ejg.354.1612107538427; Sun, 31 Jan 2021 07:38:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612107538; cv=none; d=google.com; s=arc-20160816; b=qlycGcUgoAzD7FT00TaEykPRcEawk5jT5UbCuCc1/22hMoJ60eHcTcre7uetp/560G DWAlXi3HbQbZNlZDsdJuxtakeHCYG/DkFbvVlmMz4lq0JBREeq+SqXE72w6qPgZxd3/t KmA7+kHqew40d1BmYz5siCK9Nx7bykQmZKZ6Jv+eVDBTXs57qC1wijn4KrJ8mlmzdIuC krSc3AFwGWf64H/dq1KQjKEpU1+PCjx+Ud57mBYXwcfxW1kKdFhhtmRdKk65VuWyI0cU o7MTQROZpJKJCfKHTleV6HXXvCAajqEwx37QoCFsN/SiTGP8ZY05+nMo2qeGEUhaVHjP X/Xw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:reply-to:cc:from:to :dkim-signature:date; bh=hy3HTU1Gr4SJ412CK0eDCO6whxGXOGwlEZQ/bHzh0IY=; b=GG2QH/NQXJicTX0A6SqYBT3B+wOmAskSyJMmpTlijaznG2sGsscV4oUz/w9mn9QdOm W+YgdkR9ImtSeAtLIXpMtYD+gbzlfszUEa/ndrXpStbBhU0T9ArLXPFIpyDl1mIIbTT1 r+Enu0FQaoQi56/7JwLVqxp7AdJw9wu2JDQXmVESmTJT+cwfCgtmzwGy6oR7p/ge7doN 2YPhRutRNlBuwhToiAfVdzMtnF738yWoBwngnoJBJWSAiLgOYhCs7u6KuJQdwBRyOCmO 8030O85HT2FceMLlAJwf7ywybtmzCR382pfHMEuIj4bLiqyZfYij0eRyJ2wWoIsIU4y1 w92Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pm.me header.s=protonmail header.b=gOF3DQLD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=pm.me Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id zd10si8727898ejb.77.2021.01.31.07.38.33; Sun, 31 Jan 2021 07:38:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@pm.me header.s=protonmail header.b=gOF3DQLD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=pm.me Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232464AbhAaPhG (ORCPT + 99 others); Sun, 31 Jan 2021 10:37:06 -0500 Received: from mail2.protonmail.ch ([185.70.40.22]:44681 "EHLO mail2.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232253AbhAaM6N (ORCPT ); Sun, 31 Jan 2021 07:58:13 -0500 Date: Sun, 31 Jan 2021 12:57:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail; t=1612097850; bh=hy3HTU1Gr4SJ412CK0eDCO6whxGXOGwlEZQ/bHzh0IY=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=gOF3DQLDOPbnITXBUL2KPwaqec06jg7hgwxBrpixduvxzEnKNGsfv8ItuXKrxv9Ng JiqbWegAiSb0RANpw00MRZt5dHVkVaU/4aT5yLL76tDfJs1aAdwYldD7IWkRc5kxbh 1BAJMWanlZQ2JqPkXy6HSIYWPNKbrH0EQAF1HDdchGDHYnALdR6ajs+2btoq67GU9f f5YZ1517Lx6mBTrwwu58TBCcS9IuiaspQ6k7jtFh66w62CLwSumleX42KAPMkjKfzH bHZna372czPrByZznTmm5VyRMiP9VCQ0UQEj/5CLGRQO8Ef03IeNcCrs59678BmNjl NGoTfgARWpgvw== To: Matthew Wilcox From: Alexander Lobakin Cc: Alexander Lobakin , "David S. Miller" , Jakub Kicinski , John Hubbard , David Rientjes , Yisen Zhuang , Salil Mehta , Jesse Brandeburg , Tony Nguyen , Saeed Mahameed , Leon Romanovsky , Andrew Morton , Jesper Dangaard Brouer , Ilias Apalodimas , Jonathan Lemon , Willem de Bruijn , Randy Dunlap , Pablo Neira Ayuso , Dexuan Cui , Jakub Sitnicki , Marco Elver , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, intel-wired-lan@lists.osuosl.org, linux-rdma@vger.kernel.org, linux-mm@kvack.org Reply-To: Alexander Lobakin Subject: Re: [PATCH v3 net-next 3/5] net: introduce common dev_page_is_reusable() Message-ID: <20210131125713.8710-1-alobakin@pm.me> In-Reply-To: <20210131122205.GL308988@casper.infradead.org> References: <20210131120844.7529-1-alobakin@pm.me> <20210131120844.7529-4-alobakin@pm.me> <20210131122205.GL308988@casper.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.2 required=10.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on mailout.protonmail.ch Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Matthew Wilcox Date: Sun, 31 Jan 2021 12:22:05 +0000 > On Sun, Jan 31, 2021 at 12:11:52PM +0000, Alexander Lobakin wrote: > > A bunch of drivers test the page before reusing/recycling for two > > common conditions: > > - if a page was allocated under memory pressure (pfmemalloc page); > > - if a page was allocated at a distant memory node (to exclude > > slowdowns). > > > > Introduce a new common inline for doing this, with likely() already > > folded inside to make driver code a bit simpler. >=20 > I don't see the need for the 'dev_' prefix. That actually confuses me > because it makes me think this is tied to ZONE_DEVICE or some such. Several functions right above this one also use 'dev_' prefix. It's a rather old mark that it's about network devices. > So how about calling it just 'page_is_reusable' and putting it in mm.h > with page_is_pfmemalloc() and making the comment a little less network-ce= ntric? This pair of conditions (!pfmemalloc + local memory node) is really specific to network drivers. I didn't see any other instances of such tests, so I don't see a reason to place it in a more common mm.h. > Or call it something like skb_page_is_recyclable() since it's only used > by networking today. But I bet it could/should be used more widely. There's nothing about skb. Tested page is just a memory chunk for DMA transaction. It can be used as skb head/frag, for XDP buffer/frame or for XSK umem. > > +/** > > + * dev_page_is_reusable - check whether a page can be reused for netwo= rk Rx > > + * @page: the page to test > > + * > > + * A page shouldn't be considered for reusing/recycling if it was allo= cated > > + * under memory pressure or at a distant memory node. > > + * > > + * Returns false if this page should be returned to page allocator, tr= ue > > + * otherwise. > > + */ > > +static inline bool dev_page_is_reusable(const struct page *page) > > +{ > > +=09return likely(page_to_nid(page) =3D=3D numa_mem_id() && > > +=09=09 !page_is_pfmemalloc(page)); > > +} > > + Al