Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3117000pxb; Sun, 31 Jan 2021 04:58:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJzUimXiAzBSXeXCRW4fYs5JdvbmcP6BPzN+IteY9r/yKEp+B809YBUdKlgbfPzRAu/SBGy9 X-Received: by 2002:a50:d987:: with SMTP id w7mr14473861edj.356.1612097920180; Sun, 31 Jan 2021 04:58:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612097920; cv=none; d=google.com; s=arc-20160816; b=SWPe6M6BoHsaYCo739SIPaJytp5i/6LdhTRSItYfCOpCKgp58YAl+lYeOXNfrhcYaf KimyJonaaNOuZazOKkWGb/pCYv7b0cTAOgJii6ngbZ1BBxHc58PnJfipLwayKV3H7rtT 1kWqnRdVdogXQ37YfU0qtcNiKld+lZ34R5SV1oPAG3eSzbRKuRY6mzJknwMeOv8+xaqz eHkw68HFMwoJTxiU/Tiuw3nw/+hUYnZqRTsKsitTM2iyGHY+G9YiNmbhfErbt4J5oqPv caCJhG0D7bXa0OEMaERcirkiqj9nZhhC/ed4b75rVYxzj1WUGLprjIhOMkCltUmMZVDG DyWw== 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=k4GmHXZWhLsxhmf6TA7kT97uyu8L/XM/o770SPV6Jso=; b=dL/yKvKjweK9Jyujkc2ATntdaBVD4zYvg70N6jPWeTEQ3Nd19W0lXNP3+b7nHRd/Hy yLGZLgDQ5gxN5pUguTVpMuvOF1lhGkRRCmrHm8vh6NXYVMcag2Zy0yXO+Jql0caEqdCX C2IHmKhSfEgQeZKeBaqKyk0f8Jn2rd/euXfX9KVaKoiEeC1qQBouFxD7bEh3p7maI3P+ 4vZRXfwy+yl8kmhx8tz5PzXuTZWd5PUnZXLT5NvNxQQuFTjB2a04c97kSOvIZfQ/c47M Dd8D8OBU4i9Fx8fYWlZCGsqSbYee7hDNnyTdtpekPPQRW+ZjJ0d3NvGy1aNHCOzpwSY9 OozQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pm.me header.s=protonmail header.b=S3+SybR6; 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 da23si8480247edb.104.2021.01.31.04.58.15; Sun, 31 Jan 2021 04:58:40 -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=S3+SybR6; 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 S232107AbhAaM5l (ORCPT + 99 others); Sun, 31 Jan 2021 07:57:41 -0500 Received: from mail-40136.protonmail.ch ([185.70.40.136]:30892 "EHLO mail-40136.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231667AbhAaMMk (ORCPT ); Sun, 31 Jan 2021 07:12:40 -0500 Date: Sun, 31 Jan 2021 12:11:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail; t=1612095114; bh=k4GmHXZWhLsxhmf6TA7kT97uyu8L/XM/o770SPV6Jso=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=S3+SybR6yJJC/jYt2WFCuYCGx0BAiH67Qf9QkW448q1RFTW8j81mTYOxr6H+eqX3I 7YclmedVVG6x+FabYgajZO55X7DXkUO1O5NJtYRr0cs/W6PvORnV0LlsFmlw+T05Co +RQsgjmPA/R39zKqeVxQZPLHCEHfFvy/xb8Seg62cM7wRIlC4EDhtbKB6lsqandzw3 Yp15pWB3pg8d8+QKtK/OG8HpUJpSWwT0As6jgaglJiVU1Q/D03IW4scyF9UVtEzldJ +wo0vNGG42zUMbbcIs2KQn9YD+sBg5nM9bXTeCBhNoK/LSahXX3QVEfW9buQ+Sm0AL EJoeoXC9oc4aQ== To: "David S. Miller" , Jakub Kicinski From: Alexander Lobakin Cc: 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 , Alexander Lobakin , 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: [PATCH v3 net-next 3/5] net: introduce common dev_page_is_reusable() Message-ID: <20210131120844.7529-4-alobakin@pm.me> In-Reply-To: <20210131120844.7529-1-alobakin@pm.me> References: <20210131120844.7529-1-alobakin@pm.me> 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 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. Suggested-by: David Rientjes Suggested-by: Jakub Kicinski Cc: John Hubbard Signed-off-by: Alexander Lobakin Reviewed-by: Jesse Brandeburg Acked-by: David Rientjes --- include/linux/skbuff.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index b027526da4f9..0e42c53b8ca9 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -2938,6 +2938,22 @@ static inline struct page *dev_alloc_page(void) =09return dev_alloc_pages(0); } =20 +/** + * dev_page_is_reusable - check whether a page can be reused for network R= x + * @page: the page to test + * + * A page shouldn't be considered for reusing/recycling if it was allocate= d + * 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) +{ +=09return likely(page_to_nid(page) =3D=3D numa_mem_id() && +=09=09 !page_is_pfmemalloc(page)); +} + /** *=09skb_propagate_pfmemalloc - Propagate pfmemalloc if skb is allocated a= fter RX page *=09@page: The page that was allocated from skb_alloc_page --=20 2.30.0