Re: How to check if my kernel driver is leaking memory

2014-03-10 Thread Valdis . Kletnieks
On Sun, 09 Mar 2014 22:14:24 -0700, m silverstri said:

 I am developing a kernel driver. What should I test to make sure my
 kernel driver is not leaking memory?

1) The brute force method - just add lots of printk's that have
allocating 25-byte frobozz struct and freeing 25-byte frobozz struct
and make sure they match up.

2) kmemleak.

 1. under normal operation (when applications open and close my driver 
 properly)
 2. in error situation (when application open my driver and then it
 crashes without close my driver property)

Case (2) shouldn't happen, as even if a program crashes the kernel *should*
be invoking the cleanup of open files at process termination.

A more common cause of memory leaks is for an open() or read/write/ioctl()
path to allocate N chunks of memory, hit an error, and return after having
cleaned up only N-1 of the chunks.  This is part of why most kernel code
uses a 'goto error' structure with only one return; at the end of the function.



pgpXDk8WMFJrj.pgp
Description: PGP signature
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Kernelnewbies Digest, Vol 40, Issue 16

2014-03-10 Thread Brian Brzezicki
Ok they are gone part of the order did not come in. Though it's working and the 
inside is setup very pretty. You can adjust the stones and sand there is extra 
or both on the bed.

---
Please excuse If this message is overly terse. It is because it is being sent 
on my iPad.

 On Mar 10, 2014, at 12:00 PM, kernelnewbies-requ...@kernelnewbies.org wrote:
 
 Send Kernelnewbies mailing list submissions to
kernelnewbies@kernelnewbies.org
 
 To subscribe or unsubscribe via the World Wide Web, visit
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
 or, via email, send a message with subject or body 'help' to
kernelnewbies-requ...@kernelnewbies.org
 
 You can reach the person managing the list at
kernelnewbies-ow...@kernelnewbies.org
 
 When replying, please edit your Subject line so it is more specific
 than Re: Contents of Kernelnewbies digest...
 
 
 Today's Topics:
 
   1. How to check if my kernel driver is leaking memory (m silverstri)
   2. Re: How to check if my kernel driver is leaking memory
  (valdis.kletni...@vt.edu)
 
 
 --
 
 Message: 1
 Date: Sun, 9 Mar 2014 22:14:24 -0700
 From: m silverstri michael.j.silvers...@gmail.com
 Subject: How to check if my kernel driver is leaking memory
 To: kernelnewbies kernelnewbies@kernelnewbies.org
 Message-ID:
cabmudhtc8c9hbt8qas1twyc0vncy1ywtk3i2xyyvo6momy-...@mail.gmail.com
 Content-Type: text/plain; charset=ISO-8859-1
 
 Hi,
 
 I am developing a kernel driver. What should I test to make sure my
 kernel driver is not leaking memory?
 1. under normal operation (when applications open and close my driver 
 properly)
 2. in error situation (when application open my driver and then it
 crashes without close my driver property)
 
 How can I find out the memory usage used by my driver? so that I can
 monitor it over time.
 
 Thank you.
 
 
 
 --
 
 Message: 2
 Date: Mon, 10 Mar 2014 09:58:39 -0400
 From: valdis.kletni...@vt.edu
 Subject: Re: How to check if my kernel driver is leaking memory
 To: m silverstri michael.j.silvers...@gmail.com
 Cc: kernelnewbies kernelnewbies@kernelnewbies.org
 Message-ID: 167370.1394459...@turing-police.cc.vt.edu
 Content-Type: text/plain; charset=us-ascii
 
 On Sun, 09 Mar 2014 22:14:24 -0700, m silverstri said:
 
 I am developing a kernel driver. What should I test to make sure my
 kernel driver is not leaking memory?
 
 1) The brute force method - just add lots of printk's that have
 allocating 25-byte frobozz struct and freeing 25-byte frobozz struct
 and make sure they match up.
 
 2) kmemleak.
 
 1. under normal operation (when applications open and close my driver 
 properly)
 2. in error situation (when application open my driver and then it
 crashes without close my driver property)
 
 Case (2) shouldn't happen, as even if a program crashes the kernel *should*
 be invoking the cleanup of open files at process termination.
 
 A more common cause of memory leaks is for an open() or read/write/ioctl()
 path to allocate N chunks of memory, hit an error, and return after having
 cleaned up only N-1 of the chunks.  This is part of why most kernel code
 uses a 'goto error' structure with only one return; at the end of the 
 function.
 
 -- 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/20140310/3ae80b6f/attachment-0001.bin
  
 
 --
 
 ___
 Kernelnewbies mailing list
 Kernelnewbies@kernelnewbies.org
 http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
 
 
 End of Kernelnewbies Digest, Vol 40, Issue 16
 *

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


PROCESS PRIORITY

2014-03-10 Thread Saurabh Jain
I am new to Linux kernel and I have got confused . Please can anyone give
answer to my questions :

Q1 - Is static priority of a thread changes or not ? If changes then how
it changes ?

Q2 - What is the default value of static priority and dynamic priority for
a process and thread in Linux kernel ?

Q3 - What is the initial value of static priority and dynamic priority for
a newly created thread and process?

Q4 - When we talk about the priority of a process or thread (incrementing
/ decrementing priority , setting priority etc. ) , then which priority we
are referring , is it static priority or dynamic priority ?
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Release DMA Memory

2014-03-10 Thread Matt Davis
I have a kernel module that communicates to a PCI device via DMA.  The
module allocates the shared memory using dma_alloc_coherent().  When
the module is unloaded, a call to dma_free_coherent() is executed.

My question is, since the DMA memory is not explicitly zeroed before
deallocation, is there a chance that the PCI device could still read
(non-zeroed data) and act upon the DMA memory after the module unloads
and calls dma_free_coherent()?

