kernel hack

2005-09-25 Thread kamal kc
does anybody know what is the best way
to start kernel hack.

Any references to any web page would 
be appreciated



__ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


malloc() in kernel and increasing mbuf and cluster size

2005-10-17 Thread kamal kc
this may be a trivial question for many of you
but i am confused in doing memory allocation in the 
kernel.

sys/malloc.h has function prototypes for malloc()
kern/kern_malloc.c defines the malloc()

the malloc() definition is

void *
malloc(size, type, flags)
unsigned long size;
struct malloc_type *type;
int flags;

i understand the size and flags but what shall i 
do with the malloc_type.

suppose i want to allocate 1024 bytes then how 
should i call the malloc ?

i set -->
size=1024
flags=M_WAITOK
 type= (i don't know what/how to initialize
  the type) 


Next thing is that i want to make the kernel process 
network packets very fast. 
i think of increasing the mbuf and cluster size.

i want to if there will be any effect on increasing 
the mbuf and cluster size.

what would be an appropriate size of mbuf and cluster
if I use 
 i. 512 MB RAM
 iI. 1024 MB RAM
 
which parts of the kernel will be affected by 
changing the mbuf and cluster size ?

i think somebody maybe able to help me.

thanks folks.
kamal 












__ 
Yahoo! Music Unlimited 
Access over 1 million songs. Try it free.
http://music.yahoo.com/unlimited/
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: malloc() in kernel and increasing mbuf and cluster size

2005-10-17 Thread kamal kc
> > sys/malloc.h has function prototypes for malloc()
> > kern/kern_malloc.c defines the malloc()
> > 
> > the malloc() definition is
> > 
> > void *
> > malloc(size, type, flags)
> > unsigned long size;
> > struct malloc_type *type;
> > int flags;
> > 
> > i understand the size and flags but what shall i 
> > do with the malloc_type.
> 
> man 9 malloc :-)
> 

i saw the man pages.

it says to use malloc_type via 

MALLOC_DEFINE(type,shortdesc,longdesc)
MALLOC_DECLARE(type)

the man pages use M_FOOBUF(where did it come from ??)
in the field type.

Now how should i code it.

struct malloc_type  mytype;
mytype=MALLOC_DEFINE(.,"mybuffers","mybuffers");

what should i put in the type field ??

thanks in advance,
kamal








__ 
Yahoo! Music Unlimited 
Access over 1 million songs. Try it free.
http://music.yahoo.com/unlimited/
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


in_cksum() for ip packets with multiple mbufs

2005-10-23 Thread kamal kc
i come across this unusual problem.

i changed the ip_tos field of the struct ip and
computed
the checksum by using in_cksum().

when the packet uses only one mbuf the computed 
checksum is ok but when the packet uses more than one 
mbuf then the computed checksum is wrong.

eg. pinging with payload less than 1470 bytes is ok
but with payload greater than 1480 bytes does not 
work. (the error being bad checksum --that i knew 
by capturing network packets by ethereal)

is it a real problem or i have made some mistake.

i put the code before the if_output() in the 
ip_output() function.

help !!

kamal









__ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: in_cksum() for ip packets with multiple mbufs

2005-10-23 Thread kamal kc
> > i changed the ip_tos field of the struct ip and
> computed the checksum
> > by using in_cksum().
> >
> > when the packet uses only one mbuf the computed
> checksum is ok but
> > when the packet uses more than one mbuf then the
> computed checksum is
> > wrong.
> 
> Note that the IP header contains a checksum of the
> IP header only.
> 
> A common mistake is to calculate the checksum of
> data too, which results
> in an invalid IP header checksum.

ok i made this mistake to calculate the checksum
over the entire IP payload.

i corrected this and used the ip_hl field :::
   
/* the argument m is the (struct mbuf *) that 
 * contains the packet data
 */

void copy_the_memorybuffer(struct mbuf **m)
{  
   struct mbuf *mbuf_pointer=*m;
   struct mbuf **next_packet;

   next_packet=&mbuf_pointer;

   struct ip *my_ip_hdr;
   my_ip_hdr=mtod((*next_packet),struct ip *);
   my_ip_hdr->ip_tos=64;
   my_ip_hdr->ip_sum=0;
  
   my_ip_hdr->ip_sum=
   in_cksum((*next_packet),(my_ip_hdr->ip_hl<<2));
  ...
} 

but still it doesn't seem to work. and the problem
is still there.

i am really confused ..
 
> > eg. pinging with payload less than 1470 bytes is
> ok but with payload
> > greater than 1480 bytes does not work. (the error
> being bad checksum
> > --that i knew by capturing network packets by
> ethereal)
> >
> > is it a real problem or i have made some mistake.
> >
> > i put the code before the if_output() in the
> ip_output() function.
> 
> Show us the diff, if possible :)

sorry i did not understand what to show here.
does it mean to show the packet data captured by 
the ethereal..

thanks kamal




__ 
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: in_cksum() for ip packets with multiple mbufs

2005-10-23 Thread kamal kc

> > void copy_the_memorybuffer(struct mbuf **m)
> > {
> >struct mbuf *mbuf_pointer=*m;
> >struct mbuf **next_packet;
> >
> >next_packet=&mbuf_pointer;
> >
> >struct ip *my_ip_hdr;
> >my_ip_hdr=mtod((*next_packet),struct ip *);
> >my_ip_hdr->ip_tos=64;
> >my_ip_hdr->ip_sum=0;
> >
> >my_ip_hdr->ip_sum=
> >   
> in_cksum((*next_packet),(my_ip_hdr->ip_hl<<2));
> >   ...
> > }
> 
> Why all this pointer fun?  How do you know that it's
> safe to dereference
> `m' when you do:
> 
>   struct mbuf *mbuf_pointer=*m;
> 
> Why are you dereferencing `m' once to obtain
> mbuf_pointer and then
> taking the address of that to obtain next_packet,
> when you could
> just do:
> 
>   next_packet = m;
> 
> There are also several other problems with
> copy_the_memorybuffer() as
> it's written above:
> 
> - It's considered bad style to mix declarations
> and code the way you
>   have done above
> 
> - It is probably better to return the copy of
> the mbuf you're
>   fiddling with, instead of modifying in place a
> parameter of the
>   function.
 
