Re: Kernel boot panic

2016-12-12 Thread Kristof Provost

Please don’t top-post.

On 12 Dec 2016, at 10:59, Amit Mahadik wrote:
Yes I tried mounting the SD card on another Linux machine. I can mount 
it. Following is its 
log*root@sagark-Ubu14:~/amitm# 
mount

/dev/sda1 on / type ext4 (rw,errors=remount-ro)
proc on /proc type proc (rw,noexec,nosuid,nodev)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
tmpfs on /run type tmpfs (rw,noexec,nosuid,size=10%,mode=0755)
none on /run/lock type tmpfs (rw,noexec,nosuid,nodev,size=5242880)
none on /run/shm type tmpfs (rw,nosuid,nodev)
none on /run/user type tmpfs 
(rw,noexec,nosuid,nodev,size=104857600,mode=0755)

none on /sys/fs/pstore type pstore (rw)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc 
(rw,noexec,nosuid,nodev)
systemd on /sys/fs/cgroup/systemd type cgroup 
(rw,noexec,nosuid,nodev,none,name=systemd)
/dev/sdb1 on /media/evslab/BOOT type vfat 
(rw,nosuid,nodev,uid=1001,gid=1001,shortname=mixed,dmask=0077,utf8=1,showexec,flush,uhelper=udisks2)
/dev/sdb2 on /mnt type ext3 
(rw)**
I have created the ROOTFS image using buildroot 2016.05 version. The 
/dev management option selected is "Dynamic using devtmpfs + eudev" 
and corresponding DEVTMPS options are enabled in Kernel config.



Oooh, I missed this in the log the first time round:

[6.227066] Failed to create /dev/root: -2’

This is logged by `mount_root()`, if the `create_dev()` call fails.
It returned -2, which is `-ENOENT`.

Does your rootfs have a /dev directory?

Regards,
Kristof___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Kernel boot panic

2016-12-12 Thread Kristof Provost
On 12 Dec 2016, at 9:53, Amit Mahadik wrote:
> Yes I have compiled the EXT3 support into the kernel itself. But no 
> luck yet!
> Regards,Amit.
>
Have you tried mounting the ext3 partition in another linux machine?  
Your log
indicates the kernel is not able to mount the partition, so the most 
likely
causes are that the kernel doesn’t know how to read ext3 or that 
there’s no
ext3 there.

Regards,
Kristof

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


Re: Kernel boot panic

2016-12-08 Thread Kristof Provost
On 8 Dec 2016, at 15:59, Amit Mahadik wrote:
>      Hi,
>       I am trying to boot Linux kernel version 4.4.16 on custom ARM 
> based development platform.I want to separate rootfs and kernel Image 
> so that the size of my uImage is small. I followed the following 
> steps.
> 1. Partitioned the SD card. It has 2 partition. First partition is 
> formatted as vfat partition and    has uImage (without rootfs). 
> Second partition is formatted as ext3 and has the rootfs.2. I then 
> changed the U-Boot (version 2011.05) bootargs   Kernel command line: 
> console=ttyS0,115200 noinitrd rw rootfstype=ext3 root=/dev/mmcblk0p2 
>          rootwait mem=512M coherent_pool=4M no_console_suspend 
> resume=/dev/mtdblock3.
>
> However, while booting I get the following error 
> Failed to create /dev/root: -2VFS: Cannot open root device "mmcblk0p2" 
> or unknown-block(179,2): error -2
> I have also attached log for reference. Can anyone please point out 
> what I may be missing?

Well, your kernel finds the partition, but it’s still unable to open 
the root device.
Did you remember to compile ext3 support into your kernel (so not as a 
module)?

Regards,
Kristof

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


Re: initrd in embedded systems

2016-09-07 Thread Kristof Provost
On 7 Sep 2016, at 12:42, Madhu K wrote:
> I have one doubt, does all embedded system with Linux as operating system
> have initrd?
>

It depends, but many of them do not. (In fact, I’ve not seen any that do
use an initrd, but that doesn’t mean they don’t exist.)

As the hardware is known the required drivers are built in to the kernel
directly.

Regards,
Kristof

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


Re: Booting with SYSLINUX on Loopback Device: Kernel Panic - Where to Start?

2016-03-04 Thread Kristof Provost

> On 04 Mar 2016, at 23:50, Patrick  wrote:
> ​Thanks for the response.​ I had seen that StackOverflow post and done that a 
> couple of days ago. I was hoping there was another answer, since I wouldn't 
> be able to do that if I weren't using QEMU.
> 
If you weren’t using Qemu I’d point you at netconsole. The first step in 
debugging panics is always to figure out what the panic is.

> When I looked at the output from QEMU a couple of days ago, the kernel was 
> saying that it couldn't find a device to mount with the root filesystem. So I 
> generated an initrd image on the host Linux system, and I used that on the 
> guest which got me to a BusyBox prompt. But this was totally a hack, since I 
> didn't even know if getting an initrd image was really the next thing I 
> needed to do. I was hoping someone might be able to point me to something 
> that might explain what to do to get the kernel to mount a device with the 
> root filesystem.
> 
You want to pass the ‘root=/dev/foo’ option to your kernel. Obviously change 
/dev/foo into whatever device you’re booting from.

Regards,
Kristof

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


Re: Booting with SYSLINUX on Loopback Device: Kernel Panic - Where to Start?

2016-03-04 Thread Kristof Provost
On 2016-03-04 11:38:33 (-0700), Patrick  wrote:
> I was able to install SYSLINUX on a disk image and get the kernel I built
> to start booting Linux with QEMU pointing to a loopback device associated
> with the disk image. However, at some point far into the boot process, I
> get a kernel panic. I can't read the beginning of the error messages that
> the kernel prints, because the errors run off the screen.
> 
You should be able to persuade qemu to be a bit more helpful.
'-nographic' turns off graphical output and redirects the serial port to
the console (or just use '-serial'). You can then configure your kernel
to log to the serial port.

This should get you started:
http://stackoverflow.com/questions/19565116/redirect-qemu-window-output-to-terminal-running-qemu

Regards,
Kristof

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


Re: How can I send multiple unrelated patches?

2015-07-27 Thread Kristof Provost
On 2015-07-27 14:38:49 (+0800), Navy Cheng  wrote:
> How about the unrelated patches? How can I show the order of the unrelated
> patches?
> 
If the patches are unrelated I wouldn't expect the order to matter, so
just '[PATCH] Fix foo in bar' and '[PATCH] Prettify baz' should be fine.

If the order does matter (i.e. patch B requires patch A to be applied
before it can be applied) they're not really unrelated.

Regards,
Kristof

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


Re: Trouble in making an commit .

2015-06-18 Thread Kristof Provost

> On 18 Jun 2015, at 10:14, Sébastien Hinderer 
>  wrote:
> 
> Kristof Provost (2015/06/18 09:54 +0200):
>> 
>>> On 17 Jun 2015, at 20:01, Santhosh Pai  wrote:
>>> 
>>> The issue remains the same , i'm unable to perform commit . Below is the 
>>> o/p 
>>> 
>>> bash-4.2$ git add drivers/staging/comedi/comedi_fops.c
>>> bash-4.2$ git commit -s -v
>>> usage: git diff-index [-m] [--cached] []  
>>> [...]
>> This is odd. You’re calling git commit, but you’re getting usage
>>> information for git diff-index.
> 
> Isn't that because of the -v option which may require this call to show
> differences?
> 
This doesn’t suggest that that’s likely:
# git commit -v -s --bad-option
error: unknown option `bad-option’
usage: git commit [options] [--] …

That’s with git (git version 2.3.2 (Apple Git-55)). 

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


Re: Trouble in making an commit .

2015-06-18 Thread Kristof Provost

> On 17 Jun 2015, at 20:01, Santhosh Pai  wrote:
> 
> The issue remains the same , i'm unable to perform commit . Below is the o/p 
> 
> bash-4.2$ git add drivers/staging/comedi/comedi_fops.c
> bash-4.2$ git commit -s -v
> usage: git diff-index [-m] [--cached] []  
> [...]
This is odd. You’re calling git commit, but you’re getting usage information 
for git diff-index.

How did you install git? Have you tried reinstalling? Do you have any odd 
symlinks/aliases/shell functions/ … related to git?

Regards,
Kristof



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


Re: Help learning from my mistakes

2015-04-05 Thread Kristof Provost
On 2015-04-05 15:15:12 (-0400), Nicholas Krause  wrote:
>  The only difference I can tell is the kernel version.  I was
>  wondering however if anyone who has more experience in the kernel can
>  give me tips on how to address my benchmarking. 
>
Nick, as you've been told again and again: *you* need to do the work. No
one is going to divide up the work in bite-sized chunks for you.
You have to do research, you have to think about what the logical next
step is, you have to actually *work* at this.

You keep asking what you can do to improve your reputation or get
unbanned from the kernel mailing list. It's actually simple enough: Do
the work, then show us that you've done it. Next time you ask a question
explain what you've tried and researched to answer your own question.
When people ask you questions, *answer* *all* of them.

You've essentially ignored all of the questions gave you (hint: those
are not just questions, they are parts of the work you have to
do).

Regards,
Kristof

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


Re: Help learning from my mistakes

2015-04-05 Thread Kristof Provost
On 2015-04-05 14:45:28 (-0400), Nicholas Krause  wrote:
> 
> 
> On April 5, 2015 8:29:47 AM EDT, Kristof Provost  wrote:
> >On 2015-04-05 01:15:31 (-0400), valdis.kletni...@vt.edu
> > wrote:
> >> On Sat, 04 Apr 2015 19:00:42 -0400, Nicholas Krause said:
> >> >  are now slower by up to 3 times,
> >> 
> >> So what debugging did you already do to try to narrow this down?
> >>
> >While we're on the subject, let me indulge a pet peeve: How did you
> >measure this? Can you reproduce the measurement? Is the difference
> >statistically significant? What aspect of performance is worse? Task
> >switching time? IO throughput?
> >
> >Benchmarking is *hard*, and 'up to 3 times' is not the result of a
> >careful, well thought out benchmark.
> >
> I ran the make command on all of my CPU cores and timed  it.  Furthermore it 
> seems to be slower up to 3 times then my distribution kernel based off 3.16.

So, in other words, no, you've not done a careful benchmark at all.

What's the standard deviation on both measurements? How confident are
you (your answer should be a number) that there is a difference?
How have you accounted for VFS cache effects? Have you ensured that both
builds were from a completely clean tree? How have you ensured that no
other jobs interfered with the build (i.e. cron, user interaction, ...)?

Once you've established that there really is a difference you need to
start isolating contributing factors and figure out what's causing the
difference. Alternatively, you can start trying to figure out which part
of overall system performance has been degraded. That requires actually
understanding how the system works and using inspection tools (top,
iostat, perf, ...) to find out where the performance bottleneck is.

None of that is easy or quick. None of these questions can be answered
in one quick sentence. Certainly your overall answer should include more
information, and demonstrate more thought and effort, than 'I did a
build.'.

Regards,
Kristof

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


Re: Help learning from my mistakes

2015-04-05 Thread Kristof Provost
On 2015-04-05 01:15:31 (-0400), valdis.kletni...@vt.edu 
 wrote:
> On Sat, 04 Apr 2015 19:00:42 -0400, Nicholas Krause said:
> >  are now slower by up to 3 times,
> 
> So what debugging did you already do to try to narrow this down?
>
While we're on the subject, let me indulge a pet peeve: How did you
measure this? Can you reproduce the measurement? Is the difference
statistically significant? What aspect of performance is worse? Task
switching time? IO throughput?

Benchmarking is *hard*, and 'up to 3 times' is not the result of a
careful, well thought out benchmark.

Regards,
Kristof

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


Re: Problem in Getting Mainline Kernel

2014-12-04 Thread Kristof Provost
On 2014-12-04 20:21:58 (+0800), Freeman Zhang  
wrote:
> Finally I cloned the mainline kernel from
> "git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git".
> However, when I'm looking at the git directory, I got nothing but:
> 
>   .   ..  arch  .DS_Store  .git  .gitignore  .mailmap
> 
Are you by any chance trying to do this on an OS X machine?
That's going to lead to pain and suffering.

For example, there are a couple of files which have the same name with
different case, which isn't going to work on a default OS X install.
By default OS X has a case insensitive file system. It's possible to
change that, but you *really* want a Linux system to build the kernel.

Regards,
Kristof

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


Re: User space <==> kernel space for device wakeups.

2014-10-08 Thread Kristof Provost
On 2014-10-08 21:14:43 (+0530), Jeshwanth Kumar N K  
wrote:
> Wayback when I was working on some project to wake up userspace program for
> every rising edge in GPIO pin (hall sensor), I use to send signal to the
> PID from kernel, before that userspace has to register its PID with kernel
> module. 
> 
I've seen a certain vendor[1] do something similar. They saved the task
pointer for whichever process made the magical ioctl() call and used it
to send signals from the interrupt handler. It worked, right up to the
point where the process went away and then the kernel panicked.

Regards,
Kristof

[1] Who shall remain nameless here. Naming them would only give people
the impression that other vendors might be better.

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


Re: Should I do anything about this warning?

2014-10-08 Thread Kristof Provost
On 2014-10-08 12:43:58 (+0530), Sagar Padhye  wrote:
> I am new at kernel programming. I have written a driver for a custom
> device, running on arm board. It works well (for last few months).  I
> happen to look at kernel logs and I seen,
> 
> [231250.899146] WARNING: at kernel/workqueue.c:1953 
> process_one_work+0x398/0x52c()
> 
You triggered a warning in the code.

> The device is still working after this. No issues in operation. I am
> just sceptical about analyzing this issue? Do I need to check more? If
> yes how? with this trace?
> 
Yes, this indicates a potential problem.
You start my looking at line 1953 in kernel/workqueue.c, where you'll
see which specific warning you're triggering.

It's probably this one:
>   /* ensure we're on the correct CPU */
>WARN_ON_ONCE(!(pool->flags & POOL_DISASSOCIATED) &&
> raw_smp_processor_id() != pool->cpu);

Regards,
Kristof

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


Re: How to debug "Malformed Packet (Exception occurred)" when send a udp packet?

2014-09-16 Thread Kristof Provost
On 2014-09-07 17:12:33 (+0800), lx  wrote:
>   I want to send a udp packet in kernel module. the codes is:
Why?

> // iph->version = 4; iph->ihl = 5;
> put_unaligned(0x45, (unsigned char *)send_iph);
> send_iph->tos  = 0;
> put_unaligned(htons(iph_len), &(send_iph->tot_len));
^- That's probably your problem.

Regards,
Kristof

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


Re: [PowerPC] - Define error in arch/arch/powerpc/boot/io.h ??

2014-07-24 Thread Kristof Provost
On 2014-07-24 09:00:22 (-0300), Lucas Tanure  wrote:
> Line 2 of arch/arch/powerpc/boot/io.h :
> 
>  1  #ifndef _IO_H
>  2  #define __IO_H
>  3
>  4  #include "types.h"
> 
> Should be _IO_H, not __IO_H. I'm right ?
> 
That certainly looks wrong. It's also been wrong since October 2006, so
it's probably not actually causing problems.

Try sending it to the 'Trival Patch Monkey' ("For small patches you may
want to CC the Trivial Patch Monkey triv...@kernel.org which collects
"trivial" patches.")

-- 
Kristof

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


Re: Re: Linux Kernel Module program to obtain domain name from IP

2014-07-08 Thread Kristof Provost
On 2014-07-08 20:19:09 (+0800), shhuiw  wrote:
> DNS loopkup should use UDP packet, and you have to construct UDP request
> based on your captured IP addresses in your module.
DNS can actually use both TCP and UDP.

> And you have to use DNS server fallback lists and time-out control if some DNS
> server cannot work well.

Yeah. Doing DNS lookups (forward or reverse) is complicated. 
There's a dns_query function in the kernel (net/dns_resolver), which
apparently upcalls into user space, but I'd avoid dealing with DNS in
the kernel at all.

Just pass the IP address to user space and let it deal with it. There
are plenty of DNS libraries available. Odds are you need to pass the
resulting information to user space anyway, so you're not really losing
anything.

What are you trying to accomplish anyway?

Regards,
Kristof

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


Re: hook SIGSEGV

2014-05-14 Thread Kristof Provost
On 2014-05-10 21:46:01 (+0800), net.study@gmail.com 
 wrote:
>  I want to know is it possible to hook SIGSEGV to restart the
>  thread which the signal is sent to,without restart the whole
>  process? And record the place where has caused this signal?
> 
Yes, as others have already pointed out, you can hook SIGSEGV like any
other signal.

You're not going to be able to save the process any more, but you can
still collect some useful information.

I've found it very useful to have a SIGSEGV (and SIGPIPE, SIGABRT,
SIGFPE, SIGILL) handler which logs a backtrace (look at 'man backtrace')
to syslog. Very useful for debugging on targets where core dumps are
impractical.

Others have also pointed out that it might no longer be safe to call
printf() or malloc() there. That's true, but usually it's OK, and if it
turns out that it wasn't ... Well, you were crashing anyway.

Regards,
Kristof

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


Re: How to use memcpy in kernel driver

2014-01-27 Thread Kristof Provost
On 2014-01-27 11:53:00 (-0800), m silverstri  
wrote:
> How can I use memcoyp in memcpy?
> I try #include stdio.h and string.h, but .h fails to include during 
> compilation.
> 
That's because stdio.h is a C library header. You can't use the C
library in the kernel.

You should actually be able to include string.h, but you need the kernel
version, which lives in include/linux/string.h.
The kernel provides a few of the functions usually provided by the C
library. Things like memcpy() and memset() exist. printf() doesn't, but
there is an sprintf(), ...

Kristof

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


Re: Where is the version.h?

2014-01-27 Thread Kristof Provost
On 2014-01-27 10:05:05 (+0800), parmenides  wrote:
> According to LDD3, the linux/module.h automatically includes the
> linux/version, which define some macros to help test the kernel version.
> But I search the source tree, and can not find version.h in
> include/linux. Where can I find it?
> 
It lives in include/generated/uapi/linux/version.h

If you've never built a kernel in your tree you won't find it though,
because it's created from the Makefile. Look for version_h and
filechk_version.h.

Regards,
Kristof

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


Re: Packet Loss

2013-10-29 Thread Kristof Provost
On 2013-10-29 15:09:30 (+0530), Robert Clove  wrote:
> I just want to know are there any driver or kernel parameters that we can
> adjust to get the better packet capture?
> 
Not off-hand, no.

Please keep the mailing list in CC, perhaps someone else can help too.

Regards,
Kristof

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


Re: Packet Loss

2013-10-28 Thread Kristof Provost
On 2013-10-28 17:32:43 (+0530), Robert Clove  wrote:
> Kind of Packets :- *UDP*
> How are you generating them? :-* Packeth (
> http://packeth.sourceforge.net/packeth/Home.html)*
> kernel version : uname -r -   *2.6.32-358.18.1.el6.x86_64
> *
> Are you *SURE* you're sending 1000? - *ya checked through packeth status
> bar and also through ifconfig command*
> I have connected them through LAN cable (cat 6) back to back.
> 
> Changed cable but no use.
> What should i do?
> 
Break down the problem. Get that smart switch to tell you if the packets
are lost by the sender of the receiver.

Test if it's bidirectional (i.e. does it still happen if the switch the
sender and receiver)?

Does it still happen if you send only 100 packets? Do you still lose 30%
then, or do you lose more or less?

Perhaps try a kernel that isn't nearly five years old too.

Also, don't top-post.

Regards,
Kristof


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


Re: Packet Loss

2013-10-28 Thread Kristof Provost
On 2013-10-28 15:27:37 (+0530), Robert Clove  wrote:
> I am pumping an 1000 packets at 1Gbps and receiving on 300 packets on the
> other side.
> Both the servers are back to back connected.
> 
Change the cable. I have no idea if that's the cause, but it's an
extremely cheap and quick thing to test, so eliminate that.

> Please guide me what to do.

Mostly give us (and yourself) more information. What kind of packets?
How are you generating them? What software are you using? What kernel
version are you using? Are you *SURE* you're sending 1000? What have you
already tried?

Then try to break down the problem, narrow down the possible causes. For
example: stick a (known to be reliable) switch between the two machines
and have it tell you how many packets it sees. That'll at least let you
know if you're losing packets on the sending or the receiving side.

Regards,
Kristof


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


Re: tracing send and recv system call

2013-06-03 Thread Kristof Provost
On 2013-06-03 14:12:16 (+0530), Varun Sharma  wrote:
> Hi,
> I am tracing send and recv system call .From user space to kernel space
> switching
> send in kernel space not going into sys_send .It directly going into
> sys_sendto .

Apparently glibc implements send() using the sendto() syscall.
The problem isn't really with the traces you added to the kernel, but
that you forgot there's another layer between your application and the
kernel.

Regards.
Kristof

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


Re: Why the niceness is not always taken into account ?

2013-04-16 Thread Kristof Provost
On 2013-04-16 17:38:50 (+0200), Alexandre Laurent  
wrote:
> On the computer where I am testing, I have nothing related to cgroups.
> 
> Here a 'ps aux' in case I am missing something.

cgroups wouldn't actually show up in the process list. Check mount to
see if anyone mounts an fs of type 'cgroup'.

It's perhaps even more likely that it's related to SCHED_AUTOGROUP as
Michi suggested.

-- 
Kristof

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


Re: Why the niceness is not always taken into account ?

2013-04-16 Thread Kristof Provost
On 2013-04-16 10:35:05 (+0200), Alexandre Laurent  
wrote:
> My problem is that in some cases it is not working at all. It works
> fine if I am running both programs in the same instance of the 
> terminal,
> or from a script (so, same instance of interpreter). But this is not
> working if I am running the instances in separate SSH session. When I
> say it is not working, both instances will take 24s to run and the CPU
> usage is just shared between the tasks.

Is it possible that you're running systemd or something else which is
configuring cgroups?

Regards,
Kristof

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


Re: Building multiple .ko files from a single module

2013-04-09 Thread Kristof Provost
On 2013-04-09 17:03:14 (+0530), Sankar P  wrote:
> I have some source files: a.c b.c c.c etc. Now I need to generate a
> few .ko files such as, 1.ko, 2.ko, 3.ko etc.
> 
> For example, consider the following association between source files
> and the .ko files.
> 
> a.c a.h common.c common.h => 1.ko
> b.c b.h common.c common.h => 2.ko
> 

The following (untested!) should do the trick:
obj-$(CONFIG_MYMOD) += mymod_a.o mymod_b.o
mymod_a-objs += a.o common.o
mymod_b-objs += b.o common.o

I'd probably recommend creating three modules though: a, b and common.

Regards,
Kristof


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


Re: Driver managing network interface

2013-03-27 Thread Kristof Provost
On 2013-03-27 12:16:58 (+0100), Pietro Paolini  wrote:
> I know how retrieve the module from a char device but how can I find
> the module name behind the eth0 interface or more generally of a
> network interface ?
> 
sysfs will be your best bet:

# ls -lah /sys/class/net/eth0/device/driver
lrwxrwxrwx 1 root root 0 Mar 27 08:59 /sys/class/net/eth0/device/driver -> 
../../../bus/pci/drivers/e1000e

Regards,
Kristof


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


Re: error : insmod

2013-02-11 Thread Kristof Provost
On 2013-02-11 16:50:45 (+0530), sunil  wrote:
> when i executed the below line. i din't get what i suppose to
> get...the message "hello, world"..
> 
> did i miss any steps
> sunil@ubuntu:~/test/drive$ sudo insmod helloworld.ko
> 
The traces you've inserted in your kernel module do not print to stdout.
They get logged in the kernel ring buffer.

Try 'dmesg' after loading your module.

Regards,
Kristof


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


Re: error : insmod

2013-02-11 Thread Kristof Provost
On 2013-02-11 16:24:17 (+0530), sunil  wrote:
> Have a look at this:
> 
> donno wats happening:
> 
> sunil@ubuntu:~/test/drive$ sudo rmmod helloworld
> sunil@ubuntu:~/test/drive$ lsmod|grep hellow*
> Binary file helloworld.ko matches
> Binary file helloworld.o matches

This doesn't actually do what you seem to think it does.
You're not passing the 'hellow*' argument to grep. The 'hellow*' is
first expaned by your shell, so it probably turns that command line into
'lsmod | grep helloworld.c helloworld.o helloworld.ko'.
Try using 'lsmod | grep hellow' instead (i.e. without the *).

> sunil@ubuntu:~/test/drive$ modprobe -r helloworld
> FATAL: Module helloworld not found.

Obviously, because your previous command succeeded. The module is no
longer loaded.

Regards,
Kristof

PS: Please don't top-post.
PS 2: Please keep the mailing list in cc.


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


Re: error : insmod

2013-02-11 Thread Kristof Provost
On 2013-02-11 16:10:38 (+0530), sunil  wrote:
> -output
> sunil@ubuntu:~/test/drive$ sudo insmod ./helloworld.ko
> insmod: error inserting './helloworld.ko': -1 File exists
> 
This means you've already loaded the module.

Try 'sudo rmmod helloworld' to unload it first.
This should generate the 'Goodbye, cruel world' dmesg trace.
After that you can load the module again.

Regards,
Kristof

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


Re: error : insmod

2013-02-11 Thread Kristof Provost
On 2013-02-11 15:24:08 (+0530), sunil  wrote:
> while inserting module to the linux kernel, m facing this problem
> ---ERROR-
> 
> sunil@ubuntu:~/test/drive$ insmod helloworld.ko
> insmod: error inserting 'helloworld.ko': -1 Operation not permitted
> 
For obvious reasons normal users are not allowed to load kernel modules.
This requires root access (or more accurately, CAP_SYS_MODULE
capabilities). That's why your insmod fails.

> sunil@ubuntu:~/test/drive$ sudo modprobe helloworld
> FATAL: Module helloworld not found.
> 
This is a different action from 'insmod helloworld.ko'.

modprobe tries to load the module from /lib/modules/`uname -r`.
It's slightly more convenient because it will also load all modules this
one depends on.

In this case this fails because your module doesn't actually live in
/lib/modules/

Try sudo insmod helloworld.ko instead.

Regards,
Kristof


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


Re: method to get backtrace of kernel function?

2013-01-29 Thread Kristof Provost
On 2013-01-29 14:21:24 (+0700), Mulyadi Santosa  
wrote:
> >   Can this function be used in user application?
> 
> no. But I guess I see quite similar function provided by glibc/gcc.
> Forgot the function name though, sorry...
> 
backtrace()

http://www.gnu.org/software/libc/manual/html_node/Backtraces.html

-- 
Kristof

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


Re: Kernel-space flirting with user-space

2013-01-11 Thread Kristof Provost
On 2013-01-10 16:09:49 (-0500), Simon  wrote:
>   Firstly, I was wondering if it would be possible to implement the
> filesystem entirely as a kernel module.  I would need TCP/UDP sockets.  I
> think this is really not the recommended approach, but an advantage I see
> is it could be used to mount the root filesystem before calling init (that
> would be before user-space exists, right?).  On the other hand, separating
> the work to have a program/daemon in user-space do the communication and
> processing would allow me to write that part in C++ (which I personally
> prefer).

It's certainly possible to implement a network file system entirely in
kernel space. That's where NFS is implemented.
If you *really* care about performance it's pretty much the only way to
go. If you don't you should keep as much as possible in user space.

In either case I'd recommend you start your development on top of fuse
though. That means you can implement all new code in user space, in
whatever language you prefer. It'll be much easier to debug in any case.
Think of it as a fast prototype, to validate your protocol.

Kristof


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


Re: Opening a device driver file.

2012-12-18 Thread Kristof Provost
On 2012-12-18 07:53:44 (+0530), Niroj Pokhrel  wrote:
> Output: Device Open Failed -1
> 
Does the device node /dev/niroj_char exist? Note that, depending on your
system, device nodes are never, sometimes or always created when the
kernel creates a new character device.

Regards,
Kristof


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


Re: IPV6 related constants for netlink socket

2012-10-31 Thread Kristof Provost
On 2012-10-31 15:20:58 (+0530), Murali Annamneni  wrote:
> I'm trying to create a Netlink socket to configure an ipv6 interface.
> The socket call I used is -
> 
> socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE6);
> 
> I'm getting compiler error "error: NETLINK_ROUTE6 undeclared (first use in 
> this function)"
> And I'm facing the same problem for "AF_NETLINK6".
> 
That'd be because NETLINK_ROUTE6 and AF_NETLINK6 don't actually exist.

> I grep'ed in source code of 2.6.32 kernel and system header files, I
> didn't find anywhere these constants.  Are these constants are correct
> ? If not, what are the correct one's and in which header file I can
> find them.

Take a look at rtnetlink_rcv_msg() in net/core/rtnetlink.c
One of the things it extracts from the netlink message is the family. In
other words, you need to create a plain NETLINK_ROUTE socket, and
specify the family in the message itself. You can use the same socket
for both IPv4 and IPv6.

(My comments reflect the current kernel, but they're probably also valid
for 2.6.32)

Regards,
Kristof

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


Re: Linux kernel boot process

2012-08-04 Thread Kristof Provost
On 2012-08-04 21:15:15 (+0530), Sannu K  wrote:
> Is it possible to determine the reason for more time in hibernation
> compared to windows (or profile the resume time)? If possible I could
> do it in my machine and get some info which may be useful. Some one
> may jump to solve this (or there may be some magic tweak to get a
> better resume time) once it is profiled.
> 
Possibly. I haven't looked at the details of the Linux hibernation
subsystem. Take a look at Documentation/power/basic-pm-debugging.txt for
a basic introduction.

> >> Why should all the drivers be started again? Just we can load
> >> the disk driver and some essential part of the kernel, disk driver (or
> >> only few drivers necessary for reading the hibernate image) and use
> >> the drivers stored in the disk (from hibernation image) for rest of
> >> the devices.
> > When resuming from hibernation all devices were powered down. The kernel
> > needs to run through all of the initialisation code again. It needs to
> > upload firmware, set configuration registers, ...
> 
> That makes sense. Does that mean during hibernation the state of
> drivers will not be preserved? 

That's correct.

> Will the driver code be discarded
> without saving in hibernation image (as we are starting the driver
> again while resuming)?

Again, I'm not an expert, but I see no reason to preserve the driver
state (or perhaps even the rest of the kernel state). I believe the
kernel doesn't even distinguish between a normal boot and a resume from
hibernation until just before it starts userspace.

Regards,
Kristof


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


Re: Linux kernel boot process

2012-08-04 Thread Kristof Provost
On 2012-08-04 20:53:00 (+0530), Sannu K  wrote:
> I had a doubt for long regarding hibernation. It takes a very long
> time to resume from hibernation in Linux compared to windows. 
>
I don't actually have a windows machine to compare. It's quite possible
that this is true, but I can't say why it'd be the case.

> Why should all the drivers be started again? Just we can load
> the disk driver and some essential part of the kernel, disk driver (or
> only few drivers necessary for reading the hibernate image) and use
> the drivers stored in the disk (from hibernation image) for rest of
> the devices. 
When resuming from hibernation all devices were powered down. The kernel
needs to run through all of the initialisation code again. It needs to
upload firmware, set configuration registers, ...

Regards,
Kristof


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


Re: Linux kernel boot process

2012-08-04 Thread Kristof Provost
On 2012-08-04 10:56:38 (+0530), Kumar Sukhani  wrote:
> I heard that windows 8 have change its boot process to a hybrid mood. In
> which it shutdowns the user applications and hibernates the kernel and
> device drivers[1].

The question "Why on earth would you want that?" comes to mind.

I guess you get faster hibernation if you don't need to write all of
the memory state to disk, but still...

Even then you only gain a little on core services startup. I'd infer
that they have serious architectural issues if this saves them a lot of
startup time. After all, hibernation (i.e. suspend to disk) means they
need to re-start the kernel and drivers completely anyway.

> Can the same be introduce in Linux kernel?
> 
I'm sure it's possible. In fact, I think you can probably script it with
a little help from consolekit/gnome or something like that.

Mostly I don't see the point.

Regards,
Kristof


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


Re: UDP packets are getting dropped because of invalied checksum though checksum offload is enabled in kernel-2.6.32

2012-07-19 Thread Kristof Provost
On 2012-07-19 18:28:57 (+0530), Murali Annamneni  wrote:
> Hi All,
> 
> I have written a kernel module using netfilter framework. In my code I'll do 
> some modifications to the header & payload parts of UDP packet in pre & post 
> hooks.
> After modifying the udp packet, I'm computing ip & udp checksum. This 
> computation is consuming some cpu cycles.
> Now, I want to offload this computation to the Ethernet device. For this I 
> have commented the checksum computation in my code and enabled the checksum 
> offload parameters of my Ethernet device.
> While testing, I found that kernel is dropping the packets because of invalid 
> checksums for ip & udp packets.
> I have few doubts regarding checksum offload
> 
Wild guess: try setting the checksum to zero before sending the packet.
It's possible that the offload engine won't recompute checksums unless
they're zero (i.e. it might assume non-zero checksums are already correct).

Regards,
Kristof


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


Re: [RFC]Something wrong with my module

2012-04-12 Thread Kristof Provost
On 2012-04-12 22:08:08 (+0800), harryxiyou  wrote:
> On Thu, Apr 12, 2012 at 10:04 PM, harryxiyou  wrote:
> > On Thu, Apr 12, 2012 at 9:59 PM, Frank Ch. Eigler  wrote:
> >>
> >> kristof wrote:
> >>
> >>> [...]
> >>> You're iterating over the tasks list without locking it.
> >>> [...]
> >>> Try to take the tasklist_lock.
> >>
> >> Unfortunately, tasklist_lock is not SYMBOL_EXPORT*'d to modules.
> >
> > What about other ones? Do you have any other suggestions?
> 
> What about task_lock() ?
> 
task_lock() locks a single task, not the list of tasks.

I'd be included to take the fact that tasklist_lock is not exported as a
hint that you're not supposed to be messing with the list of tasks from
kernel modules.

Regards,
Kristof


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


Re: [RFC]Something wrong with my module

2012-04-12 Thread Kristof Provost
On 2012-04-12 18:16:56 (+0800), harryxiyou  wrote:
> Hi greg,
> 
> I write a module for inserting a PCB or delete a PCB to kernel's
> PCB tree, but when i run it something wrong happens to me like following.
> My environment is "Linux 10 2.6.35-22-generic #33-Ubuntu SMP Sun Sep
> 19 20:34:50 UTC 2010 i686 GNU/Linux"
> 
>   
>   printk("Search for insert task>\n");
>   task = &init_task;
>   list_for_each(pos, &task->tasks) {
>   p = list_entry(pos, struct task_struct, tasks);
>   count++;
>   if (0 == p->pid) {
>   rm_task(p);
>   }
>   printk("pid: %d, state: %ld, comm: %s\n", p->pid, p->state, 
> p->comm);
>   }
>
You're iterating over the tasks list without locking it.

What do you think happens if someone else comes along and modifies it
while you're reading it?

Try to take the tasklist_lock.

Regards,
Kristof


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


Re: kernel panic after VFS mount in FPGA board

2012-04-11 Thread Kristof Provost
On 2012-04-11 19:03:42 (+0530), pcuser p  wrote:
> I'm getting kernel panic after cramfs root file system is mounted,I am
> expecting to enter login prompt after root file system is mounted.
> 
> Kernel cmd line : mem=32M console=ttySAC0,115200 root=/dev/ram0
> rootfstype=cramfs init=/linuxrc initrd=0x8080,8M user_debug=31
> 
> *linuxrc init script*
> #!/bin/sh**
> /bin/echo "mount /etc as ramfs"
> /bin/mount -n -t ramfs ramfs /etc
> /bin/mount -n -t tmpfs tmpfs /tmp
> exec /sbin/init
> 
> I tried  with this init script,but kernel is hanging without any message..
> I changed it a bit as below, to see if it reads the init script
> 
> #!/bin/sh
> /bin/echo "Entering Init script"
> 
Init isn't allowed to exit.
That's probably why you're seeing the panic. Try starting a shell after
the /bin/echo, or just using /bin/sh as init.

> with this changes,I am expect to get print message "Entering Init script"
> after cramfs is mounted,but I am getting panic message which is attached
> below.
>
Probably because the system panics before the stdout buffers make it to
the console.

Regards,
Kristof


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


Re: freeing locks acquired by kernel thread?

2012-04-04 Thread Kristof Provost
On 2012-04-04 10:50:23 (-0500), Asim  wrote:
> Hi,
> 
> I have a driver thread that I kill using do_exit(SIGKILL) upon
> exception. Unfortunately, I do not see it releasing all locks when it
> exits and I get a lockdep trace. The exit_sem() code does not seem to
> free my mutexes.
> 
> If anyone has had success in clearing all locks of a thread upon exit,
> or has a pointer to such an existing code in kernel it would be
> useful.
> 
"Don't do that!"

You're not programming in user space. The kernel won't clean up after you.
Manage your locks yourself, don't just kill threads and expect
everything to work!
You need to signal your thread to stop and let it clean up everything
before it exists.

More abstractly: you have mutexes which implies you have shared data
structures between the thread you want to kill and some other code.
How could you ensure the data is in a consistent state if the thread can
be killed at any point?

Regards,
Kristof


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


Re: Semaphore

2012-02-24 Thread Kristof Provost
On 2012-02-24 12:15:03 (+0200), Kosta Zertsekel  wrote:
> I think of user land program opening a socket and crashing on
> segmentation fault.
> In code 'socket' syscall does:
> sock_map_fd --> sock_alloc_file --> alloc_file --> ... get lost ...
> Where exactly in this case lock is held - I mean the lock that gets
> released when user land process dies?

In this case there doesn't appear to be any lock. The sock_map_fd
function is most probably called from the socket syscall. This call
isn't locked. Multiple processes can be in the socket syscall at the
same time.
There certainly won't be a (kernel) lock which is held between two system 
calls.

Regards,
Kristof


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


Re: Semaphore

2012-02-24 Thread Kristof Provost
On 2012-02-24 11:25:00 (+0200), Kosta Zertsekel  wrote:
> On Fri, Feb 24, 2012 at 11:04 AM, Kristof Provost  wrote:
> > On 2012-02-24 09:07:40 (+0200), Kosta Zertsekel  wrote:
> >> >> > Imagine a driver which only one app can use at a time (perhaps a 
> >> >> > serial
> >> >> > port). The kernel will take a lock when the user space app open()s the
> >> >> > device node and release it when it close()s.
> >> >> > If the app segfaults in between the open() and close() the lock will
> >> >> > still get released. The kernel always cleans up open files for stopped
> >> >> > processes, regardless of how they stop. During this cleanup the kernel
> >> >> > will close() the device node, and as a result the driver will release
> >> >> > the lock.
> >>
> >> Can you please point to some code in Linux Kernel that does the job?
> >
> > In kernel/exit.c, look at do_exit(). It cleans up a process after it's
> > terminated (for whatever reason).
> > It does a lot of cleanup, but through exit_files() -> put_files_struct()
> > -> close_files() it ends up iterating over all open file descriptors and
> > closing them.
> > What's done for each close depends on what the process had open. Normal
> > files will just be closed, or a TCP socket might be closed, or if a
> > device node was opened the corresponding drivers close() function will
> > be called.
> 
> I meant that I don't see any semaphore related stuff in do_exit().
> It seems that semaphore just remains there in the system after a user
> land task is killed...
> 
In this (fictional, I've not looked at the serial driver code) example I'm 
assuming a semaphore owned by a driver. The user space application is using 
the driver through a device node. The semaphore is managed by the driver, 
and released when the close is called.
The driver does not know how (or even if) the application stopped, only
that it closed the file descriptor.

What specific type of semaphore are you interested in? Who acquires it,
what does it protect?

Regards,
Kristof


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


Re: Semaphore

2012-02-24 Thread Kristof Provost
On 2012-02-24 09:07:40 (+0200), Kosta Zertsekel  wrote:
> >> > Imagine a driver which only one app can use at a time (perhaps a serial
> >> > port). The kernel will take a lock when the user space app open()s the
> >> > device node and release it when it close()s.
> >> > If the app segfaults in between the open() and close() the lock will
> >> > still get released. The kernel always cleans up open files for stopped
> >> > processes, regardless of how they stop. During this cleanup the kernel
> >> > will close() the device node, and as a result the driver will release
> >> > the lock.
> 
> Can you please point to some code in Linux Kernel that does the job?

In kernel/exit.c, look at do_exit(). It cleans up a process after it's
terminated (for whatever reason).
It does a lot of cleanup, but through exit_files() -> put_files_struct()
-> close_files() it ends up iterating over all open file descriptors and
closing them.
What's done for each close depends on what the process had open. Normal
files will just be closed, or a TCP socket might be closed, or if a
device node was opened the corresponding drivers close() function will
be called.

Regards,
Kristof


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


Re: Semaphore

2012-02-22 Thread Kristof Provost
On 2012-02-22 11:53:12 (+), Anuz Pratap Singh Tomar 
 wrote:
> On Wed, Feb 22, 2012 at 9:48 AM, Kristof Provost  wrote:
> 
> > On 2012-02-22 11:01:52 (+0200), Konstantin Zertsekel 
> > wrote:
> > > On Tue, Feb 21, 2012 at 6:14 PM, Dave Hylands 
> > wrote:
> > > > I'm assuming that the semaphore is one which is held across multiple
> > > > calls into the kernel, otherwise you don't have an issue in the first
> > > > place, unless there is a bug on the kernel side of things which
> > > > actually caused the process to terminate.
> > >
> > > Ok, but what happens if things go wrong?
> > > For example, it driver exists abnormally (segmentation fault or
> > something)?
> > > Anyway, it seems very strange that the responsibility is of a driver
> > alone!
> > > There is the *kernel* in the system to take care of abnormal
> > > situation, not the exit function of a driver...
> > >
> > The driver is part of the kernel. If it dies the whole kernel can
> > (perhaps even should) die.
> >
> > There are systems, like Minix, where drivers don't run in kernel mode
> > and where a crashing driver won't take the system down.
> > There are advantages and disadvantages to that approach.
> > See http://en.wikipedia.org/wiki/Microkernel
> >
> >
> I am curious though if userspace gets segmentation fault, which is SIGSEGV,
> kernel should be the one sending that to user space. And while sending
> SIGSEGV, it must be doing some exit cleanup, wherein it frees all
> resources. However unlike memory, i haven't seen exit code which frees lock
> as well?
> 
You're talking about a user space application crashing, Konstantin was
talking about crashes in kernel space. These are two very different
things.

In either case we're talking about a lock inside the kernel.

For the first case:
Imagine a driver which only one app can use at a time (perhaps a serial
port). The kernel will take a lock when the user space app open()s the
device node and release it when it close()s.
If the app segfaults in between the open() and close() the lock will
still get released. The kernel always cleans up open files for stopped
processes, regardless of how they stop. During this cleanup the kernel
will close() the device node, and as a result the driver will release
the lock.

In the second case:
A kernel thread has a lock held, for whatever reason. It can be
terminated for a variety of reasons (*all* of them bugs or hardware
problems). For example it fails a BUG_ON check, or causes a fault by
accessing unmapped memory. In that case the oops handler will terminate
the thread, but in that case the lock will still be held, and never
unlocked.
This results in an incorrect state of the kernel! Some things might
still work, others will be broken.

Regards,
Kristof


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


Re: Semaphore

2012-02-22 Thread Kristof Provost
On 2012-02-22 11:01:52 (+0200), Konstantin Zertsekel  
wrote:
> On Tue, Feb 21, 2012 at 6:14 PM, Dave Hylands  wrote:
> > I'm assuming that the semaphore is one which is held across multiple
> > calls into the kernel, otherwise you don't have an issue in the first
> > place, unless there is a bug on the kernel side of things which
> > actually caused the process to terminate.
> 
> Ok, but what happens if things go wrong?
> For example, it driver exists abnormally (segmentation fault or something)?
> Anyway, it seems very strange that the responsibility is of a driver alone!
> There is the *kernel* in the system to take care of abnormal
> situation, not the exit function of a driver...
> 
The driver is part of the kernel. If it dies the whole kernel can
(perhaps even should) die.

There are systems, like Minix, where drivers don't run in kernel mode
and where a crashing driver won't take the system down.
There are advantages and disadvantages to that approach.
See http://en.wikipedia.org/wiki/Microkernel

Kristof


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


Re: Recursive Makefile howto

2012-01-27 Thread Kristof Provost
On 2012-01-27 17:38:11 (+0530), Manavendra Nath Manav  
wrote:
> Now, I am getting error in the make part of "Build_sqllib" but the
> makefile continues to next line. I guess, I need to add "|| exit" also
> with this make command. Kristof, can you pls also explain me the
> meanings of $$d, $@, and $? as used in Makefiles.

$$d is not a make variable, but a shell variable. The double '$' is an
escape sequence. In fact, $? should be $$?, because we want the shell
to interpret it. I suspect it gets replaced by an empty string, and in
that case exit returns the exit status from the previous command.
We can just remove $$? in other words.

$@ is a make variable, an automatic variable. It always contains the
file name of the target. 

Regards,
Kristof


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


Re: Recursive Makefile howto

2012-01-27 Thread Kristof Provost
On 2012-01-27 11:43:10 (+0530), Manavendra Nath Manav  
wrote:
> I have developed a Makefile which recursively builds the code spread
> across multiple directories, each having it's own Makefile.
> 
> build_all: targetA \
>targetB \
>target C
> 
> Now, the problem is that even when the Makefile of targetA fails, the
> master Makefile continues building with targetB and targetC. I can
> also see the make errors being printed on console. I want the make to
> stop immediately at the first error encountered in any target
> Makefile. How to do this?
> 
It would be a lot easier to help you if you'd post the relevant bits of
your Makefile.

Dusting off my crystal ball, I see in the mists that your makefile looks
something like this:

build:
for d in $(DIRS) ; \
do \
$(MAKE) -C $$d $@ ; \
done

The problem here is that make considers the whole for loop as one and
doesn't get the exit status of each sub-make, but only of the last one.

Try something like this instead:

build:
for d in $(DIRS) ; \
do \
$(MAKE) -C $$d $@ || exit $? ; \
done

Regards,
Kristof


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


Re: How to create some threads running tha same function

2011-09-15 Thread Kristof Provost
On 2011-09-15 22:20:03 (+0800), Parmenides  wrote:
>I will try to test how to create kernel threads and have write a
> kernel module which creates a number of kernel threads running the
> same function. But the results is somewhat confusing.
> 
>   static int kthread_init(void)
>   {
>int i;
> 
>for (i = 0; i < MAX_KTHREAD; i++){
> ktask[i] = kthread_run(my_kthread, &i, "mythread[%d]", i);
>}
>return 0;
>   }

You're passing the address of a stack variable (i) as data pointer.
That's not right, because as soon as you exit the kthread_init function
the data may be overwritten.

The fact that it works in some cases is pure coincidence.

Regards,
Kristof


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


Re: Re: performance about use Linux as a router

2011-07-06 Thread Kristof Provost
On 2011-07-06 23:48:18 (+0800), jiangtao.jit  wrote:
> 5.brctl show like 
> bridge name bridge id   STP enabled interfaces
> br0no  eth0

You've got a loop in your Ethernet network and spanning tree is
disabled.
The surprising bit is that you manage to get any packets through at all.

Ethernet packets don't have a TTL field, so if they end up in a loop
(for example br0 -> eth0 -> LAN -> eth1 -> br0 -> ...) they just keep
getting repeated.

brctl br0 stp on should fix your network.

I suspect you're trying to do bonding though, which (as far as I know,
having never played with it myself) is configured completely differently 
and might require support from the switch.

Regards,
Kristof


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