Re: memory management with mmap

2012-10-28 Thread Sengottuvelan S
Hi Mulyadi

I am able to do mmap and access virual-memory address and pages for a
single process from user-space and working fine. I am not sure how to do it
for multiple processes for shared resources using mmap.  I better explain
in detail here what I am experimenting it.

for example:

Kernel allocates kmalloc or vmalloc of 100 pages and set those pages
as reserved. Kernel uses these pages to send/receive data to Process A or B
depends on a condition.

Process A and B do mmap those region to get/set data on those
virtual-addresses/pages because I want faster access from userpace to
kernel.

Anyone knows if this will work with mmap?. Please let me know  if anyother
way to do it.

On Sat, Oct 27, 2012 at 10:57 PM, Mulyadi Santosa mulyadi.sant...@gmail.com
 wrote:

 Hi...

 On Thu, Oct 18, 2012 at 3:02 AM, Sengottuvelan S
 sengottuvela...@gmail.com wrote:
  For example,
 
  I have 2 different user space process A,B etc. I have to allocate memory
 in
  Kernel for each of those processes (for example 2 pages) .  Each process
 is
  allowed to use only 1 page using mmap from user space.
 
  Is it possible to do with mmap?.

 Not sure, but I guess better to do it directly with page_alloc...or at
 least kmalloc() to better utilize slab.

 The thing that I think is hard to do, is to implement protection
 scheme to make sure say process A won't access page allocated by
 process B.

 Hopefully I understand your goal correctly.


 --
 regards,

 Mulyadi Santosa
 Freelance Linux trainer and consultant

 blog: the-hydra.blogspot.com
 training: mulyaditraining.blogspot.com




-- 
Regards,
S. Sengottuvelan.
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: linux segment

2012-10-28 Thread Fan Yang
2012/10/27 Jun Hu duanshui...@hotmail.com

   Can you post out your codes ?

  *From:* Fan Yang lljyang...@gmail.com
 *Sent:* Wednesday, October 24, 2012 8:04 PM
 *To:* kernelnewbies@kernelnewbies.org
 *Subject:* linux segment

 Hi all:
 I print the cs ds and ss register in the user space, and it is same as
 the __USER_CS and __USER_DS which defined in kernel as 73 and 7b. In the
 kernel __KERNEL_CS and __KERNEL_DS defined as 60 and 68, but when I print
 this two value in my kernel module, I get 60 and 7b. Why ? It should be 60
 and 68, shouldn't it?



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

 Hi Jun Hu
There is my code which run at the user space:

  1 #includestdio.h
  2 main()
  3 {
  4 unsigned long cs, ds, ss, es, fs, gs;
  5 asm volatile(movl %%CS,%0\n\t:=r(cs));
  6 asm volatile(movl %%DS,%0\n\t:=r(ds));
  7 asm volatile(movl %%SS,%0\n\t:=r(ss));
  8 asm volatile(movl %%ES,%0\n\t:=r(es));

  9 asm volatile(movl %%FS,%0\n\t:=r(fs));
 10 asm volatile(movl %%GS,%0\n\t:=r(gs));
 11 printf (**\n);
 12 printf (cs %lx\t%ld\n, cs, cs);
 13 printf (ds %lx\t%ld\n, ds, ds);
 14 printf (ss %lx\t%ld\n, ss, ss);
 15 printf (es %lx\t%ld\n, es, es);
 16 printf (fs %lx\t%ld\n, fs, fs);
 17 printf (gs %lx\t%ld\n, gs, gs);
 18 printf (**\n);
 19 }



and the result of the progress in my machine is


**
cs 73 115
ds 7b 123
ss 7b 123
es 7b 123
fs 0 0
gs 33 51
**


so, you can see the cs and ds register is 73 and 7b which are same as the
kernel defined.  And the code of the kernel module is


 1 #includelinux/init.h

  2 #includelinux/kernel.h
  3 #includelinux/module.h
  4
  5 static void __init print_init (void)
  6 {
  7 unsigned long cs, ds, ss, es, fs, gs,currenttime;
  8 asm volatile(movl %%CS,%0\n\t:=r(cs));
  9 asm volatile(movl %%DS,%0\n\t:=r(ds));
 10 asm volatile(movl %%SS,%0\n\t:=r(ss));
 11 asm volatile(movl %%ES,%0\n\t:=r(es));
 12 asm volatile(movl %%FS,%0\n\t:=r(fs));
 13 asm volatile(movl %%GS,%0\n\t:=r(gs));
 14 printk (**\n);
 15 printk (cs %lx\t%ld\n, cs, cs);
 16 printk (ds %lx\t%ld\n, ds, ds);
 17 printk (ss %lx\t%ld\n, ss, ss);
 18 printk (es %lx\t%ld\n, es, es);
 19 printk (fs %lx\t%ld\n, fs, fs);
 20 printk (gs %lx\t%ld\n, gs, gs);
 21 printk (**\n);
 22
 23 }
