vmiidF ;vnii-HiiTnj

OubI I ni i'l• Kinluml™ rmcmiDn i lUhJ. l.S-Wtt LJ iKh>| Inlvl- tKH ,TJ Uh.phPl 1flCB df EM DOB mumuii dubj ep.Ciumn AlIIvu hueilhk Duu: Irtmlf G4jblE PorU 0 Of 1 IDE ATM« HDD Qp« PCI K Mn1 Av«l|jtbl«

4PHP H »»ni>fl<l«l<X»t |Cp4.] CQMIMQ I P/Q3


WuaCnn QHaajpnaM S

addresses would be cached separately, even though they represent the same data. This is called the cache-line aliasing problem.

Generally, though, the added lookup speed of a VIVT cache outweighs its disadvantages, making it the predominant cache type for non-x86 CPUs.

A type of hybrid cache designed to overcome some of the shortcomings of the VIVT cache without sacrificing too much of its speed advantage is virtually indexed, physically tagged (VIPT) caching. The index is on the virtual address, but the tag is on the physical address, so the combination (tag, offset) must specify the full physical address. This requirement causes the tags to be larger than the tags for other cache types.

The VIPT cache gains its speed advantage over PIPT because the address translation and the cache lookup now can be done in parallel. The CPU doesn't know if the cache line is valid (the tags match), however, until the address translation has completed.

The disadvantages of VIVT are overcome because the tag is physical, thus the VIPT cache automatically detects aliasing when it sees that two tags are identical in the cache. Thus, a VIPT cache may be constructed in such a fashion that cacheline aliasing never occurs.

This fourth theoretical type of cache, physically indexed, virtually tagged (PIVT), is basically useless and is not discussed further.

The Aliasing Problem

Any time the kernel sets up more than one virtual mapping for the same physical page, cache-line aliasing may occur. The kernel is careful to avoid aliasing, so it usually occurs only in one particular instance: when the user mmaps a file. Here, the kernel has one virtual address for pages of the file in the page cache, and the user may have one or more different virtual addresses. This is possible because nothing prevents the user from mmaping the file at multiple locations.

When a file is mmaped, the kernel adds the mapping to one of the inode's lists: i_mmap, for maps that cannot change the underlying data, or i_mmap_shared, for maps that can change the file's data. The API for bringing the cache aliases of a page into sync is:

void flush_dcache_page(struct page *page);

This API must be called every time data on the page is altered by the kernel, and it should be called before reading data from the page if page->mapping->i_mmap_shared is not empty. In architecture-specific code, flush_dcache_page loops over the i_mmap_shared list and flushes the cache data. It then loops over the i_mmap list and invalidates it, thus bringing all the aliases into sync.

Separate Instruction and Data Caches

In their quest for efficiency, processors often have separate caches for the instructions they execute and the data on which they operate. Often, these caches are separate mechanisms, and a data write may not be seen by the instruction cache. This causes problems if you are trying to execute instructions you just wrote into memory, for example, during module loading or when using a trampoline. You must use the following API:

void flush_icache_range(unsigned long start, unsigned long end);

to ensure that the instructions are seen by the instruction cache prior to execution. start and end are the starting and ending addresses, respectively, of the block of memory you modified to contain your instructions.

General Cache Flushing

Two APIs globally flush the CPU caches:

void flush_cache_all(void); and void flush_cache_mm(struct mm_struct *mm);

These flush all the caches in the system and only the lines in the cache belonging to the particular process address space mm. Both of these are extremely expensive operations and should be used only when absolutely necessary.

Caching in SMP Environments

When more than one CPU is in the system, a level of caching usually exists that is unique to each CPU. Depending on the architecture, it may be the responsibility of the kernel to ensure that changes in the cache of one CPU become visible to the other CPUs. Fortunately, most CPUs handle this type of coherency problem in hardware. Even if they don't, as long as you follow the APIs listed in this article, you can maintain coherency across all the CPUs.


I hope I've given you a brief overview of how caches work and how the kernel manages them. The contents of this article should be sufficient for you to understand caching in most kernel programming situations you're likely to encounter. Be aware, however, that if you get deeply into the guts of kernel cache management (particularly in the architecture-specific code), you likely will come across concepts and APIs not discussed here.H

James Bottomley is the software architect for SteelEye. He maintains the SCSI subsystem, the Linux Voyager port and the 53c700 driver. He also has made contributions to PA-RISC Linux development in the area of DMA/device model abstraction.

If you've just converted all the GIF images on your Web site to PNG, but the HTML still refers to the original .gif filenames, just use Apache's mod_rewrite to redirect visitors to the new versions of the images:

RewriteEngine on

Best of Breed


If last month's issue left you hungry for more audio and video projects, feast your eyes and ears on our Web site. by heather mead

Our new products mailbox has been receiving a lot of press releases introducing new workstations designed specifically for high-end audio and graphic needs. If you're an animator, filmmaker or a recording engineer who uses Linux, hardware and software companies are very interested in getting your business. But, even if you're a regular desktop user, Linux developments in audio and video matter, because at least some of them eventually will make their way into a desktop distribution. So this month, we're going to point you to some LJ Web articles that discuss what is going on in the Linux multimedia world.

If you're interested in a sound card that lets you do more complicated audio tasks, such as recording and mixing music, Peter Todd discusses "Using the Hammerfall HDSP on Linux" ( The Hammerfall is a professional-grade sound card used in studios all over the world; it also happens to run under Linux, thanks to the ALSA Project drivers. It consists of an external module called the Multiface coupled to an internal PCI card. Peter explains that the big difference between the Hammerfall and regular sound cards is that the HDSP "is designed as a sound I/O device. It has inputs and outputs, and you can route sound between them arbitrarily." The article also explains how to use advanced features such as an external time code source, a must for the studio.

In the early spring of 2003, Dave Phillips, author of The Linux Book of Music & Sound, attended the first conference held specifically for Linux audio developers. The report he wrote for us, "Linux Audio Development: A Report from Karlsruhe" ( article/6762), provides an overview of the main issues discussed at the conference, as well as the directions Linux audio development is taking. Among the topics discussed was JACK, the software toolkit that "provides a professionalgrade audio server in a low-latency environment, making arbitrary audio signal routing possible, without dropouts or distortion."

Moving on to the video portion of our presentation, Roberto de Leo's article "Self-Hosting Movies with MoviX" ( explains how de Leo came to start the MoviX Project for a self-hosting movie— "a Linux CD mini-distribution that is able to boot and play automatically all audio/video files on the CD." The main point of the article, however, is to walk users through the process of building their own mini-distributions, whether for playing a movie or some other application.

Finally, Geoff Draper wrote an article for us, "The Art of Rewriting Old Games" (, in which he recounts how nostalgia for an old favorite, Nellan Is Thirsty, led him to rewrite the old 8-bit text game. The new version, Thirsty Nellan, "replaces the command-line parser interface of the original game with a point-and-click GUI environment." He also used AliaslWavefront for the scenery, which we must admit, is some of the cutest penguin artwork we've ever seen. Because many of these old 8-bit games are in the public domain, they too can be re-created for another generation of gamers. Read the article to learn exactly what Draper did, and then go rescue your own old favorite.

If you do rewrite an old game, set up a music studio or edit films on your Linux machines, drop us a line and let us know how you're doing it. And, be sure to check the Linux Journal Web site often. New articles are posted daily. 0

Heather Mead is senior editor of Linux Journal.

© 2003 Central Command, Inc. All rights reserved. Vexira, Vexira logo, and Central Command are trademarks or registered trademarks of Central Command, Inc. All other trademarks are property of there respective owners).

Central Command, Inc. phone: 330.723.2062 • fax: 330.722.6517

© 2003 Central Command, Inc. All rights reserved. Vexira, Vexira logo, and Central Command are trademarks or registered trademarks of Central Command, Inc. All other trademarks are property of there respective owners).

Fixing Swap When Moving a Drive

I am using Red Hat 9 on an HP Brio (PIII, 20GB and 192MB of RAM). I first installed Linux when my hard drive was a primary slave. Later I changed it to primary master. I am using a boot disk to boot in to Linux, but when I try to boot in to the system, I get an error that the swap partition was not initialized. The kernel could detect changes to my root and boot, but it was unable to in the case of swap partition. How can I change the swap partition dynamically? In other words, what parameter should I pass to the kernel before booting so as to specify my swap at the command line? Also, can I use the same boot disk to boot on other systems with different partition allocations, as with Windows startup disks?

Aman Hardikar, [email protected]

