Re: gettimeofday() in hping

2008-01-25 Thread Joseph Koshy
>  OK, this is the famous problem with modern CPUs that jkoshy has declined
>  to work around :(  There are patches for this in perforce, see
>
>  http://perforce.freebsd.org/changeView.cgi?CH=126189

"Famous problem" indeed :).   I declined the patch because it
is incorrect and incomplete.

First, you cannot safely treat the Core and Core 2 PMCs as P6 PMCs.
Doing so would give userland a way to program CPU MSRs with bit
patterns that have been expressly documented by the manufacturer
as "reserved" and forbidden.

Second, the change ignores the sometimes changed semantics
between P6 and Core PMCs for events sharing the same numeric
selector value.  Not handling the changed semantics could easily
trip up users; they would think that they are measuring hardware
behaviour X while the measurements would actually be for behaviour Y.

Third, the change ignores the user interface.   libpmc's event
naming conventions are to follow vendor names for events and
event modifiers as closely as possible (within the constraints of
the overall generic syntax).  This is so as to make it easy (easier?)
for users to read vendor documentation and map the information
there to the necessary event selection syntax.

Core PMCs support tons of new measurement events.  Additionally,
naming conventions in vendor documentation for Core event names
and modifiers are different from the older P6 names, even for events
with similar semantics.  The submitted patch does not address these
aspects.


I will accept a patch that demonstrates clue about the
workings of the overall system---the changes in the patch
should be safe, complete, should demonstrate that the submitter
has read and understood vendor documentation, should preserve
user experience for naming events, and each supported PMC event
needs to be documented in pmc.3.

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


Re: Memory allocation performance

2008-02-02 Thread Joseph Koshy
> I have tried it for measuring number of instructions. But I am in doubt
> that instructions is a correct counter for performance measurement as
> different instructions may have very different execution times depending
> on many reasons, like cache misses and current memory traffic. I have
> tried to use tsc to count CPU cycles, but got the error:
> # pmcstat -n 1 -S "tsc" -O sample.out
> pmcstat: ERROR: Cannot allocate system-mode pmc with specification
> "tsc": Operation not supported
> What have I missed?

You cannot sample with the TSC since the TSC does not interrupt the CPU.
For CPU cycles you would probably want to use "p4-global-power-events";
see pmc(3).

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


Re: Memory allocation performance

2008-02-02 Thread Joseph Koshy
> Thanks, I have already found this. There was only problem, that by
> default it counts cycles only when both logical cores are active while
> one of my cores was halted.

Did you try the 'active' event modifier: "p4-global-power-events,active=any"?

> Sampling on this, profiler shown results close to usual profiling, but
> looking more random:

Adding '-fno-omit-frame-pointer' to CFLAGS may help hwpmc to capture
callchains better.

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


Announcement: PmcTools callchain capture for RELENG_7

2008-07-13 Thread Joseph Koshy
Hello List(s),

I am very pleased to announce a patch, by Fabien Thomas, that brings
PmcTools' callchain capture features to 7-STABLE.  Thank you, Fabien!

The patch is linked to from the PmcTools wiki page:
http://wiki.freebsd.org/PmcTools.

The current file name is: "patch-callchain-FreeBSD-7-STABLE-2008-07-12.gz".
As the file name indicates, it should apply against a 7-STABLE tree of
2008-07-12
vintage.

To apply the patch:
% cd /home/src-7x   # or whereever your RELENG_7 tree resides
% patch < PATCH-FILE

Then you should follow the full procedure to update userland
and kernel from source as spelled out in src/UPDATING.

Please note that HWPMC(4) log files that contain callchain information are
not binary compatible with prior versions of pmc(3) and pmcstat(8).

Please do test on your systems and let  Fabien and me know
how you fared.

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


Re: Announcement: PmcTools callchain capture for RELENG_7

2008-07-14 Thread Joseph Koshy
> Does it mean that hwpmc from now will work "out of the box" with new Intel
> core2 duo/quad processors (like T7500) ?

No, someone needs to write the appropriate CPU-dependent
module for that.

For those who are interested in doing so, there is a HowTo
document at:

  http://wiki.freebsd.org/PmcTools/PmcHardwareHowTo

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


Re: pahole - Finding holes in kernel structs

2009-02-15 Thread Joseph Koshy

> Well, I think we want to inform this through actual measurement.  Right now, 
> tools like hwpmc track cache misses by point in executable code, but what 
> would be nice is if we could post-process to generate cache miss information 
> by data structure field...

That is one of the tools that I've had in mind.

The hard part in the process is tracking sample locations back to
source artifacts with acceptable accuracy.  I couldn't find existing
libraries with a compatible open-source license that I could build on,
and thus the motivation for some of the libraries listed in the
roadmap at http://elftoolchain.sourceforge.net/.

Also, hwpmc(4) would need to be augmented to use "precise" sampling on
the hardware that supports it, but this is relatively straightforward.

Koshy
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"


Re: Obtaining l2 misses and cpu utilization in a module

2009-02-18 Thread Joseph Koshy
> I would like to obtain fore mentioned data from within my module. I need
> these performance metrics to see how certain code executes, and make
> decisions during the runtime. pmc(3) seems complete, but it also seems to be
> intended for use in the userland.
>
> How to use pmc from modules? Is there any other way? Also, module is amd64
> only, so I don't care about portability.

