Re: Reg : module init and exit function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>The reason should be we are never going to unload the module. once the
>linux is shutdown its going to poweroff the cpu so no need to cleanup.

But what if there are some operations specified in the exit function of module for cleaning up, which is specific to the module e.g. flushing some module related stuff to the disk? If exit is never called such a module will not work properly because it would expect some operation go be performed in the exit function but actually exit will not be called.
Though I am also not sure if exit will get called if compiler with the kernel.

On Wed, Nov 5, 2008 at 4:31 AM, Mohamed Thalib .H <h.mohamedthalib@xxxxxxxxxxxxx> wrote:
On Wed, 2008-11-05 at 13:24 +0500, Nauman Tahir wrote:
> On Tue, Nov 4, 2008 at 11:03 AM, Santosh <ssantosh@xxxxxxxxxx> wrote:
> > Mohamed Thalib .H wrote:
> >>
> >> On Tue, 2008-11-04 at 11:14 +0530, Santosh wrote:
> >>>
> >>> Manish Katiyar wrote:
> >>>>
> >>>> On Tue, Nov 4, 2008 at 9:48 AM, Santosh <ssantosh@xxxxxxxxxx> wrote:
> >>>>>
> >>>>> Mohamed Thalib .H wrote:
> >>>>>>
> >>>>>> Hi all,
> >>>>>>
> >>>>>>       I have a doubt
> >>>>>>
> >>>>>>       Whether the code that is inside the moudles init and exit
> >>>>>> function
> >>>>>> will
> >>>>>> be executed if the module is not compiled as module and it is compiled
> >>>>>> into the kernel image itself.
> >>>>>>
> >>>>>>
> >>>>>       The module's init fucntion will be run even if it is compiled
> >>>>> statically into the kernel image. The exit function won't be run since
> >>>>> it
> >>>>> can't be unloaded from the memory.
> >>>>>
> >>>>>       In case where the kernel is configured not to unload modules the
> >>>>> exit
> >>>>> function will never be run since the module never unloads. Once the
> >>>>> init
> >>>>> function is executed the function itself is discarded since it won't be
> >>>>> needed later.
> >>>>
> >>>> Correct........and that is the memory you see when you see your bootup
> >>>> messages.  Something like
> >>>>
> >>>> "Freed 128K of memory ....."
> >>>>
> >>>> But I think for that you have to declare with __init or can it take
> >>>> this decision by default ???
> >>>
> >>> Yes, I guess to be freed up we use __init macro. Can it do this by
> >>> default, I am not sure.
> >>>>
> >>>> Thanks -
> >>>> Manish
> >>>
> >>
> >>> From the above i understand that once the __init code is complete then
> >>
> >> it will be completely remove out of memory and it will be no longer
> >> avaliable ..
> >>
> >> am I correct.
> >>
> >> and what about the __exit will it be included in the compile time or
> >> not.
> >>
> >> if included will it be removed at the time of executing free_initmem()
> >> function. - i dont think so on seeing the code it looks like it frees
> >> only the __init section. so the __exit section should be excluded in the
> >> kernel compile time itself.
> >>
> >> correct me if i am wrong.
> >>
> >
> > The exit function will not be included if the kernel is configured not to
> > unload the modules.
> What about if we want to do some book keeping/ cleanup while unloading linux itself ??? ( on reboot/shutdowns). I mean i dont understand why exit/cleanup function would not be required (even in the case of statically linked???)
>
> Regards
> Nauman

The reason should be we are never going to unload the module. once the
linux is shutdown its going to poweroff the cpu so no need to cleanup.
in case of reboot all the cpu registers will reset to its initial value
and the devices in the board too should be reseted.



--
Best Regards,
Mohamed Thalib .H


--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ




--
http://linuxexplained.blogspot.com

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux