Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 176103
b: refs/heads/master
c: 42a2478
h: refs/heads/master
i:
  176101: f3e3489
  176099: 50d5b03
  176095: d6087fd
v: v3
  • Loading branch information
Michal Simek committed Dec 14, 2009
1 parent 77ccfb4 commit c434edb
Show file tree
Hide file tree
Showing 236 changed files with 4,268 additions and 12,040 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 37222e1c9ee3ce587f5b41fed868bd8a592a992f
refs/heads/master: 42a2478b789cb1b4335909e0fecc721c07be7d90
72 changes: 4 additions & 68 deletions trunk/Documentation/md.txt
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,9 @@ All md devices contain:

resync_start
The point at which resync should start. If no resync is needed,
this will be a very large number (or 'none' since 2.6.30-rc1). At
array creation it will default to 0, though starting the array as
'clean' will set it much larger.
this will be a very large number. At array creation it will
default to 0, though starting the array as 'clean' will
set it much larger.

new_dev
This file can be written but not read. The value written should
Expand Down Expand Up @@ -296,51 +296,6 @@ All md devices contain:
active-idle
like active, but no writes have been seen for a while (safe_mode_delay).

bitmap/location
This indicates where the write-intent bitmap for the array is
stored.
It can be one of "none", "file" or "[+-]N".
"file" may later be extended to "file:/file/name"
"[+-]N" means that many sectors from the start of the metadata.
This is replicated on all devices. For arrays with externally
managed metadata, the offset is from the beginning of the
device.
bitmap/chunksize
The size, in bytes, of the chunk which will be represented by a
single bit. For RAID456, it is a portion of an individual
device. For RAID10, it is a portion of the array. For RAID1, it
is both (they come to the same thing).
bitmap/time_base
The time, in seconds, between looking for bits in the bitmap to
be cleared. In the current implementation, a bit will be cleared
between 2 and 3 times "time_base" after all the covered blocks
are known to be in-sync.
bitmap/backlog
When write-mostly devices are active in a RAID1, write requests
to those devices proceed in the background - the filesystem (or
other user of the device) does not have to wait for them.
'backlog' sets a limit on the number of concurrent background
writes. If there are more than this, new writes will by
synchronous.
bitmap/metadata
This can be either 'internal' or 'external'.
'internal' is the default and means the metadata for the bitmap
is stored in the first 256 bytes of the allocated space and is
managed by the md module.
'external' means that bitmap metadata is managed externally to
the kernel (i.e. by some userspace program)
bitmap/can_clear
This is either 'true' or 'false'. If 'true', then bits in the
bitmap will be cleared when the corresponding blocks are thought
to be in-sync. If 'false', bits will never be cleared.
This is automatically set to 'false' if a write happens on a
degraded array, or if the array becomes degraded during a write.
When metadata is managed externally, it should be set to true
once the array becomes non-degraded, and this fact has been
recorded in the metadata.




As component devices are added to an md array, they appear in the 'md'
directory as new directories named
Expand Down Expand Up @@ -379,9 +334,8 @@ Each directory contains:
Writing "writemostly" sets the writemostly flag.
Writing "-writemostly" clears the writemostly flag.
Writing "blocked" sets the "blocked" flag.
Writing "-blocked" clears the "blocked" flag and allows writes
Writing "-blocked" clear the "blocked" flag and allows writes
to complete.
Writing "in_sync" sets the in_sync flag.

This file responds to select/poll. Any change to 'faulty'
or 'blocked' causes an event.
Expand Down Expand Up @@ -418,24 +372,6 @@ Each directory contains:
array. If a value less than the current component_size is
written, it will be rejected.

recovery_start

When the device is not 'in_sync', this records the number of
sectors from the start of the device which are known to be
correct. This is normally zero, but during a recovery
operation is will steadily increase, and if the recovery is
interrupted, restoring this value can cause recovery to
avoid repeating the earlier blocks. With v1.x metadata, this
value is saved and restored automatically.

This can be set whenever the device is not an active member of
the array, either before the array is activated, or before
the 'slot' is set.

Setting this to 'none' is equivalent to setting 'in_sync'.
Setting to any other value also clears the 'in_sync' flag.



An active md device will also contain and entry for each active device
in the array. These are named
Expand Down
184 changes: 100 additions & 84 deletions trunk/Documentation/spinlocks.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,87 @@
Lesson 1: Spin locks
SPIN_LOCK_UNLOCKED and RW_LOCK_UNLOCKED defeat lockdep state tracking and
are hence deprecated.

The most basic primitive for locking is spinlock.
Please use DEFINE_SPINLOCK()/DEFINE_RWLOCK() or
__SPIN_LOCK_UNLOCKED()/__RW_LOCK_UNLOCKED() as appropriate for static
initialization.

Most of the time, you can simply turn:

static spinlock_t xxx_lock = SPIN_LOCK_UNLOCKED;