At this point of time there isn't an in-kernel API for using hwpmc(4)
(but it is on the task list, see:
http://code.google.com/p/pmctools/issues/detail?id=17).

For now, you could configure hwpmc(4) to not touch specific PMC
registers using the OP_PMCADMIN request (i.e., use pmccontrol -d).
After this you can use those registers from your kernel module without
interference from hwpmc.

Koshy
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"


Re: working of syscall handling

2009-04-08 Thread Joseph Koshy
> In the program given below the function readlink gets called up when
> printf is executed and the program ends without any output.
>
> readlink is a system call (syscall number = 58) which is being made by
> the printf function, but according to my understanding of system call,
> it is made by putting the handler number in eax register and then
> interrupting the processor, so that it can enter the kernel mode and
> execute the required function, but in this case(dont know why) my
> readlink function gets called up which should not have happened.
>
> I will be very thankful if you can help me with it.
>
>
> #include
>
> int readlink(void *a, void *b)
> {
>  exit(0);
> }
>
> int main(int argc, char **argv)
> {
>  printf("Hello World");
> }

Since you have defined 'readlink' to be a global symbol, the run time
linker will satisfy references to the symbol 'readlink' from within
libc using the definition you provided.

% cc a.c
% nm a.out | grep readlink
004006d0 T readlink

% gdb a.out
... startup messages snipped ...

Breakpoint 1, main (argc=1, argv=0x7fffe020) at a.c:11
11   printf("Hello World");
(gdb) b readlink
Breakpoint 2 at 0x4006e0: file a.c, line 6.
(gdb) c
Continuing.
Breakpoint 2, readlink (a=0x8007082a9, b=0x7fffd660) at a.c:6
6exit(0);
(gdb) bt
#0  readlink (a=0x8007082a9, b=0x7fffd660) at a.c:6
#1  0x00080069b87c in _UTF8_init () from /lib/libc.so.6
#2  0x000800703343 in __smakebuf () from /lib/libc.so.6
#3  0x0008007031e8 in __swsetup () from /lib/libc.so.6
#4  0x0008006f872e in __vfprintf () from /lib/libc.so.6
#5  0x0008006fbeae in vfprintf () from /lib/libc.so.6
#6  0x0008006e8eca in printf () from /lib/libc.so.6
#7  0x0040070e in main (argc=1, argv=0x7fffe020) at a.c:11
(gdb)

Regards,
Koshy
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"


Re: Xnu, and 'L4BSD'

2006-05-11 Thread Joseph Koshy

L4Linux exists, but it seems to be more of a means for testing out
and developing the L4 microkernel, but would there be any practical
reason to sandbox the FreeBSD kernel and force it to run as a user-
land service on top of the L4::Pistachio kernel? (for example)


Well, you could do neat stuff like migrating VMs between machines
'on-the-fly', as described in the following paper:
http://www.cl.cam.ac.uk/Research/SRG/netos/papers/2005-migration-nsdi-pre.pdf

Also, L4::Pistachio is BSD-licensed.

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


Re: The 'ln -s' command

2006-05-23 Thread Joseph Koshy

I tried the 'ln -s' command in bothe 4.3  &  4.7  in a
situation where it should fail and it did, but it still had
a return/exit code of  0 , I think it should have been
nonzero.  I tried 'ln -s  a  b' where the file  b  existed
(and was a directory) and I wanted to create the file named
a  also pointing to it.  The correct form was 'ln -s  b  a'.




FreeBSD  4.3-RELEASE FreeBSD 4.3-RELEASE #0: Sat Apr 21 \

 10:54:49 GMT 2001\
 [EMAIL PROTECTED]:/usr/src/sys/compile/GENERIC  i386


FreeBSD  4.7-RELEASE FreeBSD 4.7-RELEASE #0: Wed Oct  9 \

 15:08:34 GMT 2002 \
 [EMAIL PROTECTED]:/usr/obj/usr/src/sys/GENERIC \
 i386

I don't have a 4.3 or 4.7 box, but on 4.11 I see:

$ ls a.out
a.out
$ ln -s foo a.out
ln: a.out: File exists
$ echo $?
1

Are you really running /bin/ln?  Do you run other programs
at the time of displaying your PS1 prompt?

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


Re: Scope of Variables in sh

2006-06-01 Thread Joseph Koshy

but this doesnt function right. so i see the behavior from
$myline in the while-loop like an local variable..


If you are looking for function local variables,
use the "local" keyword.  For example:

 a.sh 
a=1
f()
{
   local a
   a=2
   echo B: In f: $a
}
echo A: Outside f: $a
f
echo C: Outside f: $a


% sh a.sh
A: Outside f: 1
B: In f: 2
C: Outside f: 1

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


Re: Alternative compiler toolchain ?

2006-07-01 Thread Joseph Koshy

jml> I've found some other compilers on the web:
jml> http://fabrice.bellard.free.fr/tcc/  (LGPL)

dn> tcc is very fast, probably has the most modern C parser of
dn> the lot, and might even be able to build world except that
dn> the shared binaries it generates aren't able to be loaded
dn> by our rtld.  It looks like tcc only emits the bare
dn> minimum to get Linux to run the executable, and I don't
dn> know enough about the ELF format to fill in the blanks.

Other bugs with tcc on FreeBSD:
-  tcc generated executables are missing an
   entry in their ELF program-header table and so do not
   execute directly.  You can work around this by
   using the base system ld for the final link step.
-  Someone reported that a few of our headers don't
   compile with tcc.  I haven't tracked down whether
   this is on account of an unsupported Gcc'ism in
   the header or whether this is a bug in tcc.

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


Re: NVIDIA FreeBSD kernel feature requests

2006-07-02 Thread Joseph Koshy

That's their commercial decision - as a result, if you
their cards, you may end up with a particularly expensive
paperweight the day they decide you need to buy a new card
for your new version of freebsd which has different
internals; or someone finds bugs in their drivers that
they wont fix.


This is the relatively benign scenario.

In the less benign one that "convenient" binary driver that
you loaded into the kernel would contain a silent security
vulnerability.  Google for "Sony DRM rootkit".


it's not like there aren't plenty of other
vendors who are more willing to help the developers with
documentation in an open manner.


True.

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


Re: Static built binaries having unknown ELF binary types

2006-07-07 Thread Joseph Koshy

I'm compiling "make" (usr.bin/make), but when I try to execute
it I got the following results:


[snip]

'Tis a bug in your toolchain.  e_ident[EI_OSABI] in the ELF
header isn't being set correctly for static executables.

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


Re: _getlogin()

2006-07-31 Thread Joseph Koshy

Where can i find source of subj?
/usr/src/lib/libc/gen/getlogin.c has
the declaration of this function, but i'm unable
to find its definition.


Its generated as part of the C library build.  See:
src/lib/libc/i386/sys/Makefile.inc
src/lib/libc/sys/Makefile.inc
sys/lib/libc/i386/SYS.h

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


Re: Is it possible to trace the routing socket messages going from the kernel to a particular daemon

2006-08-17 Thread Joseph Koshy

get a pid of a daemon-process and then somehow trace routing
socket messages coming in / going out from the kernel to that
particular daemon ?


`ktrace -p DAEMON-PID` might be what you want.

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


Re: The proper way to open a file from inside the kernel

2006-08-23 Thread Joseph Koshy

I am experimenting with modifying a kernel module and I need
to be able to open/read/write/close a file from within the
module.  Is there a preferred way to do this?  Are there any
locking or buffering issues that I need to be aware of?


sys/kern/kern_alq.c:alq_open() and sys/kern/kern_ktrace.c:ktrace()
have examples.

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


Re: installkernel target.

2006-10-04 Thread Joseph Koshy

Is there any supported way to make installkernel directly to some
directory. I want to build two kernels (like /boot/kernel.SMP/ and
/boot/kernel.UP/) in my installation script and DESTDIR is quite useless
is this case.


  make installkernel KERNCONF=YOUR_KERNEL_HERE KODIR=/boot/testkernel

See also /usr/src/UPDATING.

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


Re: pmcstat and squid

2006-12-11 Thread Joseph Koshy

I'm trying to use pmcstat to profile userspace time used in
Squid. I just can't seem to get pmcstat to report anything
useful.

The last thing I tried was something like:

# pmcstat -O file -P instructions -t 
# pmcstat -R file -g
# ls k7-retired-instructions
kernel.gmon

There doesn't seem to be a good example for
process-based counting stuff with PMC. Could anyone
give me a hand?

Thanks!


I can think of one of two scenarios:

1) the squid process was in the kernel when the
   samples got taken.  This could happen if the
   process was say in select() handling all the time.