one thing i would like to ask?

does it make any difference if i free the mbuf 'm'
passed to if_output() and pass my own mbuf to 
if_output. 

is the original mbuf referenced by any
other pointers or global variables ?? 

i couldn't figure out much from the sources.
 
> - If you are not *REALLY* copying the data of
> the mbuf, then
>   the name of copy_the_memorybuffer() is very
> confusing.

i didn't showed in the above code snippet but
actually i am copying the data contained in the 
mbufs in a character array. 

my purpose is to compress the data contained in
the ip packet
 
> - What is the magic constant 64 that is assigned
> to ip_tos?

that was just to see that i could actually modify
the ip header.

> What you probably want to do is something like:
> 
> void
> ip_set_type_of_service(struct mbuf *m)
> {
> struct ip *iph;
> 
> assert(m != NULL);
> 
> iph = mtod(m, struct ip *);
> iph->ip_tos = IPTOS_PREC_IMMEDIATE;
> iph->ip_sum = 0;
> iph->ip_sum = in_cksum((uint16_t *)iph,
> iph->ip_hl << 2);
> }

thanks i will try this code and try to make the 
code simpler next time.

> but that's not copying anything.
> 
> > but still it doesn't seem to work. and the problem
> > is still there.
> 
> You have obviously made a lot of changes that we
> haven't seen yet.
> Instead of posting snippets here and there, save a
> copy of the original
> sources somewhere, then a copy of the new sources,
> and run diff(1) on
> the two directories to extract *ALL* the changes.
> 
>   $ cd /usr/src
>   $ diff -ruN src.old/ src/ > /tmp/patchfile
> 
> and put the patchfile somewhere online where we can
> have a look at all
> the changes.

i am new to kernel sources and kernel programming and
thank you for informing me on the diff(1).

thanks to you that the problem was solved (i don't 
know if it is completely ok). i found that
   - i had made mistake in computing checksum. 
  earlier checksum was computed over the whole 
dat

I may soon put up patchfiles on web. 
thanks.



 


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: in_cksum() for ip packets with multiple mbufs

2005-10-23 Thread kamal kc

> > void copy_the_memorybuffer(struct mbuf **m)
> > {
> >struct mbuf *mbuf_pointer=*m;
> >struct mbuf **next_packet;
> >
> >next_packet=&mbuf_pointer;
> >
> >struct ip *my_ip_hdr;
> >my_ip_hdr=mtod((*next_packet),struct ip *);
> >my_ip_hdr->ip_tos=64;
> >my_ip_hdr->ip_sum=0;
> >
> >my_ip_hdr->ip_sum=
> >   
> in_cksum((*next_packet),(my_ip_hdr->ip_hl<<2));
> >   ...
> > }
> 
> Why all this pointer fun?  How do you know that it's
> safe to dereference
> `m' when you do:
> 
>   struct mbuf *mbuf_pointer=*m;
> 
> Why are you dereferencing `m' once to obtain
> mbuf_pointer and then
> taking the address of that to obtain next_packet,
> when you could
> just do:
> 
>   next_packet = m;
> 
> There are also several other problems with
> copy_the_memorybuffer() as
> it's written above:
> 
> - It's considered bad style to mix declarations
> and code the way you
>   have done above
> 
> - It is probably better to return the copy of
> the mbuf you're
>   fiddling with, instead of modifying in place a
> parameter of the
>   function.
 
one thing i would like to ask?

does it make any difference if i free the mbuf 'm'
passed to if_output() and pass my own mbuf to 
if_output. 

is the original mbuf referenced by any
other pointers or global variables ?? 

i couldn't figure out much from the sources.
 
> - If you are not *REALLY* copying the data of
> the mbuf, then
>   the name of copy_the_memorybuffer() is very
> confusing.

i didn't showed in the above code snippet but
actually i am copying the data contained in the 
mbufs in a character array. 

my purpose is to compress the data contained in
the ip packet
 
> - What is the magic constant 64 that is assigned
> to ip_tos?

that was just to see that i could actually modify
the ip header.

> What you probably want to do is something like:
> 
> void
> ip_set_type_of_service(struct mbuf *m)
> {
> struct ip *iph;
> 
> assert(m != NULL);
> 
> iph = mtod(m, struct ip *);
> iph->ip_tos = IPTOS_PREC_IMMEDIATE;
> iph->ip_sum = 0;
> iph->ip_sum = in_cksum((uint16_t *)iph,
> iph->ip_hl << 2);
> }

thanks i will try this code and try to make the 
code simpler next time.

> but that's not copying anything.
> 
> > but still it doesn't seem to work. and the problem
> > is still there.
> 
> You have obviously made a lot of changes that we
> haven't seen yet.

i did not put the whole code because i am a bit lazy 
and the code is cumbersome. and i thought that 
it was causing the problem.

> Instead of posting snippets here and there, save a
> copy of the original
> sources somewhere, then a copy of the new sources,
> and run diff(1) on
> the two directories to extract *ALL* the changes.
> 
>   $ cd /usr/src
>   $ diff -ruN src.old/ src/ > /tmp/patchfile
> 
> and put the patchfile somewhere online where we can
> have a look at all
> the changes.

i am new to kernel sources and kernel programming and
thank you for informing me on the diff(1).

thanks to you that the problem was solved (i don't 
know if it is completely ok). i found that
   - i had made mistake in computing checksum. 
  earlier checksum was computed over the whole 
  data but now i calculate checksum over the 
  header only.
- byte ordering. 
tell me one thing isn't the byte order of the 
 ip_id in network byte order in the mbuf when passed 
  to the if_output() ??
  i had to use the htons() to ip_id before computing 
  the checksum
   -  final thing does this makes any difference
 (calling the htons() twice):

  ip->ip_id=htons(ip->ip_id);
  ip->ip_id=htons(ip->ip_id);

