Received: by 2002:a05:6512:2355:0:0:0:0 with SMTP id p21csp212444lfu; Wed, 30 Mar 2022 21:12:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzPhzZhTec/daNSv2OehFkm9/HNRZiQffUVx8JmCNa1GPPfkLfjK/wcC3+GV3sS5foSBIXa X-Received: by 2002:a05:6402:5186:b0:419:49af:428f with SMTP id q6-20020a056402518600b0041949af428fmr14865926edd.177.1648699978923; Wed, 30 Mar 2022 21:12:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648699978; cv=none; d=google.com; s=arc-20160816; b=SyzdQMolwiI/qsvESE11EQzp5VcgrpVejLeqAv1Fl4xHI7U2/N9JgMxFGB+hI1BTPk OQJp8WWVDi3n/5botpq+OElMMZg0FLdRry5eVGnAmc3bMjUWoadls0cOM4fJhqVPcOi4 aHd0bhu6BGzkOtnFxK6wn9aMvYN/3YFctwWdV6CLOFGKKqEy5YIV9Daj/sKPywjw8tee l8Hww8+7BsbwqOrAmDqjEpSY3JPFnyV2n57L28IWO2Lm22HEB2i+SOHbN3y9gLxzr8wq KujrGJc2coL5xmxPIQ+S4Dq4D2SebINc+FGLbFeQMJEdesjVWxAW+N1r9YOIO9RfrCQs 3+jA== 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=ak2t2jCNQu1M2/jAOYEZkhc3R1ocF5/1qJQ+3hjAnME=; b=WA4gPQ2W7zqVTf2r88GMZx6clXNQfwFnIL7uRNrB20ZAAGRrrUNwrId5KpQXJJRFNS n7ZzZGh8htxyVClZ5jbFRhlZv94B98oDfWyiIjnpnGXofQtxhxAjoDXjcoAiiW8rYSYu TrMmRmKZyKDNQKAK3NZdMS96whUvuQ4UPYcWCyt2pg0/KN8jX9PNPeM217gnhQJ1w4HU 4Y7/ltr5wsA7l1WC2M0yHq4ri0QjUeRJGT1ZRpsmMUuZJBUkCdD5OqEdZORtyG6YdbyE gense+7xEeX9JjGBrjzzRi9wYHIEq0AdSxEVn/VHk8az+JfAPW23kZTJ2xx5QzUjSZHy zwsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=tkvUPecq; 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 bo4-20020a170906d04400b006e02fed87e7si21114653ejb.760.2022.03.30.21.12.35; Wed, 30 Mar 2022 21:12:58 -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=tkvUPecq; 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 S229543AbiCaEM6 (ORCPT + 99 others); Thu, 31 Mar 2022 00:12:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229997AbiCaEMV (ORCPT ); Thu, 31 Mar 2022 00:12:21 -0400 Received: from mail-yw1-x1134.google.com (mail-yw1-x1134.google.com [IPv6:2607:f8b0:4864:20::1134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C40B8158576 for ; Wed, 30 Mar 2022 20:53:27 -0700 (PDT) Received: by mail-yw1-x1134.google.com with SMTP id 00721157ae682-2e6650cde1bso240047707b3.12 for ; Wed, 30 Mar 2022 20:53:27 -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=ak2t2jCNQu1M2/jAOYEZkhc3R1ocF5/1qJQ+3hjAnME=; b=tkvUPecqmQulNzBQqTFmi7Dei2Lz6Mn445nrLTgnye7JELzViZqpIsbrhlyTvAs+Dc O2PzcrgIEqVcpVDVfjoBCzrwz8cX6owQtgn4k6W0tHNglJN4AxjMI4S42ir904Ky4cYz h8wULYh2QFZ3as3p2woAyxMFzGQCOFFEEsBnQAM8d1aloqJodsljEyX78x1pTQqYRTrp k2dHlWyyTA+IYWWBvIymhVYCJxorN4SNj1SlOo3wDa71/kBxms27NThdj/CmV/nrhGaF nwZr/ZqIWMYjR/DW2zaK8s6hVwv9+iUUYlf4yoK3QkMztFkKtOTVhQ/LBO/KJC3rdAKn BlhA== 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=ak2t2jCNQu1M2/jAOYEZkhc3R1ocF5/1qJQ+3hjAnME=; b=NvmK1EGbyMBo0kcC5+bZNIFbltwx+vI8hIjh9gAkhPRengV6OPeQDLovB/wmZ8vjQv Ig1c1wJ0lKLKxZ9cbIXxaExnQ45IQUpI/XtwjJskWPtGvxFYE6IJpklkkA2ydZUm/GFa 4XG/Zs15Z/bbJmAKDef4hX3aPsR11dcBtzF4dYVJnKq86V+GISsbHMHiMUMv0Er9qDH9 7h8uN0UZ/erAl3o0NCtirekzSL2hXDGvmziao7dw0POzrjtHwBpzKV2KF88kY7wm3JUt cP5QLJm8ZIO80Tq3NBaPorH1sFNfi6W40TdqtbqoNj+GXUSjsbXqYdjfObJ6sQ7Rz0dB nmOg== X-Gm-Message-State: AOAM533xSEnnFi5mrg4UQsgzNDtb3A8UDMfHjJxJZOVHpoMNst6azTDv TXgTxDZ/22j1tpGI3ouUgQ+y0BTK36wHrLUwXpIB2w== X-Received: by 2002:a0d:f685:0:b0:2e2:22e6:52d7 with SMTP id g127-20020a0df685000000b002e222e652d7mr3190538ywf.418.1648698806850; Wed, 30 Mar 2022 20:53:26 -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> In-Reply-To: <164869718565.25542.15818719940772238394@noble.neil.brown.name> From: Muchun Song Date: Thu, 31 Mar 2022 11:52:50 +0800 Message-ID: Subject: Re: [PATCH v6 12/16] mm: list_lru: replace linear array with xarray To: NeilBrown Cc: Matthew Wilcox , Andrew Morton , 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_PASS, 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 Thu, Mar 31, 2022 at 11:26 AM NeilBrown wrote: > > On Mon, 28 Feb 2022, Muchun Song wrote: > > If we run 10k containers in the system, the size of the > > list_lru_memcg->lrus can be ~96KB per list_lru. When we decrease the > > number containers, the size of the array will not be shrinked. It is > > not scalable. The xarray is a good choice for this case. We can save > > a lot of memory when there are tens of thousands continers in the > > system. If we use xarray, we also can remove the logic code of > > resizing array, which can simplify the code. > > > > Signed-off-by: Muchun Song > > Hi, > I've just tried some simple testing on NFS (xfstests generic/???) and > it reliably crashes in this code. > Specifically in list_lru_add(), list_lru_from_kmem() returns NULL, > which results in a NULL deref. > list_lru_from_kmem() returns NULL because an xa_load() returns NULL. Did you test with the patch [1]. [1] https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=ae085d7f9365de7da27ab5c0d16b12d51ea7fca9 > > The patch doesn't make any sense to me. It replaces an array of > structures with an xarray, which is an array of pointers. > It seems to assume that all the pointers in the array get magically > allocated to the required structures. I certainly cannot find when > the 'struct list_lru_node' structures get allocated. So xa_load() will > *always* return NULL in this code. struct list_lru_node is allocated via kmem_cache_alloc_lru(). > > I can provide more details of the failure stack if needed, but I doubt > that would be necessary. > If the above fix cannot fix your issue, would you mind providing the .config and stack trace? Thanks for your report.