2) There a bug in my process handling code that is
   being triggered (hwpmc undercounts process-mode
   samples), and samples are being missed.

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


Re: pmcstat and squid

2006-12-11 Thread Joseph Koshy

Squid is running but there's no profiling information for it
still..


Could you run grep the output of `pmcstat -R' (no "-g")
for mention of the squid processes pids.

Also, try pmcstat -v -v (for a breakup of the buckets).

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



Re: "Syncing cpus" on a multi-cpu, dual core system

2006-12-15 Thread Joseph Koshy

frequency but something else in addition.  A posting in the
thread said variations less than 0.1% were not problematic.
However, the poster said it was an issue in a dual cpu, dual
core system he had set up.


Why would application code care about CPU frequencies?

Is it trying to measure its 'performance' by subtracting
two TSC readings?  That won't necessarily work on
modern multi-CPU systems where each CPU could be running
at a different CPU speed.

On FreeBSD, with hwpmc(4), you can allocate a process-mode
counting pmc that counts non-sleep cycles (e.g.,
"p4-global-power-events,mask=running" on an Intel P4) and
then use RDPMC instructions where you would have used RDTSC
instructions.  This is as cheap as the RDTSC technique and
will work on SMP systems.

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


Re: if exists statement

2006-12-18 Thread Joseph Koshy

.if exists= ${PREFIX}/etc/rc.d
exit
else
${MKDIR} ${PREFIX}/etc/rc.d
.endif

but it doesn't work.

Can someone give me the right syntax?


.if exists(${PREFIX}/etc/rc.d)

.else

.endif

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


Re: Console and Shell

2007-01-15 Thread Joseph Koshy

kr> I would like to understand how the shell is tied to the
kr> console port.

Google for 'controlling terminal'.  "Advanced
Programming in the Unix Environment" by Richard Stevens
is a good book for Unix basics.

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


Re: Where's the pkg_add, etc. code?

2007-02-06 Thread Joseph Koshy

hl>  Where is the pkg_add (and related) code supposed to be?
hl>  I can't find it. I've been looking at:

hl> http://fxr.watson.org/fxr/source/?v=RELENG62

http://www.freebsd.org/cgi/cvsweb.cgi/src/usr.sbin/pkg_install/add/

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


New tutorial for review: "libelf by Example"

2007-02-09 Thread Joseph Koshy

Howdy list,

A tutorial introduction to the ELF(3)/GELF(3) API set is
available for review at the following URL:

 "libelf by Example"
 http://people.freebsd.org/~jkoshy/download/libelf/article.html

The intent is to add this tutorial to our documentation
collection.

Features:
- Covers the basics of the ELF format and ELF data
 structures.
- Contains an introduction to the ELF(3)/GELF(3) API set.
- Has 6 annotated programs showing the use of the
 API set:
 - Getting started with the elf(3) library.
 - Reading ELF data structures in an ELF object.
 - Creating new ELF objects.
 - Iterating through an ar(1) archive.
- 12 figures.

I would greatly appreciate review comments from people
with ELF expertise.

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


Re: Are there any known issues for installing FreeBSD on Vmware onwindows XP ?

2007-03-04 Thread Joseph Koshy

Further, after installation how should i ensure that all the
required kernel sources are installed?


You want the sources to the complete system, not just
the "kernel", and you would want to keep these upto-date
too.  See:

http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/synching.html
and,
http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/cvsup.html


Is there any way by which i can install a specific
package from from CD and let the OS determine and
install all the dependencies automatically? Is
there any command for this like we have apt-get in debian?


'pkg_add' should be installing dependencies automatically.

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


Re: Port/Package Management?

2007-03-11 Thread Joseph Koshy

This time I am interested in the operational principle
of  the port/package system, what is going on while
installing packages, and where is the source files if
I want to do some modification?


See /usr/src/usr.sbin/pkg_install/*

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


Re: sed -i

2007-03-26 Thread Joseph Koshy

Recently noticed that our sed(1) differs from its GNU
analog in that in -i mode it considers all files as a
single sequence of lines while the latter treats each file
independently.  The in-line mode isn't in POSIX, so it isn't
really clear which way is correct.


Aren't sed's addresses required to be cumulative across its
input files?

http://www.opengroup.org/onlinepubs/009695399/utilities/sed.html

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


Re: Writing to a file

2007-05-06 Thread Joseph Koshy

So, could anyone please give me a detailed
explanation of how to open a file in kernel and write to it - best data
types to use, functions, what to look out for, maybe a link to tutorial
or manual that deals with this (if such a thing exists), etc.?


I'm not aware of such a tutorial.  I would suggest that you start with the
source for alq_open() in "/sys/kern/kern_alq.c", looking up the manual
pages for all the functions it calls as needed.

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


Re: Writing a plain text file to disk from kernel space

2007-05-21 Thread Joseph Koshy

ls> So, I'm looking for a way to manually open up a file from within
ls> kernel space and dump characters into it.

des> Note that it opens the file in userland and passes it down to the
des> kernel.  You may want to consider a similar mechanism.

hwpmc(4) takes a similar approach, using a dedicated kthread to
to perform writes.

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


Re: SoC / PMC

2007-05-30 Thread Joseph Koshy

jk> You may need a regular i386 or amd64 PC to run FreeBSD on 'bare metal'.

mp> pmc: Unknown Intel CPU.
mp> module_register_init: MOD_LOAD (hwpmc, 0xc05b0114, 0xc3662094) error 78
mp> It seems, the module can't achieve initalization.. please help !

When the time comes for hooking up your GUI to hwpmc, I would recommend
that you use supported hardware and run FreeBSD on  'bare metal' i.e., not
under emulation.

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


Re: get active processes in python

2007-07-12 Thread Joseph Koshy

[Trimming soc-admins@ from the CC list]

mp> do you recommend a method to get active processes in a python script,
mp> as with "ps" or "top" in order to put the result into a list ? (python
mp> package, shell call...)

One option would be to wrap "kvm_getprocs(3)" and use that.

mp> PS: I would like to fire this regularly, eg every second

This shouldn't be a problem.  Most GUI toolkits offer a way of
registering a callback that will be invoked periodically.

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


Re: python modules

2007-07-13 Thread Joseph Koshy

mp> I copied libpmc.so and tryed  'import libpmc'. I have:
mp> ImportError: dynamic module does not define init function (initlibpmc)
mp> Are we really far from having a libpmc module ?

You may want to browse the following articles in Python's
documentation set:

   "Extending and Embedding the Python Interpreter" (tutorial)
   "Python/C API Reference Manual"

There is an (experimental) Python wrapper for an early version of
libpmc(3) here:

   //depot/user/jkoshy/projects/pmctools/py-libpmc/...

However this code has not been kept in sync with libpmc(3).  I'm
waiting for libpmc to stabilize :).

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


[CFT] Callchain capture in PmcTools

2007-08-03 Thread Joseph Koshy
I'm pleased to offer a patch implementing callchain capture for
hwpmc(4) for review.

Test reports, comments etc. are welcome.

Regards,
Koshy

=
 Summary  

hwpmc(4):

* hwpmc(4) can now walk kernel and user stacks and capture caller
  information for subsequent analysis by pmcstat(8).
* An additional flag in the API `PMC_F_CALLCHAIN' controls whether
  a PMC will capture a callchain.