I will try put up patchfiles on web. 

thanks very much,
kamal




 





__ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


compiling the kernel faster

2005-10-27 Thread kamal kc
hello everybody,

i am new to kernel programming.
i am developing a compression/decompression
functionality in the ip layer.

i want to compile the kernel faster.

 it would
be ok if the kernel doesn't have support for sound
devices, or other devices like scsi,usb etc. because
i would be using the compiled kernel for 
network data compression only. 

how could i do that. which source files and where in
the makefiles do i make modifications 

thanks for any suggestions

kamal







__ 
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


tcp services (ssh,ftp) does not work

2005-10-30 Thread kamal kc
dear all,

i have put sshd_enable="YES"
and inetd_enable="YES"
in /etc/rc.conf.

netstat -an also shows that the port numbers
21 and 22 are in listen state

ftp is uncommented in /etc/inetd.conf

but still the ssh/ftp services does not work.

when i ftp from another computer the netstat
shows connection established but the ftp client 
does not show anything. 

using ftp/ssh on the same computer also does not show
anything --- just blank.


what could have gone wrong.

Help !!!

kamal






__ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


kernel crash dump could not be obtained

2005-10-31 Thread kamal kc
dear all,

i have to make modifictions to the kernel and 
i have been encountering kernel crashes all the 
time.

the kernel panics with messages starting with
vm_fault: and then crashes and reboots.

i guess i have done incorrect memory operations and 
i want to know where i went wrong.

so i thought of obtaining the crash dump. i went
through the developers guide. 
and i added the following lines on the /etc/rc.conf

---
dumpdev="/dev/ad0s1b"
dumpdir="/var/crash"
savecore_flags=""
--

the /etc/fstab file is

Device  Mountpoint  FStype  Options DumpPass#
/dev/ad0s1b noneswapsw  0   0
/dev/ad0s1a /   ufs rw  1   1
/dev/ad0s1e /tmpufs rw  2   2
/dev/ad0s1f /usrufs rw  2   2
/dev/ad0s1d /varufs rw  2   2
/dev/acd0   /cdrom  cd9660  ro,noauto   0   0


swap partition is /dev/ad0s1b

swapinfo gives the output:--
Device  1K-blocks UsedAvail Capacity
/dev/ad0s1b4950480   495048 0%

My memory size according to dmesg is --
real memory  = 266600448 (254 MB)
avail memory = 251232256 (239 MB)
--

Now when the kernel crashes it prints the message 
writing dump 240MB

but rebooting does not show any crash dump file 
on /var/crash.

please help
kamal










__ 
Start your day with Yahoo! - Make it your home page! 
http://www.yahoo.com/r/hs
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


allocating 14KB memory per packet compression/decompression results in vm_fault

2005-11-02 Thread kamal kc
dear everybody,
 
i am trying to compress/decompress ip packets.
for this i have implemented the adaptive lzw compression.
i put the code in the ip_output.c and do my compression/decompression
just before the if_output() function call so that i won't interfere with
the ip processing of the kernel.
 
for my compression/decompression i use string tables and temporary
 buffers which take about 14KB of memory per packet. 

I used malloc() to allocate the memory space. i made the call as below:
 
   malloc(4096,M_TEMP, M_NOWAIT);
 
I call the malloc 3 to 4 times with 4096 bytes. and release it with call to 
free()
 
I also sometimes allocate an mbuf during compression/decompression.
i use the macro--
 
struct mbuf *m;
MGET(m, M_DONTWAIT,MT_DATA);
MCLGET(m,M_DONTWAIT);
 
These are the memory operations i perform in my code.
Now when i run the modified kernel the behaviour is unpredictable.
The compression/decompression
works fine with expected results. But soon the kernel would crash with
vm_fault: message.
 
-Is the memory requirement of 14KB per packet too high to be allocated by
  the kernel ?? 
- Are there any other techniqures to allocate memory in kernel without
   producing vm_faults ?? 
- Am I not following the correct procedures to 
  allocate and deallocate memory in kernel space ??
- Or is the problem elsewhere ??
 
I am really confused and don't know what to do as this is 
the only thing that is holding me back to implement the 
compression/decompression module.
 
I know you guys can provide some help/info.
 
Thanks 
 
kamal
 
 
 
 
 
 


-
 Yahoo! FareChase - Search multiple travel sites in one click.  
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: allocating 14KB memory per packet compression/decompression results in vm_fault

2005-11-03 Thread kamal kc

> > for my compression/decompression i use string
> tables and temporary
> >  buffers which take about 14KB of memory per
> packet.
> 
> If you're allocating 14 KB of data just to send
> (approximately) 1.4 KB
> and then you throw away the 14 KB immediately, it
> sounds terrible.

yes that's true. 

since i am using the adaptive LZW 
compression scheme it requires construction of string
table for compression/decompression. So an ip packet
 of size 1500 bytes requires a table of size (4KB +
 4KB + 2KB =12KB). 

further still i copy the ip packet
 data in another data buffer (about 1.4KB) and 
then compress it.

So all this adds up to about 14KB. 

Right now i can't do with less than 14KB.

as i said before the compression/decompression works
fine. but soon the kernel would panic with one 
of the vm_fault: error message.

what would be the best possible way to 
allocate/deallocate 14KB memory per packet without 
causing vm_faults ?? 

is there anything i am missing ??

thanks 

kamal













__ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


fatal trap 12; page fault in kernel mode --HELP

2005-11-07 Thread kamal kc
dear all,

i am written code for compression/decompression
which works very fine for binary as well as the
ascii data.

i have put the routine just before the 
if_output() so that i do not interfere with 
the kernel ip operations.


Now the compression/decompression works fine most 
of the times but eventually i get a fatal trap, 
sooner or later.

my compression/decompression uses about 14KB of 
memory per packet which i malloc/free after the
job is done. 

the fatal trap i observed is:
-

Fatal Trap 12 page fault while in kernel mode
fault virtual address=0xc195600
fault code=supervisor write, page not present
instruction pointer=0x8:0xc0594877
stack pointer =0x10:0xcc6218fc
frame pointer=0x10:0xcc621908
code segment=base 0x0, limit 0xf, type 0x1b
   = DPL 0, pres 1, def 32 1, gran
processor eflags=interrupt enabled, resume, IOPL=0
current process=37(swi1:net)
trap number=12
panic:page fault



i used the core dump with kgdb and got the following 
results:


decomp# kgdb kernel.debug /var/crash/vmcore.35
[GDB will not be able to debug user-mode threads:
/usr/lib/libthread_db.so: 
Undefined symbol "ps_pglobal_lookup"]
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General
Public License, and you are
welcome to change it and/or distribute copies of it
under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show
warranty" for details.
This GDB was configured as "i386-marcel-freebsd".
#0  doadump () at pcpu.h:159
159 __asm __volatile("movl %%fs:0,%0" : "=r" (td));
(kgdb) bt
#0  doadump () at pcpu.h:159
#1  0xc0510c86 in boot (howto=260) at
../../../kern/kern_shutdown.c:410
#2  0xc0510f1c in panic (fmt=0xc06b5c31 "%s")
at ../../../kern/kern_shutdown.c:566
#3  0xc068eb30 in trap_fatal (frame=0xcc6218bc,
eva=3247792128)
at ../../../i386/i386/trap.c:817
#4  0xc068e89b in trap_pfault (frame=0xcc6218bc,
usermode=0, eva=3247792128)
at ../../../i386/i386/trap.c:735
#5  0xc068e4fd in trap (frame=
  {tf_fs = 24, tf_es = 16, tf_ds = 16, tf_edi =
-1047715840, tf_esi = -1047207936,
 tf_ebp = -865986296, tf_isp = -865986328, tf_ebx =
-1047209984,
  tf_edx = 129, tf_ecx = 34816, tf_eax = 256,
tf_trapno = 12, tf_err = 2,
   tf_eip = -1067890569, tf_cs = 8, tf_eflags = 66054,
tf_esp = 376, tf_ss = 385})
at ../../../i386/i386/trap.c:425
#6  0xc067efea in calltrap () at
../../../i386/i386/exception.s:140
#7  0x0018 in ?? ()
#8  0x0010 in ?? ()
#9  0x0010 in ?? ()
#10 0xc18d2000 in ?? ()
#11 0xc194e000 in ?? ()
#12 0xcc621908 in ?? ()
#13 0xcc6218e8 in ?? ()
#14 0xc194d800 in ?? ()
#15 0x0081 in ?? ()
---Type  to continue, or q  to quit---
#16 0x8800 in ?? ()
#17 0x0100 in ?? ()
#18 0x000c in ?? ()
#19 0x0002 in ?? ()
#20 0xc0594877 in get_string (code=0,
decode_stack=0xc194d800 "", 
code_value=0xc18d1000, prefix_code=0xc18d2000, 
append_character=0xc194e000 "",
add_index=0xcc621940)
at ../../../netinet/ip_output.c:2733
#21 0xc0594739 in decompress_the_ip_packet
(ipheaderlength=0, 
ippacketlength=0, compressed_buffer=0xc194f000 "",

output_buffer=0xc194e800 "") at
../../../netinet/ip_output.c:2665
#22 0xc0593ec8 in copy_the_memorybuffer (m=0xc1904900)
at ../../../netinet/ip_output.c:2237
#23 0xc05922ae in ip_output (m=0xc1904900,
opt=0xc1941010, ro=0xcc6219c8, 
flags=1, imo=0x0, inp=0x0) at
../../../netinet/ip_output.c:827
#24 0xc05918d8 in ip_forward (m=0xc1904900, srcrt=0)
at ../../../netinet/ip_input.c:1780
#25 0xc05905f7 in ip_input (m=0xc1904900) at
../../../netinet/ip_input.c:679
#26 0xc05806d3 in netisr_processqueue (ni=0xc074d0b8)
at ../../../net/netisr.c:233
#27 0xc05808ca in swi_net (dummy=0x0) at
../../../net/netisr.c:346
#28 0xc04fd599 in ithread_loop (arg=0xc1541200)
at ../../../kern/kern_intr.c:547
#29 0xc04fc82c in fork_exit (callout=0xc04fd448
, 
---Type  to continue, or q  to quit---
arg=0xc1541200, frame=0xcc621d48) at
../../../kern/kern_fork.c:791
#30 0xc067f04c in fork_trampoline () at
../../../i386/i386/exception.s:209
(kgdb) list *0xc0594877
0xc0594877 is in get_string
(../../../netinet/ip_output.c:2733).
2728break;
2729}
2730*/
2731i=code-256;
2732do
2733{
decode_stack[stack_length++]=append_character[i];
2734  i=prefix_code[i]-256;
2735}while(i>=0);
2736decode_stack[stack_length]=i+256;
2737return  stack_length;
(kgdb) up 20
#20 0xc0594877 in get_string (code=0,
decode_stack=0xc194d800 "", 
code_value=0xc18d1000, prefix_code=0xc18d2000, 
append_character=0xc194e000 "",
add_index=0xcc621940)
at ../../../netinet/ip_output.c:2733
2733{
decode_stack[stack_length++]=append_character[i];
(kgdb) print i
$1 = 0
(kgdb) print code
$2 = 0
(kgdb) print &decode_stack[0]
$3 = (unsi

Fatal trap 12: page fault while in kernel mode

2005-12-25 Thread kamal kc
hello everybody,

i am recently troubled by kernel panics that occur as
soon as 
i run my modified kernel. the only modification i have
done
is i have added compression/decompression function in
the
bridge.c file. I am running 5.4 RELEASE. 

i am just a new beginner in programming the kernel and
may 
have insufficient knowledge regarding it.

things i have done in the function that could affect
the kernel operation are:
1. i frequently allocate memory using malloc() in
M_DEVBUF and 
M_TEMP with M_WAITOK flag
2. i allocate memory with malloc and construct tree.
the node count
can go up 350 so that i may call malloc about 600
times in the 
routine. i know that may sound pretty dumb but
right now i have 
no other choice now as i know so little.
3. the functions are pretty longer and contain loops
so they may consume time
since the bridge code may be called for all the
packets flowing 
through the network. 
4. i have used data structures like linked lists and
trees.

now the problem is as soon as i run my modified kernel
it panics with
fatal trap 12. the name of the process that crashed is
sometimes the cron,
sometimes ps, sometimes top, sometimes g_up, and
sometimes sendmail.

i don't know what to do because the i have tested the
function 
separately and it works fine. i used the dmalloc to
see whether 
the memory leak was present but i didnot find any. it
may be
posible that my tests with dmalloc were insufficient. 

So i have put the crash dumps here that may help 
some of you suggest me whether there is anything i 
can possibly do in order to solve this panic.

Is the problem related to memory leaks or sleeping 
on mutexes or some other causes. 

i have added my function just before the
IFQ_HANDOFF().

thanks,

kamal kc



Panic message:-->

kernel trap 12 with interrupts disabled

Fatal trap 12: page fault while in kernel mode
fault virtual address=0x6c
fault code =supervisor read, page not present
instruction pointer=0x8:0xc052eafd
stack pointer=0x10:0xd50349d0
frame pointer=0x10:0xd50349d4
code segment=base 0x0, limit 0xf, type 0x1b
=DPL 0, pres 1, def32 1, gran 1
processor eflags=resume, IOPL=0
current process=462 (sendmail)
trap number=12
panic: page fault


decomp# kgdb kernel.debug  /var/crash/vmcore.2


[GDB will not be able to debug user-mode threads:
/usr/lib/libthread_db.so: Undefined symbol
"ps_pglobal_lookup"]

GNU gdb 6.1.1 [FreeBSD]

Copyright 2004 Free Software Foundation, Inc.

GDB is free software, covered by the GNU General
Public License, and you are

welcome to change it and/or distribute copies of it
under certain conditions.

Type "show copying" to see the conditions.

There is absolutely no warranty for GDB.  Type "show
warranty" for details.

This GDB was configured as "i386-marcel-freebsd".

#0  doadump () at pcpu.h:159

159 __asm __volatile("movl %%fs:0,%0" : "=r" (td));

(kgdb) bt

#0  doadump () at pcpu.h:159

#1  0xc0510d86 in boot (howto=260) at
../../../kern/kern_shutdown.c:410

#2  0xc051101c in panic (fmt=0xc06b9b28 "%s")

at ../../../kern/kern_shutdown.c:566

#3  0xc0692820 in trap_fatal (frame=0xd5034990,
eva=108)

at ../../../i386/i386/trap.c:817

#4  0xc069200d in trap (frame=

  {tf_fs = 24, tf_es = 16, tf_ds = 16, tf_edi = 2,
tf_esi = -1049545216, tf_ebp = -721204780, tf_isp =
-721204804, tf_ebx = -1050635136, tf_edx =
-1050635136, tf_ecx = 0, tf_eax = -1049545184,
tf_trapno = 12, tf_err = 0, tf_eip = -1068307715,
tf_cs = 8, tf_eflags = 65539, tf_esp = -1049545216,
tf_ss = -721204748}) at ../../../i386/i386/trap.c:255

