PER-CPU data

2012-03-30 Thread Rajasekhar Pulluru
Hi,

I would like to know how per-cpu data are stored internally?
And how are they protected from other cores?

Thanks  Regards,
Rajasekhar

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


How to debug a kernel thread?

2012-03-30 Thread Parmenides
Hi,

  It is said that the kernel can be debugged in qemu and I take a
try. First, I started the qemu with

 qemu -m 64M -kernel arch/x86/boot/bzImage -initrd
~/image.cpio.gz  -net nic -net tap,ifname=tap0  -s

 In another console

  gdb vmlinux
  (gdb) target remote localhost:1234
  (gdb) continue

A LKM (mymodule.ko) which starts a kernel thread is made with debug
info, and was 'scp' to the guest. In guest, it is inserted by

  insmod mymodule.ko

Then, back to gdb

  (gdb) add-symbol-file mymodule.ko 0xc482e000
  (gdb) break mymodules.c:37
  (gdb) continue

The 37th line of mymodules.c is in a loop of kernel thread, which
ensures the breakpoint should be triggered every time the loop go
through.  But, the breakpoint doesn't triggered as expected. Instead,
the kernel thread is running over and over indicated by its repeated
output messages. So, I think a kernel thread can not be break by any
breakpoint.

However, I think maybe the gdb want to attach to the kernel thread.
Then, I checked the kernel thread's PID with ps and got 62.

 (gdb) control+C
 (gdb) attach 62

The gdb promted me it will kill the program being debugged. I answered
with 'yes', the gdb told me

 ptrace: No such process.

then the debug session is terminated and the guest is closed.

I started the qemu  with the above command again

 qemu -m 64M -kernel arch/x86/boot/bzImage -initrd
~/image.cpio.gz  -net nic -net tap,ifname=tap0  -s

And, without quitting the gdb

  (gdb) target remote localhost:1234
  (gdb) continue

In the guest, 'mymodule.ko' is inserted again

  insmod mymodule.ko

I found that the breakpoint set at mymodule.c:37 is triggered this
time surprisingly, and the 'insmod' didn't return immediately until
the gdb is given with another 'continue' command.

  (gdb) continue

Then, the breakpoint doesn't triggered anymore as usual,


There is two questions:

1. Why the kernel thread can not be break?
2. Why is the breakpoint triggered just when the 'mymodule.ko' is loaded?

Thanks.

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


git pull fails on linux-next (out of memory)

2012-03-30 Thread Arvid Brodin
On 2012-03-06, I cloned linux-next:

$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git 
linux-next-20120306


I now want to update this repository before posting patches, to make sure
they still apply cleanly. I first tried this on 20120328:

$ git pull
remote: Counting objects: 63784, done.
remote: Compressing objects: 100% (13595/13595), done.
remote: Total 45829 (delta 38421), reused 38448 (delta 31414)
Receiving objects: 100% (45829/45829), 9.87 MiB | 209 KiB/s, done.
Resolving deltas: 100% (38421/38421), completed with 5695 local objects.
From git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next
 + 5a377dc...bc6f15c akpm-end   - origin/akpm-end  (forced update)
   055bf38..de8856d  akpm-start - origin/akpm-start
 + a568b5f...7734592 master - origin/master  (forced update)
   055bf38..de8856d  stable - origin/stable
 * [new tag] next-20120328 - next-20120328
From git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next
 * [new tag] v3.3   - v3.3
 * [new tag] v3.3-rc7   - v3.3-rc7
warning: too many files (created: 1625 deleted: 423), skipping inexact rename 
detection
warning: too many files (created: 5127 deleted: 1509), skipping inexact rename 
detection
warning: too many files (created: 1134 deleted: 655), skipping inexact rename 
detection
warning: too many files (created: 4816 deleted: 3510), skipping inexact rename 
detection
warning: too many files (created: 1004 deleted: 544), skipping inexact rename 
detection
warning: too many files (created: 1734 deleted: 1778), skipping inexact rename 
detection
warning: too many files (created: 1069 deleted: 608), skipping inexact rename 
detection
warning: too many files (created: 1070 deleted: 764), skipping inexact rename 
detection
warning: too many files (created: 757 deleted: 405), skipping inexact rename 
detection
warning: too many files (created: 980 deleted: 542), skipping inexact rename 
detection
fatal: inflateInit: out of memory (no message)


I then forgot about it for a little while, doing other stuff. Tried it again 
today:


$ git pull
remote: Counting objects: 16816, done.
remote: Compressing objects: 100% (1595/1595), done.
remote: Total 9491 (delta 7901), reused 9254 (delta 7678)
Receiving objects: 100% (9491/9491), 2.53 MiB | 299 KiB/s, done.
Resolving deltas: 100% (7901/7901), completed with 3010 local objects.
From git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next
 + bc6f15c...73bd151 akpm-end   - origin/akpm-end  (forced update)
   de8856d..1c03658  akpm-start - origin/akpm-start
 + 7734592...1dc85fe master - origin/master  (forced update)
   de8856d..1c03658  stable - origin/stable
 * [new tag] next-20120330 - next-20120330
warning: too many files (created: 1625 deleted: 423), skipping inexact rename 
detection
warning: too many files (created: 5127 deleted: 1509), skipping inexact rename 
detection
warning: too many files (created: 1134 deleted: 655), skipping inexact rename 
detection
warning: too many files (created: 4816 deleted: 3510), skipping inexact rename 
detection
warning: too many files (created: 1004 deleted: 544), skipping inexact rename 
detection
warning: too many files (created: 1734 deleted: 1778), skipping inexact rename 
detection
warning: too many files (created: 1069 deleted: 608), skipping inexact rename 
detection
warning: too many files (created: 1070 deleted: 764), skipping inexact rename 
detection
warning: too many files (created: 757 deleted: 405), skipping inexact rename 
detection
warning: too many files (created: 1084 deleted: 773), skipping inexact rename 
detection
warning: too many files (created: 980 deleted: 542), skipping inexact rename 
detection
fatal: Out of memory? mmap failed: Cannot allocate memory

$ git gc
Counting objects: 2609985, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (392553/392553), done.
Writing objects: 100% (2609985/2609985), done.
Total 2609985 (delta 2197683), reused 2602739 (delta 2190459)

$ git pull
warning: too many files (created: 1625 deleted: 423), skipping inexact rename 
detection
warning: too many files (created: 5127 deleted: 1509), skipping inexact rename 
detection
warning: too many files (created: 1134 deleted: 655), skipping inexact rename 
detection
warning: too many files (created: 4816 deleted: 3510), skipping inexact rename 
detection
warning: too many files (created: 1004 deleted: 544), skipping inexact rename 
detection
warning: too many files (created: 1734 deleted: 1778), skipping inexact rename 
detection
warning: too many files (created: 1069 deleted: 608), skipping inexact rename 
detection
warning: too many files (created: 1070 deleted: 764), skipping inexact rename 
detection
warning: too many files (created: 757 deleted: 405), skipping inexact rename 
detection
warning: too many files (created: 1084 deleted: 773), skipping inexact rename 
detection
warning: too many files (created: 980 deleted: 542), skipping

Re: Translate keysyms to ASCII

2012-03-30 Thread Gabriel Duarte
Anyway, does not work...
I just would like to know if the kernel offers me a conversion table. As I
said, I did it already by myself, but was just looking for a more stylish
way to do...

On Thu, Mar 29, 2012 at 7:42 PM, Jeff Haran jha...@bytemobile.com wrote:

 From: kernelnewbies-boun...@kernelnewbies.org [mailto:
 kernelnewbies-boun...@kernelnewbies.org] On Behalf Of Gabriel Duarte
 Sent: Thursday, March 29, 2012 4:14 AM
 To: kernelnewbies@kernelnewbies.org
 Subject: Translate keysyms to ASCII

 Hello people,


 I working on a small proof of concept keylogger that works on kernel mode.
 It's parte of my studies of kernel development.
 I'm using the struct keyboard_notifier_param to get the keys pressed on
 the keyboard(s) attached to the system.

 At the end, I print the value, like this:

 printk(KERN_DEBUG KEY== %i, param-value);


 According to the definition of the struct keyboard_notifier_param at
 http://lxr.free-electrons.com/source/include/linux/keyboard.h#L37, the
 field value is a  keycode, unicode value or keysym.

 For example, when I press the key a, I get the value 30, but I would like
 tranlate it to the ASCII. I managed to create a translation table by
 myself, but I think there is another way more stylish to do this, or not? I
 googled a lot but could not find a consistent answer.

 Any help is appreciated,

 Gabriel.

 --
 Gabriel Duarte
 Linux User #471185
 France / Grenoble - Rhône Alpes
 http://genericdev.wordpress.com/

 The term I think you want to search for is PC keyboard scan code. This
 link seems to cover it pretty well:

 http://www.quadibloc.com/comp/scan.htm

 Jeff Haran





-- 
Gabriel Duarte
Linux User #471185
France / Grenoble - Rhône Alpes
http://genericdev.wordpress.com/
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: git pull fails on linux-next (out of memory)

