Re: Linux SMP Test Cases

2010-04-27 Thread Mulyadi Santosa
Hi Adam...

On Tue, Apr 27, 2010 at 12:52, Adam Jiang jiang.a...@gmail.com wrote:
 This article is informative. Is there a way to watch how the scheduler
 do its job visibly? For example, could I know the specific IRQ is
 handled by which cpu?

This is purely my idea. I think you can do it by periodically checking
the output of /proc/interrupts. For example:
watch -d 'cat /proc/interrupts  | grep timer'

Then see in which CPU the number grows bigger. There, we can conclude
that for recent time interval, certain IRQ is handled by certain CPU.

-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

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

--
To unsubscribe from this list: send an email with
unsubscribe kernelnewbies to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Not able to boot Linux-2.6.33.2

2010-04-27 Thread Mukesh Yadav
Hello everyone,

I wanted to upgrade form Linux-2.6.15-52-386 kernel to vanila Linux-2.6.33.2
kernel from kernel.org. I compiled and installed kernel with defualt
configurion (except for disabling booting from NFS)

Steps for compiling kernel:

$make menuconfig   --- to disable booting form NFS
$make
$make modules
$make modules_install
$make install

$cd /boot/
$mkinitramfs -o initrd.img-2.6.33.2 2.6.33.2




Following is a list of messages that I get when I try boot with new kernel:

modeprobe: FATAL: Could not load /lib/modules/2.6.33.2/modules.dep: No such
file or directory.

WARNING: Couldn't open directory /lib/modules/2.6.33.2: No such file or
directory

FATAL: Could not open /lib/modules/2.6.33.2/modules.dep.temp for writing: No
such file or directory.

ALERT!: /dev/hda1 does not exists. Dropping to a Shell!

I'm trying all this on sun virtual box. My Linux-2.6.15-52-386 still works
well.

Following are grub entries:
title   Ubuntu, kernel 2.6.33.2
root   (hd0, 0)
kernel/boot/vmlinuz-2.6.33.2  root=/dev/hda1 ro  quiet splash
initrd  /boot/initrd.img-2.6.33.2
savedefault
boot

Please help!
--
Best Regards,
Mukesh


Re: Not able to boot Linux-2.6.33.2

2010-04-27 Thread Simon Kitching
On Tue, 2010-04-27 at 13:06 +0530, Mukesh Yadav wrote:
 Hello everyone,
  
 I wanted to upgrade form Linux-2.6.15-52-386 kernel to vanila
 Linux-2.6.33.2 kernel from kernel.org. I compiled and installed kernel
 with defualt configurion (except for disabling booting from NFS)

  
 Following is a list of messages that I get when I try boot with new
 kernel:
  
 modeprobe: FATAL: Could not load /lib/modules/2.6.33.2/modules.dep: No
 such file or directory.
  

  
 Following are grub entries:
 title   Ubuntu, kernel 2.6.33.2
 root   (hd0, 0)
 kernel/boot/vmlinuz-2.6.33.2  root=/dev/hda1 ro  quiet splash 
 initrd  /boot/initrd.img-2.6.33.2
 savedefault
 boot

Have you tried this?
   root=/dev/sda1

In modern linux versions, the ata and scsi code has been merged, so all
disks are now /dev/sd..., regardless of their actual physical
interface.

It looks like your kernel is booting, and the initrd is working fine,
but is then unable to mount the correct root fs...

Regards,
Simon



--
To unsubscribe from this list: send an email with
unsubscribe kernelnewbies to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: Not able to boot Linux-2.6.33.2

2010-04-27 Thread Mukesh Yadav
More suggestions please.

--
Regards
Mukesh

