From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-182.mta0.migadu.com (out-182.mta0.migadu.com [91.218.175.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0E1B211CAB for ; Wed, 24 Jul 2024 01:57:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721786244; cv=none; b=U8xMdC1biHyLp7PhNolc9oR2enQ95OD/4ITDyGm9yrKim/D+CJsbErLscAVwEE8u+Z4hnyS+5e4lNwYUcUOSze5scYdcY8e/sx4vAmuHD8fOQbjS3LeNBr+13du222OY00uo2wuvUuKaZO2Genkaj772i7EUxznueA+MbXKhWFk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721786244; c=relaxed/simple; bh=7C93h2zHCsF3+6kcIKN1lwhv8qIcWHU+c3YseH4YRN8=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=gMBQAOy9I4aVdzIrPuMpjOwrpAs1slgxRInBicyQtiIDeaK0uijHFv1e4GqTerU3GvL4nArc3RAIYDk8asevRYxFUHBeq+7MF94uvbU5p8iusd+j4sYNDQf6o6xjJB7O0zF889iYA+fylqIC65Yp6KjxTmpsJPqlGlIoLpK1rNs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=lUesQsIH; arc=none smtp.client-ip=91.218.175.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="lUesQsIH" Message-ID: <0a63dfd1-ead3-4db3-a38c-2bc1db65f354@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1721786241; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VT5Ew9eZUkwsQ1KVPNkgUu/jPA+/4qD7R3UMmIpNcFg=; b=lUesQsIHexBh+jWlqoVfPoQhT8csj+XUHOANqoY2BmuGuj0w3JXl7qjEn8fKlhmWIu4MyB m6+1FVE7jgrSZPIA/6Vt66AejEXBEHYoH28b5QiZDgA0zvxNBykvKWvQ4zuqHjle45conT zkXWV1SOK+8igIhqo00D5A9WQNklJm4= Date: Wed, 24 Jul 2024 09:57:05 +0800 Precedence: bulk X-Mailing-List: linux-arch@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH 1/4] module: Add module_subinit{_noexit} and module_subeixt helper macros To: Christoph Hellwig Cc: Arnd Bergmann , Luis Chamberlain , Chris Mason , Josef Bacik , David Sterba , tytso@mit.edu, Andreas Dilger , Jaegeuk Kim , Chao Yu , linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-modules@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, Youling Tang References: <20240723083239.41533-1-youling.tang@linux.dev> <20240723083239.41533-2-youling.tang@linux.dev> Content-Language: en-US, en-AU X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Youling Tang In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT Hi, Christoph On 23/07/2024 22:33, Christoph Hellwig wrote: > On Tue, Jul 23, 2024 at 04:32:36PM +0800, Youling Tang wrote: >> Providing module_subinit{_noexit} and module_subeixt helps macros ensure >> that modules init/exit match their order, while also simplifying the code. >> >> The three macros are defined as follows: >> - module_subinit(initfn, exitfn,rollback) >> - module_subinit_noexit(initfn, rollback) >> - module_subexit(rollback) >> >> `initfn` is the initialization function and `exitfn` is the corresponding >> exit function. > I find the interface a little confusing. What I would have expected > is to: > > - have the module_subinit call at file scope instead of in the > module_init helper, similar to module_init/module_exit > - thus keep the rollback state explicitly in the module structure or > similar so that the driver itself doesn't need to care about at > all, and thus remove the need for the module_subexit call. module_init(initfn)/module_exit(exitfn) has two definitions (via MODULE): - buindin: uses do_initcalls() to iterate over the contents of the specified   section and executes all initfn functions in the section in the order in   which they are stored (exitfn is not required). - ko: run do_init_module(mod)->do_one_initcall(mod->init) to execute initfn   of the specified module. If we change module_subinit to something like this, not called in module_init, ``` static int init_a(void) {     ...     return 0; } static void exit_a(void) {     ... } subinitcall(init_a, exit_a); static int init_b(void) {     ...     return 0; } static void exit_b(void) {     ... } subinitcall(init_b, exit_b); ``` Not only do we want to ensure that exit is executed in reverse order of init, but we also want to ensure the order of init. This does not guarantee the order in which init will be executed (although the init/exit order will remain the same) Tanks, Youling. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 392AEC3DA49 for ; Wed, 24 Jul 2024 01:57:37 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1sWRG4-0003Vx-0k; Wed, 24 Jul 2024 01:57:36 +0000 Received: from [172.30.29.67] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1sWRG2-0003Vh-9G for linux-f2fs-devel@lists.sourceforge.net; Wed, 24 Jul 2024 01:57:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:Content-Type:In-Reply-To: From:References:Cc:To:Subject:MIME-Version:Date:Message-ID:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=VT5Ew9eZUkwsQ1KVPNkgUu/jPA+/4qD7R3UMmIpNcFg=; b=GD+2SGbY2pJtBX770nGdk4+5iR QlgHBEkrhHSWPO3+ZLVENqJaW/RjDg/oMSNAkFJZiQ1HiAeSxVrgDZckrIh7daqJy5Kaxo5KzJ1Zz bchYiJtbLxNjqQ4zeBJ9NK5BtEjbhWFbek5nB25OuHr8lCDHwv4xoOORavK95+ogg8JY=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:From:References:Cc:To: Subject:MIME-Version:Date:Message-ID:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=VT5Ew9eZUkwsQ1KVPNkgUu/jPA+/4qD7R3UMmIpNcFg=; b=kj1TMptQE8wk5uVQzahtV/cPzD 2/3y/tQUHzmNQyYTwCOAho+f6hBlBlX/IuiLN5Vf0Pb7G0FsXjO2N//YiwRr/GuEvDsR+FWlE0LPB +N6xiTzviEl3r4j0TyVAlpF2hEVYsBkN2xGQ4T3IdXw9Ep7TOvhxukGVIpgWEk0KXaVk=; Received: from out-181.mta0.migadu.com ([91.218.175.181]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1sWRG0-0001MT-UI for linux-f2fs-devel@lists.sourceforge.net; Wed, 24 Jul 2024 01:57:34 +0000 Message-ID: <0a63dfd1-ead3-4db3-a38c-2bc1db65f354@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1721786241; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VT5Ew9eZUkwsQ1KVPNkgUu/jPA+/4qD7R3UMmIpNcFg=; b=lUesQsIHexBh+jWlqoVfPoQhT8csj+XUHOANqoY2BmuGuj0w3JXl7qjEn8fKlhmWIu4MyB m6+1FVE7jgrSZPIA/6Vt66AejEXBEHYoH28b5QiZDgA0zvxNBykvKWvQ4zuqHjle45conT zkXWV1SOK+8igIhqo00D5A9WQNklJm4= Date: Wed, 24 Jul 2024 09:57:05 +0800 MIME-Version: 1.0 To: Christoph Hellwig References: <20240723083239.41533-1-youling.tang@linux.dev> <20240723083239.41533-2-youling.tang@linux.dev> Content-Language: en-US, en-AU X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Youling Tang In-Reply-To: X-Migadu-Flow: FLOW_OUT X-Headers-End: 1sWRG0-0001MT-UI Subject: Re: [f2fs-dev] [PATCH 1/4] module: Add module_subinit{_noexit} and module_subeixt helper macros X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, Youling Tang , linux-f2fs-devel@lists.sourceforge.net, tytso@mit.edu, Arnd Bergmann , Josef Bacik , linux-kernel@vger.kernel.org, Chris Mason , Luis Chamberlain , Andreas Dilger , linux-btrfs@vger.kernel.org, David Sterba , Jaegeuk Kim , linux-ext4@vger.kernel.org, linux-modules@vger.kernel.org Content-Transfer-Encoding: base64 Content-Type: text/plain; charset="utf-8"; Format="flowed" Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net SGksIENocmlzdG9waAoKT24gMjMvMDcvMjAyNCAyMjozMywgQ2hyaXN0b3BoIEhlbGx3aWcgd3Jv dGU6Cj4gT24gVHVlLCBKdWwgMjMsIDIwMjQgYXQgMDQ6MzI6MzZQTSArMDgwMCwgWW91bGluZyBU YW5nIHdyb3RlOgo+PiBQcm92aWRpbmcgbW9kdWxlX3N1YmluaXR7X25vZXhpdH0gYW5kIG1vZHVs ZV9zdWJlaXh0IGhlbHBzIG1hY3JvcyBlbnN1cmUKPj4gdGhhdCBtb2R1bGVzIGluaXQvZXhpdCBt YXRjaCB0aGVpciBvcmRlciwgd2hpbGUgYWxzbyBzaW1wbGlmeWluZyB0aGUgY29kZS4KPj4KPj4g VGhlIHRocmVlIG1hY3JvcyBhcmUgZGVmaW5lZCBhcyBmb2xsb3dzOgo+PiAtIG1vZHVsZV9zdWJp bml0KGluaXRmbiwgZXhpdGZuLHJvbGxiYWNrKQo+PiAtIG1vZHVsZV9zdWJpbml0X25vZXhpdChp bml0Zm4sIHJvbGxiYWNrKQo+PiAtIG1vZHVsZV9zdWJleGl0KHJvbGxiYWNrKQo+Pgo+PiBgaW5p dGZuYCBpcyB0aGUgaW5pdGlhbGl6YXRpb24gZnVuY3Rpb24gYW5kIGBleGl0Zm5gIGlzIHRoZSBj b3JyZXNwb25kaW5nCj4+IGV4aXQgZnVuY3Rpb24uCj4gSSBmaW5kIHRoZSBpbnRlcmZhY2UgYSBs aXR0bGUgY29uZnVzaW5nLiAgV2hhdCBJIHdvdWxkIGhhdmUgZXhwZWN0ZWQKPiBpcyB0bzoKPgo+ ICAgLSBoYXZlIHRoZSBtb2R1bGVfc3ViaW5pdCBjYWxs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