Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp4577507pxv; Tue, 27 Jul 2021 10:39:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwR7oEOwYjeGV+QN8RbifFaERt3tDUEY/tywXczU02Hfnh6v1sVu0vp27anhq0FvXIB88C8 X-Received: by 2002:aa7:c489:: with SMTP id m9mr17609400edq.256.1627407564812; Tue, 27 Jul 2021 10:39:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627407564; cv=none; d=google.com; s=arc-20160816; b=EzpgnIXAdjDtD535Uuq5s7e8/9Ei8y8Q6mjICoJ0o6zyVthTqxvY0g8XCDNki9xD9k TTMZoAql+tdlfQmvKd731hKqwO/HfIjZyD66oZm1VBoBM9inK2QiRjObtXD97JQyIqVL w1CpsjVB0WKzF4zXY0cmA9IoOcOHylohujTE0hwtAcTZ/mCyj8CkeR9jU4bDFgplKUbS YXCqBluOpzFfTLRs+roA1sWV/D19pTqwDOOo5myXeWKFbsV63u0OlhLj12ahIrp9Vyb/ Qc8nPg2k7H8NCQXR6gNlzJP+qRjm9n0LcKMl1DrpsrGC5H9ZOz12ZcWrTJMjrOMOQUjx Cb0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=CtJSDCNVg4ODCFxbc9s2lq4PD4KRlQlX7HvhdKxAPe4=; b=xpMND7mok263cPV+jhtI/hwhArzVdkjOsN4u0fEx2Yry2zH7/3TzuqAY9Zl517MCNO lYn0JKTiLC2n2LlLtD18+LLH+OPsnabtPDU1lfHT2gxLBLP9zpyW7UTttq5jQJZY7y5m 18Das7f2YNt7LH8gGDeMjNuyfYo7nf1Hpczk9rgkbGURTsmCsJA0fWx3+oegLZJXiqBL yG3V9eZcGx+ZpYEzdr8JJ0WqR2Lhe/7gjdcpuUgegmbh9naqwAvHBio4cgBLHNGqvyPI Xo88uKrbNoK2lt61FUrtlL6gkg6EZ5YEMsfRnuXj/LMCGrtzh9Y5BERLkbbAhmHZybaD MqHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=Kh3HFN8R; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d13si3285044ejb.391.2021.07.27.10.39.01; Tue, 27 Jul 2021 10:39:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=Kh3HFN8R; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S230170AbhG0RfV (ORCPT + 99 others); Tue, 27 Jul 2021 13:35:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229915AbhG0RfU (ORCPT ); Tue, 27 Jul 2021 13:35:20 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B0F1C061757; Tue, 27 Jul 2021 10:35:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=CtJSDCNVg4ODCFxbc9s2lq4PD4KRlQlX7HvhdKxAPe4=; b=Kh3HFN8R3JopyQjHnjOaWTv1Bx GbJJ48B22E72i9GZFvbYYQSp5zlOhQuGMjHhnAjVnPgNbfBpelQqOnVfokNF3bbTBm0SbopxiJ9Xm SS/ySejntjT9DUbQ83gFpLJMXslPl++vocF8ejRUgYDn1k/UFJcff+oT6S6ddk4UTpEVWw1oNOWOI jfg8qOLmPvcH/HXShcJGEHEpuaktY6hr1Tuf2ldpcTu/qijv26xjsFhWUo5kHDkSx+vPn63SNaLOs iS1+7TZuiCGZpGUWmoMSMCOvAHLPhVfh/hl0Jf+J+RKbfadvZwb3EVJ2mIZblohXtOIJCLq+35zth dTaQ9lhw==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1m8Qz0-00FaLj-8x; Tue, 27 Jul 2021 17:35:10 +0000 Date: Tue, 27 Jul 2021 10:35:10 -0700 From: Luis Chamberlain To: Greg KH , David Laight Cc: akpm@linux-foundation.org, minchan@kernel.org, jeyu@kernel.org, ngupta@vflare.org, sergey.senozhatsky.work@gmail.com, rafael@kernel.org, axboe@kernel.dk, tj@kernel.org, mbenes@suse.com, jpoimboe@redhat.com, tglx@linutronix.de, keescook@chromium.org, jikos@kernel.org, rostedt@goodmis.org, peterz@infradead.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v6 2/3] zram: fix deadlock with sysfs attribute usage and module removal Message-ID: References: <20210703001958.620899-1-mcgrof@kernel.org> <20210703001958.620899-3-mcgrof@kernel.org> <20210722221705.kyrdkpt6fwf5k56o@garbanzo> <20210723174919.ka3tzyre432uilf7@garbanzo> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210723174919.ka3tzyre432uilf7@garbanzo> Sender: Luis Chamberlain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 23, 2021 at 10:49:19AM -0700, Luis Chamberlain wrote: > We are talking about sysfs files and you're argument is that > try_module_get() should lock the module, and so cannot be used > in sysfs files. My point is that such module lock is inferred: > > 1) Sysfs files are created by a module, that same module is responsible > for removing the same sysfs files. > 2) The module can only be removed and gone, once *all* sysfs files are > removed first. > 3) If any of the module's sysfs files are present the module must > still be present > 4) kernfs ensures that if a file is opened the file will not be > removed until any pending operation completes > 5) If a sysfs file is used to write something, that means the > sysfs file has not yet been removed, and we know it will > remain in existance throughout its entire operation > 6) When a sysfs file operation is being run, the module must > always exist Greg, I'm inclined to believe my original generic solution would be better again [0]. Specially since we can drop the dev_type_get() / dev_type_put() stuff. Thoughts? [0] https://lore.kernel.org/linux-block/20210401235925.GR4332@42.do-not-panic.com/ Luis