On Tue, Apr 27, 2010 at 3:26 PM, Mukesh Yadav mukesh...@gmail.com wrote:



  On Tue, Apr 27, 2010 at 3:04 PM, Anuz Pratap Singh Tomar 
 chambilketha...@gmail.com wrote:



  On Tue, Apr 27, 2010 at 1:06 PM, Mukesh Yadav mukesh...@gmail.comwrote:

 Hello everyone,

 I wanted to upgrade form Linux-2.6.15-52-386 kernel to vanila
 Linux-2.6.33.2 kernel from kernel.org. I compiled and installed kernel
 with defualt configurion (except for disabling booting from NFS)

 Steps for compiling kernel:

 $make menuconfig   --- to disable booting form NFS
 $make
 $make modules
 $make modules_install
 $make install

 $cd /boot/
 $mkinitramfs -o initrd.img-2.6.33.2 2.6.33.2




 Following is a list of messages that I get when I try boot with new
 kernel:

 modeprobe: FATAL: Could not load /lib/modules/2.6.33.2/modules.dep: No
 such file or directory.

 WARNING: Couldn't open directory /lib/modules/2.6.33.2: No such file or
 directory

 FATAL: Could not open /lib/modules/2.6.33.2/modules.dep.temp for
 writing: No such file or directory.

 ALERT!: /dev/hda1 does not exists. Dropping to a Shell!



 not sure, but seems like u need to fix the partition info
 /dev/hda1 may not be your root.



 If this is case then same partition should not work as root for
 Linux-2.6.15.-52-386. Isn't it.



 I'm trying all this on sun virtual box. My Linux-2.6.15-52-386 still
 works well.

 Following are grub entries:
 title   Ubuntu, kernel 2.6.33.2
 root   (hd0, 0)
 kernel/boot/vmlinuz-2.6.33.2  root=/dev/hda1 ro  quiet splash
 initrd  /boot/initrd.img-2.6.33.2
 savedefault
 boot

 Please help!
 --
 Best Regards,
 Mukesh




 --
 People ask the question... what's a RocknRolla? And I tell 'em - it's not
 about drums, drugs, and hospital drips, oh no. There's more there than that,
 my friend. We all like a bit of the good life - some the money, some the
 drugs, other the sex game, the glamour, or the fame. But a RocknRolla, oh,
 he's different. Why? Because a real RocknRolla wants the fucking lot.





Re: Not able to boot Linux-2.6.33.2

2010-04-27 Thread Anuz Pratap Singh Tomar
On Tue, Apr 27, 2010 at 4:19 PM, Mukesh Yadav mukesh...@gmail.com wrote:

 More suggestions please.


Please post your /etc/fstab output
please post your fdisk -l output


As someone pointed out: scsi and ata are merged in recent kernels
between .15 and .33: there are so  many changes, its unlikely u can run it
from older distros.
 Secondly, u can boot .15 with hda1 but newer kernels require sdXn
Now they use UUID for recognizing partition, though not sure, if kernel
forces such requirements.
if you look at it: its not able to find
/lib/modules/2.6.33.2/modules.dep,http://2.6.33.2/modules.dep
Which is probably because its not able to mount /root


 --
 Regards
 Mukesh

 On Tue, Apr 27, 2010 at 3:26 PM, Mukesh Yadav mukesh...@gmail.com wrote:



  On Tue, Apr 27, 2010 at 3:04 PM, Anuz Pratap Singh Tomar 
 chambilketha...@gmail.com wrote:



  On Tue, Apr 27, 2010 at 1:06 PM, Mukesh Yadav mukesh...@gmail.comwrote:

 Hello everyone,

 I wanted to upgrade form Linux-2.6.15-52-386 kernel to vanila
 Linux-2.6.33.2 kernel from kernel.org. I compiled and installed kernel
 with defualt configurion (except for disabling booting from NFS)

 Steps for compiling kernel:

 $make menuconfig   --- to disable booting form NFS
 $make
 $make modules
 $make modules_install
 $make install

 $cd /boot/
 $mkinitramfs -o initrd.img-2.6.33.2 2.6.33.2




 Following is a list of messages that I get when I try boot with new
 kernel:

 modeprobe: FATAL: Could not load /lib/modules/2.6.33.2/modules.dep: No
 such file or directory.

 WARNING: Couldn't open directory /lib/modules/2.6.33.2: No such file or
 directory

 FATAL: Could not open /lib/modules/2.6.33.2/modules.dep.temp for
 writing: No such file or directory.

 ALERT!: /dev/hda1 does not exists. Dropping to a Shell!



 not sure, but seems like u need to fix the partition info
 /dev/hda1 may not be your root.



 If this is case then same partition should not work as root for
 Linux-2.6.15.-52-386. Isn't it.



 I'm trying all this on sun virtual box. My Linux-2.6.15-52-386 still
 works well.

 Following are grub entries:
 title   Ubuntu, kernel 2.6.33.2
 root   (hd0, 0)
 kernel/boot/vmlinuz-2.6.33.2  root=/dev/hda1 ro  quiet splash
 initrd  /boot/initrd.img-2.6.33.2
 savedefault
 boot

 Please help!
 --
 Best Regards,
 Mukesh




 --
 People ask the question... what's a RocknRolla? And I tell 'em - it's not
 about drums, drugs, and hospital drips, oh no. There's more there than that,
 my friend. We all like a bit of the good life - some the money, some the
 drugs, other the sex game, the glamour, or the fame. But a RocknRolla, oh,
 he's different. Why? Because a real RocknRolla wants the fucking lot.






-- 
People ask the question... what's a RocknRolla? And I tell 'em - it's not
about drums, drugs, and hospital drips, oh no. There's more there than that,
my friend. We all like a bit of the good life - some the money, some the
drugs, other the sex game, the glamour, or the fame. But a RocknRolla, oh,
he's different. Why? Because a real RocknRolla wants the fucking lot.


Re: Not able to boot Linux-2.6.33.2

2010-04-27 Thread Srdjan Todorovic
On 27 April 2010 12:20, Anuz Pratap Singh Tomar
chambilketha...@gmail.com wrote:

  Secondly, u can boot .15 with hda1 but newer kernels require sdXn

 if you look at it: its not able to find /lib/modules/2.6.33.2/modules.dep,
 Which is probably because its not able to mount /root

I was under the impression that the kernel will give you a fatal
message about not being able to find the root filesystem in that case.

-Srdjan

--
To unsubscribe from this list: send an email with
unsubscribe kernelnewbies to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: Not able to boot Linux-2.6.33.2

2010-04-27 Thread Anuz Pratap Singh Tomar
On Tue, Apr 27, 2010 at 5:02 PM, Srdjan Todorovic 
todorovi...@googlemail.com wrote:

 On 27 April 2010 12:20, Anuz Pratap Singh Tomar
 chambilketha...@gmail.com wrote:

   Secondly, u can boot .15 with hda1 but newer kernels require sdXn

  if you look at it: its not able to find /lib/modules/
 2.6.33.2/modules.dep,
  Which is probably because its not able to mount /root

 I was under the impression that the kernel will give you a fatal
 message about not being able to find the root filesystem in that case.

Not sure, why is this happening. For fedora, it says system going to sleep,
which is strange.
There are similar questions in ubuntu community
googling ALERT! /dev/sda1 does not exist. Dropping to a shell will show
the result.


Dynamic Kernel Module Section Addresses

2010-04-27 Thread Venkatram Tummala
Hi,

i am trying to debug kernel modules on 2.6.32 with vmware workstation.

For that, i need to add symbols to gdb using add-symbol-file by giving the
various section addresses of the kernel module ( .text, .data, .bss etc ). I
find these addresses by inserting the module  looking into
/sys/module/module-name/sections  finally i rmmod the module.

But the problem is, i add these module section addresses to gdb and attach
gdb to the vmware instance  now load the module again(this time, to debug),
the section addresses of the module change. So i can't set any breakpoints.

So, the question is -

1) Is there any way to tell the kernel not to load these module sections at
different addresses every time the module is inserted  removed . That is,
can we have the module loaded at exactly the same address everytime?

2) Is there any way to overcome this problem so that i can debug the module
using vmware even though the module is loaded at different addresses?


Thanks.

Regards,
Venkatram Tummala


Re: Dynamic Kernel Module Section Addresses

2010-04-27 Thread Mulyadi Santosa
Hi Venkatram...

On Wed, Apr 28, 2010 at 05:34, Venkatram Tummala venkatram...@gmail.com wrote:

 1) Is there any way to tell the kernel not to load these module sections at
 different addresses every time the module is inserted  removed . That is,
 can we have the module loaded at exactly the same address everytime?

None that I know. AFAIK the only way is to recheck the /sys entry and
reinsert the symbol file (your kernel module file, which has been
compiled with -g before) to proper position

 2) Is there any way to overcome this problem so that i can debug the module
 using vmware even though the module is loaded at different addresses?

AFAIK, again none that I know.

-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

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

--
To unsubscribe from this list: send an email with
unsubscribe kernelnewbies to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: Dynamic Kernel Module Section Addresses