#5  0xc0682cda in calltrap () at
../../../i386/i386/exception.s:140

#6  0x0018 in ?? ()

#7  0x0010 in ?? ()

#8  0x0010 in ?? ()

#9  0x0002 in ?? ()

#10 0xc1713600 in ?? ()

#11 0xd50349d4 in ?? ()

#12 0xd50349bc in ?? ()

#13 0xc1609480 in ?? ()

#14 0xc1609480 in ?? ()

#15 0x in ?? ()

#16 0xc1713620 in ?? ()

---Type  to continue, or q  to quit---

#17 0x000c in ?? ()

#18 0x in ?? ()

#19 0xc052eafd in turnstile_setowner (ts=0xc1609480,
owner=0x0)

at ../../../kern/subr_turnstile.c:367

#20 0xc052edbf in turnstile_wait (ts=0xc1609480,
lock=0xc16ba800, owner=0x0)

at ../../../kern/subr_turnstile.c:504

#21 0xc0508769 in _mtx_lock_sleep (m=0xc16ba800,
td=0xc1713600, opts=0, 

file=0x0, line=0) at
../../../kern/kern_mutex.c:552

#22 0xc063c691 in ufsdirhash_lookup (ip=0xc170d1a4, 

name=0xc16dd009 "nss_compat.so.1", namelen=15,
offp=0x0, bpp=0x0, 

prevoffp=0x0) at
../../../ufs/ufs/ufs_dirhash.c:349

#23 0xc063e612 in ufs_lookup (ap=0xd5034b78)

at ../../../ufs/ufs/ufs_lookup.c:214

#24 0xc0645623 in ufs_vnoperate (ap=0x0) at
../../../ufs/ufs/ufs_vnops.c:2821

#25 0xc0558402 in vfs_cache_lookup (ap=0x0) at
vnode_if.h:82

#26 0xc0645623 in ufs_vnoperate (ap=0x0) at
../../../ufs/ufs/ufs_vnops.c:2

Re: Fatal trap 12: page fault while in kernel mode

2005-12-25 Thread kamal kc
thanks,
 i will try INVARIANTS and WITNESS options and will try to get 
 freebsd 6.0. it will be only tomorrow when i'll be able to do this
 because it is already evening and i will go to my office tomorrow 
 only.
 
 in the mean time if the memory corruption is the problem then is there
 any option/configuration or possible thing i could do to 
 make sure that the kernel quits or throws some messages or panics 
 on the moment the corruption takes place rather than some 
 time later when other program is affected by it. 
 
 that way i could locate any bug in my code if present.
 
 thanks, 
 kamal
 