* Tunable kern.hwpmc.callchaindepth controls the maximum depth to
  which stacks are walked.  The default is `8'.

pmcstat(8):

* pmcstat(8) now defaults to allocating PMCs that capture callchains.
  Use the new `-N' option (a toggle) to turn this off.
* The '-g' option (gmon.out generation) now writes call arc data for
  subsequent analysis by gprof(1).
* The new '-G' option generates system-wide callchain summaries.
  The new '-z maxprintdepth' option restricts the depth of the
  the callchain summary.


 Patch Information 

1) Download the patch

   % fetch \
   http://people.freebsd.org/~jkoshy/download/pmctools-callgraph-patch.gz

   MD5 (pmctools-callgraph-patch.gz) = 632185755d1004e82c3d2bbc69827307

2) Apply using patch -p1 against a recent (Aug 3rd) -current:

   % cvs checkout -P src
   % cd src; gzip -dc pmctools-callgraph-patch.gz | patch -p1

3) Build and update the kernel+world.

   You will need to add 'options HWPMC_HOOKS' to your kernel config
   before you can use hwpmc(4).

   % (follow the usual procedure, see src/UPDATING)

 Using the patch 

1) Load hwpmc into the kernel

   % kldload hwpmc

2) Collect measurements

   % pmcstat -S instructions -O logfile etc.

3) Use option -g to generate gprof(1) style 'gmon.out' files.

   % pmcstat -R logfile -g
   % gprof /boot/kernel/kernel /kernel.gmon

4) Use option -G to generate a callchain summary:

   % pmcstat -R logfile -G summaryfile
   % vi summaryfile

 Known Bugs with this patch 

1) P4 HTT lockup

Symptom:Lockup under load of Pentium 4 machines with HTT enabled.

Workaround: Restrict sampling to one CPU using the '-c' option:

# pmcstat -c 0 -S instructions -O logfile

2) pmcstat(8) stuck in an unkillable state.