2012-03-30 Thread Arvid Brodin
Arvid Brodin wrote:
 On 2012-03-06, I cloned linux-next:
 
 $ git clone git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git 
 linux-next-20120306
 
 
 I now want to update this repository before posting patches, to make sure
 they still apply cleanly. I first tried this on 20120328:
 
 $ git pull
 remote: Counting objects: 63784, done.
 remote: Compressing objects: 100% (13595/13595), done.
 remote: Total 45829 (delta 38421), reused 38448 (delta 31414)
 Receiving objects: 100% (45829/45829), 9.87 MiB | 209 KiB/s, done.
 Resolving deltas: 100% (38421/38421), completed with 5695 local objects.
From git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next
  + 5a377dc...bc6f15c akpm-end   - origin/akpm-end  (forced update)
055bf38..de8856d  akpm-start - origin/akpm-start
  + a568b5f...7734592 master - origin/master  (forced update)
055bf38..de8856d  stable - origin/stable
  * [new tag] next-20120328 - next-20120328
From git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next
  * [new tag] v3.3   - v3.3
  * [new tag] v3.3-rc7   - v3.3-rc7
 warning: too many files (created: 1625 deleted: 423), skipping inexact rename 
 detection
 warning: too many files (created: 5127 deleted: 1509), skipping inexact 
 rename detection
 warning: too many files (created: 1134 deleted: 655), skipping inexact rename 
 detection
 warning: too many files (created: 4816 deleted: 3510), skipping inexact 
 rename detection
 warning: too many files (created: 1004 deleted: 544), skipping inexact rename 
 detection
 warning: too many files (created: 1734 deleted: 1778), skipping inexact 
 rename detection
 warning: too many files (created: 1069 deleted: 608), skipping inexact rename 
 detection
 warning: too many files (created: 1070 deleted: 764), skipping inexact rename 
 detection
 warning: too many files (created: 757 deleted: 405), skipping inexact rename 
 detection
 warning: too many files (created: 980 deleted: 542), skipping inexact rename 
 detection
 fatal: inflateInit: out of memory (no message)
 
 
 I then forgot about it for a little while, doing other stuff. Tried it 
 again today:
 
 
 $ git pull
 remote: Counting objects: 16816, done.
 remote: Compressing objects: 100% (1595/1595), done.
 remote: Total 9491 (delta 7901), reused 9254 (delta 7678)
 Receiving objects: 100% (9491/9491), 2.53 MiB | 299 KiB/s, done.
 Resolving deltas: 100% (7901/7901), completed with 3010 local objects.
From git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next
  + bc6f15c...73bd151 akpm-end   - origin/akpm-end  (forced update)
de8856d..1c03658  akpm-start - origin/akpm-start
  + 7734592...1dc85fe master - origin/master  (forced update)
de8856d..1c03658  stable - origin/stable
  * [new tag] next-20120330 - next-20120330
 warning: too many files (created: 1625 deleted: 423), skipping inexact rename 
 detection
 warning: too many files (created: 5127 deleted: 1509), skipping inexact 
 rename detection
 warning: too many files (created: 1134 deleted: 655), skipping inexact rename 
 detection
 warning: too many files (created: 4816 deleted: 3510), skipping inexact 
 rename detection
 warning: too many files (created: 1004 deleted: 544), skipping inexact rename 
 detection
 warning: too many files (created: 1734 deleted: 1778), skipping inexact 
 rename detection
 warning: too many files (created: 1069 deleted: 608), skipping inexact rename 
 detection
 warning: too many files (created: 1070 deleted: 764), skipping inexact rename 
 detection
 warning: too many files (created: 757 deleted: 405), skipping inexact rename 
 detection
 warning: too many files (created: 1084 deleted: 773), skipping inexact rename 
 detection
 warning: too many files (created: 980 deleted: 542), skipping inexact rename 
 detection
 fatal: Out of memory? mmap failed: Cannot allocate memory
 
 $ git gc
 Counting objects: 2609985, done.
 Delta compression using up to 2 threads.
 Compressing objects: 100% (392553/392553), done.
 Writing objects: 100% (2609985/2609985), done.
 Total 2609985 (delta 2197683), reused 2602739 (delta 2190459)
 
 $ git pull
 warning: too many files (created: 1625 deleted: 423), skipping inexact rename 
 detection
 warning: too many files (created: 5127 deleted: 1509), skipping inexact 
 rename detection
 warning: too many files (created: 1134 deleted: 655), skipping inexact rename 
 detection
 warning: too many files (created: 4816 deleted: 3510), skipping inexact 
 rename detection
 warning: too many files (created: 1004 deleted: 544), skipping inexact rename 
 detection
 warning: too many files (created: 1734 deleted: 1778), skipping inexact 
 rename detection
 warning: too many files (created: 1069 deleted: 608), skipping inexact rename 
 detection
 warning: too many files (created: 1070 deleted: 764), skipping inexact rename 
 detection
 warning: too many files (created: 757 deleted: 405), skipping inexact rename 
 detection
 warning: too many