Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp4287417pxb; Tue, 2 Nov 2021 07:17:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwwsJZLLPpZfOWphYR0j/e7u546xjtn2ac8qEv6oMZXprhZtuNnkXHhDodXwgzXQVFYjQtp X-Received: by 2002:a05:6402:40d0:: with SMTP id z16mr22141355edb.340.1635862678980; Tue, 02 Nov 2021 07:17:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635862678; cv=none; d=google.com; s=arc-20160816; b=WhLSReH56mC5xt1LOErvRxKwl+jMtPLupCyuGj+IAbRkxc5q1UoLNLFFsaKAEwm+QV l1KCQjMaFKGEbtVT58eaYL/1cYiR/4wT9dc/XeOLvCqVMv4UrrUOdvmyvIarIyqIM6+P vQOHM2iM5JPmu/5li4Puqum3PfG/mJK71slTvzJVJmhg/Hihu8Oh/595fZg4+XRc7hsC iC8cdyG3Zzy1SClc4P6cRGUt5CW4Vd9fR8fFeddRZFfuDL/HyWSU7g+lL05+naj76sMs z3vXVC/vxwJQEdvIvd/ysuqAsBawdmcY2btL0Tmsh9r2OJYuKyWSmrbQzr6+FdqOx/hi SGRg== 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:dkim-signature; bh=xFpCDtO7PInDq/3jdlZmBNoQmZmKE1sd4nUqSIlkTbE=; b=USRKO38+iQGzI96W7T0WWqew3XxxaX/hWyBO78Z91Cf8oWq4EJv7/gUMPOmAvLIZP6 EZ5whXzbAd0y/2Zcc2oF3EBXnDd+BRd5870ra3Kk4VcoUeRgnjdIsddF7Yv0GpI8+OOA GLiLKG1U24nPjZsi2IAGbxgnmc2dxgHK0JTFKO4kGTsUlLsAs3QkGWgJ+9X2tb2wHFfp uf+67NnfcoDtJtOsDWY6/JGz0jqc+QYkKCJzZaDNbMpzZi7ZNPpraFMpDOjZ9i0sYRYi owcZQwJH4tchm/d329DHLaj93t4jymn0oDlZvFPiU2GSkSmU7kdORdKPZz2vw5sMYxwt orDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=gRg9lKwl; 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=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qw11si4292602ejc.59.2021.11.02.07.17.32; Tue, 02 Nov 2021 07:17:58 -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=@suse.com header.s=susede1 header.b=gRg9lKwl; 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=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229530AbhKBOSA (ORCPT + 99 others); Tue, 2 Nov 2021 10:18:00 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:51556 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229981AbhKBORy (ORCPT ); Tue, 2 Nov 2021 10:17:54 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id DA6F62190C; Tue, 2 Nov 2021 14:15:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1635862517; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=xFpCDtO7PInDq/3jdlZmBNoQmZmKE1sd4nUqSIlkTbE=; b=gRg9lKwlLjnDx6mCQy5M02cnZmit4lXJJrtjo+HMQTzOb0iwvl8CTZIh6RKkA+lpqn++ol ohAiDp+5dkQNQJebie5mI3DHo57q+OuUSHa/tdu3iJEjMXE5e3OKad8Fn/SAPZ/9FShwrd 7XCNw7awdMa9MkhCOWcAhtZRuC36ggA= Received: from suse.cz (unknown [10.100.216.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 5F626A3B83; Tue, 2 Nov 2021 14:15:17 +0000 (UTC) Date: Tue, 2 Nov 2021 15:15:15 +0100 From: Petr Mladek To: Ming Lei Cc: Miroslav Benes , Luis Chamberlain , Benjamin Herrenschmidt , Paul Mackerras , tj@kernel.org, gregkh@linuxfoundation.org, akpm@linux-foundation.org, minchan@kernel.org, jeyu@kernel.org, shuah@kernel.org, bvanassche@acm.org, dan.j.williams@intel.com, joe@perches.com, tglx@linutronix.de, keescook@chromium.org, rostedt@goodmis.org, linux-spdx@vger.kernel.org, linux-doc@vger.kernel.org, linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, live-patching@vger.kernel.org Subject: Re: [PATCH v8 11/12] zram: fix crashes with cpu hotplug multistate Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue 2021-10-26 23:37:30, Ming Lei wrote: > On Tue, Oct 26, 2021 at 10:48:18AM +0200, Petr Mladek wrote: > > Below are more details about the livepatch code. I hope that it will > > help you to see if zram has similar problems or not. > > > > We have kobject in three structures: klp_func, klp_object, and > > klp_patch, see include/linux/livepatch.h. > > > > These structures have to be statically defined in the module sources > > because they define what is livepatched, see > > samples/livepatch/livepatch-sample.c > > > > The kobject is used there to show information about the patch, patched > > objects, and patched functions, in sysfs. And most importantly, > > the sysfs interface can be used to disable the livepatch. > > > > The problem with static structures is that the module must stay > > in the memory as long as the sysfs interface exists. It can be > > solved in module_exit() callback. It could wait until the sysfs > > interface is destroyed. > > > > kobject API does not support this scenario. The relase() callbacks > > kobject_delete() is for supporting this scenario, that is why we don't > need to grab module refcnt before calling show()/store() of the > kobject's attributes. > > kobject_delete() can be called in module_exit(), then any show()/store() > will be done after kobject_delete() returns. I am a bit confused. I do not see kobject_delete() anywhere in kernel sources. I see only kobject_del() and kobject_put(). AFAIK, they do _not_ guarantee that either the sysfs interface was destroyed or the release callbacks were called. For example, see schedule_delayed_work(&kobj->release, delay) in kobject_release(). By other words, anyone could still be using either the sysfs interface or the related structures after kobject_del() or kobject_put() returns. IMHO, kobject API does not support static structures and module removal. Best Regards, Petr