Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8306213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:17:06+00:00 2026-06-08T18:17:06+00:00

I was reading about linux kernel development and I just read some text that

  • 0

I was reading about linux kernel development and I just read some text that I don’t understand. Here is the paragraph, which talks about the __init and __exit macros for modules:

This demonstrates a feature of kernel 2.2 and later. Notice the change
in the definitions of the init and cleanup functions. The __init macro
causes the init function to be discarded and its memory freed once the
init function finishes for built−in drivers, but not loadable modules.
If you think about when the init function is invoked, this makes
perfect sense.

There is also an __initdata
which works similarly to __init but for init variables rather than
functions.

The __exit macro causes the omission of the function when
the module is built into the kernel, and like
__exit, has no effect for loadable modules. Again, if you consider when the cleanup function runs

I get the point; the macro __init causes the init function to be discarded and its memory freed once the init function finishes for built-in drivers. But why? not for loadable modules? I couldn’t make sense of it.

I know it’s a silly thing, but I thought about it for some time and couldn’t comprehend it fully. Why for built-in driver but not for loadable modules? Variables, addresses etc assigned in __init would be required for the both, right?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T18:17:07+00:00Added an answer on June 8, 2026 at 6:17 pm

    You’re right; even in a module there could be functions that you really don’t need after initialization, and so they could in principle be removed from memory. The reason __init has no effect for modules is more about how easy it would be to implement.

    This answer to a question about the nature of __init sheds some light on the subject. Essentially, the kernel build system looks for all of the functions flagged with __init, across all of the pieces of the kernel, and arranges them so that they will all be in the same block of memory.

    Then, when the kernel boots, it can free that one block of memory all at once.

    This pre-sorting idea doesn’t work so well with modules. The init code has to be loaded when the module is loaded, so it can’t share space with other init code. Instead, the kernel would have to pick a few hundred bytes out of each module and free them individually.

    However, hardware page sizes are typically 4KB, so it’s hard to free up memory in chunks of less than that. So trying to free the __init functions in each individual module is probably more trouble than it’s worth.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay, I'm reading about Linux kernel development and there are some code snippets using
Reading about Delphi's Exit statement (see here for instance), I cannot ignore that writing
I've been reading up on Linux's "swappiness" tuneable, which controls how aggressive the kernel
I have just started reading about threading in C, using pthreads. I know that
ok. I was reading about cassandra and every article i read mentioned that writes
I have been reading about this Sony vs GeoHot case. I however don't understand
I remember reading some books about Linux Device drivers around the end of my
I am reading some linux assembly manuals and found idea about using printf() function.
When reading about pipes in Advanced Programming in the UNIX Environment, I noticed that
Was just reading about different algos disassemblers use to identify binary as assembly instructions.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.