Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3197950pxb; Sun, 31 Jan 2021 07:33:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJxtzuUOGWXwbByyGDooJBGbSu5w4UC4tm/RkyVcIvZvXOITrATE4rMJ/DnoChWrTzRi6O3G X-Received: by 2002:a05:6402:c87:: with SMTP id cm7mr14649956edb.69.1612107213488; Sun, 31 Jan 2021 07:33:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612107213; cv=none; d=google.com; s=arc-20160816; b=f/XxglarW4/63Jqes7SSa1oiVOL4FUvkzDMRP12hr+4RKTG4AQtzqDS940fhxfNbmg KOf+qQ92fpYQW39xH0IR2K49DD3e4SSoHTvvtA6kz97GEEsVgvsWv9tjjT1MKTmk1txn xKWY6ZyMArmJTgNZTsCjQwVo8ivtXgFEzyjENNEfjyvdZtXRCajGJTMyeGMz6b4Abpjl AMTnfGABAPIEV87ayHbpRgrNpOu5hE0sQdQtXEiUnEGRzOQfQLY4PVBxSNZC+HYw1A7O mpwUgqa0CPwe7WaeODi/RkFeVTImRFzCSl2J0wso9M96XuE3VrZLuZwc102jwrQ2C7l5 X3mA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=3ierbyMbeaakxC40P45R1nniLaglqq7PY9us93p+KQw=; b=gBROyJqNi8fDjqX7aHA/vsV9/SigVpyE2XW4OEUJbG0C0zPEKxSSVJ/Rats+gOuXbV 2Gwcgyaif6aLjawZUkf/L8pHQrDf9g+rsjSD5aDHpprlcKTNzoYNCUp6Eor3zrK8kGPb SFAbil/cb/GNksMvC3IuxjKZ8hLaelDZQxnTJPV48IqCTLKfcLHlpIpybu8t1FkG8hkB e5d/4EQUy5KjEkTKG3U7pfvfSZFVaBG/s53u0BKIfVRMYF24yuGUsw0x46udnRGPBB+O Hm4RXOuyrpEhWglKmNMT/VLdbjBZ7Kr5v6c1XlkSWR+pG8a3Jc5aDcZR5f8YjBp74d2D dD7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=qikTLHGH; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d6si8950982edz.273.2021.01.31.07.33.09; Sun, 31 Jan 2021 07:33:33 -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=@infradead.org header.s=casper.20170209 header.b=qikTLHGH; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232723AbhAaNyH (ORCPT + 99 others); Sun, 31 Jan 2021 08:54:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230419AbhAaMY7 (ORCPT ); Sun, 31 Jan 2021 07:24:59 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47054C06178C; Sun, 31 Jan 2021 04:23:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=3ierbyMbeaakxC40P45R1nniLaglqq7PY9us93p+KQw=; b=qikTLHGH1/fMk3qHWKTEUrYKqH etPBhwUXi1FP84nl4bQv22D1vd7cXGv1k3A2f0MR8w4bQVcChcXIBzUeUgK1INLwq0kvSXZIUwDox SPtHCeDYP+1+P2kT3BFBRC0r3bqMxLC0UwoZOEcmVDEAZy7pKWzOCVqS8GiF/guphGy85q0IfoJrD 6+8p98UD5vx+Cw2dtA98qN7b/xLPz3tqpy4S+GWv5XhneeDzuHjPw3Ts0lyDTV7hs8PReKkQdAXnb dnaOvjZEtkMKNa33REsiB1lFXuKg59mF/vT3GVvd1mGxU9H9JTUpjEFS9KQXcS36kLRDGuUrsfM1w MH6iUUog==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1l6Bjx-00CQj7-90; Sun, 31 Jan 2021 12:22:05 +0000 Date: Sun, 31 Jan 2021 12:22:05 +0000 From: Matthew Wilcox To: Alexander Lobakin Cc: "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 Subject: Re: [PATCH v3 net-next 3/5] net: introduce common dev_page_is_reusable() Message-ID: <20210131122205.GL308988@casper.infradead.org> References: <20210131120844.7529-1-alobakin@pm.me> <20210131120844.7529-4-alobakin@pm.me> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210131120844.7529-4-alobakin@pm.me> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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. 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-centric? 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. > +/** > + * dev_page_is_reusable - check whether a page can be reused for network Rx > + * @page: the page to test > + * > + * A page shouldn't be considered for reusing/recycling if it was allocated > + * under memory pressure or at a distant memory node. > + * > + * Returns false if this page should be returned to page allocator, true > + * otherwise. > + */ > +static inline bool dev_page_is_reusable(const struct page *page) > +{ > + return likely(page_to_nid(page) == numa_mem_id() && > + !page_is_pfmemalloc(page)); > +} > +