Commit Graph

1564 Commits

Author SHA1 Message Date
黄涛
70c481fac3 Merge remote-tracking branch 'stable/linux-3.0.y' into develop-3.0
Conflicts:
	Makefile
2012-10-15 11:56:57 +08:00
Srivatsa S. Bhat
8f48f1a28e CPU hotplug, cpusets, suspend: Don't modify cpusets during suspend/resume
commit d35be8bab9 upstream.

In the event of CPU hotplug, the kernel modifies the cpusets' cpus_allowed
masks as and when necessary to ensure that the tasks belonging to the cpusets
have some place (online CPUs) to run on. And regular CPU hotplug is
destructive in the sense that the kernel doesn't remember the original cpuset
configurations set by the user, across hotplug operations.

However, suspend/resume (which uses CPU hotplug) is a special case in which
the kernel has the responsibility to restore the system (during resume), to
exactly the same state it was in before suspend.

In order to achieve that, do the following:

1. Don't modify cpusets during suspend/resume. At all.
   In particular, don't move the tasks from one cpuset to another, and
   don't modify any cpuset's cpus_allowed mask. So, simply ignore cpusets
   during the CPU hotplug operations that are carried out in the
   suspend/resume path.

2. However, cpusets and sched domains are related. We just want to avoid
   altering cpusets alone. So, to keep the sched domains updated, build
   a single sched domain (containing all active cpus) during each of the
   CPU hotplug operations carried out in s/r path, effectively ignoring
   the cpusets' cpus_allowed masks.

   (Since userspace is frozen while doing all this, it will go unnoticed.)

3. During the last CPU online operation during resume, build the sched
   domains by looking up the (unaltered) cpusets' cpus_allowed masks.
   That will bring back the system to the same original state as it was in
   before suspend.

Ultimately, this will not only solve the cpuset problem related to suspend
resume (ie., restores the cpusets to exactly what it was before suspend, by
not touching it at all) but also speeds up suspend/resume because we avoid
running cpuset update code for every CPU being offlined/onlined.

Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20120524141611.3692.20155.stgit@srivatsabhat.in.ibm.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Preeti U Murthy <preeti@linux.vnet.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-10-13 05:28:15 +09:00
黄涛
21158e22d9 Merge remote-tracking branch 'stable/linux-3.0.y' into develop-3.0
Conflicts:
	Makefile
	drivers/mmc/core/sd.c
	drivers/net/usb/asix.c
	drivers/net/wireless/ath/ath9k/recv.c
	drivers/net/wireless/b43legacy/main.c
	drivers/net/wireless/p54/p54usb.c
	drivers/net/wireless/rt2x00/rt2400pci.c
	drivers/net/wireless/rt2x00/rt2400pci.h
	drivers/net/wireless/rt2x00/rt2500pci.c
	drivers/net/wireless/rt2x00/rt2500usb.c
	drivers/net/wireless/rt2x00/rt2500usb.h
	drivers/net/wireless/rt2x00/rt2800pci.c
	drivers/net/wireless/rt2x00/rt2800usb.c
	drivers/net/wireless/rt2x00/rt61pci.c
	drivers/net/wireless/rt2x00/rt61pci.h
	drivers/net/wireless/rt2x00/rt73usb.c
	drivers/net/wireless/rt2x00/rt73usb.h
	drivers/net/wireless/rtl818x/rtl8187/dev.c
	drivers/usb/serial/option.c
	kernel/time/timekeeping.c
2012-10-08 10:28:29 +08:00
Peter Zijlstra
64ac72f81b sched: Fix race in task_group()
commit 8323f26ce3 upstream.

Stefan reported a crash on a kernel before a3e5d1091c ("sched:
Don't call task_group() too many times in set_task_rq()"), he
found the reason to be that the multiple task_group()
invocations in set_task_rq() returned different values.

Looking at all that I found a lack of serialization and plain
wrong comments.

The below tries to fix it using an extra pointer which is
updated under the appropriate scheduler locks. Its not pretty,
but I can't really see another way given how all the cgroup
stuff works.

Reported-and-tested-by: Stefan Bader <stefan.bader@canonical.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1340364965.18025.71.camel@twins
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-10-02 09:47:42 -07:00
黄涛
a2ad9f9801 Merge remote-tracking branch 'stable/linux-3.0.y' into develop-3.0-jb
Conflicts:
	drivers/net/usb/asix.c
	drivers/net/wireless/iwlwifi/iwl-agn-rs.c
	drivers/usb/serial/option.c
2012-07-12 18:46:41 +08:00
黄涛
30be6d7972 Merge remote-tracking branch 'common/android-3.0' into develop-3.0-jb
Conflicts:
	drivers/cpufreq/cpufreq_interactive.c
	drivers/misc/pmem.c
	drivers/net/usb/asix.c
	drivers/net/wireless/ath/ath9k/ani.c
	drivers/net/wireless/ath/ath9k/ar5008_phy.c
	drivers/net/wireless/ath/ath9k/ar9002_hw.c
	drivers/net/wireless/ath/ath9k/ar9003_calib.c
	drivers/net/wireless/ath/ath9k/ar9003_mac.c
	drivers/net/wireless/ath/ath9k/ar9003_phy.h
	drivers/net/wireless/ath/ath9k/calib.c
	drivers/net/wireless/ath/ath9k/hif_usb.c
	drivers/net/wireless/ath/ath9k/hw.c
	drivers/net/wireless/ath/ath9k/hw.h
	drivers/net/wireless/ath/ath9k/main.c
	drivers/net/wireless/ath/ath9k/rc.c
	drivers/net/wireless/ath/ath9k/recv.c
	drivers/net/wireless/b43/main.c
	drivers/net/wireless/bcm4319/aiutils.c
	drivers/net/wireless/bcm4319/bcmsdh.c
	drivers/net/wireless/bcm4319/bcmsdh_linux.c
	drivers/net/wireless/bcm4319/bcmsdh_sdmmc.c
	drivers/net/wireless/bcm4319/bcmsdh_sdmmc_linux.c
	drivers/net/wireless/bcm4319/bcmutils.c
	drivers/net/wireless/bcm4319/dhd_common.c
	drivers/net/wireless/bcm4319/dhd_proto.h
	drivers/net/wireless/bcm4319/dhd_sdio.c
	drivers/net/wireless/bcm4319/hndpmu.c
	drivers/net/wireless/bcm4319/include/aidmp.h
	drivers/net/wireless/bcm4319/include/bcmcdc.h
	drivers/net/wireless/bcm4319/include/bcmdefs.h
	drivers/net/wireless/bcm4319/include/bcmdevs.h
	drivers/net/wireless/bcm4319/include/bcmendian.h
	drivers/net/wireless/bcm4319/include/bcmpcispi.h
	drivers/net/wireless/bcm4319/include/bcmperf.h
	drivers/net/wireless/bcm4319/include/bcmsdbus.h
	drivers/net/wireless/bcm4319/include/bcmsdh.h
	drivers/net/wireless/bcm4319/include/bcmsdh_sdmmc.h
	drivers/net/wireless/bcm4319/include/bcmsdpcm.h
	drivers/net/wireless/bcm4319/include/bcmsdspi.h
	drivers/net/wireless/bcm4319/include/bcmsdstd.h
	drivers/net/wireless/bcm4319/include/bcmspi.h
	drivers/net/wireless/bcm4319/include/bcmutils.h
	drivers/net/wireless/bcm4319/include/bcmwifi.h
	drivers/net/wireless/bcm4319/include/dhdioctl.h
	drivers/net/wireless/bcm4319/include/epivers.h
	drivers/net/wireless/bcm4319/include/hndpmu.h
	drivers/net/wireless/bcm4319/include/hndrte_armtrap.h
	drivers/net/wireless/bcm4319/include/hndrte_cons.h
	drivers/net/wireless/bcm4319/include/hndsoc.h
	drivers/net/wireless/bcm4319/include/linux_osl.h
	drivers/net/wireless/bcm4319/include/linuxver.h
	drivers/net/wireless/bcm4319/include/miniopt.h
	drivers/net/wireless/bcm4319/include/msgtrace.h
	drivers/net/wireless/bcm4319/include/osl.h
	drivers/net/wireless/bcm4319/include/packed_section_end.h
	drivers/net/wireless/bcm4319/include/packed_section_start.h
	drivers/net/wireless/bcm4319/include/pcicfg.h
	drivers/net/wireless/bcm4319/include/proto/802.11e.h
	drivers/net/wireless/bcm4319/include/proto/802.1d.h
	drivers/net/wireless/bcm4319/include/proto/bcmeth.h
	drivers/net/wireless/bcm4319/include/proto/bcmevent.h
	drivers/net/wireless/bcm4319/include/proto/bcmip.h
	drivers/net/wireless/bcm4319/include/proto/eapol.h
	drivers/net/wireless/bcm4319/include/proto/ethernet.h
	drivers/net/wireless/bcm4319/include/proto/sdspi.h
	drivers/net/wireless/bcm4319/include/proto/vlan.h
	drivers/net/wireless/bcm4319/include/proto/wpa.h
	drivers/net/wireless/bcm4319/include/sbchipc.h
	drivers/net/wireless/bcm4319/include/sbconfig.h
	drivers/net/wireless/bcm4319/include/sbhnddma.h
	drivers/net/wireless/bcm4319/include/sbpcmcia.h
	drivers/net/wireless/bcm4319/include/sbsdio.h
	drivers/net/wireless/bcm4319/include/sbsdpcmdev.h
	drivers/net/wireless/bcm4319/include/sbsocram.h
	drivers/net/wireless/bcm4319/include/sdio.h
	drivers/net/wireless/bcm4319/include/sdioh.h
	drivers/net/wireless/bcm4319/include/sdiovar.h
	drivers/net/wireless/bcm4319/include/siutils.h
	drivers/net/wireless/bcm4319/include/trxhdr.h
	drivers/net/wireless/bcm4319/include/typedefs.h
	drivers/net/wireless/bcm4319/siutils.c
	drivers/net/wireless/bcm4319/wl_iw.c
	drivers/net/wireless/bcm4319/wl_iw.h
	drivers/net/wireless/bcmdhd/Kconfig
	drivers/net/wireless/bcmdhd/Makefile
	drivers/net/wireless/bcmdhd/bcmevent.c
	drivers/net/wireless/bcmdhd/dhd.h
	drivers/net/wireless/bcmdhd/dhd_cdc.c
	drivers/net/wireless/bcmdhd/dhd_linux.c
	drivers/net/wireless/bcmdhd/dhd_wlfc.h
	drivers/net/wireless/bcmdhd/include/Makefile
	drivers/net/wireless/bcmdhd/include/htsf.h
	drivers/net/wireless/bcmdhd/include/proto/802.11.h
	drivers/net/wireless/bcmdhd/include/proto/802.11_bta.h
	drivers/net/wireless/bcmdhd/include/proto/bt_amp_hci.h
	drivers/net/wireless/bcmdhd/include/proto/p2p.h
	drivers/net/wireless/bcmdhd/include/wlfc_proto.h
	drivers/net/wireless/bcmdhd/include/wlioctl.h
	drivers/net/wireless/bcmdhd/linux_osl.c
	drivers/net/wireless/bcmdhd/wl_android.c
	drivers/net/wireless/bcmdhd/wl_android.h
	drivers/net/wireless/bcmdhd/wl_cfg80211.c
	drivers/net/wireless/bcmdhd/wl_cfg80211.h
	drivers/net/wireless/bcmdhd/wl_cfgp2p.c
	drivers/net/wireless/bcmdhd/wl_cfgp2p.h
	drivers/net/wireless/bcmdhd/wl_linux_mon.c
	drivers/net/wireless/bcmdhd/wldev_common.c
	drivers/net/wireless/bcmdhd/wldev_common.h
	drivers/net/wireless/ipw2x00/ipw2200.c
	drivers/net/wireless/iwlwifi/iwl-agn-lib.c
	drivers/net/wireless/iwlwifi/iwl-agn-tx.c
	drivers/net/wireless/iwlwifi/iwl-agn-ucode.c
	drivers/net/wireless/iwlwifi/iwl-agn.c
	drivers/net/wireless/iwlwifi/iwl-agn.h
	drivers/net/wireless/iwlwifi/iwl-core.c
	drivers/net/wireless/iwlwifi/iwl-hcmd.c
	drivers/net/wireless/iwlwifi/iwl-rx.c
	drivers/net/wireless/iwlwifi/iwl-tx.c
	drivers/net/wireless/libertas/if_spi.c
	drivers/net/wireless/p54/p54spi.c
	drivers/net/wireless/rt2x00/rt2800lib.c
	drivers/net/wireless/rt2x00/rt2800pci.c
	drivers/net/wireless/rt2x00/rt2800usb.c
	drivers/net/wireless/rt2x00/rt2x00.h
	drivers/net/wireless/rt2x00/rt2x00dev.c
	drivers/net/wireless/rt2x00/rt2x00mac.c
	drivers/net/wireless/rt2x00/rt2x00queue.c
	drivers/usb/serial/option.c
2012-07-12 18:08:01 +08:00
黄涛
dbc0fca461 sched: Cleanup cpu_active madness
commit 5fbd036b55 upstream.

Stepan found:

CPU0		CPUn

_cpu_up()
  __cpu_up()

		boostrap()
		  notify_cpu_starting()
		  set_cpu_online()
		  while (!cpu_active())
		    cpu_relax()

<PREEMPT-out>

smp_call_function(.wait=1)
  /* we find cpu_online() is true */
  arch_send_call_function_ipi_mask()

  /* wait-forever-more */

<PREEMPT-in>
		  local_irq_enable()

  cpu_notify(CPU_ONLINE)
    sched_cpu_active()
      set_cpu_active()

Now the purpose of cpu_active is mostly with bringing down a cpu, where
we mark it !active to avoid the load-balancer from moving tasks to it
while we tear down the cpu. This is required because we only update the
sched_domain tree after we brought the cpu-down. And this is needed so
that some tasks can still run while we bring it down, we just don't want
new tasks to appear.

On cpu-up however the sched_domain tree doesn't yet include the new cpu,
so its invisible to the load-balancer, regardless of the active state.
So instead of setting the active state after we boot the new cpu (and
consequently having to wait for it before enabling interrupts) set the
cpu active before we set it online and avoid the whole mess.
2012-07-12 09:49:51 +08:00
Dimitri Sivanich
34b1a9eb1d sched: Fix the relax_domain_level boot parameter
commit a841f8cef4 upstream.

It does not get processed because sched_domain_level_max is 0 at the
time that setup_relax_domain_level() is run.

Simply accept the value as it is, as we don't know the value of
sched_domain_level_max until sched domain construction is completed.

Fix sched_relax_domain_level in cpuset.  The build_sched_domain() routine calls
the set_domain_attribute() routine prior to setting the sd->level, however,
the set_domain_attribute() routine relies on the sd->level to decide whether
idle load balancing will be off/on.

Signed-off-by: Dimitri Sivanich <sivanich@sgi.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/20120605184436.GA15668@sgi.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-06-17 11:23:12 -07:00
Todd Poynor
52f91d889a Merge commit 'v3.0.31' into android-3.0 2012-05-08 11:36:40 -07:00
Peter Zijlstra
7bfac470b5 sched: Fix nohz load accounting -- again!
commit c308b56b53 upstream.
[ backported to 3.0 by Kerin Millar <kerframil@gmail.com>]

Various people reported nohz load tracking still being wrecked, but Doug
spotted the actual problem. We fold the nohz remainder in too soon,
causing us to loose samples and under-account.

So instead of playing catch-up up-front, always do a single load-fold
with whatever state we encounter and only then fold the nohz remainder
and play catch-up.

Reported-by: Doug Smythies <dsmythies@telus.net>
Reported-by: LesÅ=82aw Kope=C4=87 <leslaw.kopec@nasza-klasa.pl>
Reported-by: Aman Gupta <aman@tmm1.net>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/n/tip-4v31etnhgg9kwd6ocgx3rxl8@git.kernel.org
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Cc: Kerin Millar <kerframil@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-05-07 08:56:50 -07:00
Colin Cross
2bb3e31015 Merge commit 'v3.0.8' into android-3.0 2011-10-27 15:01:19 -07:00
Peter Zijlstra
249cf808ba posix-cpu-timers: Cure SMP wobbles
commit d670ec1317 upstream.

David reported:

  Attached below is a watered-down version of rt/tst-cpuclock2.c from
  GLIBC.  Just build it with "gcc -o test test.c -lpthread -lrt" or
  similar.

  Run it several times, and you will see cases where the main thread
  will measure a process clock difference before and after the nanosleep
  which is smaller than the cpu-burner thread's individual thread clock
  difference.  This doesn't make any sense since the cpu-burner thread
  is part of the top-level process's thread group.

  I've reproduced this on both x86-64 and sparc64 (using both 32-bit and
  64-bit binaries).

  For example:

  [davem@boricha build-x86_64-linux]$ ./test
  process: before(0.001221967) after(0.498624371) diff(497402404)
  thread:  before(0.000081692) after(0.498316431) diff(498234739)
  self:    before(0.001223521) after(0.001240219) diff(16698)
  [davem@boricha build-x86_64-linux]$

  The diff of 'process' should always be >= the diff of 'thread'.

  I make sure to wrap the 'thread' clock measurements the most tightly
  around the nanosleep() call, and that the 'process' clock measurements
  are the outer-most ones.

  ---
  #include <unistd.h>
  #include <stdio.h>
  #include <stdlib.h>
  #include <time.h>
  #include <fcntl.h>
  #include <string.h>
  #include <errno.h>
  #include <pthread.h>

  static pthread_barrier_t barrier;

  static void *chew_cpu(void *arg)
  {
	  pthread_barrier_wait(&barrier);
	  while (1)
		  __asm__ __volatile__("" : : : "memory");
	  return NULL;
  }

  int main(void)
  {
	  clockid_t process_clock, my_thread_clock, th_clock;
	  struct timespec process_before, process_after;
	  struct timespec me_before, me_after;
	  struct timespec th_before, th_after;
	  struct timespec sleeptime;
	  unsigned long diff;
	  pthread_t th;
	  int err;

	  err = clock_getcpuclockid(0, &process_clock);
	  if (err)
		  return 1;

	  err = pthread_getcpuclockid(pthread_self(), &my_thread_clock);
	  if (err)
		  return 1;

	  pthread_barrier_init(&barrier, NULL, 2);
	  err = pthread_create(&th, NULL, chew_cpu, NULL);
	  if (err)
		  return 1;

	  err = pthread_getcpuclockid(th, &th_clock);
	  if (err)
		  return 1;

	  pthread_barrier_wait(&barrier);

	  err = clock_gettime(process_clock, &process_before);
	  if (err)
		  return 1;

	  err = clock_gettime(my_thread_clock, &me_before);
	  if (err)
		  return 1;

	  err = clock_gettime(th_clock, &th_before);
	  if (err)
		  return 1;

	  sleeptime.tv_sec = 0;
	  sleeptime.tv_nsec = 500000000;
	  nanosleep(&sleeptime, NULL);

	  err = clock_gettime(th_clock, &th_after);
	  if (err)
		  return 1;

	  err = clock_gettime(my_thread_clock, &me_after);
	  if (err)
		  return 1;

	  err = clock_gettime(process_clock, &process_after);
	  if (err)
		  return 1;

	  diff = process_after.tv_nsec - process_before.tv_nsec;
	  printf("process: before(%lu.%.9lu) after(%lu.%.9lu) diff(%lu)\n",
		 process_before.tv_sec, process_before.tv_nsec,
		 process_after.tv_sec, process_after.tv_nsec, diff);
	  diff = th_after.tv_nsec - th_before.tv_nsec;
	  printf("thread:  before(%lu.%.9lu) after(%lu.%.9lu) diff(%lu)\n",
		 th_before.tv_sec, th_before.tv_nsec,
		 th_after.tv_sec, th_after.tv_nsec, diff);
	  diff = me_after.tv_nsec - me_before.tv_nsec;
	  printf("self:    before(%lu.%.9lu) after(%lu.%.9lu) diff(%lu)\n",
		 me_before.tv_sec, me_before.tv_nsec,
		 me_after.tv_sec, me_after.tv_nsec, diff);

	  return 0;
  }

