Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp5493020pxb; Mon, 28 Mar 2022 13:15:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx2I36Un0NxMcZSJ4+fDneWyOFL4GNlcX8phzFpggdyP9fXuK3fRXGpZKARQqf7y2rWMn3f X-Received: by 2002:a17:90b:1b51:b0:1c6:f880:166d with SMTP id nv17-20020a17090b1b5100b001c6f880166dmr811812pjb.185.1648498503464; Mon, 28 Mar 2022 13:15:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648498503; cv=none; d=google.com; s=arc-20160816; b=Y826isrzOvNkEhe1bCyT+o1xsikcUuGEzcUUFQJY4ovSR7GSACp7jkrmucPV0yo9FT P094v7hxG8HCYwO62Jl46BynwbJO46nHfRFd8wXdwrCfRHok9h5g8uB3a0H44u7EIp6B bkJfTR/Lr9YLIXPSnieuQZOT/VK1ECZKQ/jIWEqz7mnjxLiCsI/d0n4O2nL8WZBmbWQ6 gTlM1CswTAJpQ3TfgAZafoXR2pg2QaO/0pmO1i0TDKBpZ/+SuCwrBtkjIM7lmWVz+Yby x8MzNvKatze9GFdOGHSXXYsDVf36L9DquK/VEBn/9hI2ZPuzqz79BBokweq38cSuDVCz Edbw== 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=2rbg0zjEEZcrrrki0TLW7AmDf91MrcPr+Sit2fUDac0=; b=Rc5mFaI+IXYOSW7hdZ1/CwxV+nUEeOXJGS9nFCqw1Jw5u5wvx9/NRhGWhQ5N/A6pTR p0C49WaTh1ojYtaBeW9u+lXz6y6xw185viFFEpsioT4vBx8V/pY1DHQszzdv0ANhrtpW L7bn0dH1RVdboUpvoJ9aFhU4Adc7yduJqwjmRo5odlvxyoHMafbfUecWAl54JYtQ6pWN a5OthC7UOZ10s6ezunCO8Tkp2fzZgXflIMBljeFx54On4/p4oFO1P0FPgIoG2yzaAfuI MNpgsHa5W2LyL32usSkA8z68dn5872eyKSwJfRmd2Q0VQy9wPNDKqD4sv/BZfQCe0kGa jpaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=T50k+e8A; 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 u9-20020a170902bf4900b001561e8d0a44si2152605pls.445.2022.03.28.13.14.48; Mon, 28 Mar 2022 13:15:03 -0700 (PDT) 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=T50k+e8A; 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 S243865AbiC1Rbr (ORCPT + 99 others); Mon, 28 Mar 2022 13:31:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232336AbiC1Rbq (ORCPT ); Mon, 28 Mar 2022 13:31:46 -0400 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 676B8633A2 for ; Mon, 28 Mar 2022 10:30:05 -0700 (PDT) Received: by mail-pj1-x102f.google.com with SMTP id mp11-20020a17090b190b00b001c79aa8fac4so264765pjb.0 for ; Mon, 28 Mar 2022 10:30:05 -0700 (PDT) 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=2rbg0zjEEZcrrrki0TLW7AmDf91MrcPr+Sit2fUDac0=; b=T50k+e8A1/6vv1rfaDGOCv8B5qU1VUl408G2Ln8z6Jp25Qjr8AdOCZrDGIrNWXxnGm c4NJx+VC/TJj02rrHHOIJdBBhvpand0nvwJrHjfwKAcIyWJmWDDZxuk10DEJXrJd7JOM eo38/C9E92JT2x3fyk0853ktk/jORrKo2Rh6U7FHXT/LXAd2bOAqXQ6bmgOowANp3cOC nGbuBfY2YGJrn4c0ZEXM7UCHbeNgF9faf5TscSYF2y7v/0E1nX2chDkmXCCJE6CWTF5T K6PIArSmkRwohFu4bcuSmwg0XSm7Hsz5z7jE7GKebgV7Cv+37AZXC3YqvCmXZADTbm3n REWQ== 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=2rbg0zjEEZcrrrki0TLW7AmDf91MrcPr+Sit2fUDac0=; b=x06alG4o1ZjSjz5KQQrOSbS+5w9yLaipBeUMTH6jCj6t+7yIMuy03Isaic4S0k1iAy 9hp1DJXCdrCV2xPt2IyEj8G+5iMy4VEVxKeSQt3JjLbr/QHdKbm8uUIKWO+v288nmmu2 Vwq10a8oNEQ8QptPvxtxon9b0vJ7ORZhq9+7VZXemYwGB8QID0KARg+I6Y+NTTfbtLc7 0FPrthnUKH/FxwD0FnWN9HBqnpepVgra9olsmDAhRolGAA6/vJAoAXoF2M996f8zuU+8 dfR9qkpQK2xjy9KurDziTyhO7TjedTyoTvSm19pzGiux5eCx0KRPr4Eq59wUlr3cqQTO yMFw== X-Gm-Message-State: AOAM530Aa+NuZ4jVaqWqhAE1POeXBdneSE/2fjGh5Sjx/Qx9I+pDzwnu uYDCosJQ7GTM//WNm82jCW0= X-Received: by 2002:a17:90a:c28c:b0:1c9:9eef:6e2b with SMTP id f12-20020a17090ac28c00b001c99eef6e2bmr232555pjt.188.1648488604648; Mon, 28 Mar 2022 10:30:04 -0700 (PDT) Received: from localhost ([2620:10d:c090:400::5:3b11]) by smtp.gmail.com with ESMTPSA id nn7-20020a17090b38c700b001c9ba103530sm100826pjb.48.2022.03.28.10.30.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Mar 2022 10:30:03 -0700 (PDT) Sender: Tejun Heo Date: Mon, 28 Mar 2022 07:30:02 -1000 From: Tejun Heo To: Imran Khan Cc: Al Viro , gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org Subject: Re: [RESEND PATCH v7 7/8] kernfs: Replace per-fs rwsem with hashed rwsems. Message-ID: References: <20220317072612.163143-1-imran.f.khan@oracle.com> <20220317072612.163143-8-imran.f.khan@oracle.com> <536f2392-45d2-2f43-5e9d-01ef50e33126@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Mon, Mar 28, 2022 at 11:15:30AM +1100, Imran Khan wrote: > Hello Al, > > On 22/3/22 1:40 pm, Al Viro wrote: > [...] > > > > Sorry, misread that thing - the reason it copies the damn thing at all is > > the use of strsep(). Yecch... Rule of the thumb regarding strsep() use, > > be it in kernel or in the userland: don't. It's almost never the right > > primitive to use. > > > > Lookups should use qstr; it has both the length and place for hash. > > Switch kernfs_find_ns() to that (and lift the calculation of length > > into the callers that do not have it - note that kernfs_iop_lookup() > > does) and you don't need the strsep() shite (or copying) anymore. > > > > Regarding using qstr in kernfs_find_ns, do you mean that I should remove > ->name and ->hash with a ->qstr in kernfs_node and further modify > kernfs_name_compare to make use of qstr.name and qstr.hash. > > Also the suggestion about removing buffer copying from kernfs_walk_ns is > not clear to me because kernfs_walk_ns invokes kernfs_find_ns with > individual path components so we need some mechanism to separate path > components. > > Sorry if I have missed or misunderstood something in your suggestion. qstr encodes the lenght of the string and doesn't need the terminating '\0', so we can just walk qstr over the passed in path instead of copying and overwriting '\0'. This is rather separate and we can revisit this later tho. Thanks. -- tejun