Re: SCSI proc_fs in 1.3.28

Linus Torvalds (Linus.Torvalds@cs.Helsinki.FI)
Tue, 19 Sep 1995 17:12:12 +0300


Kai Schulte: "SCSI proc_fs in 1.3.28" (Sep 19, 1:29):
> It appears that switching the scsi code to proc_fs has generated some
> inconsistencies that cause linking errors:
>
> _scsi_dir and _scsi_hba_dir are undefined.
>
> I'm not using the scsi driver, so I haven't taken the time to investigate.
> Maybe the problem is just a missing #ifdef ... in the proc_fs part?

Ok, I have gotten a few positive reports too: once the compilation
problems are fixed, 1.3.28 seems to be reasonably stable. Anyway, I'm
including my current "pre-patch-1.3.29" which should fix the problems
people have had with compilations and also cleans up a few other things
(and let's hope that it's stable after the "few other things" too ;-).

As always, this is a pre-patch, so if you apply this, make sure to save
the patch so that you can de-apply it again before you apply the real
thing..

(oh, btw, as you'll notice from the patch I finally upgraded to an ELF
compiler, so the default for CONFIG_KERNEL_ELF is "y" these days. Never
say I'm not on the cutting edge of development 8-)

Linus

----------
diff -u --recursive --new-file v1.3.28/linux/Makefile linux/Makefile
--- v1.3.28/linux/Makefile Mon Sep 18 14:53:47 1995
+++ linux/Makefile Mon Sep 18 14:54:52 1995
@@ -1,6 +1,6 @@
VERSION = 1
PATCHLEVEL = 3
-SUBLEVEL = 28
+SUBLEVEL = 29

ARCH = i386

diff -u --recursive --new-file v1.3.28/linux/arch/alpha/mm/init.c linux/arch/alpha/mm/init.c
--- v1.3.28/linux/arch/alpha/mm/init.c Thu Jun 1 13:22:06 1995
+++ linux/arch/alpha/mm/init.c Tue Sep 19 12:15:27 1995
@@ -68,12 +68,12 @@
i = MAP_NR(high_memory);
while (i-- > 0) {
total++;
- if (mem_map[i] & MAP_PAGE_RESERVED)
+ if (mem_map[i].reserved)
reserved++;
- else if (!mem_map[i])
+ else if (!mem_map[i].count)
free++;
else
- shared += mem_map[i]-1;
+ shared += mem_map[i].count-1;
}
printk("%d pages of RAM\n",total);
printk("%d free pages\n",free);
@@ -127,7 +127,7 @@
continue;

while (nr--)
- mem_map[pfn++] = 0;
+ mem_map[pfn++].reserved = 0;
}

/* unmap the console stuff: we don't need it, and we don't want it */
@@ -158,7 +158,7 @@
*/
tmp = KERNEL_START;
while (tmp < start_mem) {
- mem_map[MAP_NR(tmp)] = MAP_PAGE_RESERVED;
+ mem_map[MAP_NR(tmp)].reserved = 1;
tmp += PAGE_SIZE;
}

@@ -171,9 +171,9 @@
#endif

for (tmp = PAGE_OFFSET ; tmp < high_memory ; tmp += PAGE_SIZE) {
- if (mem_map[MAP_NR(tmp)])
+ if (mem_map[MAP_NR(tmp)].reserved)
continue;
- mem_map[MAP_NR(tmp)] = 1;
+ mem_map[MAP_NR(tmp)].count = 1;
free_page(tmp);
}
tmp = nr_free_pages << PAGE_SHIFT;
@@ -191,12 +191,12 @@
val->freeram = nr_free_pages << PAGE_SHIFT;
val->bufferram = buffermem;
while (i-- > 0) {
- if (mem_map[i] & MAP_PAGE_RESERVED)
+ if (mem_map[i].reserved)
continue;
val->totalram++;
- if (!mem_map[i])
+ if (!mem_map[i].count)
continue;
- val->sharedram += mem_map[i]-1;
+ val->sharedram += mem_map[i].count-1;
}
val->totalram <<= PAGE_SHIFT;
val->sharedram <<= PAGE_SHIFT;
diff -u --recursive --new-file v1.3.28/linux/arch/i386/config.in linux/arch/i386/config.in
--- v1.3.28/linux/arch/i386/config.in Mon Sep 18 14:53:48 1995
+++ linux/arch/i386/config.in Tue Sep 19 12:51:23 1995
@@ -34,7 +34,7 @@
bool 'System V IPC' CONFIG_SYSVIPC y
tristate 'Kernel support for ELF binaries' CONFIG_BINFMT_ELF y
if [ "$CONFIG_BINFMT_ELF" = "y" ]; then
-bool 'Compile kernel as ELF - if your GCC is ELF-GCC' CONFIG_KERNEL_ELF n
+bool 'Compile kernel as ELF - if your GCC is ELF-GCC' CONFIG_KERNEL_ELF y
fi
#bool 'Use -mpentium flag for Pentium-specific optimizations' CONFIG_M586 n
#if [ "$CONFIG_M586" = "n" ]; then
diff -u --recursive --new-file v1.3.28/linux/arch/i386/mm/init.c linux/arch/i386/mm/init.c
--- v1.3.28/linux/arch/i386/mm/init.c Sun Sep 3 12:26:49 1995
+++ linux/arch/i386/mm/init.c Tue Sep 19 12:16:55 1995
@@ -73,12 +73,12 @@
i = high_memory >> PAGE_SHIFT;
while (i-- > 0) {
total++;
- if (mem_map[i] & MAP_PAGE_RESERVED)
+ if (mem_map[i].reserved)
reserved++;
- else if (!mem_map[i])
+ else if (!mem_map[i].count)
free++;
else
- shared += mem_map[i]-1;
+ shared += mem_map[i].count-1;
}
printk("%d pages of RAM\n",total);
printk("%d free pages\n",free);
@@ -192,12 +192,12 @@
* controller as well..
*/
while (start_low_mem < 0x9f000) {
- mem_map[MAP_NR(start_low_mem)] = 0;
+ mem_map[MAP_NR(start_low_mem)].reserved = 0;
start_low_mem += PAGE_SIZE;
}

while (start_mem < high_memory) {
- mem_map[MAP_NR(start_mem)] = 0;
+ mem_map[MAP_NR(start_mem)].reserved = 0;
start_mem += PAGE_SIZE;
}
#ifdef CONFIG_SCSI
@@ -207,7 +207,7 @@
sound_mem_init();
#endif
for (tmp = 0 ; tmp < high_memory ; tmp += PAGE_SIZE) {
- if (mem_map[MAP_NR(tmp)]) {
+ if (mem_map[MAP_NR(tmp)].reserved) {
if (tmp >= 0xA0000 && tmp < 0x100000)
reservedpages++;
else if (tmp < (unsigned long) &_etext)
@@ -216,7 +216,7 @@
datapages++;
continue;
}
- mem_map[MAP_NR(tmp)] = 1;
+ mem_map[MAP_NR(tmp)].count = 1;
free_page(tmp);
}
tmp = nr_free_pages << PAGE_SHIFT;
@@ -249,12 +249,12 @@
val->freeram = nr_free_pages << PAGE_SHIFT;
val->bufferram = buffermem;
while (i-- > 0) {
- if (mem_map[i] & MAP_PAGE_RESERVED)
+ if (mem_map[i].reserved)
continue;
val->totalram++;
- if (!mem_map[i])
+ if (!mem_map[i].count)
continue;
- val->sharedram += mem_map[i]-1;
+ val->sharedram += mem_map[i].count-1;
}
val->totalram <<= PAGE_SHIFT;
val->sharedram <<= PAGE_SHIFT;
diff -u --recursive --new-file v1.3.28/linux/drivers/scsi/53c7,8xx.c linux/drivers/scsi/53c7,8xx.c
--- v1.3.28/linux/drivers/scsi/53c7,8xx.c Mon Sep 18 14:53:55 1995
+++ linux/drivers/scsi/53c7,8xx.c Tue Sep 19 09:34:23 1995
@@ -994,6 +994,8 @@
unsigned char pci_bus, pci_device_fn;
static short pci_index=0; /* Device index to PCI BIOS calls */

+ tpnt->proc_dir = &proc_scsi_ncr53c7xx;
+
for (current_override = count = 0; current_override < OVERRIDE_LIMIT;
++current_override) {
if (overrides[current_override].pci ?
@@ -1120,7 +1122,6 @@
* SCRIPTS.
*/

- tpnt->proc_dir = &proc_scsi_ncr53c7xx;

patch_abs_rwri_data (hostdata->script, 0, dmode_memory_to_memory, tmp);
patch_abs_rwri_data (hostdata->script, 0, dmode_memory_to_ncr, memory_to_ncr);
diff -u --recursive --new-file v1.3.28/linux/drivers/scsi/eata_dma.c linux/drivers/scsi/eata_dma.c
--- v1.3.28/linux/drivers/scsi/eata_dma.c Mon Sep 18 14:53:56 1995
+++ linux/drivers/scsi/eata_dma.c Tue Sep 19 09:34:23 1995
@@ -48,7 +48,7 @@
* Thanks also to Greg Hosler who did a lot of testing and *
* found quite a number of bugs during the development. *
************************************************************
- * last change: 95/07/18 OS: Linux 1.3.10 *
+ * last change: 95/09/17 OS: Linux 1.3.28 *
************************************************************/

/* Look in eata_dma.h for configuration and revision information */
@@ -508,6 +508,7 @@
printk("eata_queue target %d, pid %ld, HBA busy, returning DID_ERROR,"
" done.\n", cmd->target, cmd->pid);
done(cmd);
+ cp->status = FREE; /* Hmmm..... */
restore_flags(flags);
return(0);
}
@@ -857,7 +858,6 @@
"Please use the EATA-PIO driver.\n", base);
return (FALSE);
}
-
if(gc->HAA_valid == FALSE || ntohl(gc->len) < 0x22)
gc->MAX_CHAN = 0;

@@ -1124,8 +1124,8 @@
(int)pal1, (int)pal2, (int)pal3));
#endif
if (get_conf_PIO(base, buf) == TRUE) {
- DBG(DBG_PROBE && DBG_EISA, print_config(buf));
if (buf->IRQ) {
+ DBG(DBG_EISA, printk("Registering EISA HBA\n"));
register_HBA(base, buf, tpnt, IS_EISA);
} else
printk("eata_dma: No valid IRQ. HBA removed from list\n");
@@ -1151,6 +1151,7 @@
for (i = 0; i < MAXISA; i++) {
if (ISAbases[i]) {
if (get_conf_PIO(ISAbases[i],buf) == TRUE){
+ DBG(DBG_ISA, printk("Registering ISA HBA\n"));
register_HBA(ISAbases[i], buf, tpnt, IS_ISA);
} else {
if (check_blink_state(ISAbases[i]))
@@ -1176,6 +1177,7 @@
u16 com_adr;
u16 rev_device;
u32 error, i, x;
+ u8 pal1, pal2, pal3;

if (pcibios_present()) {
for (i = 0; i <= MAXPCI; ++i, ++pci_index) {
@@ -1217,21 +1219,26 @@
/* Check if the address is valid */
if (base & 0x01) {
base &= 0xfffffffe;
- /* EISA tag there ? */
- if ((inb(base) == 0x12) && (inb(base + 1) == 0x14))
- continue; /* Jep, it's forced, so move on */
- base += 0x10; /* Now, THIS is the real address */
+ /* EISA tag there ? */
+ pal1 = inb(base);
+ pal2 = inb(base + 1);
+ pal3 = inb(base + 2);
+ if (((pal1 == 0x12) && (pal2 == 0x14)) ||
+ ((pal1 == 0x38) && (pal2 == 0xa3) && (pal3 == 0x82)) ||
+ ((pal1 == 0x06) && (pal2 == 0x94) && (pal3 == 0x24)))
+ base += 0x08;
+ else
+ base += 0x10; /* Now, THIS is the real address */
+
if (base != 0x1f8) {
/* We didn't find it in the primary search */
if (get_conf_PIO(base, buf) == TRUE) {
- if (buf->FORCADR) /* If the address is forced */
- continue; /* we'll find it later */
-
+
/* OK. We made it till here, so we can go now
* and register it. We only have to check and
* eventually remove it from the EISA and ISA list
*/
-
+ DBG(DBG_PCI, printk("Registering PCI HBA\n"));
register_HBA(base, buf, tpnt, IS_PCI);

if (base < 0x1000) {
diff -u --recursive --new-file v1.3.28/linux/drivers/scsi/hosts.c linux/drivers/scsi/hosts.c
--- v1.3.28/linux/drivers/scsi/hosts.c Mon Sep 18 14:53:57 1995
+++ linux/drivers/scsi/hosts.c Tue Sep 19 12:12:38 1995
@@ -416,7 +416,7 @@
Low24 += PAGE_SIZE) {
unsigned long ForbiddenAddress = High8 + Low24;
if (ForbiddenAddress >= memory_end) goto next_host;
- mem_map[MAP_NR(ForbiddenAddress)] = MAP_PAGE_RESERVED;
+ mem_map[MAP_NR(ForbiddenAddress)].reserved = 1;
}
}
}
diff -u --recursive --new-file v1.3.28/linux/drivers/sound/soundcard.c linux/drivers/sound/soundcard.c
--- v1.3.28/linux/drivers/sound/soundcard.c Mon Sep 18 14:54:04 1995
+++ linux/drivers/sound/soundcard.c Tue Sep 19 12:13:46 1995
@@ -618,10 +618,10 @@

for (i = MAP_NR (start_addr); i <= MAP_NR (end_addr); i++)
{
- if (mem_map[i])
+ if (mem_map[i].reserved || mem_map[i].count)
panic ("sound_mem_init: Page not free (driver incompatible with kernel).\n");

- mem_map[i] = MAP_PAGE_RESERVED;
+ mem_map[i].reserved = 1;
}
}
} /* for dev */
diff -u --recursive --new-file v1.3.28/linux/fs/buffer.c linux/fs/buffer.c
--- v1.3.28/linux/fs/buffer.c Mon Sep 18 14:54:05 1995
+++ linux/fs/buffer.c Tue Sep 19 13:27:48 1995
@@ -566,7 +566,7 @@
tmp = bh->b_next_free;
if (!bh) break;

- if (mem_map[MAP_NR((unsigned long) bh->b_data)] != 1 ||
+ if (mem_map[MAP_NR((unsigned long) bh->b_data)].count != 1 ||
bh->b_dirt) {
refile_buffer(bh);
continue;
@@ -614,7 +614,7 @@
if(candidate[i] == bh) candidate[i] = NULL; /* Got last one */
if (bh->b_count || bh->b_size != size)
panic("Busy buffer in candidate list\n");
- if (mem_map[MAP_NR((unsigned long) bh->b_data)] != 1)
+ if (mem_map[MAP_NR((unsigned long) bh->b_data)].count != 1)
panic("Shared buffer in candidate list\n");
if (BADNESS(bh)) panic("Buffer in candidate list with BADNESS != 0\n");

@@ -638,7 +638,7 @@
tmp = bh->b_next_free;
if (!bh) break;

- if (mem_map[MAP_NR((unsigned long) bh->b_data)] != 1 ||
+ if (mem_map[MAP_NR((unsigned long) bh->b_data)].count != 1 ||
bh->b_dirt) {
refile_buffer(bh);
continue;
@@ -761,7 +761,7 @@
panic("Attempt to refile free buffer\n");
if (buf->b_dirt)
dispose = BUF_DIRTY;
- else if (mem_map[MAP_NR((unsigned long) buf->b_data)] > 1)
+ else if (mem_map[MAP_NR((unsigned long) buf->b_data)].count > 1)
dispose = BUF_SHARED;
else if (buf->b_lock)
dispose = BUF_LOCKED;
@@ -1048,7 +1048,7 @@
}
if (!aligned)
return try_to_align(bh, nrbuf, address);
- mem_map[MAP_NR(page)]++;
+ mem_map[MAP_NR(page)].count++;
read_buffers(bh,nrbuf); /* make sure they are actually read correctly */
while (nrbuf-- > 0)
brelse(bh[nrbuf]);
@@ -1106,7 +1106,7 @@
}
buffermem += PAGE_SIZE;
bh->b_this_page = tmp;
- mem_map[MAP_NR(address)]++;
+ mem_map[MAP_NR(address)].count++;
buffer_pages[MAP_NR(address)] = bh;
read_buffers(arr,block);
while (block-- > 0)
@@ -1308,7 +1308,7 @@
buffermem -= PAGE_SIZE;
buffer_pages[MAP_NR(page)] = NULL;
free_page(page);
- return !mem_map[MAP_NR(page)];
+ return !mem_map[MAP_NR(page)].count;
}


@@ -1471,7 +1471,7 @@
locked++;
if (bh->b_dirt)
dirty++;
- if(mem_map[MAP_NR(((unsigned long) bh->b_data))] !=1) shared++;
+ if(mem_map[MAP_NR(((unsigned long) bh->b_data))].count !=1) shared++;
if (bh->b_count)
used++, lastused = found;
bh = bh->b_next_free;
@@ -1505,7 +1505,7 @@
*bhp = bh;
page = (unsigned long) bh->b_data;
page &= PAGE_MASK;
- if(mem_map[MAP_NR(page)] != 1) return 0;
+ if(mem_map[MAP_NR(page)].count != 1) return 0;
tmp = bh;
do {
if (!tmp)
diff -u --recursive --new-file v1.3.28/linux/fs/proc/array.c linux/fs/proc/array.c
--- v1.3.28/linux/fs/proc/array.c Mon Sep 18 14:54:07 1995
+++ linux/fs/proc/array.c Tue Sep 19 12:32:48 1995
@@ -512,7 +512,7 @@
++*dirty;
if (pte_page(page) >= high_memory)
continue;
- if (mem_map[MAP_NR(pte_page(page))] > 1)
+ if (mem_map[MAP_NR(pte_page(page))].count > 1)
++*shared;
} while (address < end);
}
diff -u --recursive --new-file v1.3.28/linux/fs/proc/mem.c linux/fs/proc/mem.c
--- v1.3.28/linux/fs/proc/mem.c Thu Sep 7 17:17:18 1995
+++ linux/fs/proc/mem.c Tue Sep 19 12:31:10 1995
@@ -291,7 +291,7 @@

set_pte(src_table, pte_mkdirty(*src_table));
set_pte(dest_table, *src_table);
- mem_map[MAP_NR(pte_page(*src_table))]++;
+ mem_map[MAP_NR(pte_page(*src_table))].count++;

stmp += PAGE_SIZE;
dtmp += PAGE_SIZE;
diff -u --recursive --new-file v1.3.28/linux/include/asm-alpha/page.h linux/include/asm-alpha/page.h
--- v1.3.28/linux/include/asm-alpha/page.h Sun Sep 3 12:27:01 1995
+++ linux/include/asm-alpha/page.h Tue Sep 19 12:17:30 1995
@@ -71,9 +71,13 @@

#define PAGE_OFFSET 0xFFFFFC0000000000
#define MAP_NR(addr) ((((unsigned long) (addr)) - PAGE_OFFSET) >> PAGE_SHIFT)
-#define MAP_PAGE_RESERVED (1<<31)

-typedef unsigned int mem_map_t;
+typedef struct {
+ unsigned count:30,
+ dirty:1,
+ reserved:1;
+} mem_map_t;
+

#endif /* __KERNEL__ */

diff -u --recursive --new-file v1.3.28/linux/include/asm-alpha/pgtable.h linux/include/asm-alpha/pgtable.h
--- v1.3.28/linux/include/asm-alpha/pgtable.h Sat Sep 9 15:26:53 1995
+++ linux/include/asm-alpha/pgtable.h Tue Sep 19 13:37:35 1995
@@ -171,35 +171,30 @@

extern inline int pte_none(pte_t pte) { return !pte_val(pte); }
extern inline int pte_present(pte_t pte) { return pte_val(pte) & _PAGE_VALID; }
-extern inline int pte_inuse(pte_t *ptep) { return mem_map[MAP_NR(ptep)] != 1; }
+extern inline int pte_inuse(pte_t *ptep) { return mem_map[MAP_NR(ptep)].reserved || mem_map[MAP_NR(ptep)].count != 1; }
extern inline void pte_clear(pte_t *ptep) { pte_val(*ptep) = 0; }
extern inline void pte_reuse(pte_t * ptep)
{
- if (!(mem_map[MAP_NR(ptep)] & MAP_PAGE_RESERVED))
- mem_map[MAP_NR(ptep)]++;
+ if (!mem_map[MAP_NR(ptep)].reserved)
+ mem_map[MAP_NR(ptep)].count++;
}

extern inline int pmd_none(pmd_t pmd) { return !pmd_val(pmd); }
extern inline int pmd_bad(pmd_t pmd) { return (pmd_val(pmd) & ~_PFN_MASK) != _PAGE_TABLE || pmd_page(pmd) > high_memory; }
extern inline int pmd_present(pmd_t pmd) { return pmd_val(pmd) & _PAGE_VALID; }
-extern inline int pmd_inuse(pmd_t *pmdp) { return mem_map[MAP_NR(pmdp)] != 1; }
+extern inline int pmd_inuse(pmd_t *pmdp) { return mem_map[MAP_NR(pmdp)].reserved || mem_map[MAP_NR(pmdp)].count != 1; }
extern inline void pmd_clear(pmd_t * pmdp) { pmd_val(*pmdp) = 0; }
extern inline void pmd_reuse(pmd_t * pmdp)
{
- if (!(mem_map[MAP_NR(pmdp)] & MAP_PAGE_RESERVED))
- mem_map[MAP_NR(pmdp)]++;
+ if (!mem_map[MAP_NR(pmdp)].reserved)
+ mem_map[MAP_NR(pmdp)].count++;
}

extern inline int pgd_none(pgd_t pgd) { return !pgd_val(pgd); }
extern inline int pgd_bad(pgd_t pgd) { return (pgd_val(pgd) & ~_PFN_MASK) != _PAGE_TABLE || pgd_page(pgd) > high_memory; }
extern inline int pgd_present(pgd_t pgd) { return pgd_val(pgd) & _PAGE_VALID; }
-extern inline int pgd_inuse(pgd_t *pgdp) { return mem_map[MAP_NR(pgdp)] != 1; }
+extern inline int pgd_inuse(pgd_t *pgdp) { return mem_map[MAP_NR(pgdp)].reserved; }
extern inline void pgd_clear(pgd_t * pgdp) { pgd_val(*pgdp) = 0; }
-extern inline void pgd_reuse(pgd_t * pgdp)
-{
- if (!(mem_map[MAP_NR(pgdp)] & MAP_PAGE_RESERVED))
- mem_map[MAP_NR(pgdp)]++;
-}

/*
* The following only work if pte_present() is true.
@@ -273,7 +268,7 @@
*/
extern inline void pte_free_kernel(pte_t * pte)
{
- mem_map[MAP_NR(pte)] = 1;
+ mem_map[MAP_NR(pte)].reserved = 0;
free_page((unsigned long) pte);
}

@@ -285,7 +280,7 @@
if (pmd_none(*pmd)) {
if (page) {
pmd_set(pmd, page);
- mem_map[MAP_NR(page)] = MAP_PAGE_RESERVED;
+ mem_map[MAP_NR(page)].reserved = 1;
return page + address;
}
pmd_set(pmd, (pte_t *) BAD_PAGETABLE);
@@ -303,7 +298,7 @@

extern inline void pmd_free_kernel(pmd_t * pmd)
{
- mem_map[MAP_NR(pmd)] = 1;
+ mem_map[MAP_NR(pmd)].reserved = 0;
free_page((unsigned long) pmd);
}

@@ -315,7 +310,7 @@
if (pgd_none(*pgd)) {
if (page) {
pgd_set(pgd, page);
- mem_map[MAP_NR(page)] = MAP_PAGE_RESERVED;
+ mem_map[MAP_NR(page)].reserved = 1;
return page + address;
}
pgd_set(pgd, BAD_PAGETABLE);
diff -u --recursive --new-file v1.3.28/linux/include/asm-i386/page.h linux/include/asm-i386/page.h
--- v1.3.28/linux/include/asm-i386/page.h Sun Sep 3 12:27:02 1995
+++ linux/include/asm-i386/page.h Tue Sep 19 12:17:30 1995
@@ -81,9 +81,12 @@
/* This handles the memory map.. */
#define PAGE_OFFSET 0
#define MAP_NR(addr) (((unsigned long)(addr)) >> PAGE_SHIFT)
-#define MAP_PAGE_RESERVED (1<<15)

-typedef unsigned short mem_map_t;
+typedef struct {
+ unsigned count:30,
+ dirty:1,
+ reserved:1;
+} mem_map_t;

#endif /* __KERNEL__ */

diff -u --recursive --new-file v1.3.28/linux/include/asm-i386/pgtable.h linux/include/asm-i386/pgtable.h
--- v1.3.28/linux/include/asm-i386/pgtable.h Thu Sep 7 17:17:19 1995
+++ linux/include/asm-i386/pgtable.h Tue Sep 19 13:33:34 1995
@@ -143,12 +143,12 @@

extern inline int pte_none(pte_t pte) { return !pte_val(pte); }
extern inline int pte_present(pte_t pte) { return pte_val(pte) & _PAGE_PRESENT; }
-extern inline int pte_inuse(pte_t *ptep) { return mem_map[MAP_NR(ptep)] != 1; }
+extern inline int pte_inuse(pte_t *ptep) { return mem_map[MAP_NR(ptep)].reserved || mem_map[MAP_NR(ptep)].count != 1; }
extern inline void pte_clear(pte_t *ptep) { pte_val(*ptep) = 0; }
extern inline void pte_reuse(pte_t * ptep)
{
- if (!(mem_map[MAP_NR(ptep)] & MAP_PAGE_RESERVED))
- mem_map[MAP_NR(ptep)]++;
+ if (!mem_map[MAP_NR(ptep)].reserved)
+ mem_map[MAP_NR(ptep)].count++;
}

extern inline int pmd_none(pmd_t pmd) { return !pmd_val(pmd); }
@@ -170,13 +170,8 @@
extern inline int pgd_none(pgd_t pgd) { return 0; }
extern inline int pgd_bad(pgd_t pgd) { return 0; }
extern inline int pgd_present(pgd_t pgd) { return 1; }
-extern inline int pgd_inuse(pgd_t * pgdp) { return mem_map[MAP_NR(pgdp)] != 1; }
+extern inline int pgd_inuse(pgd_t * pgdp) { return mem_map[MAP_NR(pgdp)].reserved; }
extern inline void pgd_clear(pgd_t * pgdp) { }
-extern inline void pgd_reuse(pgd_t * pgdp)
-{
- if (!(mem_map[MAP_NR(pgdp)] & MAP_PAGE_RESERVED))
- mem_map[MAP_NR(pgdp)]++;
-}

/*
* The following only work if pte_present() is true.
@@ -243,7 +238,7 @@
*/
extern inline void pte_free_kernel(pte_t * pte)
{
- mem_map[MAP_NR(pte)] = 1;
+ mem_map[MAP_NR(pte)].reserved = 0;
free_page((unsigned long) pte);
}

@@ -255,7 +250,7 @@
if (pmd_none(*pmd)) {
if (page) {
pmd_val(*pmd) = _PAGE_TABLE | (unsigned long) page;
- mem_map[MAP_NR(page)] = MAP_PAGE_RESERVED;
+ mem_map[MAP_NR(page)].reserved = 1;
return page + address;
}
pmd_val(*pmd) = _PAGE_TABLE | (unsigned long) BAD_PAGETABLE;
diff -u --recursive --new-file v1.3.28/linux/ipc/shm.c linux/ipc/shm.c
--- v1.3.28/linux/ipc/shm.c Fri Sep 15 11:13:03 1995
+++ linux/ipc/shm.c Tue Sep 19 12:48:34 1995
@@ -664,7 +664,7 @@

done: /* pte_val(pte) == shp->shm_pages[idx] */
current->min_flt++;
- mem_map[MAP_NR(pte_page(pte))]++;
+ mem_map[MAP_NR(pte_page(pte))].count++;
return pte_modify(pte, shmd->vm_page_prot);
}

@@ -764,7 +764,7 @@
printk("shm_swap_out: page and pte mismatch\n");
set_pte(page_table,
__pte(shmd->vm_pte + SWP_ENTRY(0, idx << SHM_IDX_SHIFT)));
- mem_map[MAP_NR(pte_page(pte))]--;
+ mem_map[MAP_NR(pte_page(pte))].count--;
if (shmd->vm_mm->rss > 0)
shmd->vm_mm->rss--;
invalid++;
@@ -774,7 +774,7 @@
break;
}

- if (mem_map[MAP_NR(pte_page(page))] != 1)
+ if (mem_map[MAP_NR(pte_page(page))].count != 1)
goto check_table;
shp->shm_pages[idx] = swap_nr;
if (invalid)
diff -u --recursive --new-file v1.3.28/linux/kernel/ksyms.c linux/kernel/ksyms.c
--- v1.3.28/linux/kernel/ksyms.c Wed Sep 13 12:45:33 1995
+++ linux/kernel/ksyms.c Tue Sep 19 11:40:19 1995
@@ -92,11 +92,6 @@
off_t offset, int length,
int inode, int func) = 0; /* Dirty hack */

-#if defined(CONFIG_PROC_FS)
-extern struct proc_dir_entry scsi_dir[];
-extern struct proc_dir_entry scsi_hba_dir[];
-#endif
-
extern int sys_tz;
extern int request_dma(unsigned int dmanr, char * deviceID);
extern void free_dma(unsigned int dmanr);
@@ -417,10 +412,6 @@
X(gendisk_head),
X(resetup_one_dev),

-#if defined(CONFIG_PROC_FS)
- X(scsi_dir),
- X(scsi_hba_dir),
-#endif
X(dispatch_scsi_info_ptr),
#endif
/* Added to make file system as module */
diff -u --recursive --new-file v1.3.28/linux/mm/filemap.c linux/mm/filemap.c
--- v1.3.28/linux/mm/filemap.c Sat Sep 9 15:26:53 1995
+++ linux/mm/filemap.c Tue Sep 19 12:10:56 1995
@@ -153,7 +153,7 @@
{
unsigned long page = SWP_OFFSET(entry);

- mem_map[page]++;
+ mem_map[page].count++;
page = (page << PAGE_SHIFT) + PAGE_OFFSET;
return mk_pte(page,vma->vm_page_prot);
}
@@ -173,7 +173,7 @@
return 0;
set_pte(ptep, pte_mkclean(pte));
page = pte_page(pte);
- mem_map[MAP_NR(page)]++;
+ mem_map[MAP_NR(page)].count++;
} else {
if (pte_none(pte))
return 0;
diff -u --recursive --new-file v1.3.28/linux/mm/memory.c linux/mm/memory.c
--- v1.3.28/linux/mm/memory.c Fri Sep 15 11:13:03 1995
+++ linux/mm/memory.c Tue Sep 19 11:54:56 1995
@@ -207,7 +207,7 @@
set_pte(new_pte, pte);
return;
}
- if (pte_page(pte) > high_memory || (mem_map[MAP_NR(pte_page(pte))] & MAP_PAGE_RESERVED)) {
+ if (pte_page(pte) > high_memory || mem_map[MAP_NR(pte_page(pte))].reserved) {
set_pte(new_pte, pte);
return;
}
@@ -217,7 +217,7 @@
pte = pte_mkdirty(pte);
set_pte(new_pte, pte_mkold(pte));
set_pte(old_pte, pte);
- mem_map[MAP_NR(pte_page(pte))]++;
+ mem_map[MAP_NR(pte_page(pte))].count++;
}

static inline int copy_pte_range(pmd_t *dst_pmd, pmd_t *src_pmd, unsigned long address, unsigned long size)
@@ -315,7 +315,7 @@
return;
if (pte_present(page)) {
free_page(pte_page(page));
- if (mem_map[MAP_NR(pte_page(page))] & MAP_PAGE_RESERVED)
+ if (mem_map[MAP_NR(pte_page(page))].reserved)
return;
if (current->mm->rss <= 0)
return;
@@ -479,7 +479,7 @@
do {
pte_t oldpage = *pte;
pte_clear(pte);
- if (offset >= high_memory || (mem_map[MAP_NR(offset)] & MAP_PAGE_RESERVED))
+ if (offset >= high_memory || mem_map[MAP_NR(offset)].reserved)
set_pte(pte, mk_pte(offset, prot));
forget_pte(oldpage);
address += PAGE_SIZE;
@@ -558,7 +558,7 @@

if (page >= high_memory)
printk("put_dirty_page: trying to put page %08lx at %08lx\n",page,address);
- if (mem_map[MAP_NR(page)] != 1)
+ if (mem_map[MAP_NR(page)].count != 1)
printk("mem_map disagrees with %08lx at %08lx\n",page,address);
pgd = pgd_offset(tsk->mm,address);
pmd = pmd_alloc(pgd, address);
@@ -632,9 +632,9 @@
/*
* Do we need to copy?
*/
- if (mem_map[MAP_NR(old_page)] != 1) {
+ if (mem_map[MAP_NR(old_page)].count != 1) {
if (new_page) {
- if (mem_map[MAP_NR(old_page)] & MAP_PAGE_RESERVED)
+ if (mem_map[MAP_NR(old_page)].reserved)
++vma->vm_mm->rss;
copy_page(old_page,new_page);
set_pte(page_table, pte_mkwrite(pte_mkdirty(mk_pte(new_page, vma->vm_page_prot))));
@@ -812,7 +812,7 @@
/* is the page reasonable at all? */
if (pte_page(from) >= high_memory)
return 0;
- if (mem_map[MAP_NR(pte_page(from))] & MAP_PAGE_RESERVED)
+ if (mem_map[MAP_NR(pte_page(from))].reserved)
return 0;
/* is the destination ok? */
to_dir = pgd_offset(to_area->vm_mm,to_address);
@@ -862,7 +862,7 @@
set_pte(from_table, pte_mkdirty(from));
delete_from_swap_cache(pte_page(from));
}
- mem_map[MAP_NR(pte_page(from))]++;
+ mem_map[MAP_NR(pte_page(from))].count++;
set_pte(to_table, mk_pte(pte_page(from), to_area->vm_page_prot));
/* Check if we need to do anything at all to the 'from' field */
if (!pte_write(from))
@@ -966,7 +966,7 @@
free_page(pte_page(page));
return;
}
- if (mem_map[MAP_NR(pte_page(page))] > 1 && !(vma->vm_flags & VM_SHARED))
+ if (mem_map[MAP_NR(pte_page(page))].count > 1 && !(vma->vm_flags & VM_SHARED))
page = pte_wrprotect(page);
++vma->vm_mm->rss;
++tsk->maj_flt;
@@ -1041,7 +1041,7 @@
entry = mk_pte(page, vma->vm_page_prot);
if (write_access) {
entry = pte_mkwrite(pte_mkdirty(entry));
- } else if (mem_map[MAP_NR(page)] > 1 && !(vma->vm_flags & VM_SHARED))
+ } else if (mem_map[MAP_NR(page)].count > 1 && !(vma->vm_flags & VM_SHARED))
entry = pte_wrprotect(entry);
put_page(page_table, entry);
}
diff -u --recursive --new-file v1.3.28/linux/mm/swap.c linux/mm/swap.c
--- v1.3.28/linux/mm/swap.c Mon Sep 18 14:54:11 1995
+++ linux/mm/swap.c Tue Sep 19 13:32:20 1995
@@ -367,7 +367,7 @@
return 0;
if (page >= limit)
return 0;
- if (mem_map[MAP_NR(page)] & MAP_PAGE_RESERVED)
+ if (mem_map[MAP_NR(page)].reserved)
return 0;
if ((pte_dirty(pte) && delete_from_swap_cache(page)) || pte_young(pte)) {
set_pte(page_table, pte_mkold(pte));
@@ -380,7 +380,7 @@
if (vma->vm_ops->swapout(vma, address - vma->vm_start + vma->vm_offset, page_table))
kill_proc(pid, SIGBUS, 1);
} else {
- if (mem_map[MAP_NR(page)] != 1)
+ if (mem_map[MAP_NR(page)].count != 1)
return 0;
if (!(entry = get_swap_page()))
return 0;
@@ -393,7 +393,7 @@
return 1; /* we slept: the process may not exist any more */
}
if ((entry = find_in_swap_cache(page))) {
- if (mem_map[MAP_NR(page)] != 1) {
+ if (mem_map[MAP_NR(page)].count != 1) {
set_pte(page_table, pte_mkdirty(pte));
printk("Aiee.. duplicated cached swap-cache entry\n");
return 0;
@@ -407,7 +407,7 @@
vma->vm_mm->rss--;
pte_clear(page_table);
invalidate();
- entry = mem_map[MAP_NR(page)];
+ entry = mem_map[MAP_NR(page)].count;
free_page(page);
return entry;
}
@@ -720,18 +720,18 @@
if (addr < high_memory) {
unsigned long flag;
mem_map_t * map = mem_map + MAP_NR(addr);
- if (*map) {
- if (!(*map & MAP_PAGE_RESERVED)) {
- save_flags(flag);
- cli();
- if (!--*map) {
- free_pages_ok(addr, order);
- delete_from_swap_cache(addr);
- }
- restore_flags(flag);
- if (*map == 1)
- check_free_buffers(addr);
+ if (map->reserved)
+ return;
+ if (map->count) {
+ save_flags(flag);
+ cli();
+ if (!--map->count) {
+ free_pages_ok(addr, order);
+ delete_from_swap_cache(addr);
}
+ restore_flags(flag);
+ if (map->count == 1)
+ check_free_buffers(addr);
return;
}
printk("Trying to free free memory (%08lx): memory probably corrupted\n",addr);
@@ -775,7 +775,7 @@
mark_used((unsigned long) addr, high); \
restore_flags(flags); \
addr = (struct mem_list *) (size + (unsigned long) addr); \
- } mem_map[MAP_NR((unsigned long) addr)] = 1; \
+ } mem_map[MAP_NR((unsigned long) addr)].count = 1; \
} while (0)

unsigned long __get_free_pages(int priority, unsigned long order, unsigned long limit)
@@ -956,6 +956,8 @@
/*
* Go through process' page directory.
*/
+ if (!p->mm || pgd_inuse(p->mm->pgd))
+ return 0;
vma = p->mm->mmap;
while (vma) {
pgd_t * pgd = pgd_offset(p->mm, vma->vm_start);
@@ -1244,7 +1246,7 @@

/*
* set up the free-area data structures:
- * - mark all pages MAP_PAGE_RESERVED
+ * - mark all pages reserved
* - mark all memory queues empty
* - clear the memory bitmaps
*/
@@ -1266,8 +1268,12 @@
mem_map = (mem_map_t *) start_mem;
p = mem_map + MAP_NR(end_mem);
start_mem = LONG_ALIGN((unsigned long) p);
- while (p > mem_map)
- *--p = MAP_PAGE_RESERVED;
+ while (p > mem_map) {
+ --p;
+ p->count = 0;
+ p->dirty = 0;
+ p->reserved = 1;
+ }

for (i = 0 ; i < NR_MEM_LISTS ; i++) {
unsigned long bitmap_size;
----------