This is due to us using p->se.sum_exec_runtime in
thread_group_cputime() where we iterate the thread group and sum all
data. This does not take time since the last schedule operation (tick
or otherwise) into account. We can cure this by using
task_sched_runtime() at the cost of having to take locks.

This also means we can (and must) do away with
thread_group_sched_runtime() since the modified thread_group_cputime()
is now more accurate and would deadlock when called from
thread_group_sched_runtime().

Aside of that it makes the function safe on 32 bit systems. The old
code added t->se.sum_exec_runtime unprotected. sum_exec_runtime is a
64bit value and could be changed on another cpu at the same time.

Reported-by: David Miller <davem@davemloft.net>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1314874459.7945.22.camel@twins
Tested-by: David Miller <davem@davemloft.net>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-10-16 14:14:51 -07:00
Simon Kirby
4e41ce6988 sched: Fix up wchan borkage
commit 6ebbe7a07b upstream.

Commit c259e01a1e ("sched: Separate the scheduler entry for
preemption") contained a boo-boo wrecking wchan output. It forgot to
put the new schedule() function in the __sched section and thereby
doesn't get properly ignored for things like wchan.

Tested-by: Simon Kirby <sim@hostway.ca>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/20110923000346.GA25425@hostway.ca
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-10-16 14:14:51 -07:00
WANG Cong
70a4888b98 sched: Fix a memory leak in __sdt_free()
commit feff8fa007 upstream.

This patch fixes the following memory leak:

unreferenced object 0xffff880107266800 (size 512):
  comm "sched-powersave", pid 3718, jiffies 4323097853 (age 27495.450s)
  hex dump (first 32 bytes):
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [<ffffffff81133940>] create_object+0x187/0x28b
    [<ffffffff814ac103>] kmemleak_alloc+0x73/0x98
    [<ffffffff811232ba>] __kmalloc_node+0x104/0x159
    [<ffffffff81044b98>] kzalloc_node.clone.97+0x15/0x17
    [<ffffffff8104cb90>] build_sched_domains+0xb7/0x7f3
    [<ffffffff8104d4df>] partition_sched_domains+0x1db/0x24a
    [<ffffffff8109ee4a>] do_rebuild_sched_domains+0x3b/0x47
    [<ffffffff810a00c7>] rebuild_sched_domains+0x10/0x12
    [<ffffffff8104d5ba>] sched_power_savings_store+0x6c/0x7b
    [<ffffffff8104d5df>] sched_mc_power_savings_store+0x16/0x18
    [<ffffffff8131322c>] sysdev_class_store+0x20/0x22
    [<ffffffff81193876>] sysfs_write_file+0x108/0x144
    [<ffffffff81135b10>] vfs_write+0xaf/0x102
    [<ffffffff81135d23>] sys_write+0x4d/0x74
    [<ffffffff814c8a42>] system_call_fastpath+0x16/0x1b
    [<ffffffffffffffff>] 0xffffffffffffffff

Signed-off-by: WANG Cong <amwang@redhat.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1313671017-4112-1-git-send-email-amwang@redhat.com
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-10-03 11:40:09 -07:00
Thomas Gleixner
f4e97b682a sched: Move blk_schedule_flush_plug() out of __schedule()
commit 9c40cef2b7 upstream.

There is no real reason to run blk_schedule_flush_plug() with
interrupts and preemption disabled.

Move it into schedule() and call it when the task is going voluntarily
to sleep. There might be false positives when the task is woken
between that call and actually scheduling, but that's not really
different from being woken immediately after switching away.

This fixes a deadlock in the scheduler where the
blk_schedule_flush_plug() callchain enables interrupts and thereby
allows a wakeup to happen of the task that's going to sleep.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Tejun Heo <tj@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: http://lkml.kernel.org/n/tip-dwfxtra7yg1b5r65m32ywtct@git.kernel.org
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-10-03 11:40:09 -07:00
Thomas Gleixner
edbb7ce79e sched: Separate the scheduler entry for preemption
commit c259e01a1e upstream.

Block-IO and workqueues call into notifier functions from the
scheduler core code with interrupts and preemption disabled. These
calls should be made before entering the scheduler core.

To simplify this, separate the scheduler core code into
__schedule(). __schedule() is directly called from the places which
set PREEMPT_ACTIVE and from schedule(). This allows us to add the work
checks into schedule(), so they are only called when a task voluntary
goes to sleep.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Tejun Heo <tj@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: http://lkml.kernel.org/r/20110622174918.813258321@linutronix.de
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-10-03 11:40:08 -07:00
Colin Cross
4e111751cf Merge commit 'v3.0' into android-3.0 2011-08-10 18:04:30 -07:00
Linus Torvalds
cf6ace16a3 Merge branch 'core-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'core-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
  signal: align __lock_task_sighand() irq disabling and RCU
  softirq,rcu: Inform RCU of irq_exit() activity
  sched: Add irq_{enter,exit}() to scheduler_ipi()
  rcu: protect __rcu_read_unlock() against scheduler-using irq handlers
  rcu: Streamline code produced by __rcu_read_unlock()
  rcu: Fix RCU_BOOST race handling current->rcu_read_unlock_special
  rcu: decrease rcu_report_exp_rnp coupling with scheduler
2011-07-20 15:56:25 -07:00
Ingo Molnar
d1e9ae47a0 Merge branch 'rcu/urgent' of git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-2.6-rcu into core/urgent 2011-07-20 20:59:26 +02:00
Peter Zijlstra
c5d753a55a sched: Add irq_{enter,exit}() to scheduler_ipi()
Ensure scheduler_ipi() calls irq_{enter,exit} when it does some actual
work. Traditionally we never did any actual work from the resched IPI
and all magic happened in the return from interrupt path.

Now that we do do some work, we need to ensure irq_{enter,exit} are
called so that we don't confuse things.

This affects things like timekeeping, NO_HZ and RCU, basically
everything with a hook in irq_enter/exit.

Explicit examples of things going wrong are:

  sched_clock_cpu() -- has a callback when leaving NO_HZ state to take
                    a new reading from GTOD and TSC. Without this
                    callback, time is stuck in the past.

  RCU -- needs in_irq() to work in order to avoid some nasty deadlocks

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
2011-07-20 10:50:11 -07:00
Peter Zijlstra
d110235d2c sched: Avoid creating superfluous NUMA domains on non-NUMA systems
When creating sched_domains, stop when we've covered the entire
target span instead of continuing to create domains, only to
later find they're redundant and throw them away again.

This avoids single node systems from touching funny NUMA
sched_domain creation code and reduces the risks of the new
SD_OVERLAP code.

Requested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Anton Blanchard <anton@samba.org>
Cc: mahesh@linux.vnet.ibm.com
Cc: benh@kernel.crashing.org
Cc: linuxppc-dev@lists.ozlabs.org
Link: http://lkml.kernel.org/r/1311180177.29152.57.camel@twins
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2011-07-20 18:54:33 +02:00
Peter Zijlstra
e3589f6c81 sched: Allow for overlapping sched_domain spans
Allow for sched_domain spans that overlap by giving such domains their
own sched_group list instead of sharing the sched_groups amongst
each-other.

This is needed for machines with more than 16 nodes, because
sched_domain_node_span() will generate a node mask from the
16 nearest nodes without regard if these masks have any overlap.

Currently sched_domains have a sched_group that maps to their child
sched_domain span, and since there is no overlap we share the
sched_group between the sched_domains of the various CPUs. If however
there is overlap, we would need to link the sched_group list in
different ways for each cpu, and hence sharing isn't possible.

In order to solve this, allocate private sched_groups for each CPU's
sched_domain but have the sched_groups share a sched_group_power
structure such that we can uniquely track the power.

Reported-and-tested-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Link: http://lkml.kernel.org/n/tip-08bxqw9wis3qti9u5inifh3y@git.kernel.org
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2011-07-20 18:32:41 +02:00
Peter Zijlstra
9c3f75cbd1 sched: Break out cpu_power from the sched_group structure
In order to prepare for non-unique sched_groups per domain, we need to
carry the cpu_power elsewhere, so put a level of indirection in.

Reported-and-tested-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Link: http://lkml.kernel.org/n/tip-qkho2byuhe4482fuknss40ad@git.kernel.org
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2011-07-20 18:32:40 +02:00
Peter Zijlstra
c64be78ffb sched: Fix 32bit race
Commit 3fe1698b7f ("sched: Deal with non-atomic min_vruntime reads
on 32bit") forgot to initialize min_vruntime_copy which could lead to
an infinite while loop in task_waking_fair() under some circumstances
(early boot, lucky timing).

[ This bug was also reported by others that blamed it on the RCU
  initialization problems ]

Reported-and-tested-by: Bruno Wolff III <bruno@wolff.to>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Reviewed-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-07-15 09:54:02 -07:00
Colin Cross
bb5b603036 cgroup: Add generic cgroup subsystem permission checks
Rather than using explicit euid == 0 checks when trying to move
tasks into a cgroup via CFS, move permission checks into each
specific cgroup subsystem. If a subsystem does not specify a
'allow_attach' handler, then we fall back to doing our checks
the old way.

Use the 'allow_attach' handler for the 'cpu' cgroup to allow
non-root processes to add arbitrary processes to a 'cpu' cgroup
if it has the CAP_SYS_NICE capability set.

This version of the patch adds a 'allow_attach' handler instead
of reusing the 'can_attach' handler.  If the 'can_attach' handler
is reused, a new cgroup that implements 'can_attach' but not
the permission checks could end up with no permission checks
at all.

Change-Id: Icfa950aa9321d1ceba362061d32dc7dfa2c64f0c
Original-Author: San Mehat <san@google.com>
Signed-off-by: Colin Cross <ccross@android.com>
2011-07-12 22:58:35 -07:00