Find the answer to your Linux question:
Results 1 to 8 of 8
Hi, I've programmed a kernel module which connects to another kernel module with a certain load parameter and manages data between that kernel module and user space accessible shared memory. ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Oct 2008
    Posts
    4

    Arrow How to load a kernel module twice?


    Hi,

    I've programmed a kernel module which connects to another kernel module with a certain load parameter and manages data between that kernel module and user space accessible shared memory.

    For different devices there are different shared memories and different parameter values while talking to the another kernel module.
    I've designed my module to work just with one device and one associated shared memory, but the problem is, I may not load the module more than once with the same name.

    If I do compile the source twice, original and via a soft link (ln -s a.c b.c), the resulting a.ko, b.ko are loadable and working at the same time because everything in there is private.

    So the final question is:

    Is there a normal way to make a kernel module loadable more than once?

  2. #2
    Just Joined!
    Join Date
    Oct 2008
    Location
    Sialkot
    Posts
    3
    I think you need to remove the one you loaded 1st and then again ...

    using command "rmmod your_module_Name"

  3. #3
    Just Joined!
    Join Date
    Oct 2008
    Posts
    4
    Quote Originally Posted by speedytangent View Post
    I think you need to remove the one you loaded 1st and then again ...
    Would it then still do something?

    No, what I need is:

    insmod a.ko param=0
    insmod a.ko param=1
    ....
    insmod a.ko param=7

    And all of them should work in parallel, but for different devices and different shared memories.

  4. $spacer_open
    $spacer_close
  5. #4
    Just Joined!
    Join Date
    May 2008
    Posts
    55
    I think,
    recompile the module with different name, and put it

  6. #5
    Just Joined!
    Join Date
    Oct 2008
    Posts
    4
    Quote Originally Posted by matt_kleviar View Post
    I think,
    recompile the module with different name, and put it
    That's basically what I wrote first, about the soft link method.

    But I've asked for a regular way, but there's seems to be none. So I'll will have to rewrite the code having a loop over the devices inside the module.

  7. #6
    Just Joined!
    Join Date
    Nov 2008
    Posts
    2
    Rethinking on design might help. You can maintain a data structure for each individual device and maintain a some kind of list/queue/arrary (depends on your requirement).

  8. #7
    Just Joined!
    Join Date
    Nov 2008
    Posts
    5

    Use aliases

    Use the function: dev_alloc_name(<name>) it will create your module in specific name.

  9. #8
    Just Joined!
    Join Date
    Oct 2008
    Posts
    4
    Quote Originally Posted by wassim_dagash View Post
    Use the function: dev_alloc_name(<name>) it will create your module in specific name.
    Thanks, I'll try that.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •