LJ Archive CD

Best of Technical Support

Various

Issue #90, October 2001

Our experts answer your technical questions.

Really Big malloc()

I would like to understand what the issues are that limit the memory available to a single process under Linux.

I have an Athlon 1.2GHz processor with 1.5GB of RAM and 2GB of swap space. The OS is Red Hat 7.1 with kernel 2.4.3-12. The system sees all 1.5GB on bootup and reports as much through top and other utilities. But alas, single processes can grab no more than roughly 940MB. I'm testing the process memory limit by running a simple C program that allocates a single large char array.

—Ned Piburn, npiburn@oti.gd-ots.com

The Linux kernel has a setting on how the memory is split between the kernel and user space. It may be that your specific kernel is built to give 3GB to the kernel and 1G to user space. When you go in the kernel configuration (cd /usr/src/linux; make menuconfig), check “Processor type and features / Maximum Virtual Memory” and set it to 3GB (some patched kernels have bugs if you use 2GB).

—Marc Merlin, marc_bts@valinux.com

GNU libc uses brk() for small allocations and mmap() for larger allocations, and only about 900MB can be allocated using brk(). Many small allocations might fail where fewer large allocations would succeed. If this is the problem your code is running into, one solution would be to write a custom malloc()--either one that always allocates memory using mmap() or one that first mmap()s large chunks and then parcels out fragments within the chunks.

—Scott Maxwell, maxwell@ScottMaxwell.org

The mallopt function is covered in the GNU Info documentation for libc under “Malloc Tunable Parameters”. Set M_MMAP_THRESHOLD to force malloc() to use mmap() instead of brk().

—Don Marti, info@linuxjournal.com

Where's My Fourth CPU?

I've installed SuSE 7.1 on a three-processor machine and then added a fourth processor. The OS doesn't see the new CPU. It's a Compaq dl580, x86 architecture. Do you have to recompile or do something extra to get the OS to acknowledge the new CPU?

—Chet Jaynes, cjorlb@pacbell.net

Linux should be able to detect and use the fourth processor as long as the motherboard does. Use the BIOS setup in order to make sure the system itself is enabling it.

—Mario Neto, mneto@argo.com.br

RPM Can't Upgrade RPM

I'm currently using Red Hat Linux 6.2 with RPM-3.0.3. To upgrade from RPM-3.0.3 to RPM-4.0.2 I tried to install db3-3.1.17 as prescribed but got the error message:

rpm can only install packages with
major version number <= 3

—Atul, atul_info@yahoo.com

Install the latest release of version 3 RPM, as that deals with both RPM3 and RPM4. You can get it from ftp.rpm.prg/pub.

—Keith Trollope, keith@wishing-well.demon.co.uk

Adaptec SCSI Card under Red Hat 6.2

My Red Hat 6.2 automatically detects the Adaptec 29160 card, and a dynamic module AIC-7xxx is added to /etc/conf.modules. But when I connect an SCSI hard drive to the card, there is no /dev/sda available for fdisk. The device file exists but cannot be accessed by fdisk. If I boot Red Hat 7.1, the SCSI disk is recognized and works. But I need to boot Red Hat 6.2 with this SCSI card. How can I make it work under Rh6.2?

—Joshua, cschen@asiaa.sinica.edu.tw

One solution would be to install your Red Hat 7.1 kernel on a Red Hat 6.2 distribution. You will also need to upgrade a few other packages like modutils.

—Marc Merlin, marc_bts@valinux.com

I had the same problem when I got my Adaptec 29160 (great card, by the way). I installed Linux on an IDE drive temporarily, got a recent 2.2 series kernel from a kernel.org mirror and built the AIC-7xxx driver into the kernel, not as a module. Then I rebooted with the new kernel and copied everything over to the SCSI drive.

—Don Marti, info@linuxjournal.com

Bad User! No “cd ..”!

What can I do to make a user's directory be like a root directory, where the user just has an access to that directory or subdirectory?

—Rafael, rafaelss@ig.com.br

What you need is chroot. Many FTP dæmons chroot by default. If you want Telnet (or even better, SSH) to chroot, you can make a chroot shell. For more information go to freshmeat.net/projects/jail_c.

—Ben Ford, ben@kalifornia.com

Once you jail a user in, let's say, /home/user, you'll have to make some portion of /lib and /bin available under /home/user if you want the chrooted user to be able to run any commands at all.

—Marc Merlin, marc_bts@valinux.com

I Have No DNS and I Must wvdial.

I'm trying to connect to my ISP using an external terminal adaptor. But when wvdial connects I receive the following errors:

--> warning, can't find address for 'suse.de'
--> warning, address lookup does not work
--> Nameserver (DNS) failure, the connection may
    not work

—Mitko, mitak@post.com

Check in /etc/resolv.conf and make sure you have lines with:

nameserver aaa.bbb.ccc.ddd

where aaa.bbb.ccc.ddd is the IP addresses of a working DNS server. You can also look at the PPP log in /var/log for hints on where the problem lies.

—Felipe E. Barousse Boué, fbarousse@piensa.com

LJ Archive CD