Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp308657pxb; Wed, 23 Mar 2022 19:03:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwnfZmTDg63IGsk02V32tdL7zrDYC0bGz728+f3JtU28/HHtMAsmrJZ7c19T18/c39LG8HA X-Received: by 2002:a17:906:9c90:b0:6df:9eea:cda3 with SMTP id fj16-20020a1709069c9000b006df9eeacda3mr3232093ejc.89.1648087389114; Wed, 23 Mar 2022 19:03:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648087389; cv=none; d=google.com; s=arc-20160816; b=WynC4L5FEzw5OWRKO7iSwznX6LXfbqwg/7mQbZ21oPkPyexboxy/68zf41ji6fnn84 sRlR0Mkcp75r+kfkj1Q+LU2DjjBpAzspV40LPBwoHVeDziTVayGVUAk3NRVbplQZ/m3i T6vuirkX66pbysOKAFn0uSc+gmvEHlP+gRnxO4kbTkTNohgVteNM0mAOB20TbbMbI4NM FOHMdNM2GXxa0YcbmNG4Jp0HNuDO7xh7JzO/UBChmux01AmDnCGTWN8SY9yqqOdpJYmq RTGmIRn+YYGSq02mHTdvRp1B3vlkScurW0lEebgwcE5vl1X0Ul63/ydv7/KGVn/ZL1IL jNkg== 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=RchwFeHnAgjVWoa34ourakFD10mLtoxIuJ+lDmxFKKg=; b=VG/67WiZW++RAPQORyexaMUMnXc77m6QvsjQA3uSOoPlyIRm2q4EcwkmOHaVyCNYwt BvbWT5Q8MZ4JBJdC34qv/4UJNoDTbYhwkvOKgncWMJBudjj5r7+y1A6+SXnK09Wbb1cb d/s7n62j/1/mv90HvimmZhMgwr2hkbF2CyoRxYWkQ4VnwyAzB+LUcOyDZjH40j53RMyE d/F2mWh48BLNDROQynjJArKX9EZ6wMrMrOTmx85MbRv6yUidJdMkMO9HZjQ2fKrR60ra XOfIsGJicBN8/zL/JuAdMbCFwQBrwRaM3COQgvT23L47PLeDywv8/iHM6hzfBwj4xJEo YHQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ZqV8cykf; 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 g22-20020a17090670d600b006df76385ea3si13518080ejk.835.2022.03.23.19.02.44; Wed, 23 Mar 2022 19:03:09 -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=ZqV8cykf; 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 S235371AbiCVVVi (ORCPT + 99 others); Tue, 22 Mar 2022 17:21:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235362AbiCVVVe (ORCPT ); Tue, 22 Mar 2022 17:21:34 -0400 Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B358D4C408 for ; Tue, 22 Mar 2022 14:20:06 -0700 (PDT) Received: by mail-pg1-x529.google.com with SMTP id o13so13519897pgc.12 for ; Tue, 22 Mar 2022 14:20:06 -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=RchwFeHnAgjVWoa34ourakFD10mLtoxIuJ+lDmxFKKg=; b=ZqV8cykf9WeQtP+YSmYl6cpCPrbad2cfJeryFJXKq8NaQuH88oFy5Ywt3scHYMzsWS XZhPBvKSVHloYGZR5Px1AtbtO+nOqAWMaPRr1bQtHtA/ozHk9i0GzgYyK283QCIS69z9 q5MQvlx70XnP8/H2Ky8MJrQRnvQtT8uQxl3w+2I8ZIGQhUVpHozrjDel+AyjEiBxkIj4 EkAvL0airjZRPoXvXqMudZt/Ilax7DQuIvVSZqqWdZbnw/shR1k6B8jewK+RmNkdgwH/ e/r7XEDQA2Qm4SdwXzeUVFD4DPUAXqT5hpycPEvtWZ6B34/PFIM1VLT3FLfq+QULoixq LNTg== 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=RchwFeHnAgjVWoa34ourakFD10mLtoxIuJ+lDmxFKKg=; b=JFn8Fubg6eUC6ke890HPwcZCNamZdZkjkpyiKuBcFuye9rom23Hxrv17ftaxJfOSWj GusaQU9WfWsmP3x5oTjuPrJManx6g+Gmz50zY649fyLdd/rQ9XRCm9oC9YNeZw1APt6C SoI/+c7eF57bE0/Y17l9lDbg3zjkh9ucbtZX4ewmkPSlaZKiuT3F1rI0Sk1byZFBJL9I bvKiCjzpsgoeTjEONxuxvXT4GeBVfgYx9je1RXAfZumtcW0eAHnCz6rkyzoMDC3c88ZF qWDRyqfHLBMu5U4yN7lF7oUEjF7B5O0DeWaWbMNEC/wfWKQiRW5aeTb2NKN3Od9iKaFy UQyg== X-Gm-Message-State: AOAM530HG3ZO0ei2qMNicpq5Seqj7cKwmSjzSZu/pEAfCzRIXLzMaLIB DtEzGOZ5dvNj4BV6JINxAXVtAPqR3kdJeA== X-Received: by 2002:a05:6a00:d6a:b0:4fa:6940:f2dc with SMTP id n42-20020a056a000d6a00b004fa6940f2dcmr25906612pfv.61.1647984005775; Tue, 22 Mar 2022 14:20:05 -0700 (PDT) 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 g3-20020a056a001a0300b004fa65cbbf4esm17704415pfv.63.2022.03.22.14.20.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Mar 2022 14:20:04 -0700 (PDT) Sender: Tejun Heo Date: Tue, 22 Mar 2022 11:20:03 -1000 From: Tejun Heo To: Al Viro Cc: Imran Khan , gregkh@linuxfoundation.org, akpm@linux-foundation.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-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 Tue, Mar 22, 2022 at 08:26:54PM +0000, Al Viro wrote: > The only thing that matter wrt rcu_read_lock() is that we can't block there; > there are tons of plain spin_lock() calls done in those conditions. And > rcu_read_lock() doesn't disable interrupts, so spin_lock_irq() is usable > under it. Now, holding another spinlock with spin_lock_irq{,save}() *does* > prohibit the use of spin_lock_irq() - there you can use only spin_lock() > or spin_lock_irqsave(). Yeah, I was just listing different cases to make the point that these functions don't know what context they might get called in. > The callchains that prohibit spin_lock() do exist - for example, there's > pr_cont_kernfs_path <- pr_cont_cgroup_path <- transfer_surpluses <- ioc_timer_fn. Yeap. > Out of curiosity, what guarantees that kernfs_remove() won't do > fun things to ancestors of iocg_to_blkg(iocg)->blkcg->css.cgroup for some > iocg in ioc->active_iocgs, until after ioc_rqos_exit(ioc) has finished > del_timer_sync()? Ah, okay, I was wrong before when I said that kernfs_remove() is like free. It puts the base reference but as long as anybody has a ref on a kernfs_node, the node itself and all its parents are pinned. For iocost, ioc_pd_free() which is called from __blkg_release() ensures that the iocg is off the active list. __blkg_release() puts its css reference before calling ioc_pd_free(). If this were the last css of the cgroup, this can trigger the destruction of cgroup, so the order doesn't seem right - we should call blkg_free() first and then put the references. However, given that both css and cgroup release paths involve a RCU grace period and __blkg_release() is called from rcu callback, I don't think the race window actually exists. I'll still send a patch to reorder the puts. Thanks. -- tejun