Symptom:When interrupted, pmcstat(8) gets stuck sleeping on
wait channel "pmcctx".
Workaround: Use the '-n' option to reduce sampling frequency:

# pmcstat -n 1048576 -S instructions ...other options...


Other (older) known bugs are listed at http://wiki.freebsd.org/PmcTools.

 Other Notes 

pmcstat(8) works best with unstripped executables (e.g. set "STRIP="
in /etc/make.conf).

On the amd64 the heuristic used to determine the frame pointer given a
sampled PC address is not very good and can at times result in the
next to topmost frame being missed in the sampled callchain.

 Thanks 

 - To the users of PmcTools in the FreeBSD community for their
   feedback, encouragement and support.

 - To the FreeBSD Foundation and Google Inc., for supporting this work.

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


Re: Kernel Threads

2004-02-06 Thread Joseph Koshy


Sridhar,

> I heard that even Interrupts run under kernel threads context

See ithread(9).

> How can a kernel thread yield CPU when it detects it is idle?

kthread_suspend(), or yield().  See kthread(9), mi_switch(9).

Let me also answer your questions(s) at another level: I have found
information about the kernel in the following places:

1. The section 9 manual pages
2. The FreeBSD Arch Handbook
3. The FreeBSD Handbook
4. The sources -- use 'glimpse' on a checked out -CURRENT tree.
5. Under /usr/share/doc/papers/

If you find some documentation to be missing, and you had to figure out
something non-obvious, please file a PR with sample text.

Regards,
Koshy
<[EMAIL PROTECTED]>



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


Re: Strange FTPD behavior

2004-09-28 Thread Joseph Koshy
You could use ktrace(1) to determine what the ftpd daemon is actually doing.

rh> Is the user's shell listed in /etc/shells?  It must be there for ftpd to
rh> let them in.

vt>   I run FreeBSD 4.3-STABLE machine. I use ftpd for ftp server
daemon. It has
vt> very strange behavior with one of user accounts on my machine.
Every one user
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: Amazing.

2004-10-02 Thread Joseph Koshy
jason> features, but whenever I tried to run startx after Xorg
-configure had finished
jason> running, the screen would flash then simply go back out to the
console with the

The X server's log (/var/log/X*.log) should tell you what went wrong.  A common
problem is that you are trying to run X without the appropriate permissions.
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: 4.8-STABLE kernel crash

2004-10-29 Thread Joseph Koshy
On Thu, 28 Oct 2004 21:30:45 -0300, Allan Marshall <[EMAIL PROTECTED]> wrote:
> The box has been quite unstable, with restarts every few days
> this is the first dump ive got with DDB
> I realize this likely isnt enough information, but if you could point me in the 
> right direction
> I can provide anymore information required.

1) dmesg output please
2) Is this a new problem?  Did the box run FreeBSD stably earlier?
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: files_getstate

2004-12-17 Thread Joseph Koshy
> I can't find the source to files_getstate *anywhere* in /usr/src.

> Can anyone tell me where to find this missing function/macro?

Try "src/lib/libc/include/nss_tls.h":

...
static int  \
name##_getstate(struct name##_state **p)\
{   \
static struct name##_state st;  \
...
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: Developing device-drivers without rebuilding the hole kernel

2004-12-18 Thread Joseph Koshy
> want to rebuild the whole kernel every time i add a few new lines or a

If you use config(8) to configure your kernel in the "traditional way",
this should come for free.

See:  
http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-building.html
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: Virtual CPU or not?

2004-12-18 Thread Joseph Koshy
> I would like to find a method which determines the current number of
> active CPUs.

> Is there a better method than checking that sysctl and divide the
> hw.ncpu by two if set?

You are probably looking for:

   min(number of '0' bits in machdep.hlt_cpus, hw.ncpu)
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: clock time in milliseconds into a c program

2005-01-20 Thread Joseph Koshy
> I don't think there is a streight way to speed-up the default 
> unix time resolution, which is, as far as i know, in 
> microseconds.

On i386 (and possibly amd64) platforms you can use the
RDTSC instruction to get a direct measure of processor
cycles elapsed.

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


Re: Opening and wriiting to file in Kern

2005-02-06 Thread Joseph Koshy
> If you mist do this, the general set of steps are:
> 
> 1. use namei() to convert a pathname to a vnode
> 2. Use vn_open(), vn_rdwr(), and vn_close() to operate on the vnode.
> 3. Observe proper vnode locking and reference counting with vref(),
> vn_lock(), and vput()

Take a look at "sys/kern/kern_ktrace.c" or "sys/kern/kern_alq.c" for a template.

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


Re: How many developers?

2005-02-10 Thread Joseph Koshy
If you'd like approximate activity levels by committer, 
try something like:

% cd /cvs/FreeBSD/CVSROOT-src/commitlogs # choose repository
% gzip -dcfq * | awk '
  /^[a-z][a-z]*/ { count[$1]++ } \
  END { for (c in count) { print count[c], c } } ' | \
  sort -nr | less

... 
7193 jkh
6864 peter
6682 phk
6031 obrien
5898 ru
5261 bde
4355 ache
3737 imp
2951 brian
2867 jhb
2765 des
2399 rwatson
... [snip] ...

For 'recent' activity levels, replace the '*' with a suitable
set of commit logs.

I'd also like to point out that most of the changes to the
project come from outside of the group of 'committers' (I
remember a figure of 75% doing the rounds at one point).  
The number of  FreeBSD 'contributors' exceeds the number 
of committers by a large margin.

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


Re: Help about debugging FreeBSD kernel core dump file

2005-02-28 Thread Joseph Koshy
> How can I debug the core dump file created by kernel panic? I try to use "gdb 
> -core vmcore.0" (vmcore.0 is 4G file because I have 4G memory) and the gdb 
> said: this is not a vaild core file. Why?

AFAIK  you have to use 'gdb -k' (or 'kgdb') to use GDB's kernel debugging mode.

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


Re: Collecting data in userland from kernel

2005-03-03 Thread Joseph Koshy
> First one is in general abt the method to be followed, I
> have the following ideas ... [snip]

Have you looked at netgraph(4) and ng_socket(4)?

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


Re: Can someone please help me? Why does init fail to start?

2005-03-09 Thread Joseph Koshy
> execve(), and at the start of init.  The kernel print statement is
> shown, however the init statement is not.

> Any clues?

1) Does the execve() invocation of 'init' succeed (errno == 0)?
2) What is the value of  'init_path'.  Which executable is finally selected to
 serve as 'init'?