2010-04-27 Thread Venkatram Tummala
On Tue, Apr 27, 2010 at 5:04 PM, Mulyadi Santosa
mulyadi.sant...@gmail.comwrote:

 Hi Venkatram...

 On Wed, Apr 28, 2010 at 05:34, Venkatram Tummala venkatram...@gmail.com
 wrote:
 
  1) Is there any way to tell the kernel not to load these module sections
 at
  different addresses every time the module is inserted  removed . That
 is,
  can we have the module loaded at exactly the same address everytime?

 None that I know. AFAIK the only way is to recheck the /sys entry and
 reinsert the symbol file (your kernel module file, which has been
 compiled with -g before) to proper position


With this approach, i can set breakpoints in every function except for the
function that initializes the module because i have to insert the module to
get the kernel module section addresses from /sys  as a result of which, the
initializition routine finishes executing which means i can not set any
breakpoints in the module initialize function.

This is not a problem for the the module exit function or any other function
though.

There should be a way to tell the kernel that Look, I dont care where you
put the segments of this module but put them at the same place everytime i
re-insert the module again (atleast until the next reboot). Conceptually,
this should not be hard to implement (if its not there already) because it
is the same kernel  the same unchanged KO module that i am asking it to
insert.


  2) Is there any way to overcome this problem so that i can debug the
 module
  using vmware even though the module is loaded at different addresses?

 AFAIK, again none that I know.

 --
 regards,

 Mulyadi Santosa
 Freelance Linux trainer and consultant

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



Re: how to call system call from kernelspace

2010-04-27 Thread Joel Fernandes
On Tue, Apr 27, 2010 at 7:55 AM, rahul patil
rahul.deshmukhpa...@gmail.comwrote:

 Though it is bad idea to call a system call from kernel space
 is it possible any how to call a system call from kernel space?


Generally a better idea to user kernel interfaces directly instead of sys
calls. Further most sys call functions are not exported so you can't call
them from your kernel module. You'll have to EXPORT_SYMBOL them and
recompile your kernel which is kind of ugly.

-Joel


Re: how to call system call from kernelspace

2010-04-27 Thread Joel Fernandes
On Wed, Apr 28, 2010 at 8:09 AM, Joel Fernandes agnel.j...@gmail.comwrote:


 On Tue, Apr 27, 2010 at 7:55 AM, rahul patil 
 rahul.deshmukhpa...@gmail.com wrote:

 Though it is bad idea to call a system call from kernel space
 is it possible any how to call a system call from kernel space?


 Generally a better idea to user kernel interfaces directly instead of sys
 calls. Further most sys call functions are not exported so you can't call
 them from your kernel module. You'll have to EXPORT_SYMBOL them and
 recompile your kernel which is kind of ugly.



If you can tell us which syscalls you'd like to make, maybe we can suggest
some alternatives

-Joel


Re: how to call system call from kernelspace

2010-04-27 Thread rahul patil
i want to call open,write system calls from kernel space.

what i want to do actually is to wrap up open system call.I have done wrap
up part of open system call using jprobes.

Now i want to write name of file being opened in another file say
/home/rahul/log and code for it will be written in wrap-up part
since the wrap-up part of open system call also runs in kernel space i want
to open and write file /home/rahul/log from kernel
space.

so the code in my wrap up routine in jprobe module will look like.

long my_sys_open(char*name,int flag,int mode)
{
int fd;

 fs = get_fs(); /* save previous value */
set_fs (get_ds()); /* use kernel limit */
fd=sys_open(/home/rahul/log,O_CREAT,O_RDRW);
 set_fs(fs);

fs = get_fs(); /* save previous value */
set_fs (get_ds()); /* use kernel limit */
fwrite(fd,name,strlen(name));
set_fs(fs);

  jprobe_return();
return 0;

}

I will take care that recursion will not happen since i am calling sys_open
from wrapper of sys_open


On Wed, Apr 28, 2010 at 8:10 AM, Joel Fernandes agnel.j...@gmail.comwrote:

 On Wed, Apr 28, 2010 at 8:09 AM, Joel Fernandes agnel.j...@gmail.comwrote:


 On Tue, Apr 27, 2010 at 7:55 AM, rahul patil 
 rahul.deshmukhpa...@gmail.com wrote:

 Though it is bad idea to call a system call from kernel space
 is it possible any how to call a system call from kernel space?


 Generally a better idea to user kernel interfaces directly instead of sys
 calls. Further most sys call functions are not exported so you can't call
 them from your kernel module. You'll have to EXPORT_SYMBOL them and
 recompile your kernel which is kind of ugly.



 If you can tell us which syscalls you'd like to make, maybe we can suggest
 some alternatives

 -Joel




