All of lore.kernel.org
 help / color / mirror / Atom feed
* Iterating through all the processes in a module
@ 2012-02-07 17:45 Arokux B.
  2012-02-07 19:17 ` Greg KH
  0 siblings, 1 reply; 8+ messages in thread
From: Arokux B. @ 2012-02-07 17:45 UTC (permalink / raw)
  To: kernelnewbies

Hi,

(for learning purposes) I would like to iterate through all the tasks
in a module and output different information about them. For this task
I need to lock the list of all tasks (need I?). I've seen some example
in the kernel code which lock tasklist_lock. However this symbol
cannot be used by modules. Its export was removed by
c59923a15c12d2b3597af913bf234a0ef264a38b commit.

Is there any other way I can lock the list of tasks then?

Thanks

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Iterating through all the processes in a module
  2012-02-07 17:45 Iterating through all the processes in a module Arokux B.
@ 2012-02-07 19:17 ` Greg KH
  2012-02-22 13:07   ` Arokux B.
  0 siblings, 1 reply; 8+ messages in thread
From: Greg KH @ 2012-02-07 19:17 UTC (permalink / raw)
  To: kernelnewbies

On Tue, Feb 07, 2012 at 06:45:24PM +0100, Arokux B. wrote:
> Hi,
> 
> (for learning purposes) I would like to iterate through all the tasks
> in a module and output different information about them. For this task
> I need to lock the list of all tasks (need I?). I've seen some example
> in the kernel code which lock tasklist_lock. However this symbol
> cannot be used by modules. Its export was removed by
> c59923a15c12d2b3597af913bf234a0ef264a38b commit.
> 
> Is there any other way I can lock the list of tasks then?

Don't do such a foolish thing?  :)

Seriously, don't make your code a module, just build it into the kernel.

greg k-h

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Iterating through all the processes in a module
  2012-02-07 19:17 ` Greg KH
@ 2012-02-22 13:07   ` Arokux B.
  2012-02-22 14:53     ` Greg KH
  2012-02-22 15:30     ` Ezequiel García
  0 siblings, 2 replies; 8+ messages in thread
From: Arokux B. @ 2012-02-22 13:07 UTC (permalink / raw)
  To: kernelnewbies

Dear Greg,

thank you very much for your quick reply.

Having my code as a module I can trigger its execution (load a module)
and disable it (unload a module). How can I achieve this if the code
is inside the kernel? One possibility I see is adding an entry in the
procfs.

Regards

On Tue, Feb 7, 2012 at 8:17 PM, Greg KH <gregkh@linuxfoundation.org> wrote:
> On Tue, Feb 07, 2012 at 06:45:24PM +0100, Arokux B. wrote:
>> Hi,
>>
>> (for learning purposes) I would like to iterate through all the tasks
>> in a module and output different information about them. For this task
>> I need to lock the list of all tasks (need I?). I've seen some example
>> in the kernel code which lock tasklist_lock. However this symbol
>> cannot be used by modules. Its export was removed by
>> c59923a15c12d2b3597af913bf234a0ef264a38b commit.
>>
>> Is there any other way I can lock the list of tasks then?
>
> Don't do such a foolish thing? ?:)
>
> Seriously, don't make your code a module, just build it into the kernel.
>
> greg k-h

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Iterating through all the processes in a module
  2012-02-22 13:07   ` Arokux B.
@ 2012-02-22 14:53     ` Greg KH
  2012-02-23 11:12       ` Srivatsa Bhat
  2012-02-22 15:30     ` Ezequiel García
  1 sibling, 1 reply; 8+ messages in thread
From: Greg KH @ 2012-02-22 14:53 UTC (permalink / raw)
  To: kernelnewbies


A: No.
Q: Should I include quotations after my reply?

http://daringfireball.net/2007/07/on_top

On Wed, Feb 22, 2012 at 02:07:22PM +0100, Arokux B. wrote:
> Dear Greg,
> 
> thank you very much for your quick reply.
> 
> Having my code as a module I can trigger its execution (load a module)
> and disable it (unload a module). How can I achieve this if the code
> is inside the kernel? One possibility I see is adding an entry in the
> procfs.

I don't see what procfs has to do with this, please explain.

And as you said this was for "learning purposes", then just build it
into the kernel, there's no need for it to be a module.

good luck,

greg k-h

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Iterating through all the processes in a module
  2012-02-22 13:07   ` Arokux B.
  2012-02-22 14:53     ` Greg KH
@ 2012-02-22 15:30     ` Ezequiel García
  2012-02-22 16:43       ` Javier Martinez Canillas
  1 sibling, 1 reply; 8+ messages in thread
From: Ezequiel García @ 2012-02-22 15:30 UTC (permalink / raw)
  To: kernelnewbies

Hi Arokux,

On 2/22/12, Arokux B. <arokux@gmail.com> wrote:
> Having my code as a module I can trigger its execution (load a module)
> and disable it (unload a module). How can I achieve this if the code
> is inside the kernel? One possibility I see is adding an entry in the
> procfs.

I think you want to have the kernel execute some code of yours just for learning
purposes right?
So, your question could be put like this:
Where are the "doors" for me -userspace- to enter to the kernel?

In that case, I believe the "canonical" answer is: system calls.
If you have a copy of Love's book you could look there, or you could
just search through the
code and look how system calls are implemented and add own of your own.
Perhaps you could even modify one. You can search all syscalls definitions with:

grep "SYSCALL_DEFINE" `find . -name "*.c"`

Actually, that's the path I would take if I were to try this. You can
pick a simple syscall
like "getcwd", defined in fs/dcache.c and just add my test code there. That way
every time you call pwd in your shell, you get your code called (you
can check with
strace).

Hope this helps,
Ezequiel.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Iterating through all the processes in a module
  2012-02-22 15:30     ` Ezequiel García