3) Does 'init' run on a regular FreeBSD kernel?

... etc ...

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


Re: Freebsd 5.3 problem: SCSI Errors ...Help

2005-03-10 Thread Joseph Koshy
> (probe1:ahd0:0:1:0): No or incomplete CDB sent to device.
> (probe1:ahd0:0:1:0): Protocol violation in Message-in phase.
> Attempting to abort.
> (probe1:ahd0:0:1:0): Abort Message Sent
> (probe1:ahd0:0:1:0): SCB 14 - Abort Tag Completed.
> found == 0x1
> ahd0: Invalid Sequencer interrupt occurred.

I've seen these kinds of symptoms when the system was 
overheating or had electrical problems.

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


Re: Freebsd Asm

2005-03-10 Thread Joseph Koshy
> I already visited int80h.org and linuxassembly.org and others, And did not
> find any resources or include files..
> If anyone can share his own files, or give any tips, would be nice.

It is straightforward:

The assembly syntax is whatever is supported by gas(1) for
your architecture.  'info gas' should be of help.

The BSD make(1) infrastructure supports creating objects from
assembler sources; just name your assembler files with a
.S or .s suffix and include these names in your 'SRCS'
make variable.

Files with a ".S" suffix are preprocessed by cpp(1) before 
being fed into the assembler.  Files with a ".s" suffix are
fed into the assembler without preprocessing.  See 
"src/share/mk/sys.mk".

There are some convenient CPP macros for assembly language
programmers in  and .

You can also study the assembly sources under "src/lib/libc/*".

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


Re: How to send a signal from inside the kernel?

2005-03-17 Thread Joseph Koshy
> Here are the headers needed in case someone reads this thread:
> 
> #include  /*needed only for NULL, can be removed*/
> #include 
> #include 
> #include 
> #include 
> #include 

According to the manual page for psignal(9) in -current, you 
only need  and .

You need to hold the PROC lock for the target process before 
invoking psignal().

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


Re: Freebsd 5.0 NICs issue

2005-03-17 Thread Joseph Koshy
> ifconfig em1 inet 205.229.165.8 netmask 255.255.255.0 up

   ifconfig em1 alias ALIAS-ADDRESSS netmask NETMASK

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


Re: MDELAY()

2005-04-15 Thread Joseph Koshy
> sleep_on_timeout() call in Linux . (dont' want to waste the CPU cycles

You may want to try the manual pages.

% man -k sleep | fgrep '(9)'  
endtsleep(9), sleepinit(9), unsleep(9) - manage the queues of sleeping processes
init_sleepqueues(9) ... sleepq_wait_sig(9) - manage the queues of
sleeping threads
sleep(9), msleep(9), tsleep(9), wakeup(9) - wait for events
vm_page_sleep_busy(9)- wait for a busy page to become unbusy

% man -k DELAY | fgrep '(9)'
DELAY(9) - busy loop for an interval

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


Re: core dump submissions with send-pr?

2005-04-15 Thread Joseph Koshy
> What is the proper method for submitting cores along with 
> backtraces to the FreeBSD development team?  Is it useful to 
> submit cores, or is the backtrace sufficient?
 
Firstly, GNATS works over email and sending in a 4GB+ MIME 
encoded core file could overload the mail servers of not
just the FreeBSD project, but also those of the volunteers who
track the freebsd-bugs list.

Secondly the GNATS repository is itself replicated on many 
sites and so you would also earn the wrath of mirror
site admins across the world :).


Instead, you could first describe the problem on -stable.  
It may turn out to be a known problem (you can check yourself 
with a quick browse of the archives).

If it *is* a new bug then please do file a PR with a backtrace, 
your machine configuration, and a description of the problem.  
Many times a core file is not necessary, but if needed it
generally suffices to put it up somewhere where a developer 
can access it.

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


Re: Determine location of LD_PRELOAD'ed shared libraries/functions.

2005-04-17 Thread Joseph Koshy
> Please point me to right direction, because i've got only one 
> idea left: grep dynamic loader for LD_PRELOAD ;).

Doesn't dlsym() with handle RTLD_DEFAULT work?

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


Re: kernel programming

2005-04-19 Thread Joseph Koshy
> where's a good place for kernel programming documentation ?

In no particular order:

1. The FreeBSD Developer's Handbook.
2. The FreeBSD Architecture Handbook.
3. The book 'The Design and Implementation of the FreeBSD
   Operating System', by Kirk McKusick and George
   Neville-Neil.
3. The section 9 manual pages.
4. The source code :).

You may want to browse: http://www.freebsd.org/docs.html

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


Re: (no subject)

2005-05-23 Thread Joseph Koshy
> How can I get the process_id of a process when I've the 
> process_name from within a C program? Also can the command

You could look at the way its done in
"src/usr.bin/killall/killall.c", or read the manual page
for kvm_getprocs(3).

> kill (pid, SIGCONT) be used to restart a dead daemon process

SIGCONT can only resume existing processes that are stopped.

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


Re: cc1: internal compiler error: Abort trap: 6

2005-06-03 Thread Joseph Koshy
vijay> Is this a known issue? How can I get around this?

