Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp844985pxb; Thu, 31 Mar 2022 20:13:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxyfVApNwetfqmJGWBF/4TJwzVO7iX5ASlSo1yI4GuYUTEd/ECuLgO+WBCm5FrNJzuXZSPW X-Received: by 2002:a17:90b:3e82:b0:1c7:2920:7c54 with SMTP id rj2-20020a17090b3e8200b001c729207c54mr9626210pjb.2.1648782783296; Thu, 31 Mar 2022 20:13:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648782783; cv=none; d=google.com; s=arc-20160816; b=GwbbR5VTzr/4ZzsbmHf/MlnjiD9klUoJ0+UD3Bosb3OmJLfMOeZ7OkSSadjD7WthXx tKgQsAwTA7zGWmn2Yuer/5/4oyVNp3u8pvXal88Eu/m7GLxuAZxLVCanrucKN3aA68Kr ETfwy5tIU+CZt0QCZwzyUCuTKRNu4imqeW6uRxivuxZDljBJbRz5xND6udpKOhv/w/JF nclEgAMyk6+84kmgunD5wq60YCCywpAYX0DhKgFuRZvl6B2a94O6wJ4laMTC76T0osKo HmLPMywBngpzRPpWgcAQOk5xotkHrEVro/0Rm6Pw3v66c9KLqfI/haZbyOmNByKyJR7E cE5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=X8cwDlYjnxCV3IxzT3v3QEWgrMQiVq0GE+zAs4nW3SA=; b=Q6yR9ZSNrjM662IQLCOuJQo9IR5TxavPM5N3ZIze2HwP+M+IKMMBt+gwMR7CfDnvNv Cm3O3kB0zVX9GCy+vqWzqETg62H/kCmzw/L4S02nKC0FXKksN2QNKFceFC2e0M+ivSyQ CU266CQxxrZgf6R4FoTZQ1JeagLpnpjbrYA02vhFeK+emSgWgfE/GNbzU3+DbLpFEaFJ XHuTDwlSUfxAZcQ+am1a27F91l8L3INJ+Wf3WjOQ95V5Ni9rsjQlAccvINQrt3syubtX SKC45odsNVa51NASHdZ4Qta3UY+cEccePHoR3yhzdA1T6ZbeajnerB7AcoWcR6o7RBaR QXIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b="rikRS/Gx"; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m10-20020a638c0a000000b00382b21d7a89si1460605pgd.99.2022.03.31.20.12.36; Thu, 31 Mar 2022 20:13:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b="rikRS/Gx"; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S244083AbiDACbx (ORCPT + 99 others); Thu, 31 Mar 2022 22:31:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244081AbiDACbw (ORCPT ); Thu, 31 Mar 2022 22:31:52 -0400 Received: from mail-yb1-xb29.google.com (mail-yb1-xb29.google.com [IPv6:2607:f8b0:4864:20::b29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCB07255AB3 for ; Thu, 31 Mar 2022 19:30:03 -0700 (PDT) Received: by mail-yb1-xb29.google.com with SMTP id g9so2700431ybf.1 for ; Thu, 31 Mar 2022 19:30:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=X8cwDlYjnxCV3IxzT3v3QEWgrMQiVq0GE+zAs4nW3SA=; b=rikRS/GxwOHHVJquulYr9sEM7JfhAU8lhASRbchygaEUbfO7bShrfIZ6xZCSTFMtEw BLu3HJKZYlqMLoI/b3V+GiWUV+i2s2XEIkaJpiCLww0rNWnEcQixmZKMBjB1hGJeg4YQ ZEuUKigI11Bpnqwl/MarLJpenSrxlQSDM57lG2QmYc62fsbsIY8W9AKyY3JMkyG+TEIF QOPxk6ruqlNyOMqRjFC0HdzkD7ApjZ/iOT0Uv39n8GyNgw4TWpSgUXhSylpXyu5MsZcl aUuzKo0mcQJmE0s+oVKcjND1adWDIu3tPv5qyuJEGquxFT2taDugRt1cD4ofBSngJwI+ aR+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=X8cwDlYjnxCV3IxzT3v3QEWgrMQiVq0GE+zAs4nW3SA=; b=i34VRk61uLK4L2DTM48Ykufub3BlY/VSZUC7t+oin18qpDrsacS4WVsBrPfS8Cg69F uYdpQpv3kYP7FlIZORzohCRaA/z4mAYKR+2GekzXWB7gtoPav+j1DrzuQT3pSisyca46 A0kUjcz1WeiLxs8Wgt4xbJJzrplcWYUggcFVq63CNgpylSnMnskpJz21iTsSf1DvjDdV MuOvzIcib9dg0QobreLkBRHS/vuzVUw0S+iNtFUjdnUIZ+s+b8kEyykSj4NgTBRvA56j 2Zkx4J3djurF73USZWPhwjWRlibGnHfhJDELhZxt71/Ecwm8tVRTB5n0vFREH0hRrTOi zZRg== X-Gm-Message-State: AOAM5319kCieZdOpVrHnJROJ91yC+j2PRBB+M2aRciB+7II1s+ty81UD pYHUifNFl3aYxV2LBb1tJyLFPr1RIubR85DZ4ZPqQA== X-Received: by 2002:a25:24d:0:b0:633:6b37:bea1 with SMTP id 74-20020a25024d000000b006336b37bea1mr6516276ybc.427.1648780203076; Thu, 31 Mar 2022 19:30:03 -0700 (PDT) MIME-Version: 1.0 References: <20220228122126.37293-1-songmuchun@bytedance.com> <20220228122126.37293-13-songmuchun@bytedance.com> <164869718565.25542.15818719940772238394@noble.neil.brown.name> <164870069595.25542.17292003658915487357@noble.neil.brown.name> <164876616694.25542.14010655277238655246@noble.neil.brown.name> In-Reply-To: <164876616694.25542.14010655277238655246@noble.neil.brown.name> From: Muchun Song Date: Fri, 1 Apr 2022 10:29:26 +0800 Message-ID: Subject: Re: [PATCH v6 12/16] mm: list_lru: replace linear array with xarray To: NeilBrown Cc: Andrew Morton , Matthew Wilcox , Johannes Weiner , Michal Hocko , Vladimir Davydov , Shakeel Butt , Roman Gushchin , Yang Shi , Alex Shi , Wei Yang , Dave Chinner , trond.myklebust@hammerspace.com, anna.schumaker@netapp.com, jaegeuk@kernel.org, chao@kernel.org, Kari Argillander , Vlastimil Babka , linux-fsdevel , LKML , Linux Memory Management List , linux-nfs@vger.kernel.org, Qi Zheng , Xiongchun duan , Fam Zheng , Muchun Song Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Fri, Apr 1, 2022 at 6:36 AM NeilBrown wrote: > > On Thu, 31 Mar 2022, Muchun Song wrote: > > > > Thanks for your report. I knew the reason. It is because the following > > patch in this series was missed upstream. Could you help me test if it > > works properly? > > > > [v6,06/16] nfs42: use a specific kmem_cache to allocate nfs4_xattr_entry > > > > Thanks for the quick response! That patch helps, but has a bug. My > testing resulted in refcount underflow errors. > > Problem is that kref_init() is called in nfs4_xattr_entry_init_once(). > This means that it is initialised to '1' the first time an entry is > allocated, but it is left as zero the second time. > I applied: > --- a/fs/nfs/nfs42xattr.c > +++ b/fs/nfs/nfs42xattr.c > @@ -191,6 +191,7 @@ nfs4_xattr_alloc_entry(const char *name, const void *value, > entry = kmem_cache_alloc_lru(nfs4_xattr_entry_cachep, lru, gfp); > if (!entry) > return NULL; > + kref_init(&entry->ref); > namep = kstrdup_const(name, gfp); > if (!namep && name) > goto free_buf; > @@ -974,7 +975,6 @@ static void nfs4_xattr_entry_init_once(void *p) > { > struct nfs4_xattr_entry *entry = p; > > - kref_init(&entry->ref); > entry->bucket = NULL; > INIT_LIST_HEAD(&entry->lru); > INIT_LIST_HEAD(&entry->dispose); > > and now it seems to work. > > The complete patch that I applied is below. I haven't reviewed it, just > tested it. > Tested-by: NeilBrown > Thanks for your test. I have looked at the latest code. I found the following patch has removed GFP_ACCOUNT on allocation. 5c60e89e71f8 ("NFSv4.2: Fix up an invalid combination of memory allocation flags") But this commit forgot to remove SLAB_ACCOUNT when creating nfs4_xattr_cache_cachep (I think it is a bug). So I think the following patch could work. diff --git a/fs/nfs/nfs42xattr.c b/fs/nfs/nfs42xattr.c index ad3405c64b9e..e7b34f7e0614 100644 --- a/fs/nfs/nfs42xattr.c +++ b/fs/nfs/nfs42xattr.c @@ -997,7 +997,7 @@ int __init nfs4_xattr_cache_init(void) nfs4_xattr_cache_cachep = kmem_cache_create("nfs4_xattr_cache_cache", sizeof(struct nfs4_xattr_cache), 0, - (SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_ACCOUNT), + (SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD), nfs4_xattr_cache_init_once); if (nfs4_xattr_cache_cachep == NULL) return -ENOMEM;