Linux-Development-Sys Digest #499, Volume #8     Mon, 19 Feb 01 03:13:09 EST

Contents:
  Two variables in two dlls with the same name. (Thaddeus L Olczyk)
  Re: ioremap and virt_to_phys (Jonathan Lundell)
  Re: 2.4.1 won't mount /dev/hdb1 as root (Neal Tucker)
  Re: Module Programming Question (Unresolved symbol printk) (Weirong Zhu)
  Re: mmap limits (Tim Roberts)
  Re: mmap limits (Ulrich Weigand)
  Re: Big Brother is watching you............................please read               
                                    .  9696 (Allodoxaphobia)
  Re: SCSI Programming - READ_CAPACITY ("Uncle Nick")
  atomic pointer reads/writes (Dave Peterson)
  ENOMEM from poll (Kaelin Colclasure)
  Re: Module Programming Question (Unresolved symbol printk) ("Paul Pluzhnikov")
  Re: Two variables in two dlls with the same name. ("Arthur H. Gold")
  Re: Beginner : Device driver (John Brockmeyer)
  Re: Module Programming - problem when including certain header files (John 
Brockmeyer)
  Re: ioremap and virt_to_phys (Pete Zaitcev)
  Re: ENOMEM from poll ([EMAIL PROTECTED])
  Problem in Module <insmod, rmmod>

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

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

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?

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

From: Jonathan Lundell <[EMAIL PROTECTED]>
Subject: Re: ioremap and virt_to_phys
Date: Sun, 18 Feb 2001 17:26:04 -0800

In article <96pigj$20q$[EMAIL PROTECTED]>, [EMAIL PROTECTED] 
wrote:

>     Can someone please sort out the following for me. Why doesn't
> (virt_to_phys(ioremap(physical_address,range)) == physical_address)
> evaluate to true?  If ioremap(physical_address,range) yields a virtual
> address, then what is virt_to_phys(ioremap(physical_address,range))?
> Is it a physical address?  To understand why I'm asking, here is
> what I'm trying to accomplish.

I assume we're talking x386 here. virt_to_phys() only works for the 
kernel's statically mapped memory. The kernel maps memory starting at 
physical 0 to virtual 0xc0000000. All virt_to_phys() does is subtract 
0xc0000000 from the virtual address. That doesn't work for dynamically 
mapped addresses such as those returned by ioremap(). It *should*, or at 
least there should be a general virtual-to-physical converter, but if 
there is I haven't been able to find it.

I haven't tested this, but something like the following should be able 
to do the trick for addresses returned by ioremap(). It should probably 
be smart enough to know when to call virt_to_phys() too, but....

(pte_val(*pte_offset(pmd_offset(pgd_offset_k(va), (va)), (va))) & 
PAGE_MASK) + (va & ~PAGE_MASK)

-- 
/Jonathan Lundell.
[EMAIL PROTECTED]

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

From: [EMAIL PROTECTED] (Neal Tucker)
Subject: Re: 2.4.1 won't mount /dev/hdb1 as root
Date: 18 Feb 2001 17:58:57 -0800

Kasper Dupont  <[EMAIL PROTECTED]> wrote:
>[EMAIL PROTECTED] wrote:
>> Something must be
>> missing in the 2.4.1 kernel you have, like maybe the IDE driver
>> or the ext2 filesystem.
>> 
>
>At this point a more informative errormessage would be nice.
>Like: "can't mount device "341" as root because no block device
>is registered with major number 3".

That's a great idea.  How likely is it to get patches for stuff
like this accepted?

-Neal Tucker

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

From: Weirong Zhu <[EMAIL PROTECTED]>
Subject: Re: Module Programming Question (Unresolved symbol printk)
Date: Sun, 18 Feb 2001 20:06:58 -0600

I got the exactly same problem on my desktop. But it is not MP. So I guess it
has nothing to do with processor. I checked /proc/ksysm, there is no printk
symbol there. I tried to recompile my kernel with module support but this
problem stays. Did you get it work on your desktop now?

Weirong
[EMAIL PROTECTED]

Mudit wrote:

> Greeting,
>
> I'm trying to get up to speed on module programming. I typed the Hello World
> example from http://howto.tucows.com/LDP/LDP/lkmpg/node11.html (included
> below). It compiles ok (makefile also below). When I do an "insmod hello.o"
> from outside of X, I get:
>
> hello.o: unresolved symbol printk
>
> I'm guessing I'm missing something obvious. Any clues? I'm using RedHat 6.2.
> I believe my kernel has module support (I do an lsmod and there are modules
> loaded).
>
> Thanks,
> Mudit
>
> -------------------------------------------------
> /* hello.c
>  * Copyright (C) 1998 by Ori Pomerantz
>  *
>  * "Hello, world" - the kernel module version.
>  */
>
> /* The necessary header files */
>
> /* Standard in kernel modules */
> #include <linux/kernel.h>   /* We're doing kernel work */
> #include <linux/module.h>   /* Specifically, a module */
>
> /* Deal with CONFIG_MODVERSIONS */
> #if CONFIG_MODVERSIONS==1
> #define MODVERSIONS
> #include <linux/modversions.h>
> #endif
>
> /* Initialize the module */
> int init_module()
> {
>   printk("Hello, world - this is the kernel speaking\n");
>
>   /* If we return a non zero value, it means that
>    * init_module failed and the kernel module
>    * can't be loaded */
>   return 0;
> }
>
> /* Cleanup - undid whatever init_module did */
> void cleanup_module()
> {
>   printk("Short is the life of a kernel module\n");
> }
>
> -------------------------------------------------
> # Makefile for a basic kernel module
>
> CC=gcc
> MODCFLAGS := -Wall -DMODULE -D__KERNEL__ -DLINUX
>
> hello.o:        hello.c /usr/include/linux/version.h
>                 $(CC) $(MODCFLAGS) -c hello.c


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

From: Tim Roberts <[EMAIL PROTECTED]>
Subject: Re: mmap limits
Date: Sun, 18 Feb 2001 18:05:22 -0800

Christian Casteyde <[EMAIL PROTECTED]> wrote:
>
>ix86 have 32 bits address space => 4Go.
>You'll have to do paging of address spaces.

I can't tell from this whether you are aware of the PAE feature or not;
I'll assume you are not, and apologize if you are.

Beginning with the Pentium II Xeon, all Pentium processors have had the
ability to access 36 bits of physical address space.  Thus, you could
conceivably work with up to 64GB of physical memory.
--
- Tim Roberts, [EMAIL PROTECTED]
  Providenza & Boekelheide, Inc.

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

From: [EMAIL PROTECTED] (Ulrich Weigand)
Subject: Re: mmap limits
Date: 19 Feb 2001 03:27:12 +0100

Tim Roberts <[EMAIL PROTECTED]> writes:

>Christian Casteyde <[EMAIL PROTECTED]> wrote:
>>
>>ix86 have 32 bits address space => 4Go.
>>You'll have to do paging of address spaces.

>I can't tell from this whether you are aware of the PAE feature or not;
>I'll assume you are not, and apologize if you are.

>Beginning with the Pentium II Xeon, all Pentium processors have had the
>ability to access 36 bits of physical address space.  Thus, you could
>conceivably work with up to 64GB of physical memory.

While this is true (and Linux does in fact exploit PAE), it doesn't
change the fact that the *virtual address space* of a process is 
limited to 4GB by the IA32 architecture -- PAE nonwithstanding.
(It is in practice limited to even less than 4GB, typically 3GB, 
but conceivably 3.5 or 3.75 GB, by the Linux kernel design.)

As linear addresses remain 32bit, there is no way to access
more that 4GB of memory without changing the linear to 
physical address mapping (i.e. page tables).  The only way
a user process can do this is by sequentially mmap()ing 
different files (or shared memory segments or the like)
and unmapping them again.

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]

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

From: [EMAIL PROTECTED] (Allodoxaphobia)
Crossposted-To: comp.os.linux.hardware,comp.os.linux.development
Subject: Re: Big Brother is watching you............................please read        
                                           .  9696
Date: 19 Feb 2001 03:32:17 GMT

On Sun, 18 Feb 2001 10:56:48 +0500, Fluri Dave scribbled:
>And why do you presume that your WIndows software should be spammed to _this_ group?

And, why do you presume that spammers read followups?

Jonesy

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

From: "Uncle Nick" <[EMAIL PROTECTED]>
Subject: Re: SCSI Programming - READ_CAPACITY
Date: Mon, 19 Feb 2001 03:53:15 GMT

Marty,

The sg_utils found on this page http://www.torque.net/sg include an example
program sg_readcap.  I have tried some of the other examples and they worked
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 device
> /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 anything
> wrong? Are there any places where there are examples about that ?
>
> Marty.
>



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

From: Dave Peterson <[EMAIL PROTECTED]>
Subject: atomic pointer reads/writes
Date: Sun, 18 Feb 2001 21:19:21 -0800

Suppose I want to read or write a value to a pointer variable.
Can I safely assume that this operation is atomic on all machine
architectures?  If not, what is the most portable way of doing
atomic reads and writes to pointer variables?  I would hate to have
to grab and release a lock for something that simple.  I am aware
of the operations defined in <asm/atomic.h>, but these are defined
for values of type atomic_t rather than pointers.



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

From: Kaelin Colclasure <[EMAIL PROTECTED]>
Subject: ENOMEM from poll
Date: 18 Feb 2001 21:27:31 -0800

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

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

From: "Paul Pluzhnikov" <[EMAIL PROTECTED]>
Subject: Re: Module Programming Question (Unresolved symbol printk)
Date: Mon, 19 Feb 2001 05:54:50 GMT

