All of lore.kernel.org
 help / color / mirror / Atom feed
* [help] How to test kernel code that I wrote?
@ 2016-08-24 10:18 Louie Lu
  2016-08-24 10:23 ` Nikolay Borisov
  2016-08-25 13:35 ` Valdis.Kletnieks at vt.edu
  0 siblings, 2 replies; 7+ messages in thread
From: Louie Lu @ 2016-08-24 10:18 UTC (permalink / raw)
  To: kernelnewbies

Hi everyone,

I'm now reading *Unreliable Guide To Locking* which came from
kernelnewbies.org (https://kernelnewbies.org/Documents/Kernel-Docbooks)

What I want to do is trying run the code that in this doc from 7.1 All
In User Context.

In my knowing for kernel programming,
I'll need to compile the code to something like
`main.ko` then insert into kernel space using `insmod`.

Here is the GitHub that I'm doing PoC code:
https://github.com/grapherd/unreliable_guide_to_locking

My question is,
Is my knowing right?
and, how can I use the function in main.ko (e.g. cache_add).
I'm using these function by test.ko, is that a normal way to use it?

in this doc have mention, there have hardirq, softirq.
How can I test it from these irq method?


Thanks!
Louie Lu.

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

* [help] How to test kernel code that I wrote?
  2016-08-24 10:18 [help] How to test kernel code that I wrote? Louie Lu
@ 2016-08-24 10:23 ` Nikolay Borisov
  2016-08-24 11:39   ` Louie Lu
  2016-08-25 13:35 ` Valdis.Kletnieks at vt.edu
  1 sibling, 1 reply; 7+ messages in thread
From: Nikolay Borisov @ 2016-08-24 10:23 UTC (permalink / raw)
  To: kernelnewbies



On 08/24/2016 01:18 PM, Louie Lu wrote:
> Hi everyone,
> 
> I'm now reading *Unreliable Guide To Locking* which came from
> kernelnewbies.org (https://kernelnewbies.org/Documents/Kernel-Docbooks)
> 
> What I want to do is trying run the code that in this doc from 7.1 All
> In User Context.
> 
> In my knowing for kernel programming,
> I'll need to compile the code to something like
> `main.ko` then insert into kernel space using `insmod`.
> 
> Here is the GitHub that I'm doing PoC code:
> https://github.com/grapherd/unreliable_guide_to_locking
> 
> My question is,
> Is my knowing right?
> and, how can I use the function in main.ko (e.g. cache_add).
> I'm using these function by test.ko, is that a normal way to use it?
> 
> in this doc have mention, there have hardirq, softirq.
> How can I test it from these irq method?
> 

You have to create some sort of an interface which utilizes those kernel
function. That might be IOCTL or procfiles or debugfs or any other
number of UM<=>KM interfaces.


> 
> Thanks!
> Louie Lu.
> 
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
> 

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

* [help] How to test kernel code that I wrote?
  2016-08-24 10:23 ` Nikolay Borisov
@ 2016-08-24 11:39   ` Louie Lu
  2016-08-24 23:27     ` Dave Hylands
  0 siblings, 1 reply; 7+ messages in thread
From: Louie Lu @ 2016-08-24 11:39 UTC (permalink / raw)
  To: kernelnewbies

2016-08-24 18:23 GMT+08:00 Nikolay Borisov <n.borisov.lkml@gmail.com>:
>
>
> On 08/24/2016 01:18 PM, Louie Lu wrote:
>> Hi everyone,
>>
>> I'm now reading *Unreliable Guide To Locking* which came from
>> kernelnewbies.org (https://kernelnewbies.org/Documents/Kernel-Docbooks)
>>
>> What I want to do is trying run the code that in this doc from 7.1 All
>> In User Context.
>>
>> In my knowing for kernel programming,
>> I'll need to compile the code to something like
>> `main.ko` then insert into kernel space using `insmod`.
>>
>> Here is the GitHub that I'm doing PoC code:
>> https://github.com/grapherd/unreliable_guide_to_locking
>>
>> My question is,
>> Is my knowing right?
>> and, how can I use the function in main.ko (e.g. cache_add).
>> I'm using these function by test.ko, is that a normal way to use it?
>>
>> in this doc have mention, there have hardirq, softirq.
>> How can I test it from these irq method?
>>
>
> You have to create some sort of an interface which utilizes those kernel
> function. That might be IOCTL or procfiles or debugfs or any other
> number of UM<=>KM interfaces.
>

Thanks for reply, I'm now looking for procfs example,

like this: http://www.tldp.org/LDP/lkmpg/2.6/html/x710.html
or this: https://kernelnewbies.org/Documents/Kernel-Docbooks?action=AttachFile&do=get&target=procfs-guide_2.6.29.pdf

But it seems that all this tutorial were deprecate,
since 3.10 change for proc_create_entry()

Are there any resource for procfs to leran?

thanks!.

Louie Lu.

>
>>
>> Thanks!
>> Louie Lu.
>>
>> _______________________________________________
>> Kernelnewbies mailing list
>> Kernelnewbies at kernelnewbies.org
>> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>>

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

* [help] How to test kernel code that I wrote?
  2016-08-24 11:39   ` Louie Lu
@ 2016-08-24 23:27     ` Dave Hylands
  2016-08-25  8:04       ` Louie Lu
  0 siblings, 1 reply; 7+ messages in thread
From: Dave Hylands @ 2016-08-24 23:27 UTC (permalink / raw)
  To: kernelnewbies

You may want to look at this free course on kernel programming:
http://crashcourse.ca/introduction-linux-kernel-programming/introduction-
linux-kernel-programming
I believe that the entire course is free now (even though it mentions
costing $39).

It has a section on creating proc filesystem entries.

On Wed, Aug 24, 2016 at 4:39 AM, Louie Lu <louie.lu@hopebaytech.com> wrote:

> 2016-08-24 18:23 GMT+08:00 Nikolay Borisov <n.borisov.lkml@gmail.com>:
> >
> >
> > On 08/24/2016 01:18 PM, Louie Lu wrote:
> >> Hi everyone,
> >>
> >> I'm now reading *Unreliable Guide To Locking* which came from
> >> kernelnewbies.org (https://kernelnewbies.org/Documents/Kernel-Docbooks)
> >>
> >> What I want to do is trying run the code that in this doc from 7.1 All
> >> In User Context.
> >>
> >> In my knowing for kernel programming,
> >> I'll need to compile the code to something like
> >> `main.ko` then insert into kernel space using `insmod`.
> >>
> >> Here is the GitHub that I'm doing PoC code:
> >> https://github.com/grapherd/unreliable_guide_to_locking
> >>
> >> My question is,
> >> Is my knowing right?
> >> and, how can I use the function in main.ko (e.g. cache_add).
> >> I'm using these function by test.ko, is that a normal way to use it?
> >>
> >> in this doc have mention, there have hardirq, softirq.
> >> How can I test it from these irq method?
> >>
> >
> > You have to create some sort of an interface which utilizes those kernel
> > function. That might be IOCTL or procfiles or debugfs or any other
> > number of UM<=>KM interfaces.
> >
>
> Thanks for reply, I'm now looking for procfs example,
>
> like this: http://www.tldp.org/LDP/lkmpg/2.6/html/x710.html
> or this: https://kernelnewbies.org/Documents/Kernel-Docbooks?
> action=AttachFile&do=get&target=procfs-guide_2.6.29.pdf
>
> But it seems that all this tutorial were deprecate,
> since 3.10 change for proc_create_entry()
>
> Are there any resource for procfs to leran?
>
> thanks!.
>
> Louie Lu.
>
> >
> >>
> >> Thanks!
> >> Louie Lu.
> >>
> >> _______________________________________________
> >> Kernelnewbies mailing list
> >> Kernelnewbies at kernelnewbies.org
> >> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
> >>
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>



-- 
Dave Hylands
Shuswap, BC, Canada
http://www.davehylands.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20160824/45053ee1/attachment.html 

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

* [help] How to test kernel code that I wrote?
  2016-08-24 23:27     ` Dave Hylands
@ 2016-08-25  8:04       ` Louie Lu
  2016-08-25 13:32         ` Valdis.Kletnieks at vt.edu
  0 siblings, 1 reply; 7+ messages in thread
From: Louie Lu @ 2016-08-25  8:04 UTC (permalink / raw)
  To: kernelnewbies

> You may want to look at this free course on kernel programming:
> http://crashcourse.ca/introduction-linux-kernel-programming/introduction-linux-kernel-programming
> I believe that the entire course is free now (even though it mentions costing $39).
>
> It has a section on creating proc filesystem entries.

Thanks for this tutorial, that's great.

I'm now writing some procfs code and testing on my laptop.

Is that I'll need to use VM to test the code,
or just test it on my laptop?

I found that if sometimes I broke my code (e.g. can't remove modules,
modules panic ...etc)
I need to reboot my laptop to recover from this situation.

Is that how a true kernel developer does?
or they will open a VM to test it, then test on real hardware PC.


Thanks!

2016-08-25 7:27 GMT+08:00 Dave Hylands <dhylands@gmail.com>:
> You may want to look at this free course on kernel programming:
> http://crashcourse.ca/introduction-linux-kernel-programming/introduction-linux-kernel-programming
> I believe that the entire course is free now (even though it mentions
> costing $39).
>
> It has a section on creating proc filesystem entries.
>
> On Wed, Aug 24, 2016 at 4:39 AM, Louie Lu <louie.lu@hopebaytech.com> wrote:
>>
>> 2016-08-24 18:23 GMT+08:00 Nikolay Borisov <n.borisov.lkml@gmail.com>:
>> >
>> >
>> > On 08/24/2016 01:18 PM, Louie Lu wrote:
>> >> Hi everyone,
>> >>
>> >> I'm now reading *Unreliable Guide To Locking* which came from
>> >> kernelnewbies.org (https://kernelnewbies.org/Documents/Kernel-Docbooks)
>> >>
>> >> What I want to do is trying run the code that in this doc from 7.1 All
>> >> In User Context.
>> >>
>> >> In my knowing for kernel programming,
>> >> I'll need to compile the code to something like
>> >> `main.ko` then insert into kernel space using `insmod`.
>> >>
>> >> Here is the GitHub that I'm doing PoC code:
>> >> https://github.com/grapherd/unreliable_guide_to_locking
>> >>
>> >> My question is,
>> >> Is my knowing right?
>> >> and, how can I use the function in main.ko (e.g. cache_add).
>> >> I'm using these function by test.ko, is that a normal way to use it?
>> >>
>> >> in this doc have mention, there have hardirq, softirq.
>> >> How can I test it from these irq method?
>> >>
>> >
>> > You have to create some sort of an interface which utilizes those kernel
>> > function. That might be IOCTL or procfiles or debugfs or any other
>> > number of UM<=>KM interfaces.
>> >
>>
>> Thanks for reply, I'm now looking for procfs example,
>>
>> like this: http://www.tldp.org/LDP/lkmpg/2.6/html/x710.html
>> or this:
>> https://kernelnewbies.org/Documents/Kernel-Docbooks?action=AttachFile&do=get&target=procfs-guide_2.6.29.pdf
>>
>> But it seems that all this tutorial were deprecate,
>> since 3.10 change for proc_create_entry()
>>
>> Are there any resource for procfs to leran?
>>
>> thanks!.
>>
>> Louie Lu.
>>
>> >
>> >>
>> >> Thanks!
>> >> Louie Lu.
>> >>
>> >> _______________________________________________
>> >> Kernelnewbies mailing list
>> >> Kernelnewbies at kernelnewbies.org
>> >> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>> >>
>>
>> _______________________________________________
>> Kernelnewbies mailing list
>> Kernelnewbies at kernelnewbies.org
>> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
>
>
>
> --
> Dave Hylands
> Shuswap, BC, Canada
> http://www.davehylands.com

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

* [help] How to test kernel code that I wrote?
  2016-08-25  8:04       ` Louie Lu
@ 2016-08-25 13:32         ` Valdis.Kletnieks at vt.edu
  0 siblings, 0 replies; 7+ messages in thread
From: Valdis.Kletnieks at vt.edu @ 2016-08-25 13:32 UTC (permalink / raw)
  To: kernelnewbies

On Thu, 25 Aug 2016 16:04:58 +0800, Louie Lu said:

> Is that I'll need to use VM to test the code,
> or just test it on my laptop?
>
> I found that if sometimes I broke my code (e.g. can't remove modules,
> modules panic ...etc)
> I need to reboot my laptop to recover from this situation.
>
> Is that how a true kernel developer does?
> or they will open a VM to test it, then test on real hardware PC.

There's no such thing as a "true kernel developer".  Some run their
code in a VM because their code is something that can be tested in a VM,
some test on a real hardware PC, some write the build onto a flash
card and put it in a non-PC system (usually an ARM or MIPS based
embedded device).

All depends what your resources are, and what code you're testing.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 848 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20160825/88727042/attachment.bin 

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

* [help] How to test kernel code that I wrote?
  2016-08-24 10:18 [help] How to test kernel code that I wrote? Louie Lu
  2016-08-24 10:23 ` Nikolay Borisov
@ 2016-08-25 13:35 ` Valdis.Kletnieks at vt.edu
  1 sibling, 0 replies; 7+ messages in thread
From: Valdis.Kletnieks at vt.edu @ 2016-08-25 13:35 UTC (permalink / raw)
  To: kernelnewbies

On Wed, 24 Aug 2016 18:18:18 +0800, Louie Lu said:

> in this doc have mention, there have hardirq, softirq.
> How can I test it from these irq method?
>

First, figure out if the code in question should even be called
from those contexts, or if it's a bug if that happens.
Hard and soft IRQ contexts are basically interrupt handlers. If your
code is a "hello world" module, or if it's filesystem code, or
pretty much any part of the kernel that's not a device driver, it
probably should not be called from IRQ context.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 848 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20160825/b2191fc8/attachment.bin 

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

end of thread, other threads:[~2016-08-25 13:35 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-24 10:18 [help] How to test kernel code that I wrote? Louie Lu
2016-08-24 10:23 ` Nikolay Borisov
2016-08-24 11:39   ` Louie Lu
2016-08-24 23:27     ` Dave Hylands
2016-08-25  8:04       ` Louie Lu
2016-08-25 13:32         ` Valdis.Kletnieks at vt.edu
2016-08-25 13:35 ` Valdis.Kletnieks at vt.edu

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.