[patch] A few things from 2.0.x (Was: Pre-2.1.80..)

Dr. Werner Fink (werner@suse.de)
Wed, 14 Jan 1998 20:39:01 +0100


>
> Hi all,
> I just put a pre-2.1.80 on ftp.kernel.org that should fix the fat-related
> problems. The reason I put it there is because I got several patches that
> fixed the FAT problems _and_ something else, and they all obviously
> clashed with each other so neither part got applied.
>
> So I'd ask people who sent me patches to maybe re-send the parts of the
> patches that are still relevant,

Nothing dramatic ... only a few fixes in string-486.h done by Bernd Schmidt
<crux@pool.informatik.rwth-aachen.de> for 2.0.30 but never applied to
2.1.x ... and two simple changes by my self (the PAGE_AGE_VALUE of 16 is
a big one against PAGE_INITIAL_AGE of 3, avoid freeing a eventually not
allocated page).

Werner

--------------------------------------------------------------------------
diff -ur linux-2.1.79/include/asm-i386/string-486.h linux/include/asm-i386/string-486.h
--- linux-2.1.79/include/asm-i386/string-486.h Thu Feb 27 19:57:31 1997
+++ linux/include/asm-i386/string-486.h Tue Jan 13 17:45:36 1998
@@ -23,11 +23,11 @@
register char dummy;
__asm__ __volatile__(
"\n1:\t"
- "movb (%0),%2\n\t"
+ "movb (%0),%b2\n\t"
"incl %0\n\t"
- "movb %2,(%1)\n\t"
+ "movb %b2,(%1)\n\t"
"incl %1\n\t"
- "testb %2,%2\n\t"
+ "testb %b2,%b2\n\t"
"jne 1b"
:"=r" (src), "=r" (tmp), "=q" (dummy)
:"0" (src), "1" (tmp)
@@ -43,15 +43,15 @@
if (count) {
__asm__ __volatile__(
"\n1:\t"
- "movb (%0),%2\n\t"
+ "movb (%0),%b2\n\t"
"incl %0\n\t"
- "movb %2,(%1)\n\t"
+ "movb %b2,(%1)\n\t"
"incl %1\n\t"
"decl %3\n\t"
"je 3f\n\t"
- "testb %2,%2\n\t"
+ "testb %b2,%b2\n\t"
"jne 1b\n\t"
- "2:\tmovb %2,(%1)\n\t"
+ "2:\tmovb %b2,(%1)\n\t"
"incl %1\n\t"
"decl %3\n\t"
"jne 2b\n\t"
@@ -101,7 +101,7 @@
"incl %1\n\t"
"testb %b0,%b0\n\t"
"jne 2b\n"
- "3:\txorl %0,%0\n\t"
+ "3:\txorb %b0,%b0\n\t"
"movb %b0,(%1)\n\t"
:"=q" (dummy), "=r" (tmp), "=r" (src), "=r" (count)
:"1" (tmp), "2" (src), "3" (count)
@@ -121,11 +121,11 @@
"incl %2\n\t"
"testb %b0,%b0\n\t"
"jne 1b\n\t"
- "xorl %0,%0\n\t"
+ "xorl %k0,%k0\n\t"
"jmp 3f\n"
- "2:\tmovl $1,%0\n\t"
+ "2:\tmovl $1,%k0\n\t"
"jb 3f\n\t"
- "negl %0\n"
+ "negl %k0\n"
"3:"
:"=q" (__res), "=r" (cs), "=r" (ct)
:"1" (cs), "2" (ct)
@@ -147,11 +147,11 @@
"incl %2\n\t"
"testb %b0,%b0\n\t"
"jne 1b\n"
- "2:\txorl %0,%0\n\t"
+ "2:\txorl %k0,%k0\n\t"
"jmp 4f\n"
- "3:\tmovl $1,%0\n\t"
+ "3:\tmovl $1,%k0\n\t"
"jb 4f\n\t"
- "negl %0\n"
+ "negl %k0\n"
"4:"
:"=q" (__res), "=r" (cs), "=r" (ct), "=r" (count)
:"1" (cs), "2" (ct), "3" (count));
@@ -416,9 +416,11 @@

#define __HAVE_ARCH_MEMCPY
#define memcpy(d,s,count) \
-(__builtin_constant_p(count) ? \
- __memcpy_c((d),(s),(count)) : \
- __memcpy_g((d),(s),(count)))
+(count == 0 \
+ ? d \
+ : __builtin_constant_p(count) \
+ ? __memcpy_c((d),(s),(count)) \
+ : __memcpy_g((d),(s),(count)))

/*
* These ought to get tweaked to do some cache priming.
@@ -556,13 +558,15 @@

#define __HAVE_ARCH_MEMSET
#define memset(s,c,count) \
-(__builtin_constant_p(c) ? \
- (__builtin_constant_p(count) ? \
- __memset_cc((s),(c),(count)) : \
- __memset_cg((s),(c),(count))) : \
- (__builtin_constant_p(count) ? \
- __memset_gc((s),(c),(count)) : \
- __memset_gg((s),(c),(count))))
+(count == 0 \
+ ? s \
+ : __builtin_constant_p(c) \
+ ? __builtin_constant_p(count) \
+ ? __memset_cc((s),(c),(count)) \
+ : __memset_cg((s),(c),(count)) \
+ : __builtin_constant_p(count) \
+ ? __memset_gc((s),(c),(count)) \
+ : __memset_gg((s),(c),(count)))

extern inline void * __memset_cc_by4(void * s, char c, size_t count)
{
@@ -577,7 +581,7 @@
"decl %1\n\t"
"jnz 1b"
:"=r" (tmp), "=r" (dummy)
- :"q" (0x01010101UL * (unsigned char) c), "0" (tmp), "1" (count/4)
+ :"r" (0x01010101UL * (unsigned char) c), "0" (tmp), "1" (count/4)
:"memory");
return s;
}
@@ -595,7 +599,7 @@
"jnz 1b\n"
"2:\tmovw %w2,(%0)"
:"=r" (tmp), "=r" (dummy)
- :"q" (0x01010101UL * (unsigned char) c), "0" (tmp), "1" (count/2)
+ :"r" (0x01010101UL * (unsigned char) c), "0" (tmp), "1" (count/2)
:"memory");
return s;
}
@@ -607,9 +611,9 @@
__asm__ __volatile__ (
"movb %b0,%h0\n"
"pushw %w0\n\t"
- "shll $16,%0\n\t"
+ "shll $16,%k0\n\t"
"popw %w0\n"
- "1:\tmovl %0,(%1)\n\t"
+ "1:\tmovl %k0,(%1)\n\t"
"addl $4,%1\n\t"
"decl %2\n\t"
"jnz 1b\n"
@@ -628,9 +632,9 @@
"shrl $1,%2\n\t" /* may be divisible also by 4 */
"jz 2f\n\t"
"pushw %w0\n\t"
- "shll $16,%0\n\t"
+ "shll $16,%k0\n\t"
"popw %w0\n"
- "1:\tmovl %0,(%1)\n\t"
+ "1:\tmovl %k0,(%1)\n\t"
"addl $4,%1\n\t"
"decl %2\n\t"
"jnz 1b\n"
@@ -646,6 +650,7 @@
register void *tmp = (void *)s;
__asm__ __volatile__ (
"shrl $1,%%ecx\n\t"
+ "cld\n\t"
"rep\n\t"
"stosw\n\t"
"jnc 1f\n\t"
@@ -663,6 +668,7 @@
__asm__ __volatile__ (
"movb %%al,%%ah\n\t"
"shrl $1,%%ecx\n\t"
+ "cld\n\t"
"rep\n\t"
"stosw\n\t"
"jnc 1f\n\t"
diff -ur linux-2.1.79/include/linux/pagemap.h linux/include/linux/pagemap.h
--- linux-2.1.79/include/linux/pagemap.h Tue Jan 13 01:43:16 1998
+++ linux/include/linux/pagemap.h Wed Jan 14 20:25:06 1998
@@ -11,6 +11,7 @@

#include <linux/mm.h>
#include <linux/fs.h>
+#include <linux/swapctl.h>

static inline unsigned long page_address(struct page * page)
{
@@ -20,8 +21,6 @@
#define PAGE_HASH_BITS 11
#define PAGE_HASH_SIZE (1 << PAGE_HASH_BITS)

-#define PAGE_AGE_VALUE 16
-
extern unsigned long page_cache_size; /* # of pages currently in the hash table */
extern struct page * page_hash_table[PAGE_HASH_SIZE];

@@ -84,7 +83,7 @@
{
page_cache_size++;
set_bit(PG_referenced, &page->flags);
- page->age = PAGE_AGE_VALUE;
+ touch_page(page);
if((page->next_hash = *p) != NULL)
(*p)->pprev_hash = &page->next_hash;
*p = page;
diff -ur linux-2.1.79/mm/page_alloc.c linux/mm/page_alloc.c
--- linux-2.1.79/mm/page_alloc.c Mon Jan 12 23:33:20 1998
+++ linux/mm/page_alloc.c Tue Jan 13 17:08:26 1998
@@ -334,7 +334,8 @@
unsigned long page = __get_free_page(GFP_KERNEL);

if (pte_val(*page_table) != entry) {
- free_page(page);
+ if (page)
+ free_page(page);
return;
}
if (!page) {