into:

static DEFINE_SPINLOCK(xxx_lock);

Static structure member variables go from:

struct foo bar {
.lock = SPIN_LOCK_UNLOCKED;
};

to:

struct foo bar {
.lock = __SPIN_LOCK_UNLOCKED(bar.lock);
};

Declaration of static rw_locks undergo a similar transformation.

Dynamic initialization, when necessary, may be performed as
demonstrated below.

spinlock_t xxx_lock;
rwlock_t xxx_rw_lock;

static int __init xxx_init(void)
{
spin_lock_init(&xxx_lock);
rwlock_init(&xxx_rw_lock);
...
}

module_init(xxx_init);

The following discussion is still valid, however, with the dynamic
initialization of spinlocks or with DEFINE_SPINLOCK, etc., used
instead of SPIN_LOCK_UNLOCKED.

-----------------------

On Fri, 2 Jan 1998, Doug Ledford wrote:
>
> I'm working on making the aic7xxx driver more SMP friendly (as well as
> importing the latest FreeBSD sequencer code to have 7895 support) and wanted
> to get some info from you. The goal here is to make the various routines
> SMP safe as well as UP safe during interrupts and other manipulating
> routines. So far, I've added a spin_lock variable to things like my queue
> structs. Now, from what I recall, there are some spin lock functions I can
> use to lock these spin locks from other use as opposed to a (nasty)
> save_flags(); cli(); stuff; restore_flags(); construct. Where do I find
> these routines and go about making use of them? Do they only lock on a
> per-processor basis or can they also lock say an interrupt routine from
> mucking with a queue if the queue routine was manipulating it when the
> interrupt occurred, or should I still use a cli(); based construct on that
> one?

See <asm/spinlock.h>. The basic version is:

spinlock_t xxx_lock = SPIN_LOCK_UNLOCKED;

static DEFINE_SPINLOCK(xxx_lock);

unsigned long flags;

spin_lock_irqsave(&xxx_lock, flags);
... critical section here ..
spin_unlock_irqrestore(&xxx_lock, flags);

The above is always safe. It will disable interrupts _locally_, but the
and the above is always safe. It will disable interrupts _locally_, but the
spinlock itself will guarantee the global lock, so it will guarantee that
there is only one thread-of-control within the region(s) protected by that
lock. This works well even under UP. The above sequence under UP
essentially is just the same as doing
lock.

Note that it works well even under UP - the above sequence under UP
essentially is just the same as doing a

unsigned long flags;

Expand All @@ -24,13 +91,15 @@ essentially is just the same as doing

so the code does _not_ need to worry about UP vs SMP issues: the spinlocks
work correctly under both (and spinlocks are actually more efficient on
architectures that allow doing the "save_flags + cli" in one operation).

NOTE! Implications of spin_locks for memory are further described in:
architectures that allow doing the "save_flags + cli" in one go because I
don't export that interface normally).

Documentation/memory-barriers.txt
(5) LOCK operations.
(6) UNLOCK operations.
NOTE NOTE NOTE! The reason the spinlock is so much faster than a global
interrupt lock under SMP is exactly because it disables interrupts only on
the local CPU. The spin-lock is safe only when you _also_ use the lock
itself to do locking across CPU's, which implies that EVERYTHING that
touches a shared variable has to agree about the spinlock they want to
use.

The above is usually pretty simple (you usually need and want only one
spinlock for most things - using more than one spinlock can make things a
Expand All @@ -51,43 +120,35 @@ and another sequence that does
then they are NOT mutually exclusive, and the critical regions can happen
at the same time on two different CPU's. That's fine per se, but the
critical regions had better be critical for different things (ie they
can't stomp on each other).
can't stomp on each other).

The above is a problem mainly if you end up mixing code - for example the
routines in ll_rw_block() tend to use cli/sti to protect the atomicity of
their actions, and if a driver uses spinlocks instead then you should
think about issues like the above.
think about issues like the above..

This is really the only really hard part about spinlocks: once you start
using spinlocks they tend to expand to areas you might not have noticed
before, because you have to make sure the spinlocks correctly protect the
shared data structures _everywhere_ they are used. The spinlocks are most
easily added to places that are completely independent of other code (for
example, internal driver data structures that nobody else ever touches).

NOTE! The spin-lock is safe only when you _also_ use the lock itself
to do locking across CPU's, which implies that EVERYTHING that
touches a shared variable has to agree about the spinlock they want
to use.
easily added to places that are completely independent of other code (ie
internal driver data structures that nobody else ever touches, for
example).

----

Lesson 2: reader-writer spinlocks.

If your data accesses have a very natural pattern where you usually tend
to mostly read from the shared variables, the reader-writer locks
(rw_lock) versions of the spinlocks are sometimes useful. They allow multiple
(rw_lock) versions of the spinlocks are often nicer. They allow multiple
readers to be in the same critical region at once, but if somebody wants
to change the variables it has to get an exclusive write lock.

NOTE! reader-writer locks require more atomic memory operations than
simple spinlocks. Unless the reader critical section is long, you
are better off just using spinlocks.

The routines look the same as above:
to change the variables it has to get an exclusive write lock. The
routines look the same as above:

rwlock_t xxx_lock = RW_LOCK_UNLOCKED;


unsigned long flags;

read_lock_irqsave(&xxx_lock, flags);
Expand All @@ -98,21 +159,18 @@ The routines look the same as above:
.. read and write exclusive access to the info ...
write_unlock_irqrestore(&xxx_lock, flags);

The above kind of lock may be useful for complex data structures like
linked lists, especially searching for entries without changing the list
itself. The read lock allows many concurrent readers. Anything that
_changes_ the list will have to get the write lock.

NOTE! RCU is better for list traversal, but requires careful
attention to design detail (see Documentation/RCU/listRCU.txt).
The above kind of lock is useful for complex data structures like linked
lists etc, especially when you know that most of the work is to just
traverse the list searching for entries without changing the list itself,
for example. Then you can use the read lock for that kind of list
traversal, which allows many concurrent readers. Anything that _changes_
the list will have to get the write lock.

Also, you cannot "upgrade" a read-lock to a write-lock, so if you at _any_
Note: you cannot "upgrade" a read-lock to a write-lock, so if you at _any_
time need to do any changes (even if you don't do it every time), you have
to get the write-lock at the very beginning.

NOTE! We are working hard to remove reader-writer spinlocks in most
cases, so please don't add a new one without consensus. (Instead, see
Documentation/RCU/rcu.txt for complete information.)
to get the write-lock at the very beginning. I could fairly easily add a
primitive to create a "upgradeable" read-lock, but it hasn't been an issue
yet. Tell me if you'd want one.

----

Expand Down Expand Up @@ -175,46 +233,4 @@ indeed), while write-locks need to protect themselves against interrupts.

Linus

----

Reference information:

For dynamic initialization, use spin_lock_init() or rwlock_init() as
appropriate:

spinlock_t xxx_lock;
rwlock_t xxx_rw_lock;

static int __init xxx_init(void)
{
spin_lock_init(&xxx_lock);
rwlock_init(&xxx_rw_lock);
...
}

module_init(xxx_init);

For static initialization, use DEFINE_SPINLOCK() / DEFINE_RWLOCK() or
__SPIN_LOCK_UNLOCKED() / __RW_LOCK_UNLOCKED() as appropriate.

SPIN_LOCK_UNLOCKED and RW_LOCK_UNLOCKED are deprecated. These interfere
with lockdep state tracking.

Most of the time, you can simply turn:
static spinlock_t xxx_lock = SPIN_LOCK_UNLOCKED;
into:
static DEFINE_SPINLOCK(xxx_lock);

Static structure member variables go from:

struct foo bar {
.lock = SPIN_LOCK_UNLOCKED;
};

to:

struct foo bar {
.lock = __SPIN_LOCK_UNLOCKED(bar.lock);
};

Declaration of static rw_locks undergo a similar transformation.
5 changes: 4 additions & 1 deletion trunk/arch/arm/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,6 @@ config ARCH_SA1100
select ARCH_SPARSEMEM_ENABLE
select ARCH_MTD_XIP
select ARCH_HAS_CPUFREQ
select CPU_FREQ
select GENERIC_GPIO
select GENERIC_TIME
select GENERIC_CLOCKEVENTS
Expand Down Expand Up @@ -1360,9 +1359,13 @@ source "drivers/cpufreq/Kconfig"

config CPU_FREQ_SA1100
bool
depends on CPU_FREQ && (SA1100_H3100 || SA1100_H3600 || SA1100_LART || SA1100_PLEB || SA1100_BADGE4 || SA1100_HACKKIT)
default y

config CPU_FREQ_SA1110
bool
depends on CPU_FREQ && (SA1100_ASSABET || SA1100_CERF || SA1100_PT_SYSTEM3)
default y

config CPU_FREQ_INTEGRATOR
tristate "CPUfreq driver for ARM Integrator CPUs"
Expand Down
8 changes: 0 additions & 8 deletions trunk/arch/arm/Kconfig.debug
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,6 @@ config DEBUG_LL
in the kernel. This is helpful if you are debugging code that
executes before the console is initialized.

config EARLY_PRINTK
bool "Early printk"
depends on DEBUG_LL
help
Say Y here if you want to have an early console using the
kernel low-level debugging functions. Add earlyprintk to your
kernel parameters to enable this console.

config DEBUG_ICEDCC
bool "Kernel low-level debugging via EmbeddedICE DCC channel"
depends on DEBUG_LL
Expand Down
Loading

0 comments on commit c434edb

Please sign in to comment.