Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp18037998rwd; Tue, 27 Jun 2023 10:41:20 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ60LSAwLjsczfM0kC9B4oDVvBdCvGMst7sz0FdhE2lAsk90i2rGhLzCxIudQ2dNNyP8NfdO X-Received: by 2002:aa7:c483:0:b0:51d:7ff0:842a with SMTP id m3-20020aa7c483000000b0051d7ff0842amr6331505edq.28.1687887679888; Tue, 27 Jun 2023 10:41:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687887679; cv=none; d=google.com; s=arc-20160816; b=HqlKDtPCpUD/eqecNmOhjVOkLakU/TKl2vcK7yuSi++YjkmULpWWHLXUyknf8Pjno0 NH5hL4tihUMhPlnxu5OuPucjE80XutB8KpMSylt2Y9pO/HumYy8Fc9lUjxQHXX6XIywb ibQzek8RXmxXCgx25SFgQnPD3OunHJHSOm5D1JpVCO8FD3F9y7Bf2m+perOohr5kpaoH wV59jd6tv58s2uIBBw6qAnKAqIP47HW2kYMC3Z6J4mH0gu35pkqgXi7ifkAE43MCyF4p DV7wsJDaQRxJukyMjZCuqNIwq77WzTVT0mCFeFo+IhTuB0GjeQ56A1PtYVIR2W2Z2q/B M3EQ== 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=AEfOOj7zZRsR4093w5Xezdtfqq/JXEJS/CeyQ2VX6y0=; fh=XjfgmoRDrILL6w2Fv352UdLWQaGMeBLGa5ELCOloFxk=; b=JYo2LtMJXRcvF9j7D56i1U3Jn4t75pw7aMrE1UX3O/1AyxpEK/oUe0IMQVgGhBzmkE EdzONqBRqOo0tNxbl1u6bnmXmTeKFiDs0aZI3BAS/7Weht010wCWT2T28mRUo9nSi2xK /RAE98GjphY4ZR++l7HWL6adjLJq5PHBfGQgLpOrDxgrgdHIdliVg2vXur/IfxE4FmMw SDBE0u3YiJ08Is9Ngtaj1wObHyIiYXX1z6ogR9P//CI2bnIYJzAA7rHbISfmu5e0wa2p TO7jSpUjynMQNVwy/uB34NfyAQ3gfZkKhXudm4wyeVTMu3esVT6u9FE7t8moxnP14Yny PTYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=qAGBVo+6; 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 y14-20020aa7d50e000000b0051dacee1430si977284edq.375.2023.06.27.10.40.54; Tue, 27 Jun 2023 10:41:19 -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=qAGBVo+6; 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 S231150AbjF0RJo (ORCPT + 99 others); Tue, 27 Jun 2023 13:09:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230507AbjF0RJl (ORCPT ); Tue, 27 Jun 2023 13:09:41 -0400 Received: from mail-yb1-xb35.google.com (mail-yb1-xb35.google.com [IPv6:2607:f8b0:4864:20::b35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A21D6198D for ; Tue, 27 Jun 2023 10:09:39 -0700 (PDT) Received: by mail-yb1-xb35.google.com with SMTP id 3f1490d57ef6-bfee679b7efso4697887276.0 for ; Tue, 27 Jun 2023 10:09:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1687885779; x=1690477779; 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=AEfOOj7zZRsR4093w5Xezdtfqq/JXEJS/CeyQ2VX6y0=; b=qAGBVo+6BR+jme9c+D+CU2a/HdzfRO4Smyw+4vv/W4I1jKgLWzo2vd5hMJUHdw3fkX IJNH8qRtKo+5gPnluLFgDX0SPxosg2Tr1jNfFqqoiSu11uqRJYvDMtanGXBT1x0IkF6Y ba6+9LwZiwkO7sWkoB43e404iG9OBoNL5QBSX0MGxliMIjCNPke9m99etfmYL8jhdCUV tX883ywh8R4BwLNDanA/fkNoFWFXCJC5yWiuCCLPQoJxcVJR+gMgtIVUupMj4ruxQvGL ebhN165884+Diht68TH0anDDe0ObeWm+6pLlX+boJpCHjSxzQPWEWJVmPkxSSa+JouHz JL0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687885779; x=1690477779; 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=AEfOOj7zZRsR4093w5Xezdtfqq/JXEJS/CeyQ2VX6y0=; b=YpQ0d6yQhpzhiP6bWF4wm9P65qOQsg3pIRc5vCXRdYg0pCUIElTMCtiMOrFagWFiS+ fZ+LuzLqcb/HHoFV+ivRwCkLT1BYB9S5HxlyQdlFRIPxNSyLCRSCR8QVv378VXuqp6Je mZZqqMozPMQGQ5TkkiHfeMzStciTEhZewvK40wZ0acYzLmFJHyUWOSnMD93BLv+AqEVk 2AKPDCUUvYgHCgAFxTnvidR6QNa9dFczZOFGFvOQiNmeaTPHH+OxQHeFHyKXBOcFmCQx OzrlxKZAHGnzVVmVk+OIH7z3K+TbOewJA4/iPAOh//fcHpzrTETbwYDhZwFyxrP8l+iK zWyg== X-Gm-Message-State: AC+VfDw+NxT/nAcRD2rylW25ThLsegULAR0a70gcJTR0AGpULONJJFC5 hNZqHnYpCnhaDxMqxxJ0tmNqS9tNuFj4yilaOSMt+A== X-Received: by 2002:a25:2903:0:b0:bff:d530:f06 with SMTP id p3-20020a252903000000b00bffd5300f06mr16876866ybp.41.1687885778638; Tue, 27 Jun 2023 10:09:38 -0700 (PDT) MIME-Version: 1.0 References: <20230626201713.1204982-1-surenb@google.com> <20230627-kanon-hievt-bfdb583ddaa6@brauner> In-Reply-To: <20230627-kanon-hievt-bfdb583ddaa6@brauner> From: Suren Baghdasaryan Date: Tue, 27 Jun 2023 10:09:27 -0700 Message-ID: Subject: Re: [PATCH 1/2] kernfs: add kernfs_ops.free operation to free resources tied to the file To: Christian Brauner Cc: Tejun Heo , 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=ham 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:24=E2=80=AFAM Christian Brauner wrote: > > On Mon, Jun 26, 2023 at 10:31:49AM -1000, Tejun Heo wrote: > > On Mon, Jun 26, 2023 at 01:17:12PM -0700, Suren Baghdasaryan wrote: > > > diff --git a/include/linux/kernfs.h b/include/linux/kernfs.h > > > index 73f5c120def8..a7e404ff31bb 100644 > > > --- a/include/linux/kernfs.h > > > +++ b/include/linux/kernfs.h > > > @@ -273,6 +273,11 @@ struct kernfs_ops { > > > */ > > > int (*open)(struct kernfs_open_file *of); > > > void (*release)(struct kernfs_open_file *of); > > > + /* > > > + * Free resources tied to the lifecycle of the file, like a > > > + * waitqueue used for polling. > > > + */ > > > + void (*free)(struct kernfs_open_file *of); > > > > I think this can use a bit more commenting - ie. explain that release m= ay be > > called earlier than the actual freeing of the file and how that can lea= d to > > problems. Othre than that, looks fine to me. > > It seems the more natural thing to do would be to introduce a ->drain() > operation and order it before ->release(), no? I assume you mean we should add a ->drain() operation and call it when kernfs_drain_open_files() causes kernfs_release_file()? That would work but if any existing release() handler counts on the current behavior (release() being called while draining) then we should find and fix these. Hopefully they don't really depend on the current behavior but I dunno.