This is easy to explain; Linux is looking for the swap partition on one device (the primary slave), probably named /deb/hdbX, X being the partition number, and it happens that it now resides on the primary master disk, which probably is /dev/hdaX. Therefore, Linux can't find the designated swap partition and is unable to initialize it. To fix this, edit your /etc/fstab file and change the device on the line that has the swap entry. It may be something like:

/dev/hdb2 swap swap defaults 0 0

So, change it to:

/dev/hda2 swap swap defaults 0 0

In this example, the swap partition is number 2 on the disks. Then, reboot your system, and it should work fine. An alternate way to reboot would be to start the swap partition manually with the command swapon -a -e, after editing the /etc/fstab file as indicated above.

Felipe Barousse Boue, [email protected] Serial ATA Support?

I intend to install SuSE 8.2 and want to know if I can install it on a Serial ATA hard drive.

Daniel Gustafsson, [email protected]

Serial ATA hard drives are supported by Linux (including the SuSE 8.2 distribution's stock kernel version 2.4.19). This will be obvious, but as always, first you must check that the BIOS and/or disk controller hardware of your system does support Serial ATA hard drives.

Felipe Barousse Boue, [email protected]

As usual, the first question is, does your BIOS support booting from your serial ATA interfaces? If your BIOS doesn't support booting from this controller, you might be able to install Linux to boot from some other device.

Jim Dennis, [email protected]

You can look up your hardware on SuSE's component database at Other Linux distributions also maintain their own hardware compatibility lists. Although something technically might be supported in the kernel version that your distribution ships, it's best to check your distribution's hardware compatibility list before you go hardware shopping. Items on the list are more likely to be detected by the installer automatically, and your distribution is more likely to include up-to-date utilities with support for items on the list.

Don Marti, [email protected]

Many on-line help resources are available on the Linux Journal Web pages. Sunsite mirror sites, FAQs and HOWTOs can all be found at

Answers published in Best of Technical Support are provided by a team of Linux experts. If you would like to submit a question for consideration for use in this column, please fill out the Web form at lj-issues/techsup.html or send e-mail with the subject line "BTS" to [email protected]

Please be sure to include your distribution, kernel version, any details that seem relevant and a full description of the problem.

Simple Document Management System:

Tu-M ■ _ i.r. "I QM-^kHI' BJ» ". | Q ■ I P

Tu-M ■ _ i.r. "I QM-^kHI' BJ» ". | Q ■ I P

iiumgl ri n cum ht ■


■ -■ ■■ ir I ;■ 1 h

b iL h'îi

. uahw

LMhH-H 'ItJÉrt j ■ ■ ■ ■ ■ ïlf OTM 1 ih

i m

i "áértrH -1 : SM HM1 ' »T' ! ■! H

» G» ■■«aci- m " ï 1> h

- —"

^-iV uni

i ■tü.IPB.

1 v ■'IJ.-j-' JKu 'lUTjïrt- Ï-IF £


Nl'l li'si



+'!' IfHI

1 H^-tW«

" ■ - ■ JVÎ: > ' - üKaiMi h


■■■■I ■

mnr'ji',- ijvnïmiII i


A lot of companies and even some individuals need a system to archive documents. This document management system uses MySQL for storage and provides varying levels of access to those who need it. Access can be denied, read-only, modify or god-mode (which allows almost anything) on a document-by-document basis. Requires: MySQL, PHP, Web server and Web browser. 1.1 has released version 1.1 of its office suite for Linux, Windows and Solaris in a variety of languages, including English, German, Swedish, Spanish and Japanese. New features for version 1.1 include native, one-click PDF export, Flash export, a faster load time, improved MS Office file compatibility and accessibility support. In addition, support for AportisDoc, Pocket Word and Pocket Excel has been added for easier transfer of documents to PDAs and handheld devices. 1.1 also offers an open, future-proof XML file format, which allows users to avoid file format lock-in situations. The suite and its source code can be downloaded from download.html.

CONTACT, Panasas ActiveScale Storage Cluster

Employing an object-based architecture that manages data as large virtual objects, the ActiveScale Storage Cluster is comprised of the ActiveScale File System, StorageBlades and DirectorBlades, a 4U system shelf and an integrated gigabit Ethernet switch. The ActiveScale File System turns files into smart data objects and then dynamically distributes data activity across the StorageBlades. This design enables parallel data paths between servers and StorageBlades, eliminating performance and capacity bottlenecks. Application and user data is stored in the StorageBlades, and filesystem activity is coordinated by the DirectorBlades. DirectorBlades also virtual-ize data objects across the range of StorageBlades so the system can be viewed as a single namespace.

CONTACT Panasas, 6520 Kaiser Drive, Fremont, California 94555, 510-608-7790,

Aqua Data Studio 3.5

Aqua Data Studio 3.5 is a database query and administration tool that allows developers to create, edit and execute SQL scripts, as well as

browse and modify database structures. Aqua Data Studio provides an integrated database environment with a single consistent interface to all major relational databases. This allows the database administrator or developer to tackle multiple tasks simultaneously from one application. Aqua Data Studio includes support for such database platforms as Oracle 8i/9i, IBM DB2, Informix Dynamic Server, Sybase Adaptive Server, Microsoft SQL Server, MySQL and PostgreSQL. New features for version 3.5 include complete schema extractions, SQL scripting of database objects and expanded Query Analyzer options.

CON TACT AquaFold, Inc., Stratus/PMC

Stratus/PMC is a dual-head graphics controller PMC card designed for use in VME and CompactPCI embedded systems. It features a 128-bit graphics module for video capture with analog/digital I/O. Stratus/PMC's two display channels simultaneously deliver dual VGA or LVDS outputs or a single DVI output. Using the Silicon Motion SM731 graphics accelerator, Stratus/PMC supports single displays at screen resolutions up to 1600x1200x24bpp (with 16.7 million colors) and dual displays at 1024x768x24bpp. It also has an onboard 33/66MHz, 32-bit PCI interface; 16MB of SDRAM on-chip; composite and S-Video PAL/NTSC/SECAM support; and field-programmable VGA BIOS EEPROM. Stratus/PMC offers support for VxWorks, XFree86 and Microsoft Windows.

CONTACT Peritek, 5550 Redwood Road, Oakland, California 94619, 800-281-4567,

Xybernaut ServicePoint

Xybernaut has announced the release of ServicePoint, a mobile mini-server that is configured and shipped as a mobile application services platform. ServicePoint can function as a mobile or even wearable mini-server to direct information and application services to various devices and users over a wireless or wired network. Shipping with Red Hat Linux Professional Server, ServicePoint devices include a 500MHz

Mobile Celeron Ultra Low Voltage Memory and Storage processor, 256MB of SDRAM, 5 or 10GB internal expandable hard drives, optional external drive ports, CompactFlash and USB ports, 8MB of SDRAM and a built-in sound card for full-duplex, stereo I/O.

CONTACT Xybernaut Corporation, 12701 Fair Lakes Circle, Suite 550, Fairfax, Virginia 22033, 703-631-6925,

GEME Series Embedded Computers

Adlink's new embedded computer series, the General Embedded Machine Engine (GEME), is designed for measurement, automation and communication needs. GEME combines an embedded SBC and power supply unit with optional storage peripherals, such as CompactFlash or a 2.5" hard drive. Featuring multiple mounting schemes, the modular chassis design allows one PMC and multiple PC/104 modules to be added. GEMEs come in three base configurations, all featuring low voltage, fanless processors and various extension modules, including video capture, gigabit Ethernet interface, remote I/O, serial communications and 64-channel DI/DO.

CONTACT Adlink Technology America, Inc., 15279 Alton Pkwy., Suite 400, Irvine, California 92618, 949-727-2077,

NemeSys DAW64

RackSaver and AMD have collaborated on the new NemeSys 64-Bit Digital Audio Workstation (DAW64), which features AMD's 64-bit Opteron processor. Designed for digital audio processing, editing and mastering needs in a studio environment, DAW64 is a 4U rackmountable system with dual Opteron processors, 4GB of RAM, four 36GB Raptor SATA hard drives, a 3ware RAID controller and an NVIDIA Quadro 4 380XGL graphics card. The 64-bit address spaces provide users with direct access to virtual instruments and music libraries in physical memory, eliminating the need for distributed content on multiple workstations.

CONTACT RackSaver, Inc., 9449 Carroll Park Drive, San Diego, California 92121, 858-8743800,

Please send information about releases of Linux-related products to Heather Mead at [email protected] or New Products c/o Linux Journal, PO Box 55549, Seattle, WA 98155-0549, or fax to 206-782-7191. Submissions are edited for length and content.

Was this article helpful?

0 0

Post a comment