-- 
Regards,
Rahul Patil


Re: Dynamic Kernel Module Section Addresses

2010-04-27 Thread Manish Katiyar
On Wed, Apr 28, 2010 at 6:38 AM, Venkatram Tummala
venkatram...@gmail.com wrote:
 On Tue, Apr 27, 2010 at 5:04 PM, Mulyadi Santosa mulyadi.sant...@gmail.com
 wrote:

 Hi Venkatram...

 On Wed, Apr 28, 2010 at 05:34, Venkatram Tummala venkatram...@gmail.com
 wrote:
 
  1) Is there any way to tell the kernel not to load these module sections
  at
  different addresses every time the module is inserted  removed . That
  is,
  can we have the module loaded at exactly the same address everytime?

 None that I know. AFAIK the only way is to recheck the /sys entry and
 reinsert the symbol file (your kernel module file, which has been
 compiled with -g before) to proper position

 With this approach, i can set breakpoints in every function except for the
 function that initializes the module because i have to insert the module to
 get the kernel module section addresses from /sys  as a result of which, the
 initializition routine finishes executing which means i can not set any
 breakpoints in the module initialize function.

 This is not a problem for the the module exit function or any other function
 though.

 There should be a way to tell the kernel that Look, I dont care where you
 put the segments of this module but put them at the same place everytime i
 re-insert the module again (atleast until the next reboot). Conceptually,
 this should not be hard to implement (if its not there already) because it
 is the same kernel  the same unchanged KO module that i am asking it to
 insert.

  2) Is there any way to overcome this problem so that i can debug the
  module
  using vmware even though the module is loaded at different addresses?

Probably i didn't understand the question. Can't you find it by
looking at p modules from gdb ?

Thanks -
Manish



 AFAIK, again none that I know.

 --
 regards,

 Mulyadi Santosa
 Freelance Linux trainer and consultant

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





-- 
Thanks -
Manish
==
[$\*.^ -- I miss being one of them
==

--
To unsubscribe from this list: send an email with
unsubscribe kernelnewbies to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: how to call system call from kernelspace

2010-04-27 Thread Joel Fernandes
On Wed, Apr 28, 2010 at 8:35 AM, rahul patil rahul.deshmukhpa...@gmail.com
 wrote:

 i want to call open,write system calls from kernel space.


[oops, didn't hit reply-to-all at first, sorry rahul!]

Not sure about open, but for read/write system calls, provided you already
have file opened and have the file descriptor, the following code snippets
should work:

For reads:
struct file *file = fget(fd)
if (file) {
loff_t pos = file_pos_read(file);
ret = vfs_read(file, buf, count, pos);
file_pos_write(file, pos);
fput(file);
}

For writes:
struct file *file = fget(fd)
if (file) {
loff_t pos = file_pos_read(file);
ret = vfs_write(file, buf, count, pos);
file_pos_write(file, pos);
fput(file);
}

No magic there, this is essentially the same code that gets executed when
you make read/write system calls defined in fs/read_write.c except that you
don't have to export sys_read and sys_write

Its a better idea to call file-f_op-read and file-f_op-write directly
instead of vfs_write in the above code, skips a lot of checks and stuff. See
how loop driver does this in drivers/block/loop.c in function
 __do_lo_send_write.
You could even call write_begin and write_end directly if your backs fs
supports address space ops. Again good examples in loop driver.

HTH,
-Joel


question about get_user

2010-04-27 Thread Yang Fangkai
Hi, all,

I have a problem with get_user() macro. What I did is as follows:

I run the following program

int main()
{
   int a = 20;
   printf(address of a: %p, a);
   sleep(200);
   return 0;
}

When the program runs, it outputs the address of a, say, 0xbff91914.

Then I pass this address to a module running in Kernel Mode that
retrieves the contents at this address (at the time when I did this, I
also made sure the process didn't terminate, because I put it to sleep
for 200 seconds... ):

The address is firstly sent as a string, and I cast them into pointer type.

int * ptr = (int*)simple_strtol(buffer, NULL,16);
printk(address: %p,ptr); // I use this line to make sure the cast is
correct. When running, it does output bff91914
int val = 0;
int res;
res= get_user(val, (int*) ptr);

However, res is always not 0, meaning that get_user returns error. I
am wondering what is the problem

Thank you!!

--
To unsubscribe from this list: send an email with
unsubscribe kernelnewbies to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