Xin LI <[EMAIL PROTECTED]> wrote: Hi,

On 12/25/05, kamal kc  wrote:
[...]
> Is the problem related to memory leaks or sleeping
> on mutexes or some other causes.

>From the backtrace you have provided, it looks like a memory
corruption.  In order to aid your debugging, you will want INVARIANTS
and WITESS, etc. to be enabled.  Also, if feasible, please consider
using code from -CURRENT or at least RELENG_6_0, as there are more
debugging aids that is likely to catch bugs early.

Cheers,
--
Xin LI  http://www.delphij.net
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"




-
 Yahoo! DSL Something to write home about. Just $16.99/mo. or less
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


using get_system_info() - obtaining system load averages

2006-01-09 Thread kamal kc
dear everybody,

i want to use the routine get_system_info() to get the
load 
averages of the cpu. i found it that top uses it.

but i do not know which object files do i need to link
it to 
my program. also the struct system_info is defined
in the machine.h of the /usr/src/contrib/top. do i
need
to include it or is there another header defining it.

actually i want to know the load averages when my
program 
runs in the kernel mode. 

is there other methods of obtaining the sytem load
averages ???  

thanks,
kamal 



__ 
Yahoo! DSL – Something to write home about. 
Just $16.99/mo. or less. 
dsl.yahoo.com 

___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: using get_system_info() - obtaining system load averages

2006-01-09 Thread kamal kc
> On Mon, 2006-Jan-09 19:14:53 -0800, kamal kc wrote:
> >i want to use the routine get_system_info() to get
> the
> >load averages of the cpu. i found it that top uses
> it.
> 
> The approved mechanism is via the sysctl(3) name
> "vm.loadavg" or OID
> CTL_VM.VM_LOADAVG - which returns a struct loadavg. 
> See sysctl(3)
> for details.

thanks a lot. i will use it .

kamal




__ 
Yahoo! DSL – Something to write home about. 
Just $16.99/mo. or less. 
dsl.yahoo.com 

___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: using get_system_info() - obtaining system load averages

2006-01-10 Thread kamal kc

--- Dan Nelson <[EMAIL PROTECTED]> wrote:

> In the last episode (Jan 09), kamal kc said:
> > dear everybody,
> > 
> > i want to use the routine get_system_info() to get
> the load averages
> > of the cpu. i found it that top uses it.
> 
> get_system_info is just a function /in/ top itself
> that gets the CPU
> usage.  It uses the vm.loadavg sysctl to get the
> load average.  A
> simpler way is to just call the getloadavg()
> function; see its manpage
> for more info.

thanks i tried getloadavg() it worked.

but when i tried to put it in the kernel the kernel
 failed to link. 

i also looked at sysctl(3) and i guess it is also for
user 
based programs.

so i looked at the sys/sysctl.h and found that there
was
sysctl_find_oid() that was defined for kernel. but i
don't 
know how to use it. i could not get any info on the
web.

the function declaration was ::

int sysctl_find_oid(int *name, u_int namelen, struct
sysctl_oid **noid,
int *nindx, struct sysctl_req *req);

isn't it the function i should be using to retrieve
the sysctl 
value ???
how should i use it ??

any demo on using it would be immensely helpful for
me.

thanks, 

kamal









__ 
Yahoo! DSL – Something to write home about. 
Just $16.99/mo. or less. 
dsl.yahoo.com 

___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: using get_system_info() - obtaining system load averages

2006-01-10 Thread kamal kc

--- Peter Jeremy <[EMAIL PROTECTED]> wrote:

> On Mon, 2006-Jan-09 23:59:10 -0800, kamal kc wrote:
> >thanks i tried getloadavg() it worked.
> >
> >but when i tried to put it in the kernel the kernel
> > failed to link. 
> 
> You didn't mention the kernel bit before.  To access
> the load average in the kernel, you just access
> "averunnable" (see ).  Note that you
> cannot do floating point arithmetic in the kernel so
> the load averages are stored as fixed point numbers.
> 

thanks , it worked  

i used the ldavg[] and fscale of averunnable to get
the system load.


you people are great .. 

kamal









__ 
Yahoo! DSL – Something to write home about. 
Just $16.99/mo. or less. 
dsl.yahoo.com 

___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: using get_system_info() - obtaining system load averages

2006-01-10 Thread kamal kc


--- Tofik Suleymanov <[EMAIL PROTECTED]> wrote:

> kamal kc wrote:
> 
> >--- Peter Jeremy <[EMAIL PROTECTED]>
> wrote:
> >>>thanks i tried getloadavg() it worked.
> >>>
> >>>but when i tried to put it in the kernel the
> kernel
> >>>failed to link. 
> >>You didn't mention the kernel bit before.  To
> access
> >>the load average in the kernel, you just access
> >>"averunnable" (see ).  Note that
> you
> >>cannot do floating point arithmetic in the kernel
> so
> >>the load averages are stored as fixed point
> numbers.

> >thanks , it worked  
> >
> >i used the ldavg[] and fscale of averunnable to get
> >the system load.
> >
> >
> >you people are great .. 
> >
> >kamal
> >
> Just a curiosity: why use kernel-space functions to
> get system load ? 
> Isn't it better to use sysctls in user-space ?

actually the thing is , i have put some code in the
bridge.c
routine that attempts to compress/decompress ip
packets. 

i don't know if it was a good idea since i am just a
beginner 
in programming in the kernel and have a little
knowledge 
regarding it. 

after i put my code i got a very high amount
of interrupts (irq 21: xl1 interrupts) that overloads
the 
cpu withing seconds if i pump about 4Mbps traffic
through it.

so i thought as a temp solution that i could turn off
the 
compression if ever the cpu gets overloaded and that's
it.

But after a second thought-->
 the very idea of putting the large compression
