Skip to content

Commit

Permalink
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/git/x86/linux-2.6-x86

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/x86/linux-2.6-x86:
  xen: fix UP setup of shared_info
  xen: fix RMW when unmasking events
  x86, documentation: nmi_watchdog=2 works on x86_64
  x86: stricter check in follow_huge_addr()
  rdc321x: GPIO routines bugfixes
  x86: ptrace.c: fix defined-but-unused warnings
  x86: fix prefetch workaround
  • Loading branch information
Linus Torvalds committed Mar 27, 2008
2 parents 074fcab + 2e8fe71 commit fb8c7fb
Show file tree
Hide file tree
Showing 10 changed files with 287 additions and 164 deletions.
3 changes: 1 addition & 2 deletions Documentation/nmi_watchdog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ kernel debugging options, such as Kernel Stack Meter or Kernel Tracer,
may implicitly disable the NMI watchdog.]

For x86-64, the needed APIC is always compiled in, and the NMI watchdog is
always enabled with I/O-APIC mode (nmi_watchdog=1). Currently, local APIC
mode (nmi_watchdog=2) does not work on x86-64.
always enabled with I/O-APIC mode (nmi_watchdog=1).

Using local APIC (nmi_watchdog=2) needs the first performance register, so
you can't use it for other purposes (such as high precision performance
Expand Down
169 changes: 85 additions & 84 deletions arch/x86/kernel/ptrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -600,21 +600,6 @@ static int ptrace_bts_read_record(struct task_struct *child,
return sizeof(ret);
}

static int ptrace_bts_write_record(struct task_struct *child,
const struct bts_struct *in)
{
int retval;

if (!child->thread.ds_area_msr)
return -ENXIO;

retval = ds_write_bts((void *)child->thread.ds_area_msr, in);
if (retval)
return retval;

return sizeof(*in);
}

static int ptrace_bts_clear(struct task_struct *child)
{
if (!child->thread.ds_area_msr)
Expand Down Expand Up @@ -657,75 +642,6 @@ static int ptrace_bts_drain(struct task_struct *child,
return end;
}

static int ptrace_bts_realloc(struct task_struct *child,
int size, int reduce_size)
{
unsigned long rlim, vm;
int ret, old_size;

if (size < 0)
return -EINVAL;

old_size = ds_get_bts_size((void *)child->thread.ds_area_msr);
if (old_size < 0)
return old_size;

ret = ds_free((void **)&child->thread.ds_area_msr);
if (ret < 0)
goto out;

size >>= PAGE_SHIFT;
old_size >>= PAGE_SHIFT;

current->mm->total_vm -= old_size;
current->mm->locked_vm -= old_size;

if (size == 0)
goto out;

rlim = current->signal->rlim[RLIMIT_AS].rlim_cur >> PAGE_SHIFT;
vm = current->mm->total_vm + size;
if (rlim < vm) {
ret = -ENOMEM;

if (!reduce_size)
goto out;

size = rlim - current->mm->total_vm;
if (size <= 0)
goto out;
}

rlim = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur >> PAGE_SHIFT;
vm = current->mm->locked_vm + size;
if (rlim < vm) {
ret = -ENOMEM;

if (!reduce_size)
goto out;

size = rlim - current->mm->locked_vm;
if (size <= 0)
goto out;
}

ret = ds_allocate((void **)&child->thread.ds_area_msr,
size << PAGE_SHIFT);
if (ret < 0)
goto out;

current->mm->total_vm += size;
current->mm->locked_vm += size;

out:
if (child->thread.ds_area_msr)
set_tsk_thread_flag(child, TIF_DS_AREA_MSR);
else
clear_tsk_thread_flag(child, TIF_DS_AREA_MSR);

return ret;
}

static int ptrace_bts_config(struct task_struct *child,
long cfg_size,
const struct ptrace_bts_config __user *ucfg)
Expand Down Expand Up @@ -828,6 +744,91 @@ static int ptrace_bts_status(struct task_struct *child,
return sizeof(cfg);
}


static int ptrace_bts_write_record(struct task_struct *child,
const struct bts_struct *in)
{
int retval;

if (!child->thread.ds_area_msr)
return -ENXIO;

retval = ds_write_bts((void *)child->thread.ds_area_msr, in);
if (retval)
return retval;

return sizeof(*in);
}

static int ptrace_bts_realloc(struct task_struct *child,
int size, int reduce_size)
{
unsigned long rlim, vm;
int ret, old_size;

if (size < 0)
return -EINVAL;

old_size = ds_get_bts_size((void *)child->thread.ds_area_msr);
if (old_size < 0)
return old_size;

ret = ds_free((void **)&child->thread.ds_area_msr);
if (ret < 0)
goto out;

size >>= PAGE_SHIFT;
old_size >>= PAGE_SHIFT;

current->mm->total_vm -= old_size;
current->mm->locked_vm -= old_size;

if (size == 0)
goto out;

rlim = current->signal->rlim[RLIMIT_AS].rlim_cur >> PAGE_SHIFT;
vm = current->mm->total_vm + size;
if (rlim < vm) {
ret = -ENOMEM;

if (!reduce_size)
goto out;

size = rlim - current->mm->total_vm;
if (size <= 0)
goto out;
}

rlim = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur >> PAGE_SHIFT;
vm = current->mm->locked_vm + size;
if (rlim < vm) {
ret = -ENOMEM;

if (!reduce_size)
goto out;

size = rlim - current->mm->locked_vm;
if (size <= 0)
goto out;
}

ret = ds_allocate((void **)&child->thread.ds_area_msr,
size << PAGE_SHIFT);
if (ret < 0)
goto out;

current->mm->total_vm += size;
current->mm->locked_vm += size;

out:
if (child->thread.ds_area_msr)
set_tsk_thread_flag(child, TIF_DS_AREA_MSR);
else
clear_tsk_thread_flag(child, TIF_DS_AREA_MSR);

return ret;
}

void ptrace_bts_take_timestamp(struct task_struct *tsk,
enum bts_qualifier qualifier)
{
Expand Down
Loading

0 comments on commit fb8c7fb

Please sign in to comment.