Likely causes include flaky RAM, overclocking and CPU 
overheating.  Did the machine get through a full buildworld 
cycle previously?

You can check your CPU temperature with 'mbmon'.

roman> gcc has just been upgraded to 3.4.4 so I expect a lot of 
roman> ICEs fixed ;) ICE can

True, but he's using v3.4.2, which has been pretty stable.

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


Re: using beastie.4th to alternate boot i386 / amd64

2005-06-06 Thread Joseph Koshy
> I'm trying to get beastie.4th to allow me to select either
> amd64 or i386 as my running system. I can get this to happen
> from the boot loader using:

> set currdev=disk1s1d
> set rootdev=disk1s1d
> unload
> load /boot/kernel/kernel
> load /boot/kernel/acpi.ko
> load /boot/kernel/hptmv.ko
> boot

If you are looking for a way to manage i386/amd64 dual
booting, the you can just interrupt the boot sequence at the 
boot: prompt and then load /boot/loader itself from the 
appropriate root partition.  You can specify a 'default'
in file /boot.config in the disk's 'a' partition.

Using FORTH would allow for a nice menu though :).

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


Re: How to check root powers on a struct proc ?

2005-06-17 Thread Joseph Koshy
> I am trying to check that a process (struct proc) has root 
> powers when it calls my KLD system call.

Don't you get a 'struct thread *' as an argument to your
system call entry point?

The 'flag' argument to suser_cred(9) is documented in its
manual page.

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


Re: hello world but not in 32bit x86 but in amd64 for amd64 platform

2005-08-17 Thread Joseph Koshy
av> "Hello World" assembly program written in 64bit assembly
av> which I can compile and run on my FreeBSD,AMD64 platform

You could also look at "src/lib/libc/amd64/SYS.h" for how
system calls are implemented.  In particular,

  #define KERNCALLmovq %rcx, %r10; syscall

A system call transfers control to: 

  "src/sys/amd46/amd64/exception.S":
  ... snip ...
  IDTVEC(fast_syscall)
  swapgs
  movq%rsp,PCPU(SCRATCH_RSP)
  movqPCPU(RSP0),%rsp
  ... etc ...

The x86-64 ABI is defined in:

   http://x86-64.org/documentation/abi.pdf

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


Re: getenv semantics

2005-10-15 Thread Joseph Koshy
> Is this analysis correct?  Can someone point me to the (a?)
> standard that describes this.  The FreeBSD behaviour makes
> sense, I am trying to understand what is the expected
> behaviour on other platforms.

>From "The Open Group Base Specifications Issue 6"
http://www.cnop.net/docs/susv3/functions/getenv.html

"The getenv() function shall search the environment of the
 calling process (see the Base Definitions volume of IEEE Std
 1003.1-2001, Chapter 8, Environment Variables) for the
 environment variable name if it exists and return a pointer to
 the value of the environment variable. If the specified
 environment variable cannot be found, a null pointer shall be
 returned."

--
FreeBSD Volunteer, http://people.freebsd.org/~jkoshy
___
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-04 Thread Joseph Koshy
> - Am I not following the correct procedures to
>   allocate and deallocate memory in kernel space ??
> - Or is the problem elsewhere ??

You didn't say whether you've checked your code for buffer
overruns.

If the fault is happening in seemingly unrelated parts of
the kernel with your module is enabled, this could be a
root cause.

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


UFS2 max limits?

2005-11-12 Thread Joseph Koshy
The Wikipedia page referenced below says that UFS2 supports a
filesystem size of 2^80 Bytes (1YiB) with the limit on a given
file being 2^55 bytes (32 PiB).

Are these numbers correct?  I somehow remember the limits as
being much lower (of the order of 16TB or so).

  http://en.wikipedia.org/wiki/Comparison_of_file_systems

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


Re: How do I control the load address in Elf header

2005-11-17 Thread Joseph Koshy
> I am one of the firmware guys that is writing a Secondary Boot  Loader that 
> boots
> FreeBSD kernel. From what I see in the ELF header for FreeBSD kernel, the load
> address seems to have a value of  0x8020 which seems to be a Virtual 
> address
> for me. If I want to put the Physical address where I want the FreeBSD to go,
> what are the FreeeBSD files I need to change?

See loader(8) ...  /usr/src/sys/boot/*

AFAIR we switch to protected mode in the loader itself.

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


Re: dump causing system idle

2005-11-26 Thread Joseph Koshy
k> freebsd 53 idles on
k>  
k> WARNING: / was not properly dismounted
k>  start_init: trying /sbin/init
k> ==

Does /sbin/init exist?  Does it match the /sbin/init on a
'good' partition?

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


Re: easy question about kill command

2005-12-16 Thread Joseph Koshy
> Is there anyone who can explain me, why when i say 'kill -HUP >
> id', and its failed to restart, kill say nothing?
> It is such an easy to implement...

Your application could be choosing to ignore SIGHUP
(restarting on SIGHUP is a convention, not a OS defined
requirement)?

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


Re: Building a release

2005-12-27 Thread Joseph Koshy
> Why?  I'm wondering if this is the problem as both ports and
> doc are not populated.
>
> Any suggestions, ideas?

The ports and doc collections use tags of the form RELEASE_X_Y_Z,
while src uses RELENG_X_Y_Z_RELEASE.

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


Re: Lua 5.0 and FreeBSD 4.1

2006-01-17 Thread Joseph Koshy
> In what version of FreeBSD (or libc) these functions (sin, cos,
> tan, ...) were implemented?

Are you linking with libm?

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


Re: KTR not working !!

2006-01-25 Thread Joseph Koshy
> #-
> options KTR
> options KTR_ENTRIES=8192
> options KTR_VERBOSE
...
>   Am i missing something very important ?

What is the value of sysctl debug.ktr.mask?

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


Re: What is '_KERNEL' in the source ?

2006-02-06 Thread Joseph Koshy
>   In various kernel source files,i came across '#ifdef _KERNEL'.
> What is '_KERNEL' used for ? In some files _KERNEL is #defined to nothing ??
> Can anybody please explain this ?

It is used to control the visibility of types and prototypes in system headers.
Kernel builds define _KERNEL, but userland compiles usually do not.  Thus a
#include  has a different meaning in userland than in the kernel.
See: src/sys/conf/{kern.pre,kmod}.mk

A few userland utilities (e.g., fstat) define _KERNEL before including
headers from  because they need more knowledge of kernel
data structures than is the norm for userland.

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


Re: Poweredge 2850 keyboard problem

2006-02-13 Thread Joseph Koshy
ak> options, perc4 controller set-up, etc. The keyboard works
ak> fine also if I boot into single user mode. However, if
ak> I do a normal boot into multi-user mode (the keyboard
ak> works fine when selecting a boot option) then when I
ak> get to the login prompt, no keyboard input at all.

I worked around the problem by turning off USB.

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


Re: Dual booting Free BSD 6 and Slackware

2006-02-17 Thread Joseph Koshy
> What is the equiv of this in Free BSD? /boot/kernel doesn't seem to work on
> lilo and I'd really like to use it for booting and I've done it before, that
> and Free BSD didn't want to boot Linux at first (Was my fault) so does anyone
> know... Actually I'm assuming you do know because that's why I asked here
> instead, but anyway, I've been reading through the books I bought, and it
> doesn't mention anything like "Ok, in Linux it's /boot/vmlinuz, in Free BSD
> it's"

Try "/boot/loader"

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


Re: world's toolchain & CPUTYPE

2006-02-26 Thread Joseph Koshy
yt> - tried to install the world over NFS on an old Pentium
yt> machine with some 5.3-BETA;

AFAIK, the only 'supported' installation mode is to have
the installworld step running on the same machine that did
the build.  I.e., you need to export '/' from the old
Pentium box, mount it somewhere on your Athlon and
run a make installworld (on the Athlon) with the appropriate
DESTDIR value.

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


Re: unversal watchdog

2006-02-27 Thread Joseph Koshy
dc> As to answer the question - I am not aware of any facility for
dc> automatically restarting things (unless you can get init to do
dc> it via /etc/ttys somehow)

Wasn't there a port of launchd in the wings?

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


Re: Fastest timecounter ?

2006-02-27 Thread Joseph Koshy
vg> I wrote a piece of software that has to get the current
vg> timestamp, one way or the other, a huge number of times per
vg> second. Apart from the empyrical tests one can perform to
vg> find out the timekeeping scheme with the less performance
vg> impact, is there any rule of thumb as to what choice to go
vg> for ?

vg> Any kind of advice is most welcome, especially reading
vg> material.

vg> P.S. I know that some of you may say that calling
vg> gettimeofday() that often is braindead, and at some
vg> point I agree. Unfortunatley, right now I can't do
vg> anything better. I need timekeeping to comb the
vg> algorithms that deal with my data structures a bit more,
vg> after which I can switch to time-related optimizations.

If you just want a relative count (i.e., not absolute
time) and if your machine's aren't going to be in sleep
modes, you could use the RDTSC instruction directly.

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


Re: Difference between signal related structures

2006-02-27 Thread Joseph Koshy
ps> Can anybody tell me that why there are two different structures named
ps> 1)struct   sigcontext
ps> 2)struct   osigcontext
ps> are defined in /sys/i386/include/signal.h
ps> I want to know what is basic difference between them?

 % cvs log -r1.10 /usr/src/sys/i386/include/signal.h
 % cvs log -r1.11 /usr/src/sys/i386/include/signal.h

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


Determining CPU features / cache organization from userland

2003-10-10 Thread Joseph Koshy


Hi -hackers,

I'm looking for ways that a userland program can determine the CPU
features available on an SMP machine -- processor model, stepping
numbers, supported features, cache organization etc.

For example, on some x86 processors the CPUID instruction could be
used to determine some of these parameters, but using this instruction
in an SMP context is a little tricky since we do not know which CPU 
gets to execute the instruction.

Would you know of any existing APIs, in use in other OSes, for
retrieving this kind of information?

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


Re: Determining CPU features / cache organization from userland

2003-10-15 Thread Joseph Koshy


Hi Bruce,

A few thoughts on your API:

1) Rather than naming the struct's as "l1", "l2" etc, it may be more
   orthogonal to use an array of cache entries like so

   struct entry { ... } entries[MAX_ENTRIES];  where MAX_ENTRIES would be say, 
8.

2) We could pass information back about whether the cache is write-back or
   write-through and whether it uses write-allocate.  In some CPUs (e.g. 
   the AMD K6-2) this aspect of the cache is programmable at boot time.

3) Have a bit indicating whether the cache is indexed virtually or physically. 

   This allows us to describe TLBs and caches using the same descriptor; the
   MIPS R4K used virtually addressed L1 caches, IIRC.

4) For caches and TLBs that support variable line/page sizes, we would 
   be reporting the currently programmed size (the kernel knows this
   information) I guess?

The 'type' field of the cache descriptor could be an `u_int32_t' or 
`u_int16_t',
allocated out as follows:

kind:   tlb/cache/other 2 bits
addressing: virtual/physical/unknown2 bits
mode:   data/instruction/both/unknown   2 bits
distance:   L0/L1/L2/whatever   3 bits
on-write-hit:   write-back/write-thru/unknown   2 bits
on-write-miss:  write-allocate/unknown  2 bits

Another suggestion I have is that the sysctl return:

int n_entries;
struct entry entries[n_entries];

since it isn't clear how many levels of cache and how many kinds
of TLBs are going to be used in the systems of tomorrow.

Regards,
Koshy
<[EMAIL PROTECTED]>

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