24
 25 static void __exit print_exit (void)
 26 {
 27 unsigned long cs, ds, ss;
 28 asm volatile(movl %%cs,%0\n\t:=r(cs));
 29 asm volatile(movl %%ds,%0\n\t:=r(ds));
 30 asm volatile(movl %%ss,%0\n\t:=r(ss));
 31
 32 printk (**\n);
 33 printk (cs %lx\t%ld\n, cs, cs);
 34 printk (ds %lx\t%ld\n, ds, ds);
 35 printk (ss %lx\t%ld\n, ss, ss);
 36 printk (**\n);
 37 printk (*bye***\n);
 38 }
 39
 40 module_init (print_init);
 41 module_exit (print_exit);

 42 MODULE_LICENSE (GPL);


the result of the running this module is

[root@shell--box kernel_mod]# dmesg -c
**
cs 60 96
ds 7b 123
ss 68 104
es 7b 123
fs d8 216
gs e0 224
**

The cs and ds in the kernel space is 60 and 7b. But the kernel define the
 KERNEL_CS as 60 and the KERNEL_DS as 7b.  Where am I wrong?


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


Re: linux segment

2012-10-28 Thread Fan Yang
2012/10/28 Fan Yang lljyang...@gmail.com



 2012/10/27 Jun Hu duanshui...@hotmail.com

   Can you post out your codes ?

  *From:* Fan Yang lljyang...@gmail.com
 *Sent:* Wednesday, October 24, 2012 8:04 PM
 *To:* kernelnewbies@kernelnewbies.org
 *Subject:* linux segment

 Hi all:
 I print the cs ds and ss register in the user space, and it is same
 as the __USER_CS and __USER_DS which defined in kernel as 73 and 7b. In the
 kernel __KERNEL_CS and __KERNEL_DS defined as 60 and 68, but when I print
 this two value in my kernel module, I get 60 and 7b. Why ? It should be 60
 and 68, shouldn't it?



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

 Hi Jun Hu
 There is my code which run at the user space:

   1 #includestdio.h
   2 main()
   3 {
   4 unsigned long cs, ds, ss, es, fs, gs;
   5 asm volatile(movl %%CS,%0\n\t:=r(cs));
   6 asm volatile(movl %%DS,%0\n\t:=r(ds));
   7 asm volatile(movl %%SS,%0\n\t:=r(ss));
   8 asm volatile(movl %%ES,%0\n\t:=r(es));

   9 asm volatile(movl %%FS,%0\n\t:=r(fs));
  10 asm volatile(movl %%GS,%0\n\t:=r(gs));
  11 printf (**\n);
  12 printf (cs %lx\t%ld\n, cs, cs);
  13 printf (ds %lx\t%ld\n, ds, ds);
  14 printf (ss %lx\t%ld\n, ss, ss);
  15 printf (es %lx\t%ld\n, es, es);
  16 printf (fs %lx\t%ld\n, fs, fs);
  17 printf (gs %lx\t%ld\n, gs, gs);
  18 printf (**\n);
  19 }



 and the result of the progress in my machine is


 **
 cs 73 115
 ds 7b 123
 ss 7b 123
 es 7b 123
 fs 0 0
 gs 33 51
 **


 so, you can see the cs and ds register is 73 and 7b which are same as the
 kernel defined.  And the code of the kernel module is


  1 #includelinux/init.h

   2 #includelinux/kernel.h
   3 #includelinux/module.h
   4
   5 static void __init print_init (void)
   6 {
   7 unsigned long cs, ds, ss, es, fs, gs,currenttime;
   8 asm volatile(movl %%CS,%0\n\t:=r(cs));
   9 asm volatile(movl %%DS,%0\n\t:=r(ds));
  10 asm volatile(movl %%SS,%0\n\t:=r(ss));
  11 asm volatile(movl %%ES,%0\n\t:=r(es));
  12 asm volatile(movl %%FS,%0\n\t:=r(fs));
  13 asm volatile(movl %%GS,%0\n\t:=r(gs));
  14 printk (**\n);
  15 printk (cs %lx\t%ld\n, cs, cs);
  16 printk (ds %lx\t%ld\n, ds, ds);
  17 printk (ss %lx\t%ld\n, ss, ss);
  18 printk (es %lx\t%ld\n, es, es);
  19 printk (fs %lx\t%ld\n, fs, fs);
  20 printk (gs %lx\t%ld\n, gs, gs);
  21 printk (**\n);
  22
  23 }
 24
  25 static void __exit print_exit (void)
  26 {
  27 unsigned long cs, ds, ss;
  28 asm volatile(movl %%cs,%0\n\t:=r(cs));
  29 asm volatile(movl %%ds,%0\n\t:=r(ds));
  30 asm volatile(movl %%ss,%0\n\t:=r(ss));
  31
  32 printk (**\n);
  33 printk (cs %lx\t%ld\n, cs, cs);
  34 printk (ds %lx\t%ld\n, ds, ds);
  35 printk (ss %lx\t%ld\n, ss, ss);
  36 printk (**\n);
  37 printk (*bye***\n);
  38 }
  39
  40 module_init (print_init);
  41 module_exit (print_exit);

  42 MODULE_LICENSE (GPL);


 the result of the running this module is

 [root@shell--box kernel_mod]# dmesg -c
 **
 cs 60 96
 ds 7b 123
 ss 68 104
 es 7b 123
 fs d8 216
 gs e0 224
 **

 The cs and ds in the kernel space is 60 and 7b. But the kernel define the
  KERNEL_CS as 60 and the KERNEL_DS as 7b.  Where am I wrong?


 Thanks
 Fan


