Staging
v0.8.1
v0.8.1
https://github.com/torvalds/linux
Revision c9d20af62c59e49684f3882503351153964ff14b authored by Linus Torvalds on 22 May 2006, 01:31:53 UTC, committed by Linus Torvalds on 22 May 2006, 01:31:53 UTC
* master.kernel.org:/pub/scm/linux/kernel/git/mchehab/v4l-dvb: (33 commits) V4L/DVB (3965): Fix CONFIG_VIDEO_VIVI=y build bug V4L/DVB (3964): Bt8xx/bttv-cards.c: fix off-by-one errors V4L/DVB (3914): Vivi build fix V4L/DVB (3912): Sparc32 vivi fix V4L/DVB (3832): Get_dvb_firmware: download nxt2002 firmware from new driver location V4L/DVB (3829): Fix frequency values in the ranges structures of the LG TDVS H06xF tuners V4L/DVB (3826): Saa7134: Missing 'break' in Terratec Cinergy 400 TV initialization V4L/DVB (3825): Remove broken 'fast firmware load' from cx25840. V4L/DVB (3819): Cxusb-bluebird: bug-fix: power down corrupts frontend V4L/DVB (3813): Add support for TCL M2523_5N_E tuner. V4L/DVB (3804): Tweak bandselect setup fox cx24123 V4L/DVB (3803): Various correctness fixes to tuning. V4L/DVB (3797): Always wait for diseqc queue to become ready before transmitting a diseqc message V4L/DVB (3796): Add several debug messages to cx24123 code V4L/DVB (3795): Fix for CX24123 & low symbol rates V4L/DVB (3792): Kbuild: DVB_BT8XX must select DVB_ZL10353 V4L/DVB (3790): Use after free in drivers/media/video/em28xx/em28xx-video.c V4L/DVB (3788): Fix compilation with V4L1_COMPAT V4L/DVB (3782): Removed uneeded stuff from pwc Makefile V4L/DVB (3775): Add VIVI Kconfig stuff ...
Tip revision: c9d20af62c59e49684f3882503351153964ff14b authored by Linus Torvalds on 22 May 2006, 01:31:53 UTC
Merge master.kernel.org:/pub/scm/linux/kernel/git/mchehab/v4l-dvb
Merge master.kernel.org:/pub/scm/linux/kernel/git/mchehab/v4l-dvb
Tip revision: c9d20af
thrash.c
/*
* mm/thrash.c
*
* Copyright (C) 2004, Red Hat, Inc.
* Copyright (C) 2004, Rik van Riel <riel@redhat.com>
* Released under the GPL, see the file COPYING for details.
*
* Simple token based thrashing protection, using the algorithm
* described in: http://www.cs.wm.edu/~sjiang/token.pdf
*/
#include <linux/jiffies.h>
#include <linux/mm.h>
#include <linux/sched.h>
#include <linux/swap.h>
static DEFINE_SPINLOCK(swap_token_lock);
static unsigned long swap_token_timeout;
static unsigned long swap_token_check;
struct mm_struct * swap_token_mm = &init_mm;
#define SWAP_TOKEN_CHECK_INTERVAL (HZ * 2)
#define SWAP_TOKEN_TIMEOUT (300 * HZ)
/*
* Currently disabled; Needs further code to work at HZ * 300.
*/
unsigned long swap_token_default_timeout = SWAP_TOKEN_TIMEOUT;
/*
* Take the token away if the process had no page faults
* in the last interval, or if it has held the token for
* too long.
*/
#define SWAP_TOKEN_ENOUGH_RSS 1
#define SWAP_TOKEN_TIMED_OUT 2
static int should_release_swap_token(struct mm_struct *mm)
{
int ret = 0;
if (!mm->recent_pagein)
ret = SWAP_TOKEN_ENOUGH_RSS;
else if (time_after(jiffies, swap_token_timeout))
ret = SWAP_TOKEN_TIMED_OUT;
mm->recent_pagein = 0;
return ret;
}
/*
* Try to grab the swapout protection token. We only try to
* grab it once every TOKEN_CHECK_INTERVAL, both to prevent
* SMP lock contention and to check that the process that held
* the token before is no longer thrashing.
*/
void grab_swap_token(void)
{
struct mm_struct *mm;
int reason;
/* We have the token. Let others know we still need it. */
if (has_swap_token(current->mm)) {
current->mm->recent_pagein = 1;
if (unlikely(!swap_token_default_timeout))
disable_swap_token();
return;
}
if (time_after(jiffies, swap_token_check)) {
if (!swap_token_default_timeout) {
swap_token_check = jiffies + SWAP_TOKEN_CHECK_INTERVAL;
return;
}
/* ... or if we recently held the token. */
if (time_before(jiffies, current->mm->swap_token_time))
return;
if (!spin_trylock(&swap_token_lock))
return;
swap_token_check = jiffies + SWAP_TOKEN_CHECK_INTERVAL;
mm = swap_token_mm;
if ((reason = should_release_swap_token(mm))) {
unsigned long eligible = jiffies;
if (reason == SWAP_TOKEN_TIMED_OUT) {
eligible += swap_token_default_timeout;
}
mm->swap_token_time = eligible;
swap_token_timeout = jiffies + swap_token_default_timeout;
swap_token_mm = current->mm;
}
spin_unlock(&swap_token_lock);
}
return;
}
/* Called on process exit. */
void __put_swap_token(struct mm_struct *mm)
{
spin_lock(&swap_token_lock);
if (likely(mm == swap_token_mm)) {
mm->swap_token_time = jiffies + SWAP_TOKEN_CHECK_INTERVAL;
swap_token_mm = &init_mm;
swap_token_check = jiffies;
}
spin_unlock(&swap_token_lock);
}
Computing file changes ...