Linux-Development-Sys Digest #500, Volume #8     Mon, 19 Feb 01 13:13:22 EST

Contents:
  Where is printk? (Weirong Zhu)
  Re: mmap limits (Kasper Dupont)
  Re: Module Programming Question (Unresolved symbol printk) (Josef Moellers)
  Re: SCSI Programming - READ_CAPACITY (Josef Moellers)
  Re: Where is printk? (Josef Moellers)
  Re: ENOMEM from poll (Kasper Dupont)
  Re: Problem in Module <insmod, rmmod> (Kasper Dupont)
  Re: Two variables in two dlls with the same name. (Thaddeus L Olczyk)
  how to get current queue len?? (NortonNg)
  Re: How to write a blocking function in a module? ("Z")
  Re: bugreport: NFS crashed my Linux (Jyrki Havia)
  Re: Two variables in two dlls with the same name. ("Arthur H. Gold")
  Re: bugreport: NFS crashed my Linux ("Christian")
  Re: ENOMEM from poll (Kaelin Colclasure)
  Re: ENOMEM from poll (Kaelin Colclasure)
  can't find X includes ("Franck")

----------------------------------------------------------------------------

From: Weirong Zhu <[EMAIL PROTECTED]>
Subject: Where is printk?
Date: Mon, 19 Feb 2001 02:19:28 -0600

Anybody knows where is printk physically located? Is it in libc or in
kernel image. I can't find the function prototype declaration in
/usr/include/linux.

Here is where my question from:

I have problem to insmod the Hello module in Rubini's book (Linux Device
Driver). The error I got is "unresolved symbol: printk". I tried to
recompile the kernel with kernel module loadable option but it did not
work. The kernel is definitely module enabled because I saw some modules
in /proc/module.

Since printk is such a fundamental kernel system call I believe there is
something wrong in the linux I installed. I use mandrake 6.2 which is
based on Redhat 6.2. The kernel version is 2.2.13. The kernel source
file is also 2.2.13 version. Looks like symbol printk is not exported.
If I know the place that printk's object resides I can probably check
that file to see the version.

Thanks in advance for your suggestion.

Weirong Zhu

[EMAIL PROTECTED]




------------------------------

From: Kasper Dupont <[EMAIL PROTECTED]>
Subject: Re: mmap limits
Date: Mon, 19 Feb 2001 09:12:44 +0000

Ulrich Weigand wrote:
> 
[...]
> 
> Segmentation doesn't help either, as 48bit segmented addresses
> are translated to 32bit linear addresses *first*, before those
> are finally mapped to 36bit physical addresses (assuming PAE).
> 
> --
>   Dr. Ulrich Weigand
>   [EMAIL PROTECTED]

It could help, the kernel could swap segments in and
out of the virtual address space. If you had a large
number of 1GB segments, you could have 3 or 4 mapped
in the 32bit linear space. This feature is however
not implemented, and I don't think anybody wants to
do that.

-- 
Kasper Dupont

------------------------------

From: Josef Moellers <[EMAIL PROTECTED]>
Subject: Re: Module Programming Question (Unresolved symbol printk)
Date: Mon, 19 Feb 2001 10:24:05 +0100

Paul Pluzhnikov wrote:

> On my system:
> =

>   paul@buffalo:~>cat /proc/ksyms | grep printk
>   c0112fc2 printk_R1b7d4074
> =

> This means that the kernel was compled with CONFIG_MODVERSIONS=3Dy
> Check your top-level .config ...

You may want to check the /usr/src/linux/configs directory.
It has the .config files for the single- and multi-processor kernels
that were installed during system install.

For single-CPU systems, just do a
cd /usr/src/linux
cp configs/kernel-2.2.14-i386.config .config
make oldconfig

And you're all set up.

HTH,
-- =

Josef M=F6llers (Pinguinpfleger bei FSC)
        If failure had no penalty success would not be a prize
                                                -- T.  Pratchett

------------------------------

From: Josef Moellers <[EMAIL PROTECTED]>
Subject: Re: SCSI Programming - READ_CAPACITY
Date: Mon, 19 Feb 2001 10:28:40 +0100

