Stephen Rothwell [Mon, 24 Mar 2003 00:20:13 +0000 (16:20 -0800)]
[PATCH] another fix for compat_ptr
This is the other part of the missing bits of the compat_ptr patch
pointed out to me by Andrew Morton and Dave Miller. This is just
the architectures I have permission to send you. Dave has sent you
his own already.
The problem turns out to be that q->backing_dev_info.memory_backed is not
initialized, leaving it to be whatever was there before. The end result is
that my "driver" never saw write requests, but reads came through fine.
Took a while to figure out that one...
Here's the fix, for what it's worth. (I had, BTW, tried just zeroing the
whole structure in blk_init_queue(), but that makes IDE oops at boot - it
sets q->queuedata early).
Stephen Rothwell [Sun, 23 Mar 2003 12:59:16 +0000 (04:59 -0800)]
[PATCH] compat_uptr_t and compat_ptr
This creates compat_uptr_t (to represent a user mode pointer passed to
the kernel other than as a syscall parameter) and compat_ptr() to
convert it to a kernel pointer.
This fixes a couple of bugs in s390x (where the conversion of pointers
actually does something).
swap.h is basically the header for MM internals instead of the
public API (mm_internal.h would have been a better name..). Stop
including it in mm.h - this only needs moving one function that
should be in swap.h anyway to the right place and fixing up a bunch
of places using it.
Ulrich Drepper [Sun, 23 Mar 2003 11:39:43 +0000 (03:39 -0800)]
[PATCH] more generic syscall return value type fixes
It was good to see the syscall return value types being fixed but still
some cases are missing. I attach a patch which fixes at least those
which cause problems to me in the moment.
Linus Torvalds [Sun, 23 Mar 2003 08:56:08 +0000 (00:56 -0800)]
Use '#ifdef' instead of '#if' to test CONFIG_xxxx variables. It works
both ways, but anal compilers will warn about using identifiers that
have never been defined in preprocessor expression statements.
Andrew Morton [Sat, 22 Mar 2003 15:35:06 +0000 (07:35 -0800)]
[PATCH] ext3: fix use-after-free bug
ext3_writepage() calls ext3_journal_stop(), which dereferences the affected
inode.
It does this _after_ writing the page out, which is illegal. The IO can
complete, the page can be repeased from the inode and the inode can be freed
up.
It's a long-standing bug. It has been reported happening on preemptible
kernels, where the timing window is larger.
Fix that up by teaching ext3_journal_stop to locate the superblock via the
journal structure, not via the inode.
This means that ext3_journal_stop() does not need the inode argument at all.
Also uninline the affected functions. It saves 5.5 kbytes.
Also remove the setting of sb->s_dirt in ext3_journal_stop(). That was an
awkward way of telling sys_sync() that the filesystem needs a commit, and
with the ext3_sync_fs() that is no longer needed.
Andrew Morton [Sat, 22 Mar 2003 15:34:59 +0000 (07:34 -0800)]
[PATCH] pagecache accounting speedup
From: Alex Tomas <bzzz@tmi.comex.ru>
This is the second half of the vm_enough_memory() speedup.
When overcommit_memory != 1, vm_enough_memory() calls get_page_state() to
calculate the amount of used pagecache. It does this on every call to
sys_brk().
get_page_state() is really expensive on SMP.
So the patch arranges for pagecache accounting to be in a global atomic_t,
with per-cpu batching and approximate accounting to amortise the cost of the
global atomic.
The nr_pagecache field of /proc/vmstat is removed.
Andrew Morton [Sat, 22 Mar 2003 15:34:50 +0000 (07:34 -0800)]
[PATCH] simplify the timer lockup avoidance code
From: george anzinger <george@mvista.com>
The recently-added code which avoids a lockup when a timer handler re-adds
the timer right now can be simplified.
If we change __run_timers() to increment base->timer_jiffies _before_ running
the timers, then any re-additions will not be inserted in the list which
__run_timers is presently walking.
Andrew Morton [Sat, 22 Mar 2003 15:34:35 +0000 (07:34 -0800)]
[PATCH] dev_t [3/3]: major.h cleanups
Patch from Andries.Brouwer@cwi.nl
The third patch removes the last occurrences of MAX_BLKDEV and MAX_CHRDEV and
sorts the majors in major.h. It also updates the definition of
SCSI_DISK_MAJOR.
so that the old register_chrdev registers a single major and 256 minors.
Later this can be changed (but see my letter to Al last week).
The only driver that is tricky is the tty driver. Here some major cleanup
happened - all tty specific stuff disappeared from char_dev.c, and tty uses
the actual register_chrdev_region() call.
There is a race in register_chrdev_region() that I did not worry about: when
two dynamic majors 0 are registered simultaneously, one of them will be first
and the other one gets -EBUSY. If this is a problem, the code there will
have to be uglified a little. I didn't do that because it disappears again
in a subsequent patch.
Andrew Morton [Sat, 22 Mar 2003 15:34:20 +0000 (07:34 -0800)]
[PATCH] dev_t [1/3]: kill cdev
Patch from Andries.Brouwer@cwi.nl
Now that 2.5.65 is out, the next dev_t patch. It was a bit large and
unreadable, so I split it into three clean pieces. Afterwards, since many
people ask for this, a fourth patch that actually changes the type of dev_t
(not to be applied yet, that is just for playing).
The first patch is the cdev-kill patch that I sent out earlier. It is no use
having two forms of chardev registration in the source, and my version of the
path of small modifications does not pass through this version, although the
final result will not be that different. So, kill cdev_cachep,
cdev_cache_init, cdfind, cdget, cdput, inode->i_cdev, struct char_device.
All of this is dead code today.
Andrew Morton [Sat, 22 Mar 2003 15:34:13 +0000 (07:34 -0800)]
[PATCH] mwave oops fixes
The mwave driver oopses if you do not have the hardware installed. It is
running device_unregister() and device_remove_file() against things whch were
never created.
Andrew Morton [Sat, 22 Mar 2003 15:33:43 +0000 (07:33 -0800)]
[PATCH] remove lock_kernel() from readdir implementations.
Filesystems which are using generic_file_llseek() do not need lock_kernel()
in their readir implementations. All operations (including llseek) are
serialised by the directory's i_sem.
Just fix ext2 and ext3 for now. Others may need locking between readdir and
who-knows-what.
Andrew Morton [Sat, 22 Mar 2003 15:33:34 +0000 (07:33 -0800)]
[PATCH] speed up vm_enough_memory()
This function is called a lot. Every brk(). The atomic_add() against a
global counter hurts on large SMP machines.
The patch simply reduces the rate at which that atomic operation is
performed, by accumulating a per-cpu count which is spilled into the global
counter when the local counter overflows.
It trades off efficiency for a little inaccuracy.
I tried various implementations involving kmalloc_percpu() and open-coded
per-cpu arrays in a generic "per-cpu counter" thing. They all were
surprisingly sucky - the additional cache misses involved in walking the more
complex data structures really showed up.
Andrew Morton [Sat, 22 Mar 2003 15:33:13 +0000 (07:33 -0800)]
[PATCH] inode a/c/mtime modification speedup
For some filesystems (ext3, reiserfs at least), ->dirty_inode() is very
expensive. The kernel is currently calling mark_inode_dirty() at up to 1000
times/sec/inode. But there is no need to do this if the filesystem cannot
store high-resolution times on-disk.
This patch restores the optimisation of only dirtying the filesystem inode
when its on-disk representation has actually changed.
The filesystem will set the MS_ONE_SECOND flag in sb->s_flags to indicate
that it wishes to receive this treatment.
The patch does reduce the call rate to ext3_mark_inode_dirty() from 1000/sec
to 1/sec, but it doesn't make much difference at all to performance because
we're calling ext3_mark_inode_dirty() from other callsites as well. Those
can be optimised too.
Andrew Morton [Sat, 22 Mar 2003 15:32:49 +0000 (07:32 -0800)]
[PATCH] filemap_populate speedup
filemap_populate() is currently doing page-at-a-time synchronous I/O. Add a
call to do_page_cache_readahead() in there so we do a big slurp of IO first.
This is minimal - a lot of the filemap_populate() code can be
rationalised yet.