routine 
in the bridge code now seems awkward to me. since the
compression 
takes time and putting the code in the bridge may be 
causing high interrupts i now think if i can do the
compression
stuffs in separate thread/process than in the bridge
process itself.

but right now i don't know how do i create a separate
process/thread, 
what are the routines that i need to implement for
this..
and also how to dispatch control from the bridge
process to a new 
process without blocking. i am looking into these
stuffs and 
hope i find something from the sources but it is
getting really
difficult ...
 
maybe you people could have something to say, any
advice 
on whether i am doing the right stuffs would be
greatly
helpful to me ..


thanks,

kamal













 













__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


rescheduling tasks using swi_add()

2006-01-11 Thread kamal kc
dear everybody,

i had previous thread going on about the cpu load 
average. and had some discussion regarding it. i have 
a newer thing to discuss on so i started this thread.

as i mentioned earlier i had put some code in the
bridge.c
that performed compression which took a long time and
hence 
i got a high number of interface interrupts (irq22: xl
interrupts).

so i thought of rescheduling the compression tasks
without 
blocking the bridge function. i found this function
swi_add() 
which i could use to add software interrupt handlers
that 
could be run at a later time without causing high
interface 
interrupts.

the man page discussed the swi_add() and swi_sched()
functions.

what i don't understand is, how do i register my
handler 
function ??
if i use the swi_add() for that purpose what 
do i use for the void *arg argument.
 
and how can i dispatch control to the software
interrupt handler ??
the swi_sched() uses only the cookie and the flags
arguments. 
there is no way i can pass arguments to my handler
function ..

i guess most of you are familiar with this and can
help me 
out ..



thanks, 

kamal







 
 



__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: rescheduling tasks using swi_add()

2006-01-11 Thread kamal kc


--- John Baldwin <[EMAIL PROTECTED]> wrote:

> >
> > the man page discussed the swi_add() and
> swi_sched()
> > functions.
> >
> > what i don't understand is, how do i register my
> > handler
> > function ??
> > if i use the swi_add() for that purpose what
> > do i use for the void *arg argument.
> >
> > and how can i dispatch control to the software
> > interrupt handler ??
> > the swi_sched() uses only the cookie and the flags
> > arguments.
> > there is no way i can pass arguments to my handler
> > function ..
> >
> > i guess most of you are familiar with this and can
> > help me
> > out ..
> 
> Queue a task to a taskqueue.  Behind the scenes that
> will invoke a swi_add if 
> you use the taskqueue_swi queue.  However, given
> that you want to do some 
> rather complicated work, you'd be better off
> creating a dedicated taskqueue 
> thread and queueing tasks off to it I think.

thanks for the suggestion on the taskqueue. i tried it

on a dummy kernel module and got some output, but i 
don't know if they were correct or not. i would like
to know
if i followed the right steps. here is the code i 
used ::


struct taskqueue_arguments
{ int a;
  int b;
};

void taskqueue_function(void *,int);
typedef void taskqueue_function_t(void *,int);

