Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp446071pxb; Tue, 14 Sep 2021 00:46:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxIJXll/j1nhbLPnLpt904ww8omhz9OvCe17VYvCpOP8v88Nr+PBnLSGSNX9dnBiscufV9K X-Received: by 2002:aa7:c9d6:: with SMTP id i22mr18283496edt.307.1631605592436; Tue, 14 Sep 2021 00:46:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631605592; cv=none; d=google.com; s=arc-20160816; b=wlYLCO7zHyFB5aHbyw4fW7hpioVdoWDqisvY1N2FZE6beiW6Qq5/QoFo5KX6nMwEr6 +1TC2uuzbYgVrhMw6l2R6CIFrBm8xuFmjd8p2tbQhfyivRjNZUkSb6pS6GmHMzPkmvmN qc+ACR/MHKvRd9WxVPl8B503oS+acyT/kgXzXMCrb4hNA3T/ZxlkHFIA2PbufETLTAq7 t34o6RwzOaja+Ao3BJiNIjfimXLzOyhAvrYU2A0toNf2lHN6kaNoFQrsf4vD5tTGZbOq SZHjZ7x75GmI6KppOAdu6ukReTMnsEisvIhi0sVn1SsFUk8KYXaLGW0whNNifK6BjbF7 K/zA== 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:date:subject:cc:to:from :dkim-signature; bh=O9BJLsBD6jksCciTZGdmyHq2qkXc8II2TIDnrT2cyiU=; b=oJB0aBJGH7JNu4OUduTsYPWTzWNzgmkeQA3m3dsa3VuIbBxr9UjMEU8lQdY/fuPGqB MkMXft7q2xy4p8eS6aY49LqXx1MtNuUKvBmri9KDcrZBQWak0T5UY/CiXavtujl5nBzq 11sOKUQaq+HMgY3lhSL5jrK8iAR6tR02lbEVkLhzONbhIZyLdFxTlhGI1SH+eqkx0HDr 8Hz1xfAdK25upmx4nvkcXSyjum32OMBEftu9YAoTgUsIlhfGyhMpO9fy69oCeUgRdmhx cQQ/fm5HKc1PEx7tbyfkVIFgPSop5GkFUr627SAN1Gl//YEHGYau/xtQOgQORyUmvpEz X02Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20150623.gappssmtp.com header.s=20150623 header.b=cxJV9i43; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h16si6389059ejl.461.2021.09.14.00.46.09; Tue, 14 Sep 2021 00:46:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-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=@bytedance-com.20150623.gappssmtp.com header.s=20150623 header.b=cxJV9i43; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235925AbhINHql (ORCPT + 99 others); Tue, 14 Sep 2021 03:46:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237384AbhINHp4 (ORCPT ); Tue, 14 Sep 2021 03:45:56 -0400 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DEFEFC0613A3 for ; Tue, 14 Sep 2021 00:41:04 -0700 (PDT) Received: by mail-pj1-x102d.google.com with SMTP id g13-20020a17090a3c8d00b00196286963b9so1458534pjc.3 for ; Tue, 14 Sep 2021 00:41:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=O9BJLsBD6jksCciTZGdmyHq2qkXc8II2TIDnrT2cyiU=; b=cxJV9i43g6uZ64FMZlPy6vGws06VDwvTYOU9J60k2oXFzhujZG9VoAPuhPBT9r/YiN Ab4AAog0W/jtZekEXv66wyjDw/oUvI6mkO/SwrMoxubzvfuSs5P3/mKXw5Ff1Qv1lf5e wGbXHU8HJ++y2FEg8o0rWeAje5ppyGGqA+8+Qj7gMUt8/QY/Twi8JOWRYK231oLK0Dbr 6UC70hV6iVuq0zR8hkLYicw2UTucdi71woBs/u4D5EMK5j2JkEiT2CIcRJNdGWq1OJgm wdfAiWYT1P8R0LwJqfenct+YSLo6jk7+r2UgPIqEnNhykvt01imNPXAoq1BZ5CYBeLac 2otg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=O9BJLsBD6jksCciTZGdmyHq2qkXc8II2TIDnrT2cyiU=; b=Jcamf5FPYT8JgdMs28MV2vv66keVHJ082BDB3jRTgGnFoAm4qtNlUY5TlhIVBANlIg 34ZcGwxSA/i7YjPoVd59EpntZoL4Gchve3gTjqZ4WhJu68ZkT5wsUtjfRKL9rFjHbmGg XQu7xGgJvOMRTf7lJ/d32syoWjIis8duSCJnq8HlsXvnMKIaRZgwo3h/cjVRHabPbl9/ z6AyfttczTmwbcM4h9zVqVYoxvTC87yCmQcGx2wL5XcvPzuxWqXwnDNsLdAwnEAM2bhl CxS+yVYYR9tuLbR+QlKhn42CB7Cmw5Im2IdXWzAd3VMAE4RVhHBdYz9+f/EAuThUaoBz EKug== X-Gm-Message-State: AOAM533sEztovM5Yky1zZzGiOWQMwGQu6fJ0ZaFWaPsEUadVDZLugNRu 2MzJKowfMsm6fCCal8J5Wbz0VQ== X-Received: by 2002:a17:90b:3890:: with SMTP id mu16mr605394pjb.78.1631605264454; Tue, 14 Sep 2021 00:41:04 -0700 (PDT) Received: from localhost.localdomain ([139.177.225.244]) by smtp.gmail.com with ESMTPSA id s3sm9377839pfd.188.2021.09.14.00.40.58 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Sep 2021 00:41:04 -0700 (PDT) From: Muchun Song To: willy@infradead.org, akpm@linux-foundation.org, hannes@cmpxchg.org, mhocko@kernel.org, vdavydov.dev@gmail.com, shakeelb@google.com, guro@fb.com, shy828301@gmail.com, alexs@kernel.org, richard.weiyang@gmail.com, david@fromorbit.com, trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-nfs@vger.kernel.org, zhengqi.arch@bytedance.com, duanxiongchun@bytedance.com, fam.zheng@bytedance.com, smuchun@gmail.com, Muchun Song Subject: [PATCH v3 68/76] xarray: use kmem_cache_alloc_lru to allocate xa_node Date: Tue, 14 Sep 2021 15:29:30 +0800 Message-Id: <20210914072938.6440-69-songmuchun@bytedance.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122) In-Reply-To: <20210914072938.6440-1-songmuchun@bytedance.com> References: <20210914072938.6440-1-songmuchun@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org The workingset will add the xa_node to the shadow_nodes list. So the allocation of xa_node should be done by kmem_cache_alloc_lru(). The workingset can use xas_set_lru() to pass the list_lru. Signed-off-by: Muchun Song --- include/linux/xarray.h | 9 ++++++++- lib/xarray.c | 10 +++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/include/linux/xarray.h b/include/linux/xarray.h index a91e3d90df8a..31f3e5ef3c7b 100644 --- a/include/linux/xarray.h +++ b/include/linux/xarray.h @@ -1317,6 +1317,7 @@ struct xa_state { struct xa_node *xa_node; struct xa_node *xa_alloc; xa_update_node_t xa_update; + struct list_lru *xa_lru; }; /* @@ -1336,7 +1337,8 @@ struct xa_state { .xa_pad = 0, \ .xa_node = XAS_RESTART, \ .xa_alloc = NULL, \ - .xa_update = NULL \ + .xa_update = NULL, \ + .xa_lru = NULL, \ } /** @@ -1613,6 +1615,11 @@ static inline void xas_set_update(struct xa_state *xas, xa_update_node_t update) xas->xa_update = update; } +static inline void xas_set_lru(struct xa_state *xas, struct list_lru *lru) +{ + xas->xa_lru = lru; +} + /** * xas_next_entry() - Advance iterator to next present entry. * @xas: XArray operation state. diff --git a/lib/xarray.c b/lib/xarray.c index f5d8f54907b4..e9b818abc823 100644 --- a/lib/xarray.c +++ b/lib/xarray.c @@ -302,7 +302,7 @@ bool xas_nomem(struct xa_state *xas, gfp_t gfp) } if (xas->xa->xa_flags & XA_FLAGS_ACCOUNT) gfp |= __GFP_ACCOUNT; - xas->xa_alloc = kmem_cache_alloc(radix_tree_node_cachep, gfp); + xas->xa_alloc = kmem_cache_alloc_lru(radix_tree_node_cachep, xas->xa_lru, gfp); if (!xas->xa_alloc) return false; xas->xa_alloc->parent = NULL; @@ -334,10 +334,10 @@ static bool __xas_nomem(struct xa_state *xas, gfp_t gfp) gfp |= __GFP_ACCOUNT; if (gfpflags_allow_blocking(gfp)) { xas_unlock_type(xas, lock_type); - xas->xa_alloc = kmem_cache_alloc(radix_tree_node_cachep, gfp); + xas->xa_alloc = kmem_cache_alloc_lru(radix_tree_node_cachep, xas->xa_lru, gfp); xas_lock_type(xas, lock_type); } else { - xas->xa_alloc = kmem_cache_alloc(radix_tree_node_cachep, gfp); + xas->xa_alloc = kmem_cache_alloc_lru(radix_tree_node_cachep, xas->xa_lru, gfp); } if (!xas->xa_alloc) return false; @@ -371,7 +371,7 @@ static void *xas_alloc(struct xa_state *xas, unsigned int shift) if (xas->xa->xa_flags & XA_FLAGS_ACCOUNT) gfp |= __GFP_ACCOUNT; - node = kmem_cache_alloc(radix_tree_node_cachep, gfp); + node = kmem_cache_alloc_lru(radix_tree_node_cachep, xas->xa_lru, gfp); if (!node) { xas_set_err(xas, -ENOMEM); return NULL; @@ -1014,7 +1014,7 @@ void xas_split_alloc(struct xa_state *xas, void *entry, unsigned int order, void *sibling = NULL; struct xa_node *node; - node = kmem_cache_alloc(radix_tree_node_cachep, gfp); + node = kmem_cache_alloc_lru(radix_tree_node_cachep, xas->xa_lru, gfp); if (!node) goto nomem; node->array = xas->xa; -- 2.11.0