Thanks!

-Matt

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


how to rmmod module

2014-03-10 Thread 于运超
Hi,
  when u insmod module,yours PC maybe dump. and u can not rmmod your
module except reboot. i want to know has other ways to solution module
loader error?
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Release DMA Memory

2014-03-10 Thread Chetan Nanda
On Mar 11, 2014 7:57 AM, Matt Davis mattdav...@gmail.com wrote:

 I have a kernel module that communicates to a PCI device via DMA.  The
 module allocates the shared memory using dma_alloc_coherent().  When
 the module is unloaded, a call to dma_free_coherent() is executed.

 My question is, since the DMA memory is not explicitly zeroed before
 deallocation, is there a chance that the PCI device could still read
 (non-zeroed data) and act upon the DMA memory after the module unloads
 and calls dma_free_coherent()?

Ideally you should stop the device before freeing the memory.
If device is allowed to run and access the memory after memory is free this
may leads to memory coruption that would be hard to debug.

 Thanks!

 -Matt


-Chetan ___
 Kernelnewbies mailing list
 Kernelnewbies@kernelnewbies.org
 http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: how to rmmod module

2014-03-10 Thread edsionte
I guess you'd better figure out why the dump occur firstly.


2014-03-11 10:30 GMT+08:00 于运超 wuyaa...@gmail.com:

 Hi,
   when u insmod module,yours PC maybe dump. and u can not rmmod your
 module except reboot. i want to know has other ways to solution module
 loader error?

 ___
 Kernelnewbies mailing list
 Kernelnewbies@kernelnewbies.org
 http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: A new way to dive into the kernel!

2014-03-10 Thread sanjeev sharma
Hello All,

Have you guys getting your assignment's ?

Regards
Sanjeev Sharma


On Wed, Mar 5, 2014 at 10:50 AM, Mallesh Koujalagi 
mallesh.koujalagi.sandi...@gmail.com wrote:

 Good info, thanks for sharing


 On Tue, Mar 4, 2014 at 8:38 PM, Amit Saha amitsaha...@gmail.com wrote:

 On Wed, Mar 5, 2014 at 2:19 PM, Mandeep Sandhu
 mandeepsandhu@gmail.com wrote:
  Came across this in Greg (KH)s G+ feed.
 
  http://eudyptula-challenge.org/
 
  Thought I'd share it here too in case someone missed it.
 
  Looks like a fun and interesting way to start off doing stuff in the
 kernel!

 Interesting! Thanks for sharing.


 --
 http://echorand.me

 ___
 Kernelnewbies mailing list
 Kernelnewbies@kernelnewbies.org
 http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies



 ___
 Kernelnewbies mailing list
 Kernelnewbies@kernelnewbies.org
 http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Does register_chrdev function make device file under /dev ?

2014-03-10 Thread 김찬
Hi,

This should be a basic question.
Does the regisetr_chrdev function make the device file under /dev directory?
I am running linux on our embedded system and inside vcs_init, register_chrdev 
is called as below.

int __init vcs_init(void)
{
unsigned int i;
if (register_chrdev(VCS_MAJOR, vcs, vcs_fops))
panic(unable to get major %d for vcs device, VCS_MAJOR);

I can see the function is returning ok but I don't see any vcs* file under /dev.
Does it only register the device on /sys or /proc directory and not under /dev?
Thanks in advance.

Chan

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Does register_chrdev function make device file under /dev ?

2014-03-10 Thread Kernel


 On Mar 10, 2014, at 10:25 PM, 김찬 c...@etri.re.kr wrote:
 
 Hi,
  
 This should be a basic question.
 Does the regisetr_chrdev function make the device file under /dev directory?
 I am running linux on our embedded system and inside vcs_init, 
 register_chrdev is called as below.
  
 int __init vcs_init(void)
 {
 unsigned int i;
 if (register_chrdev(VCS_MAJOR, vcs, vcs_fops))
 panic(unable to get major %d for vcs device, VCS_MAJOR);
  
 I can see the function is returning ok but I don't see any vcs* file under 
 /dev.
 Does it only register the device on /sys or /proc directory and not under 
 /dev?
 Thanks in advance.
  
 Chan
  

You have to create a device file using 'mknod'

Ex: mknod -m 666 /dev/vcs c major no minor no


 ___
 Kernelnewbies mailing list
 Kernelnewbies@kernelnewbies.org
 http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: A new way to dive into the kernel!

2014-03-10 Thread Mandeep Sandhu
Yes.

Just remember to send a plain text mail.

HTH,
-mandeep


On Tue, Mar 11, 2014 at 10:36 AM, sanjeev sharma
sanjeevsharmae...@gmail.com wrote:
 Hello All,

 Have you guys getting your assignment's ?

 Regards
 Sanjeev Sharma


 On Wed, Mar 5, 2014 at 10:50 AM, Mallesh Koujalagi
 mallesh.koujalagi.sandi...@gmail.com wrote:

 Good info, thanks for sharing


 On Tue, Mar 4, 2014 at 8:38 PM, Amit Saha amitsaha...@gmail.com wrote:

 On Wed, Mar 5, 2014 at 2:19 PM, Mandeep Sandhu
 mandeepsandhu@gmail.com wrote:
  Came across this in Greg (KH)s G+ feed.
 
  http://eudyptula-challenge.org/
 
  Thought I'd share it here too in case someone missed it.
 
  Looks like a fun and interesting way to start off doing stuff in the
  kernel!

 Interesting! Thanks for sharing.


 --
 http://echorand.me

 ___
 Kernelnewbies mailing list
 Kernelnewbies@kernelnewbies.org
 http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies



 ___
 Kernelnewbies mailing list
 Kernelnewbies@kernelnewbies.org
 http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies



___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies