1. 23 Sep, 2009 40 commits
    • Jarkko Lavinen's avatar
      mmc: add mmc card sleep and awake support · b1ebe384
      Jarkko Lavinen authored
      Add support for the new MMC command SLEEP_AWAKE.
      Signed-off-by: default avatarJarkko Lavinen <jarkko.lavinen@nokia.com>
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@nokia.com>
      Acked-by: default avatarMatt Fleming <matt@console-pimps.org>
      Cc: Ian Molton <ian@mnementh.co.uk>
      Cc: "Roberto A. Foglietta" <roberto.foglietta@gmail.com>
      Cc: Jarkko Lavinen <jarkko.lavinen@nokia.com>
      Cc: Denis Karpov <ext-denis.2.karpov@nokia.com>
      Cc: Pierre Ossman <pierre@ossman.eu>
      Cc: Philip Langdale <philipl@overt.org>
      Cc: "Madhusudhan" <madhu.cr@ti.com>
      Cc: <linux-mmc@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      b1ebe384
    • Adrian Hunter's avatar
      mmc: add ability to save power by powering off cards · eae1aeee
      Adrian Hunter authored
      Power can be saved by powering off cards that are not in use.  This is
      similar to suspend / resume except it is under the control of the driver,
      and does not require any power management support.  It can only be used
      when the driver can monitor whether the card is removed, otherwise it is
      unsafe.  This is possible because, unlike suspend, the driver still
      receives card detect and / or cover switch interrupts.
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@nokia.com>
      Acked-by: default avatarMatt Fleming <matt@console-pimps.org>
      Cc: Ian Molton <ian@mnementh.co.uk>
      Cc: "Roberto A. Foglietta" <roberto.foglietta@gmail.com>
      Cc: Jarkko Lavinen <jarkko.lavinen@nokia.com>
      Cc: Denis Karpov <ext-denis.2.karpov@nokia.com>
      Cc: Pierre Ossman <pierre@ossman.eu>
      Cc: Philip Langdale <philipl@overt.org>
      Cc: "Madhusudhan" <madhu.cr@ti.com>
      Cc: <linux-mmc@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      eae1aeee
    • Adrian Hunter's avatar
      mmc: add MMC_CAP_NONREMOVABLE host capability · 9feae246
      Adrian Hunter authored
      eMMC's are not removable, so unsafe resume is OK always.
      
      To permit this a new host capability MMC_CAP_NONREMOVABLE has been added
      and suspend / resume updated accordingly.
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@nokia.com>
      Acked-by: default avatarMatt Fleming <matt@console-pimps.org>
      Cc: Ian Molton <ian@mnementh.co.uk>
      Cc: "Roberto A. Foglietta" <roberto.foglietta@gmail.com>
      Cc: Jarkko Lavinen <jarkko.lavinen@nokia.com>
      Cc: Denis Karpov <ext-denis.2.karpov@nokia.com>
      Cc: Pierre Ossman <pierre@ossman.eu>
      Cc: Philip Langdale <philipl@overt.org>
      Cc: "Madhusudhan" <madhu.cr@ti.com>
      Cc: <linux-mmc@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      9feae246
    • Adrian Hunter's avatar
      mmc: allow host claim / release nesting · 319a3f14
      Adrian Hunter authored
      This change allows the MMC host to be claimed in situations where the host
      may or may not have already been claimed.  Also 'mmc_try_claim_host()' is
      now exported.
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@nokia.com>
      Acked-by: default avatarMatt Fleming <matt@console-pimps.org>
      Cc: Ian Molton <ian@mnementh.co.uk>
      Cc: "Roberto A. Foglietta" <roberto.foglietta@gmail.com>
      Cc: Jarkko Lavinen <jarkko.lavinen@nokia.com>
      Cc: Denis Karpov <ext-denis.2.karpov@nokia.com>
      Cc: Pierre Ossman <pierre@ossman.eu>
      Cc: Philip Langdale <philipl@overt.org>
      Cc: "Madhusudhan" <madhu.cr@ti.com>
      Cc: <linux-mmc@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      319a3f14
    • Adrian Hunter's avatar
      mmc: add 'enable' and 'disable' methods to mmc host · 8ea926b2
      Adrian Hunter authored
      MMC hosts that support power saving can use the 'enable' and 'disable'
      methods to exit and enter power saving states.  An explanation of their
      use is provided in the comments added to include/linux/mmc/host.h.
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@nokia.com>
      Acked-by: default avatarMatt Fleming <matt@console-pimps.org>
      Cc: Ian Molton <ian@mnementh.co.uk>
      Cc: "Roberto A. Foglietta" <roberto.foglietta@gmail.com>
      Cc: Jarkko Lavinen <jarkko.lavinen@nokia.com>
      Cc: Denis Karpov <ext-denis.2.karpov@nokia.com>
      Cc: Pierre Ossman <pierre@ossman.eu>
      Cc: Philip Langdale <philipl@overt.org>
      Cc: "Madhusudhan" <madhu.cr@ti.com>
      Cc: <linux-mmc@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      8ea926b2
    • Ohad Ben-Cohen's avatar
      sdio: do not ignore MMC_VDD_165_195 · 27cce39f
      Ohad Ben-Cohen authored
      This is needed for 1.8V embedded SDIO devices and supporting host controllers
      (e.g. TI 127x and ZOOM2 boards)
      Signed-off-by: default avatarOhad Ben-Cohen <ohad@bencohen.org>
      Acked-by: default avatarMatt Fleming <matt@console-pimps.org>
      Cc: Ian Molton <ian@mnementh.co.uk>
      Cc: Pierre Ossman <pierre@ossman.eu>
      Cc: Ian Molton <ian@mnementh.co.uk>
      Cc: "Roberto A. Foglietta" <roberto.foglietta@gmail.com>
      Cc: Philip Langdale <philipl@overt.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      27cce39f
    • Uwe Kleine-König's avatar
      mmc: register mmci-omap-hs using platform_driver_probe · f400cd8c
      Uwe Kleine-König authored
      omap_mmc_probe lives in .init.text, so using platform_driver_register to
      register it is wrong because binding a device after the init memory is
      discarded (e.g.  via sysfs) results in an oops.
      
      As requested by David Brownell platform_driver_probe is used instead of
      moving the probe function to .devinit.text as proposed initially.  This
      saves some memory, but devices registered after the driver is probed are
      not bound (probably there are none) and binding via sysfs isn't possible.
      Signed-off-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
      Cc: Jean Pihet <jpihet@mvista.com>
      Cc: Tony Lindgren <tony@atomide.com>
      Cc: Pierre Ossman <drzeus@drzeus.cx>
      Cc: Andy Lowe <alowe@mvista.com>
      Cc: Adrian Hunter <ext-adrian.hunter@nokia.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Acked-by: default avatarDavid Brownell <dbrownell@users.sourceforge.net>
      Cc: Madhusudhan Chikkature<madhu.cr@ti.com>
      Cc: Greg Kroah-Hartman <gregkh@suse.de>
      Cc: Matt Fleming <matt@console-pimps.org>
      Cc: Ian Molton <ian@mnementh.co.uk>
      Cc: "Roberto A. Foglietta" <roberto.foglietta@gmail.com>
      Cc: Philip Langdale <philipl@overt.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      f400cd8c
    • Joe Perches's avatar
      msm_sdcc.c: move overly indented code to separate function · b5a74d60
      Joe Perches authored
      Signed-off-by: default avatarJoe Perches <joe@perches.com>
      Cc: Pavel Machek <pavel@ucw.cz>
      Cc: Brian Swetland <swetland@google.com>
      Cc: Pierre Ossman <drzeus-list@drzeus.cx>
      Cc: San Mehat <san@android.com>
      Cc: Matt Fleming <matt@console-pimps.org>
      Cc: Ian Molton <ian@mnementh.co.uk>
      Cc: "Roberto A. Foglietta" <roberto.foglietta@gmail.com>
      Cc: Philip Langdale <philipl@overt.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      b5a74d60
    • Joe Perches's avatar
      msm_sdcc.c: stylistic cleaning · 75d14528
      Joe Perches authored
      Make it a bit more like typical kernel style.
      Signed-off-by: default avatarJoe Perches <joe@perches.com>
      Cc: Pavel Machek <pavel@ucw.cz>
      Cc: Brian Swetland <swetland@google.com>
      Cc: Pierre Ossman <drzeus-list@drzeus.cx>
      Cc: San Mehat <san@android.com>
      Cc: Matt Fleming <matt@console-pimps.org>
      Cc: Ian Molton <ian@mnementh.co.uk>
      Cc: "Roberto A. Foglietta" <roberto.foglietta@gmail.com>
      Cc: Philip Langdale <philipl@overt.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      75d14528
    • Joe Perches's avatar
      msm_sdcc.c: convert printk(KERN_<level> to pr_<level>( · 0a7ff7c7
      Joe Perches authored
      Signed-off-by: default avatarJoe Perches <joe@perches.com>
      Cc: Pavel Machek <pavel@ucw.cz>
      Cc: Brian Swetland <swetland@google.com>
      Cc: Pierre Ossman <drzeus-list@drzeus.cx>
      Cc: San Mehat <san@android.com>
      Cc: Matt Fleming <matt@console-pimps.org>
      Cc: Ian Molton <ian@mnementh.co.uk>
      Cc: "Roberto A. Foglietta" <roberto.foglietta@gmail.com>
      Cc: Philip Langdale <philipl@overt.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      0a7ff7c7
    • San Mehat's avatar
      mmc: msm_sdccc: driver for HTC Dream · 9d2bd738
      San Mehat authored
      MMC Driver for HTC Dream.  I picked the code up from Google git trees,
      removed stuff not strictly necessary, and did a few cleanups.  It still
      works :-).
      Signed-off-by: default avatarPavel Machek <pavel@ucw.cz>
      Cc: Brian Swetland <swetland@google.com>
      Cc: Pierre Ossman <drzeus-list@drzeus.cx>
      Cc: Joe Perches <joe@perches.com>
      Cc: Matt Fleming <matt@console-pimps.org>
      Cc: Ian Molton <ian@mnementh.co.uk>
      Cc: "Roberto A. Foglietta" <roberto.foglietta@gmail.com>
      Cc: Philip Langdale <philipl@overt.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      9d2bd738
    • Anand Gadiyar's avatar
      OMAP: HSMMC: do not enable buffer ready interrupt if using DMA · ccdfe3a6
      Anand Gadiyar authored
      This considerably reduces the number of interrupts during a transfer
      and ought to result in some power saving.
      Signed-off-by: default avatarAnand Gadiyar <gadiyar@ti.com>
      Signed-off-by: default avatarSantosh Shilimkar <santosh.shilimkar@ti.com>
      Acked-by: default avatarKishore Kadiyala <kishore.kadiyala@ti.com>
      Cc: Pierre Ossman <drzeus@drzeus.cx>
      Cc: Matt Fleming <matt@console-pimps.org>
      Cc: Ian Molton <ian@mnementh.co.uk>
      Cc: "Roberto A. Foglietta" <roberto.foglietta@gmail.com>
      Cc: Philip Langdale <philipl@overt.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      ccdfe3a6
    • Balaji Rao's avatar
      mmc: in mmc_power_up(), use previously selected ocr if available · 500f3564
      Balaji Rao authored
      When mmc_power_up is called during unsafe resume, host->ocr should be used
      instead of host->ocr_avail.
      Signed-off-by: default avatarBalaji Rao <balajirrao@openmoko.org>
      Cc: Andy Green <andy@openmoko.com>
      Cc: Pierre Ossman <drzeus-mmc@drzeus.cx>
      Cc: Ian Molton <ian@mnementh.co.uk>
      Cc: "Roberto A. Foglietta" <roberto.foglietta@gmail.com>
      Cc: Philip Langdale <philipl@overt.org>
      Acked-by: default avatarMatt Fleming <matt@console-pimps.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      500f3564
    • Mike Frysinger's avatar
      Blackfin: override text/data checking functions · e56770fb
      Mike Frysinger authored
      Signed-off-by: default avatarMike Frysinger <vapier@gentoo.org>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Robin Getz <rgetz@blackfin.uclinux.org>
      Cc: Sam Ravnborg <sam@ravnborg.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      e56770fb
    • Mike Frysinger's avatar
      lockdep: use new arch_is_kernel_data() · 2a9ad18d
      Mike Frysinger authored
      This allows lockdep to locate symbols that are in arch-specific data
      sections (such as data in Blackfin on-chip SRAM regions).
      Signed-off-by: default avatarMike Frysinger <vapier@gentoo.org>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Robin Getz <rgetz@blackfin.uclinux.org>
      Cc: Sam Ravnborg <sam@ravnborg.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      2a9ad18d
    • Mike Frysinger's avatar
      kallsyms: use new arch_is_kernel_text() · 128e8db3
      Mike Frysinger authored
      This allows kallsyms to locate symbols that are in arch-specific text
      sections (such as text in Blackfin on-chip SRAM regions).
      Signed-off-by: default avatarMike Frysinger <vapier@gentoo.org>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Robin Getz <rgetz@blackfin.uclinux.org>
      Cc: Sam Ravnborg <sam@ravnborg.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      128e8db3
    • Mike Frysinger's avatar
      asm/sections: add text/data checking functions for arches to override · 00afe029
      Mike Frysinger authored
      Some ports (like the Blackfin arch) have a discontiguous memory map which
      means there may be text or data that falls outside of the standard range
      of the start/end text/data symbols.  Creating some helper functions allows
      these non-standard ports to declare these regions without adversely
      affecting anyone else.
      Signed-off-by: default avatarMike Frysinger <vapier@gentoo.org>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Robin Getz <rgetz@blackfin.uclinux.org>
      Cc: Sam Ravnborg <sam@ravnborg.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      00afe029
    • Paul Mundt's avatar
      kallsyms: fix segfault in prefix_underscores_count() · a9ece53c
      Paul Mundt authored
      Commit b478b782 "kallsyms, tracing: output
      more proper symbol name" introduces a "bugfix" that introduces a segfault
      in kallsyms in my configurations.
      
      The cause is the introduction of prefix_underscores_count() which attempts
      to count underscores, even in symbols that do not have them.  As a result,
      it just uselessly runs past the end of the buffer until it crashes:
      
        CC      init/version.o
        LD      init/built-in.o
        LD      .tmp_vmlinux1
        KSYM    .tmp_kallsyms1.S
      /bin/sh: line 1: 16934 Done                    sh-linux-gnu-nm -n .tmp_vmlinux1
           16935 Segmentation fault      | scripts/kallsyms > .tmp_kallsyms1.S
      make: *** [.tmp_kallsyms1.S] Error 139
      
      This simplifies the logic and just does a straightforward count.
      Signed-off-by: default avatarPaul Mundt <lethal@linux-sh.org>
      Reviewed-by: default avatarLi Zefan <lizf@cn.fujitsu.com>
      Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
      Cc: Sam Ravnborg <sam@ravnborg.org>
      Cc: Paulo Marques <pmarques@grupopie.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: <stable@kernel.org>		[2.6.30.x, 2.6.31.x]
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      a9ece53c
    • Jiri Pirko's avatar
      getrusage: fill ru_maxrss value · 1f10206c
      Jiri Pirko authored
      Make ->ru_maxrss value in struct rusage filled accordingly to rss hiwater
      mark.  This struct is filled as a parameter to getrusage syscall.
      ->ru_maxrss value is set to KBs which is the way it is done in BSD
      systems.  /usr/bin/time (gnu time) application converts ->ru_maxrss to KBs
      which seems to be incorrect behavior.  Maintainer of this util was
      notified by me with the patch which corrects it and cc'ed.
      
      To make this happen we extend struct signal_struct by two fields.  The
      first one is ->maxrss which we use to store rss hiwater of the task.  The
      second one is ->cmaxrss which we use to store highest rss hiwater of all
      task childs.  These values are used in k_getrusage() to actually fill
      ->ru_maxrss.  k_getrusage() uses current rss hiwater value directly if mm
      struct exists.
      
      Note:
      exec() clear mm->hiwater_rss, but doesn't clear sig->maxrss.
      it is intetionally behavior. *BSD getrusage have exec() inheriting.
      
      test programs
      ========================================================
      
      getrusage.c
      ===========
       #include <stdio.h>
       #include <stdlib.h>
       #include <string.h>
       #include <sys/types.h>
       #include <sys/time.h>
       #include <sys/resource.h>
       #include <sys/types.h>
       #include <sys/wait.h>
       #include <unistd.h>
       #include <signal.h>
       #include <sys/mman.h>
      
       #include "common.h"
      
       #define err(str) perror(str), exit(1)
      
      int main(int argc, char** argv)
      {
      	int status;
      
      	printf("allocate 100MB\n");
      	consume(100);
      
      	printf("testcase1: fork inherit? \n");
      	printf("  expect: initial.self ~= child.self\n");
      	show_rusage("initial");
      	if (__fork()) {
      		wait(&status);
      	} else {
      		show_rusage("fork child");
      		_exit(0);
      	}
      	printf("\n");
      
      	printf("testcase2: fork inherit? (cont.) \n");
      	printf("  expect: initial.children ~= 100MB, but child.children = 0\n");
      	show_rusage("initial");
      	if (__fork()) {
      		wait(&status);
      	} else {
      		show_rusage("child");
      		_exit(0);
      	}
      	printf("\n");
      
      	printf("testcase3: fork + malloc \n");
      	printf("  expect: child.self ~= initial.self + 50MB\n");
      	show_rusage("initial");
      	if (__fork()) {
      		wait(&status);
      	} else {
      		printf("allocate +50MB\n");
      		consume(50);
      		show_rusage("fork child");
      		_exit(0);
      	}
      	printf("\n");
      
      	printf("testcase4: grandchild maxrss\n");
      	printf("  expect: post_wait.children ~= 300MB\n");
      	show_rusage("initial");
      	if (__fork()) {
      		wait(&status);
      		show_rusage("post_wait");
      	} else {
      		system("./child -n 0 -g 300");
      		_exit(0);
      	}
      	printf("\n");
      
      	printf("testcase5: zombie\n");
      	printf("  expect: pre_wait ~= initial, IOW the zombie process is not accounted.\n");
      	printf("          post_wait ~= 400MB, IOW wait() collect child's max_rss. \n");
      	show_rusage("initial");
      	if (__fork()) {
      		sleep(1); /* children become zombie */
      		show_rusage("pre_wait");
      		wait(&status);
      		show_rusage("post_wait");
      	} else {
      		system("./child -n 400");
      		_exit(0);
      	}
      	printf("\n");
      
      	printf("testcase6: SIG_IGN\n");
      	printf("  expect: initial ~= after_zombie (child's 500MB alloc should be ignored).\n");
      	show_rusage("initial");
      	signal(SIGCHLD, SIG_IGN);
      	if (__fork()) {
      		sleep(1); /* children become zombie */
      		show_rusage("after_zombie");
      	} else {
      		system("./child -n 500");
      		_exit(0);
      	}
      	printf("\n");
      	signal(SIGCHLD, SIG_DFL);
      
      	printf("testcase7: exec (without fork) \n");
      	printf("  expect: initial ~= exec \n");
      	show_rusage("initial");
      	execl("./child", "child", "-v", NULL);
      
      	return 0;
      }
      
      child.c
      =======
       #include <sys/types.h>
       #include <unistd.h>
       #include <sys/types.h>
       #include <sys/wait.h>
       #include <stdio.h>
       #include <stdlib.h>
       #include <string.h>
       #include <sys/types.h>
       #include <sys/time.h>
       #include <sys/resource.h>
      
       #include "common.h"
      
      int main(int argc, char** argv)
      {
      	int status;
      	int c;
      	long consume_size = 0;
      	long grandchild_consume_size = 0;
      	int show = 0;
      
      	while ((c = getopt(argc, argv, "n:g:v")) != -1) {
      		switch (c) {
      		case 'n':
      			consume_size = atol(optarg);
      			break;
      		case 'v':
      			show = 1;
      			break;
      		case 'g':
      
      			grandchild_consume_size = atol(optarg);
      			break;
      		default:
      			break;
      		}
      	}
      
      	if (show)
      		show_rusage("exec");
      
      	if (consume_size) {
      		printf("child alloc %ldMB\n", consume_size);
      		consume(consume_size);
      	}
      
      	if (grandchild_consume_size) {
      		if (fork()) {
      			wait(&status);
      		} else {
      			printf("grandchild alloc %ldMB\n", grandchild_consume_size);
      			consume(grandchild_consume_size);
      
      			exit(0);
      		}
      	}
      
      	return 0;
      }
      
      common.c
      ========
       #include <stdio.h>
       #include <stdlib.h>
       #include <string.h>
       #include <sys/types.h>
       #include <sys/time.h>
       #include <sys/resource.h>
       #include <sys/types.h>
       #include <sys/wait.h>
       #include <unistd.h>
       #include <signal.h>
       #include <sys/mman.h>
      
       #include "common.h"
       #define err(str) perror(str), exit(1)
      
      void show_rusage(char *prefix)
      {
          	int err, err2;
          	struct rusage rusage_self;
          	struct rusage rusage_children;
      
          	printf("%s: ", prefix);
          	err = getrusage(RUSAGE_SELF, &rusage_self);
          	if (!err)
          		printf("self %ld ", rusage_self.ru_maxrss);
          	err2 = getrusage(RUSAGE_CHILDREN, &rusage_children);
          	if (!err2)
          		printf("children %ld ", rusage_children.ru_maxrss);
      
          	printf("\n");
      }
      
      /* Some buggy OS need this worthless CPU waste. */
      void make_pagefault(void)
      {
      	void *addr;
      	int size = getpagesize();
      	int i;
      
      	for (i=0; i<1000; i++) {
      		addr = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
      		if (addr == MAP_FAILED)
      			err("make_pagefault");
      		memset(addr, 0, size);
      		munmap(addr, size);
      	}
      }
      
      void consume(int mega)
      {
          	size_t sz = mega * 1024 * 1024;
          	void *ptr;
      
          	ptr = malloc(sz);
          	memset(ptr, 0, sz);
      	make_pagefault();
      }
      
      pid_t __fork(void)
      {
      	pid_t pid;
      
      	pid = fork();
      	make_pagefault();
      
      	return pid;
      }
      
      common.h
      ========
      void show_rusage(char *prefix);
      void make_pagefault(void);
      void consume(int mega);
      pid_t __fork(void);
      
      FreeBSD result (expected result)
      ========================================================
      allocate 100MB
      testcase1: fork inherit?
        expect: initial.self ~= child.self
      initial: self 103492 children 0
      fork child: self 103540 children 0
      
      testcase2: fork inherit? (cont.)
        expect: initial.children ~= 100MB, but child.children = 0
      initial: self 103540 children 103540
      child: self 103564 children 0
      
      testcase3: fork + malloc
        expect: child.self ~= initial.self + 50MB
      initial: self 103564 children 103564
      allocate +50MB
      fork child: self 154860 children 0
      
      testcase4: grandchild maxrss
        expect: post_wait.children ~= 300MB
      initial: self 103564 children 154860
      grandchild alloc 300MB
      post_wait: self 103564 children 308720
      
      testcase5: zombie
        expect: pre_wait ~= initial, IOW the zombie process is not accounted.
                post_wait ~= 400MB, IOW wait() collect child's max_rss.
      initial: self 103564 children 308720
      child alloc 400MB
      pre_wait: self 103564 children 308720
      post_wait: self 103564 children 411312
      
      testcase6: SIG_IGN
        expect: initial ~= after_zombie (child's 500MB alloc should be ignored).
      initial: self 103564 children 411312
      child alloc 500MB
      after_zombie: self 103624 children 411312
      
      testcase7: exec (without fork)
        expect: initial ~= exec
      initial: self 103624 children 411312
      exec: self 103624 children 411312
      
      Linux result (actual test result)
      ========================================================
      allocate 100MB
      testcase1: fork inherit?
        expect: initial.self ~= child.self
      initial: self 102848 children 0
      fork child: self 102572 children 0
      
      testcase2: fork inherit? (cont.)
        expect: initial.children ~= 100MB, but child.children = 0
      initial: self 102876 children 102644
      child: self 102572 children 0
      
      testcase3: fork + malloc
        expect: child.self ~= initial.self + 50MB
      initial: self 102876 children 102644
      allocate +50MB
      fork child: self 153804 children 0
      
      testcase4: grandchild maxrss
        expect: post_wait.children ~= 300MB
      initial: self 102876 children 153864
      grandchild alloc 300MB
      post_wait: self 102876 children 307536
      
      testcase5: zombie
        expect: pre_wait ~= initial, IOW the zombie process is not accounted.
                post_wait ~= 400MB, IOW wait() collect child's max_rss.
      initial: self 102876 children 307536
      child alloc 400MB
      pre_wait: self 102876 children 307536
      post_wait: self 102876 children 410076
      
      testcase6: SIG_IGN
        expect: initial ~= after_zombie (child's 500MB alloc should be ignored).
      initial: self 102876 children 410076
      child alloc 500MB
      after_zombie: self 102880 children 410076
      
      testcase7: exec (without fork)
        expect: initial ~= exec
      initial: self 102880 children 410076
      exec: self 102880 children 410076
      Signed-off-by: default avatarJiri Pirko <jpirko@redhat.com>
      Signed-off-by: default avatarKOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Hugh Dickins <hugh.dickins@tiscali.co.uk>
      Cc: Ingo Molnar <mingo@elte.hu>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      1f10206c
    • Andi Kleen's avatar
      kmap_types.h: rename D macro · b28cfd2c
      Andi Kleen authored
      I tend to use a 'D' debugging macro a lot during debugging.  When I define
      it before includes I often get conflicts with kmap_types.h's use of 'D'
      too.  It's not very nice when a global include pollutes the name space
      like this.
      
      Rename the kmap_types.h D to KMAP_D.  It is only used temporarily in the
      header so has no effect on anything else.
      Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
      Reviewed-by: default avatarWANG Cong <xiyou.wangcong@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      b28cfd2c
    • Rolf Eike Beer's avatar
      Make sure the value in abs() does not get truncated if it is greater than 2^32 · a49c59c0
      Rolf Eike Beer authored
      abs() will truncate the input if is it outside the 2^32 range.  Fix that
      by assuming `long' input.
      
      This might generate worse code in the common case.
      Signed-off-by: default avatarRolf Eike Beer <eike-kernel@sf-tec.de>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      a49c59c0
    • Suzuki Poulose's avatar
      fix compat_sys_utimensat() · d7d7561c
      Suzuki Poulose authored
      Compat utimensat() returns EINVAL when the tv_nsec is one of UTIME_OMIT or
      UTIME_NOW and the tv_sec is set to non-zero.  As per man pages, the tv_sec
      field should be ignored.
      
      sys_utimensat() works fine in this case.
      
      Test case:
      
      #define _GNU_SOURCE
      #define _ATFILE_SOURCE
      #include <stdio.h>
      #include <fcntl.h>
      #include <unistd.h>
      #include <sys/stat.h>
      #include <stdlib.h>
      
      main(int argc, char *argv[])
      {
      	struct timespec ts[2];
      	struct timespec *tsp;
      
      	if (argc < 2) {
      		fprintf(stderr, "Usage : %s filename\n", argv[0]);
      		exit (-1);
      	}
      
      	ts[0].tv_nsec = ts[1].tv_nsec = UTIME_NOW;
      	ts[0].tv_sec = ts[1].tv_sec = 1;
      
      	tsp = ts;
      
      	if (utimensat(AT_FDCWD, argv[1],tsp,0) == -1)
      		perror("utimensat");
      	else
      		fprintf(stdout, "utimensat success\n");
      	return 0;
      }
      mjs22lp5:~ # cc -m64 utimensat-test.c -o utimensat_test64
      mjs22lp5:~ # cc -m32 utimensat-test.c -o utimensat_test32
      mjs22lp5:~ # ./utimensat_test32 /tmp/utimensat_test
      utimensat: Invalid argument
      mjs22lp5:~ # ./utimensat_test64 /tmp/utimensat_test
      utimensat success
      mjs22lp5:~ # uname -r
      2.6.31-rc8
      
      With the patch :
      
      mjs22lp5:~ # ./utimensat_test64 /tmp/utimensat_test
      utimensat success
      mjs22lp5:~ # ./utimensat_test32 /tmp/utimensat_test
      utimensat success
      mjs22lp5:~ # uname -r
      2.6.31-rc8utimensat
      Signed-off-by: default avatarSuzuki K P <suzuki@in.ibm.com>
      Cc: Ulrich Drepper <drepper@redhat.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      d7d7561c
    • Jaswinder Singh Rajput's avatar
      vlynq: includecheck fix: drivers/vlynq/vlynq.c · 54447c3e
      Jaswinder Singh Rajput authored
      Fix the following 'make includecheck' warning:
      
      drivers/vlynq/vlynq.c: linux/device.h is included more than once.
      Signed-off-by: default avatarJaswinder Singh Rajput <jaswinderrajput@gmail.com>
      Signed-off-by: default avatarFlorian Fainelli <florian@openwrt.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      54447c3e
    • Christoph Hellwig's avatar
      qnx4: remove write support · 945ffe54
      Christoph Hellwig authored
      qnx4 wrte support has never been fully implement, is broken since the dawn
      of time and hasn't been actively developed since before git history
      started.
      
      Instead of letting it further bitrot and complicate API transition (like
      the new truncate code) remove it.
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Cc: Anders Larsen <al@alarsen.net>
      Cc: Nick Piggin <npiggin@suse.de>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      945ffe54
    • Christoph Hellwig's avatar
      ntfs: remove ntfs_file_write · 8a9f47dd
      Christoph Hellwig authored
      do_sync_write() does the right thing for turning the aio_writev method
      into a normal non-vectored synchronous write, no need to duplicate it in
      ntfs.
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Acked-by: default avatarAnton Altaparmakov <aia21@cantab.net>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      8a9f47dd
    • Davide Libenzi's avatar
      anonfd: split interface into file creation and install · 562787a5
      Davide Libenzi authored
      Split the anonfd interface into a bare file pointer creation one, and a
      file pointer creation plus install one.
      
      There are cases, like the usage of eventfds inside other kernel
      interfaces, where the file pointer created by anonfd needs to be used
      inside the initialization of other structures.
      
      As it is right now, as soon as anon_inode_getfd() returns, the kenrle can
      race with userspace closing the newly installed file descriptor.
      
      This patch, while keeping the old anon_inode_getfd(), introduces a new
      anon_inode_getfile() (whose services are reused in anon_inode_getfd())
      that allows to split the file creation phase and the fd install one.
      
      Once all the kernel structures are initialized, the code can call the
      proper fd_install().
      
      Gregory manifested the need for something like this inside KVM.
      Signed-off-by: default avatarDavide Libenzi <davidel@xmailserver.org>
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Cc: James Morris <jmorris@namei.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Gregory Haskins <ghaskins@novell.com>
      Acked-by: default avatarSerge Hallyn <serue@us.ibm.com>
      Acked-by: default avatarRoland Dreier <rolandd@cisco.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      562787a5
    • Bartlomiej Zolnierkiewicz's avatar
      MAINTAINERS: remove dead ncpfs list · 515350b6
      Bartlomiej Zolnierkiewicz authored
      On Saturday 01 August 2009 00:30:39 Mail Delivery Subsystem wrote:
      > Delivery to the following recipient failed permanently:
      >
      >      linware@sh.cvut.cz
      >
      > Technical details of permanent failure:
      > Google tried to deliver your message, but it was rejected by the recipient
      > domain. We recommend contacting the other email provider for further
      > information about the cause of this error. The error that the other server
      > returned was: 450 450 <linware@sh.cvut.cz>: Recipient address rejected:
      > undeliverable address: unknown user: "linware" (state 14).
      
      Cc: Petr Vandrovec <vandrove@vc.cvut.cz>
      Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      515350b6
    • H Hartley Sweeten's avatar
      aio.c: move EXPORT* macros to line after function · 385773e0
      H Hartley Sweeten authored
      As mentioned in Documentation/CodingStyle, move EXPORT* macro's
      to the line immediately after the closing function brace line.
      
      Also, move the __initcall() similarly.
      Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
      Cc: Zach Brown <zach.brown@oracle.com>
      Cc: Benjamin LaHaise <bcrl@kvack.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      385773e0
    • Jan Beulich's avatar
      BUILD_BUG_ON(): fix it and a couple of bogus uses of it · 8c87df45
      Jan Beulich authored
      gcc permitting variable length arrays makes the current construct used for
      BUILD_BUG_ON() useless, as that doesn't produce any diagnostic if the
      controlling expression isn't really constant.  Instead, this patch makes
      it so that a bit field gets used here.  Consequently, those uses where the
      condition isn't really constant now also need fixing.
      
      Note that in the gfp.h, kmemcheck.h, and virtio_config.h cases
      MAYBE_BUILD_BUG_ON() really just serves documentation purposes - even if
      the expression is compile time constant (__builtin_constant_p() yields
      true), the array is still deemed of variable length by gcc, and hence the
      whole expression doesn't have the intended effect.
      
      [akpm@linux-foundation.org: make arch/sparc/include/asm/vio.h compile]
      [akpm@linux-foundation.org: more nonsensical assertions in tpm.c..]
      Signed-off-by: default avatarJan Beulich <jbeulich@novell.com>
      Cc: Andi Kleen <andi@firstfloor.org>
      Cc: Rusty Russell <rusty@rustcorp.com.au>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Rajiv Andrade <srajiv@linux.vnet.ibm.com>
      Cc: Mimi Zohar <zohar@us.ibm.com>
      Cc: James Morris <jmorris@namei.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      8c87df45
    • H Hartley Sweeten's avatar
      fs/buffer.c: clean up EXPORT* macros · 1fe72eaa
      H Hartley Sweeten authored
      According to Documentation/CodingStyle the EXPORT* macro should follow
      immediately after the closing function brace line.
      
      Also, mark_buffer_async_write_endio() and do_thaw_all() are not used
      elsewhere so they should be marked as static.
      
      In addition, file_fsync() is actually in fs/sync.c so move the EXPORT* to
      that file.
      Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      1fe72eaa
    • Nick Piggin's avatar
      fs: turn iprune_mutex into rwsem · 88e0fbc4
      Nick Piggin authored
      We have had a report of bad memory allocation latency during DVD-RAM (UDF)
      writing.  This is causing the user's desktop session to become unusable.
      
      Jan tracked the cause of this down to UDF inode reclaim blocking:
      
      gnome-screens D ffff810006d1d598     0 20686      1
       ffff810006d1d508 0000000000000082 ffff810037db6718 0000000000000800
       ffff810006d1d488 ffffffff807e4280 ffffffff807e4280 ffff810006d1a580
       ffff8100bccbc140 ffff810006d1a8c0 0000000006d1d4e8 ffff810006d1a8c0
      Call Trace:
       [<ffffffff804477f3>] io_schedule+0x63/0xa5
       [<ffffffff802c2587>] sync_buffer+0x3b/0x3f
       [<ffffffff80447d2a>] __wait_on_bit+0x47/0x79
       [<ffffffff80447dc6>] out_of_line_wait_on_bit+0x6a/0x77
       [<ffffffff802c24f6>] __wait_on_buffer+0x1f/0x21
       [<ffffffff802c442a>] __bread+0x70/0x86
       [<ffffffff88de9ec7>] :udf:udf_tread+0x38/0x3a
       [<ffffffff88de0fcf>] :udf:udf_update_inode+0x4d/0x68c
       [<ffffffff88de26e1>] :udf:udf_write_inode+0x1d/0x2b
       [<ffffffff802bcf85>] __writeback_single_inode+0x1c0/0x394
       [<ffffffff802bd205>] write_inode_now+0x7d/0xc4
       [<ffffffff88de2e76>] :udf:udf_clear_inode+0x3d/0x53
       [<ffffffff802b39ae>] clear_inode+0xc2/0x11b
       [<ffffffff802b3ab1>] dispose_list+0x5b/0x102
       [<ffffffff802b3d35>] shrink_icache_memory+0x1dd/0x213
       [<ffffffff8027ede3>] shrink_slab+0xe3/0x158
       [<ffffffff8027fbab>] try_to_free_pages+0x177/0x232
       [<ffffffff8027a578>] __alloc_pages+0x1fa/0x392
       [<ffffffff802951fa>] alloc_page_vma+0x176/0x189
       [<ffffffff802822d8>] __do_fault+0x10c/0x417
       [<ffffffff80284232>] handle_mm_fault+0x466/0x940
       [<ffffffff8044b922>] do_page_fault+0x676/0xabf
      
      This blocks with iprune_mutex held, which then blocks other reclaimers:
      
      X             D ffff81009d47c400     0 17285  14831
       ffff8100844f3728 0000000000000086 0000000000000000 ffff81000000e288
       ffff81000000da00 ffffffff807e4280 ffffffff807e4280 ffff81009d47c400
       ffffffff805ff890 ffff81009d47c740 00000000844f3808 ffff81009d47c740
      Call Trace:
       [<ffffffff80447f8c>] __mutex_lock_slowpath+0x72/0xa9
       [<ffffffff80447e1a>] mutex_lock+0x1e/0x22
       [<ffffffff802b3ba1>] shrink_icache_memory+0x49/0x213
       [<ffffffff8027ede3>] shrink_slab+0xe3/0x158
       [<ffffffff8027fbab>] try_to_free_pages+0x177/0x232
       [<ffffffff8027a578>] __alloc_pages+0x1fa/0x392
       [<ffffffff8029507f>] alloc_pages_current+0xd1/0xd6
       [<ffffffff80279ac0>] __get_free_pages+0xe/0x4d
       [<ffffffff802ae1b7>] __pollwait+0x5e/0xdf
       [<ffffffff8860f2b4>] :nvidia:nv_kern_poll+0x2e/0x73
       [<ffffffff802ad949>] do_select+0x308/0x506
       [<ffffffff802adced>] core_sys_select+0x1a6/0x254
       [<ffffffff802ae0b7>] sys_select+0xb5/0x157
      
      Now I think the main problem is having the filesystem block (and do IO) in
      inode reclaim.  The problem is that this doesn't get accounted well and
      penalizes a random allocator with a big latency spike caused by work
      generated from elsewhere.
      
      I think the best idea would be to avoid this.  By design if possible, or
      by deferring the hard work to an asynchronous context.  If the latter,
      then the fs would probably want to throttle creation of new work with
      queue size of the deferred work, but let's not get into those details.
      
      Anyway, the other obvious thing we looked at is the iprune_mutex which is
      causing the cascading blocking.  We could turn this into an rwsem to
      improve concurrency.  It is unreasonable to totally ban all potentially
      slow or blocking operations in inode reclaim, so I think this is a cheap
      way to get a small improvement.
      
      This doesn't solve the whole problem of course.  The process doing inode
      reclaim will still take the latency hit, and concurrent processes may end
      up contending on filesystem locks.  So fs developers should keep these
      problems in mind.
      Signed-off-by: default avatarNick Piggin <npiggin@suse.de>
      Cc: Jan Kara <jack@ucw.cz>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Christoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      88e0fbc4
    • Roland Dreier's avatar
      printk_once(): use bool for boolean flag · 70867453
      Roland Dreier authored
      Using the type bool (instead of int) for the __print_once flag in the
      printk_once() macro matches the intent of the code better, and allows the
      compiler to generate smaller code; eg a typical callsite with gcc 4.3.3 on
      i386:
      
      add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-6 (-6)
      function                                     old     new   delta
      static.__print_once                            4       1      -3
      get_cpu_vendor                               146     143      -3
      
      Saving 6 bytes of object size per callsite by slightly improving the
      readability of the source seems like a win to me.
      Signed-off-by: default avatarRoland Dreier <rolandd@cisco.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      70867453
    • Scott James Remnant's avatar
      proc connector: add event for process becoming session leader · 02b51df1
      Scott James Remnant authored
      The act of a process becoming a session leader is a useful signal to a
      supervising init daemon such as Upstart.
      
      While a daemon will normally do this as part of the process of becoming a
      daemon, it is rare for its children to do so.  When the children do, it is
      nearly always a sign that the child should be considered detached from the
      parent and not supervised along with it.
      
      The poster-child example is OpenSSH; the per-login children call setsid()
      so that they may control the pty connected to them.  If the primary daemon
      dies or is restarted, we do not want to consider the per-login children
      and want to respawn the primary daemon without killing the children.
      
      This patch adds a new PROC_SID_EVENT and associated structure to the
      proc_event event_data union, it arranges for this to be emitted when the
      special PIDTYPE_SID pid is set.
      
      [akpm@linux-foundation.org: coding-style fixes]
      Signed-off-by: default avatarScott James Remnant <scott@ubuntu.com>
      Acked-by: default avatarMatt Helsley <matthltc@us.ibm.com>
      Cc: Oleg Nesterov <oleg@tv-sign.ru>
      Cc: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
      Acked-by: default avatar"David S. Miller" <davem@davemloft.net>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      02b51df1
    • James Morris's avatar
      seq_file: constify seq_operations · 88e9d34c
      James Morris authored
      Make all seq_operations structs const, to help mitigate against
      revectoring user-triggerable function pointers.
      
      This is derived from the grsecurity patch, although generated from scratch
      because it's simpler than extracting the changes from there.
      Signed-off-by: default avatarJames Morris <jmorris@namei.org>
      Acked-by: default avatarSerge Hallyn <serue@us.ibm.com>
      Acked-by: default avatarCasey Schaufler <casey@schaufler-ca.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      88e9d34c
    • Ladinu Chandrasinghe's avatar
      Documentation/: fix warnings from -Wmissing-prototypes in HOSTCFLAGS · b7ed698c
      Ladinu Chandrasinghe authored
      Fix up -Wmissing-prototypes in compileable userspace code, mainly under
      Documentation/.
      Signed-off-by: default avatarLadinu Chandrasinghe <ladinu.pub@gmail.com>
      Signed-off-by: default avatarTrevor Keith <tsrk@tsrk.net>
      Cc: Sam Ravnborg <sam@ravnborg.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      b7ed698c
    • Roel Kluin's avatar
      dme1737: Keep index within pwm_config[] · 912e837a
      Roel Kluin authored
      The static code scanner "Parfait" reported this because pwm_config is
      only 3 bytes - pwm_config[3] is out of range.
      
      Since this code path is never called with ix == 3 (the device has no PWM4
      output) this doesn't change anything in practice.  But to encourage
      testing with Parfait, lets make the warning go away...
      Signed-off-by: default avatarRoel Kluin <roel.kluin@gmail.com>
      Acked-by: default avatarJean Delvare <khali@linux-fr.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      912e837a
    • Xiao Guangrong's avatar
      generic-ipi: make struct call_function_data lockless · 54fdade1
      Xiao Guangrong authored
      This patch can remove spinlock from struct call_function_data, the
      reasons are below:
      
      1: add a new interface for cpumask named cpumask_test_and_clear_cpu(),
         it can atomically test and clear specific cpu, we can use it instead
         of cpumask_test_cpu() and cpumask_clear_cpu() and no need data->lock
         to protect those in generic_smp_call_function_interrupt().
      
      2: in smp_call_function_many(), after csd_lock() return, the current's
         cfd_data is deleted from call_function list, so it not have race
         between other cpus, then cfs_data is only used in
         smp_call_function_many() that must disable preemption and not from
         a hardware interrupthandler or from a bottom half handler to call,
         only the correspond cpu can use it, so it not have race in current
         cpu, no need cfs_data->lock to protect it.
      
      3: after 1 and 2, cfs_data->lock is only use to protect cfs_data->refs in
         generic_smp_call_function_interrupt(), so we can define cfs_data->refs
         to atomic_t, and no need cfs_data->lock any more.
      Signed-off-by: default avatarXiao Guangrong <xiaoguangrong@cn.fujitsu.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Jens Axboe <jens.axboe@oracle.com>
      Cc: Nick Piggin <nickpiggin@yahoo.com.au>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Acked-by: default avatarRusty Russell <rusty@rustcorp.com.au>
      [akpm@linux-foundation.org: use atomic_dec_return()]
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      54fdade1
    • Trevor Keith's avatar
      Fix all -Wmissing-prototypes warnings in x86 defconfig · 5c725138
      Trevor Keith authored
      Signed-off-by: default avatarTrevor Keith <tsrk@tsrk.net>
      Cc: Sam Ravnborg <sam@ravnborg.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      5c725138
    • Michael Buesch's avatar
      dac960: fix undefined behavior on empty string · e8988933
      Michael Buesch authored
      Fix undefined behavior due to a buffer underrun if an empty string is
      written to the proc file.
      Signed-off-by: default avatarMichael Buesch <mb@bu3sch.de>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      e8988933
    • Neil Horman's avatar
      kmod: fix race in usermodehelper code · c02e3f36
      Neil Horman authored
      The user mode helper code has a race in it.  call_usermodehelper_exec()
      takes an allocated subprocess_info structure, which it passes to a
      workqueue, and then passes it to a kernel thread which it creates, after
      which it calls complete to signal to the caller of
      call_usermodehelper_exec() that it can free the subprocess_info struct.
      
      But since we use that structure in the created thread, we can't call
      complete from __call_usermodehelper(), which is where we create the kernel
      thread.  We need to call complete() from within the kernel thread and then
      not use subprocess_info afterward in the case of UMH_WAIT_EXEC.  Tested
      successfully by me.
      Signed-off-by: default avatarNeil Horman <nhorman@tuxdriver.com>
      Cc: Rusty Russell <rusty@rustcorp.com.au>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      c02e3f36