Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp548888rdg; Thu, 12 Oct 2023 13:19:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFtIsZEv7nLh/Xe2odaM5+mX+b2jkYva/zU7u5wV02c0ZuFLrmiggiDC/7nzjH9nl6ju9UK X-Received: by 2002:a05:6359:5148:b0:163:ce28:91ec with SMTP id oc8-20020a056359514800b00163ce2891ecmr14598011rwb.22.1697141944497; Thu, 12 Oct 2023 13:19:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697141944; cv=none; d=google.com; s=arc-20160816; b=eF849FYWPDsy6qkcMEBq20uAq4PLS2fsgh2WRDkqcmuknDPBS93KGWgqUXgqVrqLpM bZja3m/I7DtKk5OC55eQK73yRChvSpwguhbi6GzNy+LjMq7VdxoiYaEByx0MEZxlcpz7 Lkg3+aSObni2gDvhoQfuSiHd3u2a95djyhRazv9yChljWJnlYd9t9A0OwqBsQ0NOTXMK tgjlLR2PyIfodsvhE4fG31GRuMndX2fcSBdqk9VRb1dMV7hsCG12mlnv9FlhKYAMdml1 85uxq3nceh8y4iuJ9bH1y70t3/Fj5ZyOxWJmF6rLY4vzmteFHTcs8Lzs43ewnsTJ1xK6 rw3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:mail-followup-to:message-id:subject:cc:to :from:date:dkim-signature; bh=hc6HCNMBp8IlLh8DN5mOo6xzjEiwvUjh2K14S7K06EQ=; fh=0V1RiIu2YSGmCSZWQ8t3oaMTWawgle1r1AlaCt0RQqo=; b=IzaJ3yC8b1c+kQXDoZV57aKR7n7whqzF3YCZlqCkK4fdTCwhdW1Zg9l9BPdEOe/oJT dHa51ku6rDxn7uizcEwwvhTNHWHzwRfS0t7vFShm9I818ipwyFQnwKcSaaXZIWE6eI9h siKL1WKGYTrvFdW9noOn8ZBeb+n5FdheuD5cahiUrE+C/G4A9Gk33WCV84vgDlKDduhQ 6s+Cq/QThkHSiNyiTatjzwvPU5dP9qEgYw8L2oXhEe9ClX+TYpXdAYpnLyFJkRkGhe0q EPr90HjDQjLMHH+8tyw0uk1n24r2x2vaV8XSjrAToz3X0TtVpY0ZjSmPxfps5V/CahjC IJIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=temperror (no key for signature) header.i=@infradead.org header.s=zeniv-20220401 header.b=UXgboL6T; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id 138-20020a630090000000b00584a7618163si3094157pga.601.2023.10.12.13.19.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 13:19:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=temperror (no key for signature) header.i=@infradead.org header.s=zeniv-20220401 header.b=UXgboL6T; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 F020481D55D9; Thu, 12 Oct 2023 13:18:59 -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 S1347400AbjJLUSu (ORCPT + 99 others); Thu, 12 Oct 2023 16:18:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43628 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347403AbjJLUSr (ORCPT ); Thu, 12 Oct 2023 16:18:47 -0400 Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [IPv6:2a03:a000:7:0:5054:ff:fe1c:15ff]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF86CDD for ; Thu, 12 Oct 2023 13:18:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=zeniv-20220401; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=hc6HCNMBp8IlLh8DN5mOo6xzjEiwvUjh2K14S7K06EQ=; b=UXgboL6T6vWj55vMADPJkX8CSk gvNHxS4VgKU8FrVZzda+94awkU07ZZcPRsaGdhBlL2sW01X3iIeBEHS+NBA3QfgmYJCZ01kbHKCAM zJ2ni/YxaRuJ6vKxvrE6jcmZ1EXo0/XfWVJMWDc6RNf7Gav4qipw0vtwcGLx9St8wToVsY4RIa6gE vmKc72e3sILpfqrMBe4+91KN/qYgvJjqo/UumT38BjjGUD2ioIo53ez5BuRfvzDtyIojYPspUaQHd 3IVUG5m0jh2JXRGOQh3V7GVe1ZItZaidt1wC1x6/Z1tQpo+ze7A/Z3vrEX0QbMQkwJaJJH6jne61i l30AfPHw==; Received: from jlbec by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1qr28n-000gUf-0E; Thu, 12 Oct 2023 20:18:41 +0000 Date: Thu, 12 Oct 2023 13:18:32 -0700 From: Joel Becker To: Seamus Connor Cc: Christoph Hellwig , linux-kernel@vger.kernel.org Subject: Re: [PATCH] [WIP] configfs: improve item creation performance Message-ID: Mail-Followup-To: Seamus Connor , Christoph Hellwig , linux-kernel@vger.kernel.org References: <20231011213919.52267-1-sconnor@purestorage.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231011213919.52267-1-sconnor@purestorage.com> X-Burt-Line: Trees are cool. X-Red-Smith: Ninety feet between bases is perhaps as close as man has ever come to perfection. Sender: Joel Becker X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, 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 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]); Thu, 12 Oct 2023 13:19:00 -0700 (PDT) On Wed, Oct 11, 2023 at 02:39:19PM -0700, Seamus Connor wrote: > On my machine, creating 40,000 Items in a single directory takes roughly > 40 seconds. With this patch applied, that time drops down to around 130 > ms. Nice. > @@ -207,7 +212,10 @@ static struct configfs_dirent *configfs_new_dirent(struct configfs_dirent *paren > return ERR_PTR(-ENOENT); > } > sd->s_frag = get_fragment(frag); > - list_add(&sd->s_sibling, &parent_sd->s_children); > + if (configfs_dirent_is_pinned(sd)) > + list_add_tail(&sd->s_sibling, &parent_sd->s_children); > + else > + list_add(&sd->s_sibling, &parent_sd->s_children); > spin_unlock(&configfs_dirent_lock); This is subtle. Your patch description of course describes why we are partitioning the items and attributes, but that will get lost into the memory hole very quickly. Please add a comment. > @@ -449,6 +454,10 @@ static struct dentry * configfs_lookup(struct inode *dir, > > spin_lock(&configfs_dirent_lock); > list_for_each_entry(sd, &parent_sd->s_children, s_sibling) { > + > + if (configfs_dirent_is_pinned(sd)) > + break; > + > if ((sd->s_type & CONFIGFS_NOT_PINNED) && > !strcmp(configfs_get_name(sd), dentry->d_name.name)) { > struct configfs_attribute *attr = sd->s_element; There's a lack of symmetry here. The pinned check is an inline function, whereas the `CONFIGFS_NOT_PINNED` check is an open-coded bitmask. Why not just: ``` if (sd->s_type & CONFIGFS_IS_PINNED) break; ``` Plus, aren't the pinned/not-pinned checks redundant? Can't we avoid the extra conditional? ``` spin_lock(&configfs_dirent_lock); list_for_each_entry(sd, &parent_sd->s_children, s_sibling) { - if ((sd->s_type & CONFIGFS_NOT_PINNED) && - !strcmp(configfs_get_name(sd), dentry->d_name.name)) { + /* + * The dirents for config_items are pinned in the + * dcache, so configfs_lookup() should never be called + * for items. Thus, we're only looking up attributes. + * + * s_children is ordered so that attributes + * (CONFIGFS_NOT_PINNED) come before items (see + * configfs_new_dirent(). If we have reached a child item, + * we are done looking. + */ + if (!(sd->s_type & CONFIGFS_NOT_PINNED)) + break; + + if (!strcmp(configfs_get_name(sd), dentry->d_name.name)) { struct configfs_attribute *attr = sd->s_element; umode_t mode = (attr->ca_mode & S_IALLUGO) | S_IFREG; ``` > -void configfs_hash_and_remove(struct dentry * dir, const char * name) > -{ > - struct configfs_dirent * sd; > - struct configfs_dirent * parent_sd = dir->d_fsdata; Man, I thought we removed this years ago: https://lkml.indiana.edu/hypermail/linux/kernel/0803.0/0905.html. No idea why that patch didn't land. Thanks, Joel -- Life's Little Instruction Book #222 "Think twice before burdening a friend with a secret." http://www.jlbec.org/ jlbec@evilplan.org