/* taskqueue function */
void taskqueue_function(void *arguments,int int_arg)
{
   struct taskqueue_arguments *arg;
   arg=(struct taskqueue_arguments *)arguments;
   printf("\ntakqueue_function was called the args are
%d 
%d",arg->a,arg->b);
return;
}











__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: rescheduling tasks using swi_add()

2006-01-11 Thread kamal kc


--- John Baldwin <[EMAIL PROTECTED]> wrote:

> > the man page discussed the swi_add() and
> swi_sched()
> > functions.
> >
> > what i don't understand is, how do i register my
> > handler
> > function ??
> > if i use the swi_add() for that purpose what
> > do i use for the void *arg argument.
> >
> > and how can i dispatch control to the software
> > interrupt handler ??
> > the swi_sched() uses only the cookie and the flags
> > arguments.
> > there is no way i can pass arguments to my handler
> > function ..
> >
> > i guess most of you are familiar with this and can
> > help me
> > out ..
> 
> Queue a task to a taskqueue.  Behind the scenes that
> will invoke a swi_add if 
> you use the taskqueue_swi queue.  However, given
> that you want to do some 
> rather complicated work, you'd be better off
> creating a dedicated taskqueue 
> thread and queueing tasks off to it I think.
> 

thanks for the suggestion on the taskqueue. i tried it

on my dummy kernel module and got some output but i 
am not sure if i followed the correct steps to 
use the taskqueue. the only thing i found 
was the man pages and the taskqueue.h.

here is the code:
---

struct taskqueue_arguments
{ int a;
  int b;
};

void taskqueue_function(void *,int);
typedef void taskqueue_function_t(void *,int);

/* taskqueue function */
void taskqueue_function(void *arguments,int int_arg)
{
struct taskqueue_arguments *arg;
arg=(struct taskqueue_arguments *)arguments;
printf("\ntakqueue_function was called the args
are %d %d",arg->a,arg->b);
return;
}


/* function implementing the syscall */
static int
hello(struct thread *td, void *arg)
{.
struct task mytask; 
taskqueue_function_t *taskqueue_function_ptr;
taskqueue_function_ptr=taskqueue_function; 

struct taskqueue_arguments arg_var;
arg_var.a=10;
arg_var.b=20;

   
TASK_INIT(&mytask,50,taskqueue_function_ptr,&arg_var);
taskqueue_enqueue(taskqueue_swi, &mytask);

...
} 

did i do it correctly ???

thanks,

kamal






__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: rescheduling tasks using swi_add()

2006-01-12 Thread kamal kc


--- kamal kc <[EMAIL PROTECTED]> wrote:

> > 
> > Queue a task to a taskqueue.  Behind the scenes
> that
> > will invoke a swi_add if 
> > you use the taskqueue_swi queue.  However, given
> > that you want to do some 
> > rather complicated work, you'd be better off
> > creating a dedicated taskqueue 
> > thread and queueing tasks off to it I think.
> > 
> 
> thanks for the suggestion on the taskqueue. i tried
> it
> 
> on my dummy kernel module and got some output but i 
> am not sure if i followed the correct steps to 
> use the taskqueue. the only thing i found 
> was the man pages and the taskqueue.h.
> 
> here is the code:
> ---
> 
> struct taskqueue_arguments
> { int a;
>   int b;
> };
> 
> void taskqueue_function(void *,int);
> typedef void taskqueue_function_t(void *,int);
> 
> /* taskqueue function */
> void taskqueue_function(void *arguments,int int_arg)
> {
> struct taskqueue_arguments *arg;
> arg=(struct taskqueue_arguments *)arguments;
> printf("\ntakqueue_function was called the args
> are %d %d",arg->a,arg->b);
> return;
> }
> 
> /* function implementing the syscall */
> static int
> hello(struct thread *td, void *arg)
> {.
> struct task mytask;   
> taskqueue_function_t *taskqueue_function_ptr;
> taskqueue_function_ptr=taskqueue_function; 
> 
> struct taskqueue_arguments arg_var;
> arg_var.a=10;
> arg_var.b=20;
>   
>
>
TASK_INIT(&mytask,50,taskqueue_function_ptr,&arg_var);
> taskqueue_enqueue(taskqueue_swi, &mytask);
> 
> ...
> } 
> 

dear all ,

 i run the above code and the kernel 
would crash whenever i would do the syscall for few 
number of times. the crashing process is 
(swi6: task queue). the kernel crashes very soon 
when i make the system call in a loop.

i guess i didn't follow all the steps to use  
the taskqueue 

i think some of you can help what did i 
miss 

thanks, 
kamal












__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: rescheduling tasks using swi_add()

2006-01-12 Thread kamal kc


--- John Baldwin <[EMAIL PROTECTED]> wrote:

> On Thursday 12 January 2006 06:19 am, kamal kc
> wrote:
> > --- kamal kc <[EMAIL PROTECTED]> wrote:
> > > > Queue a task to a taskqueue.  Behind the
> scenes
> > >
> > > that
> > >
> > > > will invoke a swi_add if
> > > > you use the taskqueue_swi queue.  However,
> given
> > > > that you want to do some
> > > > rather complicated work, you'd be better off
> > > > creating a dedicated taskqueue
> > > > thread and queueing tasks off to it I think.
> > >
> > > thanks for the suggestion on the taskqueue. i
> tried
> > > it
> > >
> > > on my dummy kernel module and got some output
> but i
> > > am not sure if i followed the correct steps to
> > > use the taskqueue. the only thing i found
> > > was the man pages and the taskqueue.h.
> > >
> > > here is the code:
> > > ---
> > >
> > > struct taskqueue_arguments
> > > { int a;
> > >   int b;
> > > };
> > >
> > > void taskqueue_function(void *,int);
> > > typedef void taskqueue_function_t(void *,int);
> > >
> > > /* taskqueue function */
> > > void taskqueue_function(void *arguments,int
> int_arg)
> > > {
> > > struct taskqueue_arguments *arg;
> > > arg=(struct taskqueue_arguments *)arguments;
> > > printf("\ntakqueue_function was called the
> args
> > > are %d %d",arg->a,arg->b);
> > > return;
> > > }
> > >
> > > /* function implementing the syscall */
> > > static int
> > > hello(struct thread *td, void *arg)
> > > {.
> > > struct task mytask;
> > > taskqueue_function_t
> *taskqueue_function_ptr;
> > > taskqueue_function_ptr=taskqueue_function;
> > >
> > > struct taskqueue_arguments arg_var;
> > > arg_var.a=10;
> > > arg_var.b=20;
> >
> >
>
TASK_INIT(&mytask,50,taskqueue_function_ptr,&arg_var);
> >
> > > taskqueue_enqueue(taskqueue_swi, &mytask);
> 
> You can just use the name of the function w/o having
> to have an explicit 
> function pointer var:
> 
> TASK_INIT(&mytask, 50, taskqueue_functino,
> &arg_var);
> 
> > >
> > > ...
> > > }
> >
> > dear all ,
> >
> >  i run the above code and the kernel
> > would crash whenever i would do the syscall for
> few
> > number of times. the crashing process is
> > (swi6: task queue). the kernel crashes very soon
> > when i make the system call in a loop.
> >
> > i guess i didn't follow all the steps to use
> > the taskqueue 
> >
> > i think some of you can help what did i
> > miss 

the problem is solved i guess. 

now i used the structure :

 struct taskqueue_struct
   { struct task mytask;
 int a; 
 int b;
   }

  everytime i call TASK_INIT() i allocate memory for
  the taskqueue_struct. 

  and in the handler function deallocate the struct 
   taskqueue_struct. 
  this allowed me to do memory safe operation i guess
!!

> 
> Are you calling TASK_INIT() while your task is still
> pending?  Just init the 
> task the first time, then call enqueue() to queue it
> up.  You might want to 
> call TASK_INIT() during the MOD_LOAD() event in your
> module handler for 
> example.  Be sure to call taskqueue_drain() during
> MOD_UNLOAD() to make sure 
> your task has finished all the pending executes
> before your module is 
> unloaded as well.

yes , i will do these things. now i will try to make a
separate 
taskqueue thread for the job like you said before. i
am 
looking at the kthread and other stuffs. i am more
optimistic 
now than ever..

i am enjoying these stuffs ..

thanks,
kamal






 



__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


giving more cpu time to cpu intensive kernel daemon

2006-01-15 Thread kamal kc
dear all,

i created a kernel daemon thread using the SYSINIT().

i want that daemon thread to do more cpu 
intensive tasks and that's why
i want to give it more cpu time. 

my daemon thread get a priority of -84 and
 a nice value of 0.

i guess when the nice value is 0 it affects 
its scheduling. 

how could i give it a good nice value ?

are there any other options that i may 
have to look upon to ensure the daemon
gets more of the cpu time ??

thanks,

kamal






 

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"