Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1456985pxb; Tue, 8 Feb 2022 18:42:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJwaqEOnVt44hAM1CFYM12CN/GRC+dRxWPfgVEM9Y+yDl8PrXqLAGnSOVsdbj0J7b67gR3K4 X-Received: by 2002:a17:906:58d4:: with SMTP id e20mr75457ejs.769.1644374571003; Tue, 08 Feb 2022 18:42:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644374570; cv=none; d=google.com; s=arc-20160816; b=T8yiUa4ckKIiK5qMBLOLW1ZfChQvPStnjt5/JxajhjpTEiPCrkZw9mmsAGgtQPrKHM 7jAzMhvXHdUXcypU5sGRZb5TasJcO6ed3OnaWzKEjCwDsCGp+rtDoUUCOuJImNjxDGob WuAvhNqf0yhD0dMPr3+J9HKY4sNwZWR8FU8B2WgW4Vfy02DXKKPZwpREGG1AGJkvLIMc 23iqdY2xGQbZFC2+BdVOAOCriC3XrdzCCa34X/n/jpckUdh+vBBWP+nQCPU4HvLwkfoo 9yoFoXL0CMj3nmspwooHrvQ6baSFYewyppgopry+rTDOCwgnhYqgJ381FbxKF3+K09OI px2A== 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:sender:dkim-signature; bh=vkwsMg8JIcYCvuRxCKyZKhniS3wznCIEfN9JuWpZlzs=; b=YoQ4xbtULxiyXheCzLOre0FvmjG4qFbFxqzPA/Rb3u3Jjnw8nz0+MeQg0d1pGMNEhh YJMguQBJJomlJtiqIQokwRD4UkfBroAe1bRbsyr8+5oKZHWLBS8+dzkW+1tK+e4xV8Rx DGxqPeu78te6vrVdpOVKj8qV97Xdu0fI6vm0lDBo7admkxraY8sqhkFA3uByrg3KxmIb dt4iwu6wUSiE4lv1oYJhRJwet/6Bc/+lu3D5HG3nwiOt+p5LSjP5X30Elr97HMTm4f49 vwmv6zT4/PPL2T8DXQ1uvhbJyNtzNyUJ8c4NRWKxBMoCBUXOD8aEwUteaGja/q8IoC9m kiiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=MkXyom8x; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c15si12435347ede.581.2022.02.08.18.42.26; Tue, 08 Feb 2022 18:42:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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=@gmail.com header.s=20210112 header.b=MkXyom8x; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384217AbiBHRWt (ORCPT + 99 others); Tue, 8 Feb 2022 12:22:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384210AbiBHRWs (ORCPT ); Tue, 8 Feb 2022 12:22:48 -0500 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5A6EC061576 for ; Tue, 8 Feb 2022 09:22:47 -0800 (PST) Received: by mail-pj1-x102f.google.com with SMTP id y15-20020a17090a474f00b001b88562650aso1981607pjg.0 for ; Tue, 08 Feb 2022 09:22:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=vkwsMg8JIcYCvuRxCKyZKhniS3wznCIEfN9JuWpZlzs=; b=MkXyom8xyiPG/WxwzZZXl1x8vpzzXwe2JoYx8oz1Jl8dQTST0raqTCSmKisnBq5O30 xCNDZaSb/+kMjKLx7lS0YJZWnbJ3/t0zgZXtSeBANnhLzPP9lMLNuoroIURJbszDGK7Y 8TzyFbpmmqjLTquQPirjmezBA6bMoSHBtouYbA+FfTbSUEVLGFYe7lrbExAzSfEQiWJV iLCN5Ev61nBRm+oGiUKq4wnTkTCBlN0In/QIgQtko/aF9geOr/Vrd85K6/EBoR5oyqTg X7VsQLg9M+AJPvFhh2v8qRnJn4F6sVHJVvSoLGxWD2BMEC6bNl2SXwF8Xy9AJnY114e+ dE8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=vkwsMg8JIcYCvuRxCKyZKhniS3wznCIEfN9JuWpZlzs=; b=DqmVIMDcfduKNRp/Kb0RF+RXrwGFZ359DKntHn4ryNOHh//iIHYSFQw71L3OMsScq0 43F8uhc6qtbRA09MVFd92ZBXX6dPy0FpaLqT39C1jABvntjTJmK2aBqnGSvjY7xz3IlU 39Ka2/wtsP1eKycR3Wh0K8gSdIbEJXPWo0k2yHMORrNxCFIIHha5zsvm/4Bc0es/b//u hjBVdxXMPIdX5NDR/AfcYDvmP4vfj0cUGHBvn0PSLEBSukfvf2YTl9bt5P2wUL7utWaH zMXBmFKIPXwpz1+ybHrBiCwSX0OHXi3d6S61/VmTh1mneLbaccoOg1HRZKfspPgfRhL2 ksHA== X-Gm-Message-State: AOAM530yIZc2AntQL6fnco/Wy2V8IUePqIoFcPeafKYCtiZ36xw07ul/ V3AHxzREU4BKYF4rrVOVjKw= X-Received: by 2002:a17:903:41d0:: with SMTP id u16mr5490152ple.144.1644340967022; Tue, 08 Feb 2022 09:22:47 -0800 (PST) Received: from localhost (2603-800c-1a02-1bae-e24f-43ff-fee6-449f.res6.spectrum.com. [2603:800c:1a02:1bae:e24f:43ff:fee6:449f]) by smtp.gmail.com with ESMTPSA id f3sm16813620pfe.43.2022.02.08.09.22.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 09:22:46 -0800 (PST) Sender: Tejun Heo Date: Tue, 8 Feb 2022 07:22:45 -1000 From: Tejun Heo To: Imran Khan Cc: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 1/2] kernfs: use hashed mutex and spinlock in place of global ones. Message-ID: References: <20220206010925.1033990-1-imran.f.khan@oracle.com> <20220206010925.1033990-2-imran.f.khan@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220206010925.1033990-2-imran.f.khan@oracle.com> X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no 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-kernel@vger.kernel.org On Sun, Feb 06, 2022 at 12:09:24PM +1100, Imran Khan wrote: > +/* > + * NR_KERNFS_LOCK_BITS determines size (NR_KERNFS_LOCKS) of hash > + * table of locks. > + * Having a small hash table would impact scalability, since > + * more and more kernfs_node objects will end up using same lock > + * and having a very large hash table would waste memory. > + * > + * At the moment size of hash table of locks is being set based on > + * the number of CPUs as follows: > + * > + * NR_CPU NR_KERNFS_LOCK_BITS NR_KERNFS_LOCKS > + * 1 1 2 > + * 2-3 2 4 > + * 4-7 4 16 > + * 8-15 6 64 > + * 16-31 8 256 > + * 32 and more 10 1024 > + */ > +#ifdef CONFIG_SMP > +#define NR_KERNFS_LOCK_BITS (2 * (ilog2(NR_CPUS < 32 ? NR_CPUS : 32))) > +#else > +#define NR_KERNFS_LOCK_BITS 1 > +#endif > + > +#define NR_KERNFS_LOCKS (1 << NR_KERNFS_LOCK_BITS) I have a couple questions: * How did you come up with the above numbers? Are they based on some experimentation? It'd be nice if the comment explains why the numbers are like that. * IIRC, we split these locks to per kernfs instance recently as a way to mitigate lock contention occurring across kernfs instances. I don't think it's beneficial to keep these hashed locks separate. It'd be both simpler and less contended to double one shared hashtable than splitting the table into two separate half sized ones. So, maybe switch to global hashtables and increase the size? Thanks. -- tejun