"Weirong Zhu" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]...
> I got the exactly same problem on my desktop. But it is not MP. So I guess
it
> has nothing to do with processor. I checked /proc/ksysm, there is no
printk
> symbol there. I tried to recompile my kernel with module support but this
> problem stays. Did you get it work on your desktop now?
>
> Weirong
> [EMAIL PROTECTED]
>
> Mudit wrote:
>
> > Greeting,
> >
> > I'm trying to get up to speed on module programming. I typed the Hello
World
> > example from http://howto.tucows.com/LDP/LDP/lkmpg/node11.html (included
> > below). It compiles ok (makefile also below). When I do an "insmod
hello.o"
> > from outside of X, I get:
> >
> > hello.o: unresolved symbol printk
> >

On my system:

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

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




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

Date: Mon, 19 Feb 2001 00:24:11 -0600
From: "Arthur H. Gold" <[EMAIL PROTECTED]>
Subject: Re: Two variables in two dlls with the same name.

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!).

HTH,
--ag 
-- 
Artie Gold, Austin, TX  (finger the cs.utexas.edu account
for more info)
mailto:[EMAIL PROTECTED] or mailto:[EMAIL PROTECTED]
--
Verbing weirds language.

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

From: John Brockmeyer <[EMAIL PROTECTED]>
Subject: Re: Beginner : Device driver
Date: Sun, 18 Feb 2001 23:09:13 -0700

So many things wrong
1.  limit count to len, not vice versa   if(count>len) count=len;
2 copy_from_user(k_buff, user_buff , /*>>>*/count/*<<<*/);
3 return /*>>>*/ count /*<<<*/;
4 since you didn't show either the open or release, how can one answer your
question
  also need to show the file_operations structure, and the registration of the
device on
initialization.

Aminudin Khalid wrote:

>  Hi,
>
> I've written a simple module program  with  write , read ,open ,release  and
> ioctl  functionality .
> The  code look like the followings .
>
> ----------------------------------------
> ssize_t
> driver1_write(struct file *file, const char *user_buff,
>        size_t count, loff_t *pos)
> {
>   int len;
>
>   char k_buff[50];
>
>   write_count++;
>   len=49;
>   printk("count = %d \n",count);
>   if(len>count)
>     len=count;
>   copy_from_user(k_buff,user_buff,50);
>   k_buff[len]='\0';
>   printk("DEVICE1_WRITE:\n");
>   printk("   offered: %d bytes   obtained: %d bytes\n",count,len);
>   printk("   message: '%s'\n",k_buff);
>   printk("write_count = %d \n",write_count);
>   return len;
>
> }
>
> -----------------------------------
>
> After loading the module and testing with  "cat xxxxx.dat > /dev/device1"  the
> module didnt execute the "xxxxx_release "  function.
> What's wrong ?




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

From: John Brockmeyer <[EMAIL PROTECTED]>
Subject: Re: Module Programming - problem when including certain header files
Date: Sun, 18 Feb 2001 23:21:22 -0700

Among other possible sins, RH7.0 distribution has /usr/include/linux holding .h
file for 2.4.0, not
2.2.18. Not sure what else is at fault, but this is a dandy
John Brockmeyer

Sujita Purushothaman wrote:

> I'm running Redhat Linux 7.0 with kernel version 2.2.18.
> I have a problem including 2 header files. When I include these two
> header files,
> 'timex.h' and 'timer.h ' either directly or indirectly(some other
> header files include
> then) I get these error messages :
> 1. " Field 'time' has incomplete type "
> 2. "Field 'list' has  incomplete type"
>
> Why does this error occur and how to solve the problem?
> I'm new to kernel programming and need all help I can get..
> Thanks for a ll help in advance!
>
> Sujita




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

From: [EMAIL PROTECTED] (Pete Zaitcev)
Subject: Re: ioremap and virt_to_phys
Date: Mon, 19 Feb 2001 07:27:42 GMT

> From: [EMAIL PROTECTED] <[EMAIL PROTECTED]>

>     Can someone please sort out the following for me. Why doesn't
> (virt_to_phys(ioremap(physical_address,range)) == physical_address)
> evaluate to true?  If ioremap(physical_address,range) yields a virtual
> address, then what is virt_to_phys(ioremap(physical_address,range))?
> Is it a physical address?

virt_to_phys is defined for actual memory addresses only.
The cookie that ioremap returns cannot be passed to virt_to_phys.
On most architectures virt_to_phys is just ((v)-PAGE_OFFSET).

>     I'm writing a driver for a PCI card that requires a large contiguous
> physical address space in which to perform DMA. [...]

You are reinventing a wheel that was invented several times over.
I prefer Pauline's wheel:
  http://www.polyware.nl/~middelink/En/hob-v4l.html

-- Pete

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

From: [EMAIL PROTECTED]
Subject: Re: ENOMEM from poll
Date: Mon, 19 Feb 2001 07:27:59 -0000

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.

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.

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.

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

-- 
=================================================================
| Phil Howard - KA9WGN |   Dallas   | http://linuxhomepage.com/ |
| [EMAIL PROTECTED] | Texas, USA | http://phil.ipal.org/     |
=================================================================

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

From: <[EMAIL PROTECTED]>
Subject: Problem in Module <insmod, rmmod>
Date: Mon, 19 Feb 2001 07:30:08 -0000

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/

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


** 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