sorry, the kernel define the KERNEL_DS as 68, but I get 7b in my machine.
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Tools for checking incorrect usage of locking techniques in k-space

2012-10-28 Thread Srivatsa Bhat
Hi,

On Sun, Oct 28, 2012 at 12:36 AM, Kumar amit mehta gmate.a...@gmail.com wrote:
 Thank you Srivatsa. It seems that lockdep framework is enabled on my running
 kernel.

 snip
 amit@ubuntu:/boot$ egrep -i debug_kernel|lockdep config-3.2.0-29-generic-pae
 CONFIG_LOCKDEP_SUPPORT=y
 CONFIG_DEBUG_KERNEL=y

You'll need CONFIG_LOCKDEP=y as well. An easy way to configure lock debugging
checks is to run 'make menuconfig' and enable the required options under the
Kernel hacking section.

Regards,
Srivatsa S. Bhat

 snip

 If above configuration is all that I need, then should I be seeing 
 warning/error
 messages in kernel logs(/var/log/kern.log) when there is inconsistency in
 locking ? To test my hypothesis, I modified my simple kernel module to
 deliberately induce locking error (After initializing read-write semaphore, I 
 call
 down_write() and do not free this semaphore lock by commenting out up_write()
 invocation). But still I don't see any error or warning message trace in 
 kernel
 logs, I think, I'm missing something.

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


Re: Etiquette of submitting patches for fixing coding style.

2012-10-28 Thread Eugene Voronkov
On Sat, Oct 27, 2012 at 10:09 AM, Robert P. J. Day rpj...@crashcourse.cawrote:

 On Fri, 26 Oct 2012, Greg Freemyer wrote:

  fyi: Robert Day just asked for help cleaning up the Doc Book stuff.
 
  Doc Book pull comments out of the .c files and creates documentation.
  To clean it up, patches to the source files will be required.  These
  are more likely to be accepted.
 
  So you could to a doc book series like:
 
  0/2 a patch series to correct the documentation for xyz subsystem
  1/2 checkpatch cleanup of the 2 files with doc updates
  2/2 doc updates

   if you want to get started making fixes and submitting patches, i
 suggest doc fixes as an easy way to jump in for the simple reason that
 just making changes to documentation shouldn't break anything. :-)
 there is a separate list just for kernel documentation:

   http://vger.kernel.org/vger-lists.html#linux-doc

 so you know you'll be on-topic there chatting about documentation.
 from the perspective of someone who has no *official* connection with
 the kernel but who's submitted lots of pedantic patches over the
 years, let me make a couple suggestions.

   first, a *lot* of what's under the Documentation/ directory is
 absurdly old and worthless, and should probably be just deleted.
 ignore that stuff. other stuff under there is perfectly up-to-date,
 and should be left alone.

   the middle ground is the stuff that can be updated to reflect the
 current kernel, so pick a single file under there that reflects
 something you're interested in, start going through it, make
 corrections, and submit the final patch to the linux-doc list.  try to
 work with a single file or topic at a time, it's easier to get your
 patches accepted.

   post on the kernel-doc stuff coming shortly, for the interested.

 rday

 --

 
 Robert P. J. Day Ottawa, Ontario, CANADA
 http://crashcourse.ca

 Twitter:   http://twitter.com/rpjday
 LinkedIn:   http://ca.linkedin.com/in/rpjday
 



Thanks I'll be following the documentation mailing list.
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies