Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp628085pxb; Tue, 2 Feb 2021 13:40:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJz2hZDp3Bo40E8wYdq95FnSK17SOZmJofxICQS4kp52RDUJXR3mCP6cjL9lbAF4Lo4iFnkY X-Received: by 2002:a17:906:780c:: with SMTP id u12mr7754ejm.125.1612302036664; Tue, 02 Feb 2021 13:40:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612302036; cv=none; d=google.com; s=arc-20160816; b=pbcu0rbLT59MiyG1RnHZU3aWoOAzBVgFekyL9osxFKp9g1246umaZACK9vPZ8ouis2 /QmCHrmR/LDZ68euL45Br58RQ6mbuBb8o4j4p5cwoojEpsy7b+ULQjhuzHB+Q7hp1vwh RToXsSqN8Z1YEurrq9C0d8mWZF2RlhSNlwu4l58hfqbFRnAKGoUE6/d6WV5/N4AeLEFj ySC/HWK/KrOXZKyz5hm88FPYGRQ0J1Iv8vZgFHojp3qkLo5xIjOI65olcM0CQkz8D8xl FBNgrpgBBWwVxiZ4KPwGP4bndSJq8Xsi9A6NhtpBlcOz4ULxTlT18a5qFfbyUkHMJuu0 VwYg== 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=uMJByY3n2GqnEyy0JWdL3CJi2y5xqcOTPvLq0Lp0r64UUNlmc1neu5G6CMO+0vs+r7 6hFwuXxCjinfS3sVow9sv7pcdJbtFqIpieIrUaYtOVKxZGKpypi9Qfj2+Nx00zMw7TqD ux7mU+yKbTlAwklOxKz5xMCqGV+rha3qbhn8L9Sq7B5NRaw0f2smnqBwSjI3LTVrst7i VyufnYhDvjQIcQoj1/zIBJjzFEGXf07OZOwHzta32mA/rdCzX2azjB6BWnmQJgyIwq4N knMeimQ1cPXv1jR9SC4v7pxBtNMDy31wMi5tPEgONXgQKjJ3X8mCmtWNzUATgbRcWn53 FhBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pm.me header.s=protonmail header.b=Q1dpUXr9; 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 r2si13308938edv.308.2021.02.02.13.40.11; Tue, 02 Feb 2021 13:40:36 -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=Q1dpUXr9; 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 S232579AbhBBNe7 (ORCPT + 99 others); Tue, 2 Feb 2021 08:34:59 -0500 Received: from mail-40136.protonmail.ch ([185.70.40.136]:17494 "EHLO mail-40136.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232445AbhBBNcJ (ORCPT ); Tue, 2 Feb 2021 08:32:09 -0500 Date: Tue, 02 Feb 2021 13:31:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail; t=1612272687; bh=k4GmHXZWhLsxhmf6TA7kT97uyu8L/XM/o770SPV6Jso=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=Q1dpUXr9oBypKbuAjeH7WV3Gae5fmMAmUR7KAban/Vqhjxcn+5cyBNUn5HdwYZAlT 6xTrUz972h23w7+1pwYxCanhFCiNiCgcbjY+olsESYbqVTPRclm0E2iwZ7hfQhd11k 5kRbSrx8BEr/lf7ftBdRPmv8QHCFM/Luv8l8ND/MNQoDiKD71gyDiuZGvxdfZqsD/9 3o/TXmsbnepA7Y1Yp1PBLWqGoIYCAYyoXZ0cCnZi2o+RCU54apDplLl0nKT4fXv658 icxCgo90aUJ0s/MLjZi7eRbLlJ0QA+xecdx9saAOXSL1lv//lk8tUoyAWdthDbfCax wW13ECXVgRZyA== 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 RESEND v3 net-next 3/5] net: introduce common dev_page_is_reusable() Message-ID: <20210202133030.5760-4-alobakin@pm.me> In-Reply-To: <20210202133030.5760-1-alobakin@pm.me> References: <20210202133030.5760-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