Uncle Nick wrote:
> =

> Marty,
> =

> The sg_utils found on this page http://www.torque.net/sg include an exa=
mple
> program sg_readcap.  I have tried some of the other examples and they w=
orked
> fine.
> =

> Good Luck.
> Nick
> =

> "Marty" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]...
> > I want to get the capacity and block size of my SCSI hard disk.
> > I followed the Inquiry example in SCSI Programming - HOWTO to use a
> > write system call to send a READ_CAPACITY command to the generic devi=
ce
> > /dev/sga and then use a read system call to get back the capacity and=

> > block size.
> > However, the values I retrieved is not reasonable, have I made anythi=
ng
> > wrong? Are there any places where there are examples about that ?
> >
> > Marty.
> >

I have been playing around with sg for some time. I have a small shared
object for tcl/tk that provides scsi_in and scsi_out commands as well as
a Perl scsi module.
It was all hacked together just to fill my own needs, but so was Linux
B-{)

Mail me if you'd like it.

Josef
-- =

Josef M=F6llers (Pinguinpfleger bei FSC)
        If failure had no penalty success would not be a prize
                                                -- T.  Pratchett

------------------------------

From: Josef Moellers <[EMAIL PROTECTED]>
Subject: Re: Where is printk?
Date: Mon, 19 Feb 2001 10:32:28 +0100

Weirong Zhu wrote:

> Since printk is such a fundamental kernel system call I believe there i=
s
> something wrong in the linux I installed. I use mandrake 6.2 which is
> based on Redhat 6.2. The kernel version is 2.2.13. The kernel source
> file is also 2.2.13 version. Looks like symbol printk is not exported.
> If I know the place that printk's object resides I can probably check
> that file to see the version.

It most probebly is there.
Just do an
        fgrep printk /proc/ksyms

-- =

Josef M=F6llers (Pinguinpfleger bei FSC)
        If failure had no penalty success would not be a prize
                                                -- T.  Pratchett

------------------------------

From: Kasper Dupont <[EMAIL PROTECTED]>
Subject: Re: ENOMEM from poll
Date: Mon, 19 Feb 2001 09:39:35 +0000

Kaelin Colclasure wrote:
> 
> I'm working with a server that's consistantly dying on an ENOMEM from
> poll.  The service runs on dual-CPU i86 linux boxes with with 1GB of
> RAM and a fairly stock Redhat 6.2 distro.  In order to deal with the
> sheer number of clients using this service, each server ups its
> process fd limit to 16000. (!)
> 
> The server does use a lot of memory, and allocates and frees
> constantly as it services requests and as clients come and go. But
> it's *always* the call to poll that generates an ENOMEM. Thus I have a
> suspicion that this may be no ordinary memory leak, but a case of
> exhausting the memory pool available to the kernel.
> 
> I understand that the 4GB i86 address space is partitioned into 1GB
> for the kernel's use and 3GB for the userland process. I know what
> this means to the userland process -- but how exactly does the kernel
> use its 1GB? Does this mean that the kernel is limited to 1GB of
> kalloc'd (or whatever) memory for all processes in the system? Or for
> each process?  And is there a simple way to find out if I am indeed
> bumping into some such limit?
> 
> Another possibility is that the working set is simply so large that
> the machine is running out of physical RAM pages for the kernel to
> allocate. Again, how would I test this theory?
> 
> -- Kaelin

The 1GB kernel space have the same layout in all processes.
This range is divided into to parts, the first part is used
for a 1:1 mapping of physical memory. The rest is used for
a virtual address space. (for kmalloc as far as I remember.)

With 1 GB of physical memory there will not be much space
left for the virtual memory. I suggest you either try using
less than 1GB of memory by passing mem=512m or mem=768m to
the kernel. Or try using a kernel compiled with a 2:2 split
instead of 1:3.

This hint is not a solution, but hopefully a way to find the
reason for your problem.

-- 
Kasper Dupont

------------------------------

From: Kasper Dupont <[EMAIL PROTECTED]>
Subject: Re: Problem in Module <insmod, rmmod>
Date: Mon, 19 Feb 2001 09:43:35 +0000

[EMAIL PROTECTED] wrote:
> 
> Hello,
> 
> I'm new to Linux Device Driver.
> I'm refering "Linux Devive Drivers" by Alessandro Rubini.
> 
> The Very first example given in that book is:
> #define MODULE
> #include <linux/module.h>
> 
> int init_module(void) {
>         printk("<1> Hello World\n");
>         return 0;
> }
> 
> void cleanup_module(void){
>         printk("<2> Goodbye cruel World\n");
> }
> 
> I'm in superuser mode. And I gave the following commands:
> 
> #gcc -c hello.c
> 
> #insmod hello.o
> 
> I got no output, where as in book its given as Hello World.
> So I tried the same again
> 
> #insmod hello.o
> 
> This time I got the following result
> "insmod: a module named hello.o already exist"
> Then I tried
> 
> #rmmod hello.c
> And I got the output as "rmmod: module hello.o is not loaded"
> 
> Can someone give me some advice?
> 
> Thanks in advance,
> Regards,
> Vidula
> 
> 
> 
> --
> Posted via CNET Help.com
> http://www.help.com/

If you are runing X (which I presume you are) the
messages will not go directly to the screen. The
messages are normally logged in the file
/var/log/messages. I also think xconsole can be
configured to show them.

To remove your module you should remove .c and
only type: "rmmod hello"

-- 
Kasper Dupont

------------------------------

From: [EMAIL PROTECTED] (Thaddeus L Olczyk)
Subject: Re: Two variables in two dlls with the same name.
Date: Mon, 19 Feb 2001 10:37:41 GMT
Reply-To: [EMAIL PROTECTED]

On Mon, 19 Feb 2001 00:24:11 -0600, "Arthur H. Gold" <[EMAIL PROTECTED]>
wrote:

>Thaddeus L Olczyk wrote:
>> 
>> I was at a Borland demo of Kylix and the guy claimed that
>> you could not have two variables/functions with the same name in two
>> different dlls, it they are loaded statically ( at startup ).
>> He wasn't sure if you  could load them dynamically ( dlopen, dlsym (I
>> think)).
>> Is this trtue, what about dynamic loading?
>The deal is that if two variables of the same name are in
>global scope, one will always win (with, usually, at best,
>unpredictable results). 
>However, you can actually turn this behavior to your
>advantage through controlled use of function interposition
>coupled with dlsym().
>
>That is also why DSOs should _only_ export symbols it really
>_means_ to export (that's what version scripts are for!).
>

1) What's a version script.
2) OK. But if I follow this procedure, call dlopen on liba, call dlsym
on foo in liba ->pFooa, call dlopen on libb, call dlsym on foo in libb
->pFoob, do stuff, close libb,close liba. Can I then simply use the
pointers that I extracted? Or will that cause problems with pFoob
( since it might be pFoob).

3) What if both liba and libb are loaded but inseperate processes?

------------------------------

From: NortonNg <[EMAIL PROTECTED]>
Subject: how to get current queue len??
Date: Mon, 19 Feb 2001 13:31:26 +0000 (UTC)


hi all,
      
        the ifconfig show the maximum queue len size. (100 packets),
if anyone know how to get the size of current queue len? I means how many
bytes are using and how many space are available.

jkng.

------------------------------

From: "Z" <[EMAIL PROTECTED]>
Subject: Re: How to write a blocking function in a module?
Date: Mon, 19 Feb 2001 14:35:21 +0100

Once upon a while "Srikrishna Gurugubelli" <[EMAIL PROTECTED]> wrote:

> Hi,
> 
>   how do we write a blocking read function in a module?
> 
> I am trying to implement a smaller version of the tcp stack and need to
> make the read call blocking.  i tried using the kernel code, but it doesnt
> work from the module.
> 
> any help would be greatly appreciated.
> 
> thanks,
> krishna.


look up the functions interruptible_sleep_on() and sleep_on()
with wake_up_interruptible() and wake_up(). which are
implemented as wait queues. 

Go to 
http://www.atnf.csiro.au/~rgooch/linux/docs/index.html
to see how the wiat queue interface changed thru the last
releases.


-- 
Z ([EMAIL PROTECTED])
"LISP  is worth learning for  the profound enlightenment  experience
you will have when you finally get it; that experience will make you
a better programmer for the rest of your days."   -- Eric S. Raymond

------------------------------

From: [EMAIL PROTECTED] (Jyrki Havia)
Crossposted-To: alt.os.linux,sfnet.atk.linux
Subject: Re: bugreport: NFS crashed my Linux
Date: 19 Feb 2001 15:52:49 +0200

"Christian" <[EMAIL PROTECTED]> writes:

> "M. Tavasti" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
>
> hm, there is a nfs mount option "soft". it will let you interrupt the mount
> process by typing ^C if the nfs server is unreachable. maybe it's good for
> the unmount process too ? so, when it works, you'll only have "unclean
> unmounted nfs shares" (but try to fsck them ;-))

        Please do not confuse soft mount and interruptible NFS operations.

        Soft mount destroys you data, DO NOT USE SOFT MOUNTS.

        But you can and usually should use interruptible mounts.

        When a NFS operation begins, kernel send a NFS request and
        waits for an answer.  If timer expires AND mount is not soft,
        the request is resend, and the cycle begins from start. If the
        mount is a soft one, an error is reported to the application
        (if operation was write, data did not got written, but
        applicatin has no means to know which data was and which
        was not written!).

        If user presses ctrl-c (or sends any other singnal) for the
        application, the signal interrups NFS operation only if the NFS
        mount was done with option "intr".

        The relevant pieces from the mount manpage (Redhat 7):

       hard   The  program accessing a file on a NFS mounted file
              system will hang when the server crashes. The  pro­
              cess  cannot  be  interrupted  or killed unless you
              also specify intr.  When the  NFS  server  is  back
              online  the  program will continue undisturbed from
              where it was. This is probably what you want.

       soft   This option allows the kernel to time  out  if  the
              nfs  server  is  not  responding for some time. The
              time can be specified with timeo=time.  This option
              might  be  useful  if  your  nfs  server  sometimes
              doesn't respond or will be rebooted while some pro­
              cess  tries to get a file from the server.  Usually
              it just causes lots of trouble.


-- 
[EMAIL PROTECTED], University of Helsinki, Computing Centre

------------------------------

Date: Mon, 19 Feb 2001 10:21:40 -0600
From: "Arthur H. Gold" <[EMAIL PROTECTED]>
Crossposted-To: comp.os.linux.development.apps
Subject: Re: Two variables in two dlls with the same name.

Thaddeus L Olczyk wrote:
> 
> On Mon, 19 Feb 2001 00:24:11 -0600, "Arthur H. Gold" <[EMAIL PROTECTED]>
> wrote:
> 
> >Thaddeus L Olczyk wrote:
> >>
> >> I was at a Borland demo of Kylix and the guy claimed that
> >> you could not have two variables/functions with the same name in two
> >> different dlls, it they are loaded statically ( at startup ).
> >> He wasn't sure if you  could load them dynamically ( dlopen, dlsym (I
> >> think)).
> >> Is this trtue, what about dynamic loading?
> >The deal is that if two variables of the same name are in
> >global scope, one will always win (with, usually, at best,
> >unpredictable results).
> >However, you can actually turn this behavior to your
> >advantage through controlled use of function interposition
> >coupled with dlsym().
> >
> >That is also why DSOs should _only_ export symbols it really
> >_means_ to export (that's what version scripts are for!).
> >
> 
> 1) What's a version script.
A version script is a script that is input to ld (as part of
the linking step of creating a shared object) that gives you
control over how and what symbols are exported from a
library. See the ld info pages (`info ld') for details. This
essentially allows you to create a `library' scope for
functions that can't be declared static (as they're used
from multiple translation units within the library), but you
don't want out in the global namespace. Further, it serves
to protect intra-library linkages.
> 2) OK. But if I follow this procedure, call dlopen on liba, call dlsym
> on foo in liba ->pFooa, call dlopen on libb, call dlsym on foo in libb
> ->pFoob, do stuff, close libb,close liba. Can I then simply use the
> pointers that I extracted? Or will that cause problems with pFoob
> ( since it might be pFoob).
This is a little unclear.
First of all, calling a function from a dlopen()-ed library
after dlclose()-ing that library is a Bad Idea(tm). Think of
it as the equivalent of a dangling pointer.
Consider the following code:

   void * liba_handle = dlopen( "libA.so", RTLD_LAZY );
   void * libb_handle = dlopen( "libB.so", RTLD_LAZY );
   void * liba_func_pointer;
   void * libb_func_pointer;
   if (liba_handle && libb_handle) {
      liba_func_pointer = dlsym( liba_handle, "func" );
      libb_func_pointer = dlsym( libb_handle, "func" );
      /* now liba_func_pointer points to the function
         "func" from libA, and libb_func_pointer points
         to the function (we're assuming no error has
occurred) */

At this point we can cast the function pointers to their
appropriate types and call them. HOWEVER, if, both versions
of "func" call another library function, say "func2", and
"func2" is _also_ exported from both libraries, they will
each see the first "func2" in the link order, which is
likely _not_ what you want.
       
That's why controlling scope is important.
> 
> 3) What if both liba and libb are loaded but inseperate processes?
Then they're separate address spaces, and it's all
irrelavnat (IIUYC).

HTH,
--ag

[this discussion properly belongs in
news:comp.os.linux.development.apps; followup set]
-- 
Artie Gold, Austin, TX  (finger the cs.utexas.edu account
for more info)
mailto:[EMAIL PROTECTED] or mailto:[EMAIL PROTECTED]
--
Verbing weirds language.

------------------------------

From: "Christian" <[EMAIL PROTECTED]>
Crossposted-To: alt.os.linux,sfnet.atk.linux
Subject: Re: bugreport: NFS crashed my Linux
Date: Mon, 19 Feb 2001 17:35:07 +0100


"Jyrki Havia" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
news:96r8fh$lfj$[EMAIL PROTECTED]...
> If user presses ctrl-c (or sends any other singnal) for the
> application, the signal interrups NFS operation only if the NFS
> mount was done with option "intr".
>

uh, Thank you !
i also have some nfs shares, and when i automount them, they are hard-
mounted by default. but sometimes my server was down, and i was always
waiting until something happend and the "mount failed". i did not read the
entire manpage, but a friend told me to do a "soft mount" . so i alwaya did
a soft mount, not knowing that this can be dangerous.

Thanks again.
Christian.



------------------------------

From: Kaelin Colclasure <[EMAIL PROTECTED]>
Subject: Re: ENOMEM from poll
Date: 19 Feb 2001 09:25:05 -0800

[EMAIL PROTECTED] writes:

> On 18 Feb 2001 21:27:31 -0800 Kaelin Colclasure <[EMAIL PROTECTED]> wrote:
> 
> | I'm working with a server that's consistantly dying on an ENOMEM from
> | poll.  The service runs on dual-CPU i86 linux boxes with with 1GB of
> | RAM and a fairly stock Redhat 6.2 distro.  In order to deal with the
> | sheer number of clients using this service, each server ups its
> | process fd limit to 16000. (!)
> |
> | The server does use a lot of memory, and allocates and frees
> | constantly as it services requests and as clients come and go. But
> | it's *always* the call to poll that generates an ENOMEM. Thus I have a
> | suspicion that this may be no ordinary memory leak, but a case of
> | exhausting the memory pool available to the kernel.
> |
> | I understand that the 4GB i86 address space is partitioned into 1GB
> | for the kernel's use and 3GB for the userland process. I know what
> | this means to the userland process -- but how exactly does the kernel
> | use its 1GB? Does this mean that the kernel is limited to 1GB of
> | kalloc'd (or whatever) memory for all processes in the system? Or for
> | each process?  And is there a simple way to find out if I am indeed
> | bumping into some such limit?
> |
> | Another possibility is that the working set is simply so large that
> | the machine is running out of physical RAM pages for the kernel to
> | allocate. Again, how would I test this theory?
> 
> Can you get the process to output the number of active fd's when
> it gets ENOMEM and keep a "high water mark" on the number of fd's
> and output that value when it increases.  I'm curious if it is at
> the maximum number of fd's it has ever seen when it's getting
> ENOMEM.

Anecdotally it does not seem to be tied to the all-time high water mark,
but does seem to correlate to an increasing client load. But capturing
these numbers in the log makes sense.

> Could you add code in there after the call to poll() and check
> specifically for ENOMEM, and if that occurs, call poll() again
> with 0 fd's specified and a 1 second timeout.  Then if there is
> no error from that, try the main poll() again ... with a counter
> to limit how many times this sequence happens.  I'm just wondering
> if the situation can clear given some time.  That wouldn't be an
> intended solution, but it might give some indication what could
> be happening.  You'll probably still want to have it output a
> message on each of those wait and retry cycles.

Ah, this suggests the expedient of splitting the work into two calls to
poll when one call gets ENOMEM. The first call with the normal timeout,
and the second with a zero timeout just to service the remaining fds.
Not pretty -- but it might buy us some time to experiment with tuning
the kernel memory, etc. I'll try it!

> 1GB seems to me like plenty for 16000 fd's.  But how many processes
> have 16000 fd's open?  If you're running hundreds or thousands of
> those, I can see a problem.

Only one of these processes per machine.

> What's the chance of try it with RAM divided to give 2GB to kernel?

I suspect that'll run us out of RAM in userspace well before we get to
the current problematic client load levels... But it may be worth
experimenting with anyway.

Thanks for the excellent suggestions. Please stay tuned for results. ;-)

-- Kaelin

------------------------------

From: Kaelin Colclasure <[EMAIL PROTECTED]>
Subject: Re: ENOMEM from poll
Date: 19 Feb 2001 09:32:52 -0800

Kasper Dupont <[EMAIL PROTECTED]> writes:

[...]
> The 1GB kernel space have the same layout in all processes.
> This range is divided into to parts, the first part is used
> for a 1:1 mapping of physical memory. The rest is used for
> a virtual address space. (for kmalloc as far as I remember.)
> 
> With 1 GB of physical memory there will not be much space
> left for the virtual memory. I suggest you either try using
> less than 1GB of memory by passing mem=512m or mem=768m to
> the kernel. Or try using a kernel compiled with a 2:2 split
> instead of 1:3.

Can a literal 1:1 mapping be right? Then what happens when there's more
than 1GB of physical RAM in a machine?

Does a bigmem kernel do any of this stuff differently, in a potentially
helpful way?

> This hint is not a solution, but hopefully a way to find the
> reason for your problem.

Well, the boot parameter is certainly easy enough to try. And swap
should pick up the slack in that case. With a 2:2 split I suspect
the userland part of the VM will exhaust too soon...

More knobs to twist. :-) I'll post the results when I've had a chance
to try some of them.

-- Kaelin

------------------------------

From: "Franck" <[EMAIL PROTECTED]>
Subject: can't find X includes
Date: Mon, 19 Feb 2001 19:00:22 +0100

This is the message I have when I create a new project with Kdevelop :

- configure error : can't find X includes : please check your installation
and add the correct paths !

How to know if these files are on my hard disk or in the CD of Linux ?
If not, Where could I find these files ?

Merci
Franck




------------------------------


** FOR YOUR REFERENCE **

The service address, to which questions about the list itself and requests
to be added to or deleted from it should be directed, is:

    Internet: [EMAIL PROTECTED]

You can send mail to the entire list by posting to the
comp.os.linux.development.system newsgroup.

Linux may be obtained via one of these FTP sites:
    ftp.funet.fi                                pub/Linux
    tsx-11.mit.edu                              pub/linux
    sunsite.unc.edu                             pub/Linux

End of Linux-Development-System Digest
******************************

Reply via email to