@ 2012-02-22 16:43       ` Javier Martinez Canillas
  2012-02-23 11:07         ` Arokux B.
  0 siblings, 1 reply; 8+ messages in thread
From: Javier Martinez Canillas @ 2012-02-22 16:43 UTC (permalink / raw)
  To: kernelnewbies

2012/2/22 Ezequiel Garc?a <elezegarcia@gmail.com>:
> Hi Arokux,
>
> On 2/22/12, Arokux B. <arokux@gmail.com> wrote:
>> Having my code as a module I can trigger its execution (load a module)
>> and disable it (unload a module). How can I achieve this if the code
>> is inside the kernel? One possibility I see is adding an entry in the
>> procfs.
>
> I think you want to have the kernel execute some code of yours just for learning
> purposes right?
> So, your question could be put like this:
> Where are the "doors" for me -userspace- to enter to the kernel?
>
> In that case, I believe the "canonical" answer is: system calls.
> If you have a copy of Love's book you could look there, or you could
> just search through the
> code and look how system calls are implemented and add own of your own.
> Perhaps you could even modify one. You can search all syscalls definitions with:
>
> grep "SYSCALL_DEFINE" `find . -name "*.c"`
>
> Actually, that's the path I would take if I were to try this. You can
> pick a simple syscall
> like "getcwd", defined in fs/dcache.c and just add my test code there. That way
> every time you call pwd in your shell, you get your code called (you
> can check with
> strace).
>
> Hope this helps,
> Ezequiel.
>

This is also a good summary of Kernel space / User space interfaces

http://people.ee.ethz.ch/~arkeller/linux/kernel_user_space_howto.html

Hope it helps,

-- 
Javier Mart?nez Canillas
(+34) 682 39 81 69
Barcelona, Spain

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Iterating through all the processes in a module
  2012-02-22 16:43       ` Javier Martinez Canillas
@ 2012-02-23 11:07         ` Arokux B.
  0 siblings, 0 replies; 8+ messages in thread
From: Arokux B. @ 2012-02-23 11:07 UTC (permalink / raw)
  To: kernelnewbies

Hi all,

thank you very much guys. Your answers helped me to realize what I
really wanted to do.

Best regards,
Arokux

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Iterating through all the processes in a module
  2012-02-22 14:53     ` Greg KH
@ 2012-02-23 11:12       ` Srivatsa Bhat
  0 siblings, 0 replies; 8+ messages in thread
From: Srivatsa Bhat @ 2012-02-23 11:12 UTC (permalink / raw)
  To: kernelnewbies

On Wed, Feb 22, 2012 at 8:23 PM, Greg KH <greg@kroah.com> wrote:

>
> A: No.
> Q: Should I include quotations after my reply?
>
> http://daringfireball.net/2007/07/on_top
>
> On Wed, Feb 22, 2012 at 02:07:22PM +0100, Arokux B. wrote:
> > Dear Greg,
> >
> > thank you very much for your quick reply.
> >
> > Having my code as a module I can trigger its execution (load a module)
> > and disable it (unload a module). How can I achieve this if the code
> > is inside the kernel? One possibility I see is adding an entry in the
> > procfs.
>
> I don't see what procfs has to do with this, please explain.
>
> And as you said this was for "learning purposes", then just build it
> into the kernel, there's no need for it to be a module.
>
>
Heh, you can just put back the relevant parts of what commit
c59923a15c12d2b3597af913bf234a0ef264a38b removed and then do what
you want as a module, if it is for learning purposes :-)

Regards,
Srivatsa S. Bhat
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20120223/52b52959/attachment.html 

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-02-23 11:12 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-07 17:45 Iterating through all the processes in a module Arokux B.
2012-02-07 19:17 ` Greg KH
2012-02-22 13:07   ` Arokux B.
2012-02-22 14:53     ` Greg KH
2012-02-23 11:12       ` Srivatsa Bhat
2012-02-22 15:30     ` Ezequiel García
2012-02-22 16:43       ` Javier Martinez Canillas
2012-02-23 11:07         ` Arokux B.

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.