Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp18286821rwd; Tue, 27 Jun 2023 14:47:38 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5fVkuhcxSxLaKxiBwsgiowlVHjeH+VvJtkOgRu0ABJFBCpPbvhwWyGF7CYLKnUDGcsFQog X-Received: by 2002:a17:906:4793:b0:978:8937:19ba with SMTP id cw19-20020a170906479300b00978893719bamr29749172ejc.44.1687902458577; Tue, 27 Jun 2023 14:47:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687902458; cv=none; d=google.com; s=arc-20160816; b=LGDRfQQpDFDQYiKZjBlXrVNCs8YFj/f4FAsHNzUJnAUoqSb5EGVMbV8e/BbU/EpWCQ eCls/f25aydTclBF8TugDdSu0nXpLuh+QsqWINredm0DEiILHbYej0J8wXoTA9TleS8d p8Ql8SSOHwbIAe5t2b2lcKnlAZAbzjhgdUZ/08R+egSRYfMmq0bZhmaeHIUYrs5/L9qz QXWBTAd+E8EyMq7Ip5TFN9EfJ2u7HPClBsyUBXmgu2/0vRjEnK2zVg7NplAYAbBXsnWg S/BjGuA8XL74Q+gG6wIolU1jmao+mGsTFLJRTCJvPpfiDESax4TFfvprUD7cQyvUWp7x ALaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=MSllMEfZxRxH/Ncdk3MCdEqFObJmS1OPb8q9+W1DegI=; fh=gWOXbR8Go8ZZzSq1qnvwsWT+mN+uIrppteKEhejTBsg=; b=PcCMyZwPGe2VdsEeu3LFVbfvF+Uixdq/2Fps6g8rO98sxiAKpdbWkTasW5ge0pl2La CH7QjAwj3FyRXwENkfAdzcLF+IaeLJ6L7F8Zbg1RI3MhouGunn0eh4tjty+SBHS5Y4gb RKQDvwrOX89lfyit6nrNumG85o/xAPZSnw/OhtkhIDstrch1mCdcWnrn+cQyY1VxYa4K LXZiU882uc/a9Pc5+srW0WY4wY3MQ7j2g0BYWJZVat6Kc4zyj7E0pEY56tSe0kvAm3gv 97zfUMn/v2T1fhINBEnZ/zj3GipEfGhj+NirxlGWt0JTtVoFUyUVIjjfHm1SmxQaf1EN rF4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=2+sKZNQh; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x19-20020a170906299300b00988546306cdsi4862878eje.839.2023.06.27.14.47.13; Tue, 27 Jun 2023 14:47:38 -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=@google.com header.s=20221208 header.b=2+sKZNQh; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230311AbjF0VnW (ORCPT + 99 others); Tue, 27 Jun 2023 17:43:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230271AbjF0VnU (ORCPT ); Tue, 27 Jun 2023 17:43:20 -0400 Received: from mail-oi1-x231.google.com (mail-oi1-x231.google.com [IPv6:2607:f8b0:4864:20::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 098472726 for ; Tue, 27 Jun 2023 14:43:19 -0700 (PDT) Received: by mail-oi1-x231.google.com with SMTP id 5614622812f47-39ed35dfa91so3765946b6e.3 for ; Tue, 27 Jun 2023 14:43:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1687902198; x=1690494198; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=MSllMEfZxRxH/Ncdk3MCdEqFObJmS1OPb8q9+W1DegI=; b=2+sKZNQhP9V45I8qJWmARf2B8RZm3gD3w1G+fLrVbz3etG8Oy46GcaOZIS6i7K3h/K SnY+Z8y93mRayVYzD/bBmI80k6bOpZEltc522mgvrW4dvBA20utkIhJVmxipLS63eotD OyLxRMnsUYN/ZiQUZzCEJJzijs2bOmz42QDP0WZjEI6cTrxikwWePyRBiuQ5A9UsY3dC HKRakkm9SFetS+kNfa6Lt+7YxydPGWd5AFikKCGvrj1w+1hBmz0IlQzke2XDQmZMWaJi uq+Mg+T2/IijmOF+rcVsmhWxm+1bEl6ldl8lqzk8I27SotQNuNZbyDyOsVEeygiRqyqr bXoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687902198; x=1690494198; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MSllMEfZxRxH/Ncdk3MCdEqFObJmS1OPb8q9+W1DegI=; b=ZC6G1kiD2YDk5KbZ6wuVNrm0nnYw+P8RpI0xwa0eQrT0B5DwYNqrY6Ooy3OSJakwGG f+NVlcLxco/UED9btabUJJ0r99uhqdlO3rahHDPAl36CclmPY71bgTGPNJM+S460A06+ PR+KwVfyMpgjqrv8DPFJv+Hjs0doM9xHhUfz7KyENlJFBPOjoX0kyH9FEnxeiLBdE9Hp JB+U2d9Wrmh9cJGFR75sGfwiiBlDUR2qCRgQ9+rmaBUqMbUvVbj+sKhpi7zzbPp1wVhU rMn57Xv6RtLbUcp2Udso0F6hqZPtzj8ACWSoNEiJB5Dvy0BwRHr1mMRr7GuI1qf7v+j3 UJKQ== X-Gm-Message-State: AC+VfDy6qTXsdStIxCKeqbprYz/5Lx8Q+pvYeztkzUOWOEgAMnmnWJzn Paql+vXAQxrtHc/NIeL2UmjRvlR8hT1uQqYzXD3l/g== X-Received: by 2002:a05:6808:21a2:b0:3a2:de7b:775f with SMTP id be34-20020a05680821a200b003a2de7b775fmr2907663oib.22.1687902198145; Tue, 27 Jun 2023 14:43:18 -0700 (PDT) MIME-Version: 1.0 References: <20230626201713.1204982-1-surenb@google.com> <20230627-kanon-hievt-bfdb583ddaa6@brauner> <20230627-ausgaben-brauhaus-a33e292558d8@brauner> In-Reply-To: From: Suren Baghdasaryan Date: Tue, 27 Jun 2023 14:43:06 -0700 Message-ID: Subject: Re: [PATCH 1/2] kernfs: add kernfs_ops.free operation to free resources tied to the file To: Tejun Heo Cc: Christian Brauner , gregkh@linuxfoundation.org, peterz@infradead.org, lujialin4@huawei.com, lizefan.x@bytedance.com, hannes@cmpxchg.org, mingo@redhat.com, ebiggers@kernel.org, oleg@redhat.com, akpm@linux-foundation.org, viro@zeniv.linux.org.uk, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-fsdevel@vger.kernel.org, kernel-team@android.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable 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, Jun 27, 2023 at 1:09=E2=80=AFPM Suren Baghdasaryan wrote: > > On Tue, Jun 27, 2023 at 11:42=E2=80=AFAM Tejun Heo wrote: > > > > Hello, Christian. > > > > On Tue, Jun 27, 2023 at 07:30:26PM +0200, Christian Brauner wrote: > > ... > > > ->release() was added in > > > > > > commit 0e67db2f9fe91937e798e3d7d22c50a8438187e1 > > > kernfs: add kernfs_ops->open/release() callbacks > > > > > > Add ->open/release() methods to kernfs_ops. ->open() is called w= hen > > > the file is opened and ->release() when the file is either releas= ed or > > > severed. These callbacks can be used, for example, to manage > > > persistent caching objects over multiple seq_file iterations. > > > > > > Signed-off-by: Tejun Heo > > > Acked-by: Greg Kroah-Hartman > > > Acked-by: Acked-by: Zefan Li > > > > > > which mentions "either releases or severed" which imho already points= to > > > separate methods. > > > > This is because kernfs has revoking operation which doesn't exist for o= ther > > filesystems. Other filesystem implemenations can't just say "I'm done. = Bye!" > > and go away. Even if the underlying filesystem has completely failed, t= he > > code still has to remain attached and keep aborting operations. > > > > However, kernfs serves as the midlayer to a lot of device drivers and o= ther > > internal subsystems and it'd be really inconvenient for each of them to= have > > to implement "I want to go away but I gotta wait out this user who's ho= lding > > onto my tuning knob file". So, kernfs exposes a revoke or severing sema= ntics > > something that's exposing interface through kernfs wants to stop doing = so. > > > > If you look at it from file operation implementation POV, this seems ex= actly > > like ->release. All open files are shutdown and there won't be any futu= re > > operations. After all, revoke is forced closing of all fd's. So, for mo= st > > users, treating severing just like ->release is the right thing to do. > > > > The PSI file which caused this is a special case because it attaches > > something to its kernfs file which outlives the severing operation bypa= ssing > > kernfs infra. A more complete way to fix this would be supporting the > > required behavior from kernfs side, so that the PSI file operates on ke= rnfs > > interface which knows the severing event and detaches properly. That sa= id, > > currently, this is very much an one-off. > > > > Suren, if you're interested, it might make sense to pipe poll through k= ernfs > > properly so that it has its kernfs operation and kernfs can sever it. T= hat > > said, as this is a fix for something which is currently causing crashes= , > > it'd be better to merge this simpler fix first no matter what. > > I'm happy to implement the right fix if you go into more details. > AFAIKT kernfs_ops already has poll() operation, we are hooking > cgroup_file_poll() to it and using kernfs_generic_poll(). I thought > this is the right way to pipe poll through kernfs but if that's > incorrect, please let me know. I'm happy to fix that. Ah, sorry, for PSI we are not using kernfs_generic_poll(), so my claim misrepresents the situation. Let me look into how kernfs_generic_poll() is implemented and maybe I can find a better solution for PSI. Thanks, Suren. > Thanks, > Suren. > > > > > Thanks. > > > > > -- > > tejun