Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp2841896rdb; Tue, 12 Sep 2023 13:58:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFwarl8iSWqwkyL1Nbg9jfhJpcKOffRJ9Mq+yKVMkJQgKI4Iwqj8ZQx23eiufSVO2XJLkJ7 X-Received: by 2002:a05:6830:1551:b0:6b9:68fb:5a28 with SMTP id l17-20020a056830155100b006b968fb5a28mr919223otp.27.1694552306332; Tue, 12 Sep 2023 13:58:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694552306; cv=none; d=google.com; s=arc-20160816; b=iiM/gbsrS49eSTVy3mCpfGHIBjai90tcskjivzePVcyU05i3J+m/AILY6xQ7jwJnLK JcfNA/95AwkrQsC79kHrFokvYC0np9OWd3+/zHCsMq5cFgEzIkJ/nfuzKIEPioycQo9Q jfUXfwrbKUn06huYzbMv5Xtm2B+OFaagJDeA+mO4i4XXYporCn2rqO9p3vp6C745Bw+u 4IUE55TY3UZjXRp+xKQ2MnWB0z/TQviBUbzI1Le/SdJwOpX+2199qcX30OqeWTk5k4Y/ bwtdMmk+YIzoL3TYVUQ9ZnFLSImFAxiAQtp8V+WNvC6gmTQIOayeSdJA/01/L2Jz8AVy XnjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=v/ufbF5AE1kJWZUkhHfxUWS38u59OErgU7vO9+D/zZc=; fh=peghe4ux2SMztWfrqkM9dkaooYqlTOHYpmNbm5Rj/hg=; b=RHyes2fqte36nY/byY4FGQm95t2QM8BYqRhU18niCifQj5olXAogngvSR6gQnSr1TH G/TbLtp8L+bDgt0RKmBDLH+64Cjgq5RMSOtMcfgtFwNJMrUKWMZhvcKZulOI1/xa1z0d tMZVurNxIOyGy6FtrzV/3yyWw3ZhWfIpreBE/h+H1dkIFrup0shwjgARicbsY9iqZJwb bxwL5br87TE252yloVbBsclAJzzMCAglHKy54oD8kZTvTemBB7zAEJxX63Mzrf3Hy4sB k5IK9Odc/TyCO5UYGew/UonvneLVejNpwRVGTkzxaChON4DQc27ZTycLLGgwgYX+5kex Uw/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=BkC0Kvx3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id bs124-20020a632882000000b0056514d0595fsi8371859pgb.296.2023.09.12.13.58.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 13:58:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=BkC0Kvx3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 0620F823D9F8; Tue, 12 Sep 2023 09:02:35 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233775AbjILQCc (ORCPT + 99 others); Tue, 12 Sep 2023 12:02:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236452AbjILQCS (ORCPT ); Tue, 12 Sep 2023 12:02:18 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64ADE10EB for ; Tue, 12 Sep 2023 09:02:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=v/ufbF5AE1kJWZUkhHfxUWS38u59OErgU7vO9+D/zZc=; b=BkC0Kvx3yCVD5ZX3c+tL3s/w4j F0gMhWxTtbpUS8TtfyTsvUMqIpvBUekNvF10dTvQ6HT/Gwap/UWRoDqN0NlX9IQiZVrS13KuvCvQa CLRo1Gf1M5SYYEKkfYGgHtOfee0zp6nGabFsd8MeRk0KqqHZAqiWa93H8+PabHODYDFuhFTSvF3BI GVcr0FxKWQJjLx/yyofeMxP0aixTeqxcuT3m5wPjGmLJwDx7kUFm8nd4rewwTc+TY0lO9l4+T2lWB p2Z/TAiEwyIzUOt/eK3LqVgbgxUZD0vdFEGke8NWqFa2W++o0zHPkq0/zckdogDow2xMU0Kz06+wo V4ZMsk7w==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qg5pv-008S9t-Vc; Tue, 12 Sep 2023 16:02:00 +0000 Date: Tue, 12 Sep 2023 17:01:59 +0100 From: Matthew Wilcox To: Feng Tang Cc: Chuck Lever III , "Sang, Oliver" , "oe-lkp@lists.linux.dev" , lkp , Linux Kernel Mailing List , Christian Brauner , linux-mm , "Huang, Ying" , "Yin, Fengwei" , "Liam R. Howlett" Subject: Re: [linus:master] [shmem] a2e459555c: aim9.disk_src.ops_per_sec -19.0% regression Message-ID: References: <202309081306.3ecb3734-oliver.sang@intel.com> <84984801-F885-4739-B4B3-DE8DE4ABE378@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Tue, 12 Sep 2023 09:02:35 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email On Tue, Sep 12, 2023 at 11:14:42PM +0800, Feng Tang wrote: > > Well that's the problem. Since I can't run the reproducer, there's > > nothing I can do to troubleshoot the problem myself. > > We dug more into the perf and other profiling data from 0Day server > running this case, and it seems that the new simple_offset_add() > called by shmem_mknod() brings extra cost related with slab, > specifically the 'radix_tree_node', which cause the regression. > > Here is some slabinfo diff for commit a2e459555c5f and its parent: > > 23a31d87645c6527 a2e459555c5f9da3e619b7e47a6 > ---------------- --------------------------- > > 26363 +40.2% 36956 slabinfo.radix_tree_node.active_objs > 941.00 +40.4% 1321 slabinfo.radix_tree_node.active_slabs > 26363 +40.3% 37001 slabinfo.radix_tree_node.num_objs > 941.00 +40.4% 1321 slabinfo.radix_tree_node.num_slabs I can't find the benchmark source, but my suspicion is that this creates and deletes a lot of files in a directory. The 'stable directory offsets' series uses xa_alloc_cyclic(), so we'll end up with a very sparse radix tree. ie it'll look something like this: 0 - "." 1 - ".." 6 - "d" 27 - "y" 4000 - "fzz" 65537 - "czzz" 643289767 - "bzzzzzz" (i didn't work out the names precisely here, but this is approximately what you'd get if you create files a-z, aa-zz, aaa-zzz, etc and delete almost all of them) The radix tree does not handle this well. It'll allocate one node for: entries 0-63 (covers the first 4 entries) entries 0-4095 entries 3968-4031 (the first 5) entries 0-262143 entries 65536-69631 entries 65536-65599 (the first 6) entries 0-16777215 entries 0-1073741823 entries 637534208-654311423 entries 643039232-643301375 entries 643289088-643293183 entries 643289728-643289791 (all 7) That ends up being 12 nodes (you get 7 nodes per page) to store 7 pointers. Admittedly to get here, you have to do 643289765 creations and nearly as many deletions, so are we going to see it in a non-benchmark situation? The maple tree is more resilient against this kind of shenanigan, but we're not there in terms of supporting the kind of allocation you want. For this kind of allocation pattern, you'd get all 7 pointers in a single 256-byte node.