Linux-Development-Sys Digest #359, Volume #8 Mon, 18 Dec 00 16:13:22 EST
Contents:
Re: How to ensure a page not being swapped out (Richard Kolb)
spinlocks and blocking (Matthew Impett)
Re: How to ensure a page not being swapped out (Arne Driescher)
Re: How to ensure a page not being swapped out (Richard Kolb)
Re: spinlocks and blocking (Richard Kolb)
IPC on the same machine ("Alan")
Re: SMP support and current->mm behaviour on 2.2 ([EMAIL PROTECTED])
Re: Test suites for Linux (Moritz Franosch)
2.4.0 and PCMCIA - not working again (bill davidsen)
Re: routing table internals (Andi Kleen)
DHCP ("Ken Wilson")
Re: Signal handling (Andi Kleen)
Re: DHCP (=?iso-8859-1?Q?Rasmus_B=F8g_Hansen?=)
Re: DHCP (Lew Pitcher)
Re: Problem with LVM and LILO (David Vidal Rodriguez)
Open file in module? (Naushit Sakarvadia)
Re: How to ensure a page not being swapped out (Thomas Petazzoni)
Re: Problem with LVM and LILO (=?iso-8859-1?Q?Rasmus_B=F8g_Hansen?=)
Re: Linix terminal emulation software ("Matthew Smith")
----------------------------------------------------------------------------
From: Richard Kolb <[EMAIL PROTECTED]>
Subject: Re: How to ensure a page not being swapped out
Date: Mon, 18 Dec 2000 17:25:36 +0200
Hi Eric,
Eric wrote:
> A well, they're gone now :-)
Cool, at least someone is having luck today.
>
> This code is to be in a device driver that performs a DMA access to PC
> RAM.
> Turned out that the hardware had a small bug, that gave a write to a
> wrong location.
> Ergo kernel oops. I /var/log/messages I found an oops that mentioned an
> address simular
> to where I was writing to. The message mentioned "unable to handle
> kernel paging request at ..."
> So I immediatly thought that swapping might have been the problem. But
> it wasn't.
You are probably using redhat , which seems to use ksymoops for you.
> Now I have GFP_KERNEL again, and it works :-)
> You say it should be GFP_ATOMIC for cli calls?
> I'm not sure if I understand that.
In between a cli() and sti() (where all interrupts are disabled )
you can't use memory that is swappable, since if the memory is swapped to
disk, a interrupt is required to get the memory back.
and therefore needs to be atomic.
I saw this in a book called linux device drivers,
I could not find a reference to what atomic does in the linux code ( sorry
)
> If I would do something like `cp /dev/My_Device a_file` my system would
> hang?
If you are writing a block device driver yes, (the cli , sti is done for
you )
If a char device driver, no (since no request block is used )
Anyway,
Good Luck,
Richard.
------------------------------
From: Matthew Impett <[EMAIL PROTECTED]>
Subject: spinlocks and blocking
Date: 18 Dec 2000 15:23:42 GMT
I was reading the "Unreliable Guide to Hacking the Linux Kernel" and came
across something which I do not understand. In chapter 5, "Recipes for
Deadlock", it is mentioned that you cannot call routines which may sleep if
#2 -- you own any spinlocks.
I don't quite understand this. I can understand why this could be disastrous,
where if I own some spinlock x, and sleep, waiting for some resource, which
will only be released by someone once they obtain spinlock x, we will deadlock.
However, it seems to me that if written carefully enough, it would be possible
to sleep while holding a spinlock... If I am wrong about this could someone
please explain before I do something terribly wrong..
thanks,
Matt Impett
------------------------------
From: Arne Driescher <[EMAIL PROTECTED]>
Subject: Re: How to ensure a page not being swapped out
Date: Mon, 18 Dec 2000 16:26:24 +0100
Eric wrote:
>
> Richard Kolb wrote:
> >
> > Hi Eric,
> >
> > All memory needs to be GFP_ATOMIC ,
> > if you use GFP_KERNEL memory in a cli call eg a request block,
> > you will get a system hang ,
> >
> > ATOMIC memory is can't be paged out of primary memory.
> >
> > Check out some of the comments in ll_rw_blk.c
> >
>
> Hi richard,
>
> I can't find any reference to either "GFP_" or "kmalloc" in ll_rw_blk.c
>
> (/usr/src/linux-2.2.5/drivers/block/ll_rw_blk.c that is)
>
> Eric
Hi Eric,
ATOMIC is reserved for memory request that _must_ be fullfilled
without delay. A interrupt time you can hardly wait for swapping.
Therefore, IRQ handler should either make memory allocations
at a saver time or stick to ATOMIC allocations.
According to Rubinis book, every page allocated by GFP_KERNEL
is suitable for PCI-DMA. I think this means:
If you get the page it is yours and will not be swapped out.
However, to get it you probably have to wait until some other
memory is swapped out. Therefor, preallocated DMA buffer obtained
by kmalloc(..,GFP_KERNEL) do exactly what you want them to do.
-Arne
------------------------------
From: Richard Kolb <[EMAIL PROTECTED]>
Subject: Re: How to ensure a page not being swapped out
Date: Mon, 18 Dec 2000 17:39:29 +0200
Eric wrote:
> Richard Kolb wrote:
> >
> > Hi Eric,
> >
> > All memory needs to be GFP_ATOMIC ,
> > if you use GFP_KERNEL memory in a cli call eg a request block,
> > you will get a system hang ,
> >
> > ATOMIC memory is can't be paged out of primary memory.
> >
> > Check out some of the comments in ll_rw_blk.c
> >
>
> Hi richard,
>
> I can't find any reference to either "GFP_" or "kmalloc" in ll_rw_blk.c
>
> (/usr/src/linux-2.2.5/drivers/block/ll_rw_blk.c that is)
>
> Eric
Hi Eric,
There is a comment saying, ( in my 2.4.0 test 9 kernel )
/*
* NOTE: the device-specific queue() functions
* have to be atomic!
*/
and
/*
* Now we acquire the request spinlock, we have to be mega careful
* not to schedule or do something nonatomic
*/
As far as I know this refers to block device drivers that are implemented
in drivers,
In block device drivers , where interrupts are disabled.
Just as a test for your driver,
type sync (syncs memory/buffers , may cause swap to disk )
and then try to use your driver some more.
I had this problem.
Richard.
PS I'm not an expert at device drivers, so maybe take this with a pinch of
salt.
------------------------------
From: Richard Kolb <[EMAIL PROTECTED]>
Subject: Re: spinlocks and blocking
Date: Mon, 18 Dec 2000 17:46:13 +0200
Hi Matthew,
This is probably referring to race conditions,
and producer , consumer problems.
Which may cause a deadlock , hang etc.
I'm not very good at explaining , but if you can get the book "modern operating
systems" it would help you on this.
Thanks,
Richard.
Matthew Impett wrote:
> I was reading the "Unreliable Guide to Hacking the Linux Kernel" and came
> across something which I do not understand. In chapter 5, "Recipes for
> Deadlock", it is mentioned that you cannot call routines which may sleep if
> #2 -- you own any spinlocks.
>
> I don't quite understand this. I can understand why this could be disastrous,
> where if I own some spinlock x, and sleep, waiting for some resource, which
> will only be released by someone once they obtain spinlock x, we will deadlock.
> However, it seems to me that if written carefully enough, it would be possible
> to sleep while holding a spinlock... If I am wrong about this could someone
> please explain before I do something terribly wrong..
>
> thanks,
>
> Matt Impett
------------------------------
From: "Alan" <[EMAIL PROTECTED]>
Crossposted-To: comp.os.linux.development.apps
Subject: IPC on the same machine
Date: Mon, 18 Dec 2000 16:37:18 -0000
Hello,
Does any one know of any good sites/examples of how you
would write code to get two processes to communicate on
the same machine?
What I'm aiming for is a daemon and a program you'd run
from the shell to control the daemon.
Thank you,
Alan
------------------------------
From: [EMAIL PROTECTED]
Subject: Re: SMP support and current->mm behaviour on 2.2
Date: Mon, 18 Dec 2000 22:05:01 +0500
Lee Cremeans wrote:
>
> I'm working on a driver that uses current->mm in a function that
> ferrets out a physical address for a user-mode buffer. The function
> seems to work fine on a 2.2 kernel without SMP support compiled in, but
> it crashes the driver with SMP support there. I investigated and found
> that current->mm was returning NULL. Is there something I'm missing?
> This is my first time working with Linux's SMP support.
>
> -lee
>
> Sent via Deja.com
> http://www.deja.com/
This code is worked on 2.2.16-SMP.
/* convert virtual user memory address to physical address */
static inline unsigned long uvirt_to_kva(pgd_t *pgd, unsigned long adr)
{
unsigned long ret = 0UL;
pmd_t *pmd;
pte_t *ptep, pte;
if (!pgd_none(*pgd)) {
pmd = pmd_offset(pgd, adr);
if (!pmd_none(*pmd)) {
ptep = pte_offset(pmd, adr);
pte = *ptep;
if (pte_present(pte))
ret = pte_page(pte) | (adr & (PAGE_SIZE-1));
}
}
return ret;
}
--
+----------------------+
| Andrey V. Valik |
| Papillon Systems |
|Mailto:[EMAIL PROTECTED]|
+----------------------+
------------------------------
From: Moritz Franosch <[EMAIL PROTECTED]>
Subject: Re: Test suites for Linux
Date: 18 Dec 2000 18:27:09 +0100
Ravi <[EMAIL PROTECTED]> writes:
> Is there a set of tests that I can run on Linux to validate
> the system? If I am playing around with the kernel, I would
> like to ensure I didn't break anything. Any hints on this will
> be helpful.
This is a test suite in development
http://oss.sgi.com/projects/ltp/
Moritz
------------------------------
Subject: 2.4.0 and PCMCIA - not working again
From: [EMAIL PROTECTED] (bill davidsen)
Date: Mon, 18 Dec 2000 17:27:46 GMT
After a bit of not working, PCMCIA flash cards started working at
test10pre7 (pre to test11). This without pcmcia-cs or anything, just
working. Well, almost, adding a flash card to a running system produced
a panic, but I could boot and read the flash, and do useful things.
With test12, it says it can't find the ide-cs module (which it doesn't
need in 11pre7). Are we going backwards here? Does anyone have this
working?
This is with an SMP system, if that is useful info, 2x500MHz, 256MB RAM,
7G ATA/33, 20G ATA/66 drives, NEC SCSI+CD burner.
I built the kernel with the old config after "make oldconfig" to get new
options in. There are no pcmcia modules for either kernel, so I didn't
put in the old 2.2 pcmcia stuff and mess things up.
--
bill davidsen, <[EMAIL PROTECTED]>
------------------------------
From: Andi Kleen <[EMAIL PROTECTED]>
Subject: Re: routing table internals
Date: 18 Dec 2000 18:19:46 +0100
Matthew Impett <[EMAIL PROTECTED]> writes:
> Can anyone point me to a good reference on the structure of the linux
> kernel routing tables? I have tried looking at the code but through all
> the fib_{rules,frontend,etc,etc,etc} my head started spinning and I thought
> there has to be a better way. I have also tried looking on the web but have
> not found anything of any real use...
Here is an old ASCII art picture that I saved.
It should be accurate for 2.2/2.4, except that it does not cover
routing-by-fwmark (which is just another key into the level2 table)
Hope it helps,
-Andi
============= please bite here ============= bitte hier abbeissen =========
struct fn_zone *fn_zones[33]
+---------------+---------+---------+- - - - - - - +----------+
Zones | address=<def> | 1 bit | 2 bits | | 32 bits |
+---------------+---+-----+---------+ -+ - - - - - +----+-----+
| | |
+--------------+ | | |
| fn_zone_list +-+ V V V
+--------------+ | +-------------+ +-------------+ +-------------+
+->| fz_next +-->| fz_next +--->| fz_next |
+-------------fz_hash | | ... | | ... |
| | # of entries| | ... | | ... |
| | hash_divisor| | | | |
| | hash_mask | | | | |
| | zone order | | | | |
| | | | | | |
| | <<fn_zone>> | | <<fn_zone>> | | <<fn_zone>> |
| +-------------+ +-------------+ +-------------+
| (( Zones chained in descending order of address prefix length ))
|
|
|
Level 2 | Hashtable
V (( Hash bucket of nodes in ascending order of
+----------+ [key, tos, priority] ))
| | +--------------+ +------------+ +------------+
| +----->| next +------>| next +->| next |
+----------+ | info -----------+ | ... | | ... |
| | | key | | | | | |
| +--+ | tos | | | | | |
+----------+ | | scope | | |<<fib_node>>| |<<fib_node>>|
| | | | state | | +------------+ +------------+
| | | | | |
+----------+ | | <<fib_node>> | |
| | | +--------------+ |
| | | | +--------------+ +-----------+
+----------+ +--> ( more hash- | | next +-->| next |
| | buckets ) +--->| prev |<--+ ... |
| +-----> | refcnt | | ... |
+----------+ +----------->| metrics | | |
| | nextHop | | |
| +- - - - - - - + | |
| | nextHop2 | |<<fib_info>|
| +- - - - - - - + +-----------+
| | nextHop3 |
| +- - - - - - - +
| | |
| | <<fib_info>> |
| +--------------+
+---------------+ |
| fib_info_list +-----------+ (( Many hops if multipath
+---------------+ routing enabled ))
(( All fib_info entries chained
in one list (Used to mark
fib_info nodes when an i/f
goes up/down ))
------------------------------
From: "Ken Wilson" <[EMAIL PROTECTED]>
Subject: DHCP
Date: Mon, 18 Dec 2000 09:59:41 -0800
How does DHCP (Dynamic Host Configuration Protocol) work
in Linux? How does Linux support it?
-Ken
------------------------------
From: Andi Kleen <[EMAIL PROTECTED]>
Subject: Re: Signal handling
Date: 18 Dec 2000 18:31:50 +0100
Thomas Petazzoni <[EMAIL PROTECTED]> writes:
> Hi,
>
> Yesterday, I was wondering where is the code for handling signals like
> SIGKILL or SIGSEGV. You don't need to call explicitly signal() or
> sigaction() to handle these signals. So where is the code to handle
> these signals ?
In the kernel.
For IA32 in /usr/src/linux/arch/i386/kernel/signal.c:handle_signal()
-Andi
------------------------------
From: =?iso-8859-1?Q?Rasmus_B=F8g_Hansen?= <[EMAIL PROTECTED]>
Subject: Re: DHCP
Date: Mon, 18 Dec 2000 19:10:33 +0100
On Mon, 18 Dec 2000, Ken Wilson wrote:
> How does DHCP (Dynamic Host Configuration Protocol) work
> in Linux? How does Linux support it?
Linux supports DHCP fine - both on the server and client side.
It was possible in my first linux distro - RedHat 5.0 - in 1997.
With any newer distibution, you will probably ant to configure your
network settings with 'linuxconf'.
Rasmus B. Hansen
------------------------------
From: [EMAIL PROTECTED] (Lew Pitcher)
Subject: Re: DHCP
Reply-To: [EMAIL PROTECTED]
Date: Mon, 18 Dec 2000 19:16:04 GMT
On Mon, 18 Dec 2000 09:59:41 -0800, "Ken Wilson"
<[EMAIL PROTECTED]> wrote:
>
>How does DHCP (Dynamic Host Configuration Protocol) work
>in Linux?
Yes, DHCP works in Linux
> How does Linux support it?
How do you mean?
There's a dhcpd server daemon for Linux, and a dhcp client for Linux
>-Ken
>
>
Lew Pitcher
Information Technology Consultant
Toronto Dominion Bank Financial Group
([EMAIL PROTECTED])
(Opinions expressed are my own, not my employer's.)
------------------------------
From: David Vidal Rodriguez <[EMAIL PROTECTED]>
Subject: Re: Problem with LVM and LILO
Date: Mon, 18 Dec 2000 20:24:47 +0100
Josef Moellers wrote:
> > I have read somewhere that ext2 automatically defragments
> > filesystems, how does LILO handle that?
>
> ext2 doesn't "automaticall defragment", it is designed not to fragment
> in the first place by allocating all blocks of a file within a cylinder
> group, i.e. within a small range of cylinders.
>
> LILO gets absolute disk addresses from where to load disk blocks. If you
> modify the disk/filesystem structure of the partition containing the
> files LILO needs (usually the filesystem containing /boot), then LILO
> will load incorrect blocks and will probably make a hard landing.
>
> --
> Josef M�llers (Pinguinpfleger bei FSC)
> If failure had no penalty success would not be a prize (T. Pratchett)
Apropos fragmentation: what happens if the kernel image has to be put in
non-contiguous blocks? Imagine a kernel stored in a VFAT-partition or something
like that...
--
------------------------------------------------------------------------
David Vidal R. ([EMAIL PROTECTED])
------------------------------
From: Naushit Sakarvadia <[EMAIL PROTECTED]>
Subject: Open file in module?
Date: Mon, 18 Dec 2000 13:21:55 -0600
Hi
How do I open a file in module..I need to open one text file from module
I am writing...
can I use alll standard file system call like Open , Close write read
etc..etc.. from module?
Thanks
------------------------------
From: Thomas Petazzoni <[EMAIL PROTECTED]>
Subject: Re: How to ensure a page not being swapped out
Date: Mon, 18 Dec 2000 16:40:47 +0100
Reply-To: [EMAIL PROTECTED]
> Does anyone know here what flag is required to ensure that a kmalloc'ed
> page isn't swapped out?
> Is GFP_KERNEL sufficient, or do I need GFP_ATOMIC (or even GFP_DMA)
what does the flags GFP_KERNEL and GFP_ATOMIC exactly do ?
i've already read the manpages, but i need more explanations about how
they exactly work.
thx a lot,
thomas
--
PETAZZONI Thomas
[EMAIL PROTECTED] ICQ : 34937744
[EMAIL PROTECTED] http://kos.enix.org
------------------------------
From: =?iso-8859-1?Q?Rasmus_B=F8g_Hansen?= <[EMAIL PROTECTED]>
Subject: Re: Problem with LVM and LILO
Date: Mon, 18 Dec 2000 21:16:00 +0100
On Mon, 18 Dec 2000, David Vidal Rodriguez wrote:
> Josef Moellers wrote:
>
> > > I have read somewhere that ext2 automatically defragments
> > > filesystems, how does LILO handle that?
> >
> > ext2 doesn't "automaticall defragment", it is designed not to fragment
> > in the first place by allocating all blocks of a file within a cylinder
> > group, i.e. within a small range of cylinders.
> >
> > LILO gets absolute disk addresses from where to load disk blocks. If you
> > modify the disk/filesystem structure of the partition containing the
> > files LILO needs (usually the filesystem containing /boot), then LILO
> > will load incorrect blocks and will probably make a hard landing.
> >
> > --
> > Josef M�llers (Pinguinpfleger bei FSC)
> > If failure had no penalty success would not be a prize (T. Pratchett)
>
> Apropos fragmentation: what happens if the kernel image has to be put in
> non-contiguous blocks? Imagine a kernel stored in a VFAT-partition or something
> like that...
That would be no problem, as LILO stores a map of what blocks the kernel
image resides at. Provided still, you do not mess around with the kernel
_after_ LILO has been installed (= run).
Rasmus B�g Hansen
------------------------------
From: "Matthew Smith" <[EMAIL PROTECTED]>
Subject: Re: Linix terminal emulation software
Date: Mon, 18 Dec 2000 20:43:33 -0000
hyperterminal is the one that comes with Win95/98
There is a better one with Win 3.1 called terminal.exe which emulates VT52
and VT100 without fuss.
Matt
------------------------------
** 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
******************************