1. 09 5月, 2007 40 次提交
    • C
      kprobes: kretprobes simplifications · 4c4308cb
      Christoph Hellwig 提交于
       - consolidate duplicate code in all arch_prepare_kretprobe instances
         into common code
       - replace various odd helpers that use hlist_for_each_entry to get
         the first elemenet of a list with either a hlist_for_each_entry_save
         or an opencoded access to the first element in the caller
       - inline add_rp_inst into it's only remaining caller
       - use kretprobe_inst_table_head instead of opencoding it
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Cc: Prasanna S Panchamukhi <prasanna@in.ibm.com>
      Acked-by: NAnanth N Mavinakayanahalli <ananth@in.ibm.com>
      Cc: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      4c4308cb
    • A
      revert "rtc: Add rtc_merge_alarm()" · 416ce32e
      Andrew Morton 提交于
      David says "884b4aaa should be reverted.  It
      added an rtc_merge_alarm() call to the 2.6.20 kernel, which hasn't yet been
      used by any in-tree driver; this patch obviates the need for that call, and
      uses a more robust approach."
      
      Cc: Scott Wood <scottwood@freescale.com>
      Cc: Alessandro Zummo <a.zummo@towertech.it>
      Cc: David Brownell <david-b@pacbell.net>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      416ce32e
    • D
      rtc-cmos wakeup interface · 87ac84f4
      David Brownell 提交于
      I finally got around to testing the updated wakeup event hooks for rtc-cmos,
      and they follow in two patches:
      
       - Interface update ... when a simple enable_irq_wake() doesn't suffice,
         the platform data can hold suspend/resume callback hooks.
      
       - ACPI implementation ... provides callback hooks to do ACPI magic, and
         eliminate the legacy /proc/acpi/alarm file.
      
      The interface update could go into 2.6.21, but that's not essential; they
      will be NOPs on most PCs, without the ACPI stuff.
      
      I suspect the ACPI folk may have opinions about how to merge that second
      patch, and how to obsolete that legacy procfs file.  I'd like to see that
      merge into 2.6.22 if possible...
      
      As for how to kick it in ... two ways:
      
       - The appended "rtcwake" program; updated since the last time it was
         posted, it deals much better with timezones and DST.
      
       - Write the /sys/class/rtc/.../wakealarm file, then go to sleep.
      
      For some reason RTC wake from "swsusp" stopped working on a system where
      it previously worked; the alarm setting appears to get clobbered.  But
      on the bright side, RTC wake from "standby" worked on a system that had
      never been able to resume from that state before ... IDEACPI is my guess
      as to why it finally started to work.  It's the old "two steps forward,
      one step back" dance, I guess.
      
      - Dave
      
      /* gcc -Wall -Os -o rtcwake rtcwake.c */
      
      #include <stdio.h>
      #include <getopt.h>
      #include <fcntl.h>
      #include <stdlib.h>
      #include <string.h>
      #include <unistd.h>
      #include <errno.h>
      #include <time.h>
      
      #include <sys/ioctl.h>
      #include <sys/time.h>
      #include <sys/types.h>
      
      #include <linux/rtc.h>
      
      /* constants from legacy PC/AT hardware */
      #define	RTC_PF	0x40
      #define	RTC_AF	0x20
      #define	RTC_UF	0x10
      
      /*
       * rtcwake -- enter a system sleep state until specified wakeup time.
       *
       * This uses cross-platform Linux interfaces to enter a system sleep state,
       * and leave it no later than a specified time.  It uses any RTC framework
       * driver that supports standard driver model wakeup flags.
       *
       * This is normally used like the old "apmsleep" utility, to wake from a
       * suspend state like ACPI S1 (standby) or S3 (suspend-to-RAM).  Most
       * platforms can implement those without analogues of BIOS, APM, or ACPI.
       *
       * On some systems, this can also be used like "nvram-wakeup", waking
       * from states like ACPI S4 (suspend to disk).  Not all systems have
       * persistent media that are appropriate for such suspend modes.
       *
       * The best way to set the system's RTC is so that it holds the current
       * time in UTC.  Use the "-l" flag to tell this program that the system
       * RTC uses a local timezone instead (maybe you dual-boot MS-Windows).
       */
      
      static char		*progname;
      
      #ifdef	DEBUG
      #define	VERSION	"1.0 dev (" __DATE__ " " __TIME__ ")"
      #else
      #define	VERSION	"0.9"
      #endif
      
      static unsigned		verbose;
      static int		rtc_is_utc = -1;
      
      static int may_wakeup(const char *devname)
      {
      	char	buf[128], *s;
      	FILE	*f;
      
      	snprintf(buf, sizeof buf, "/sys/class/rtc/%s/device/power/wakeup",
      			devname);
      	f = fopen(buf, "r");
      	if (!f) {
      		perror(buf);
      		return 0;
      	}
      	fgets(buf, sizeof buf, f);
      	fclose(f);
      
      	s = strchr(buf, '\n');
      	if (!s)
      		return 0;
      	*s = 0;
      
      	/* wakeup events could be disabled or not supported */
      	return strcmp(buf, "enabled") == 0;
      }
      
      /* all times should be in UTC */
      static time_t	sys_time;
      static time_t	rtc_time;
      
      static int get_basetimes(int fd)
      {
      	struct tm	tm;
      	struct rtc_time	rtc;
      
      	/* this process works in RTC time, except when working
      	 * with the system clock (which always uses UTC).
      	 */
      	if (rtc_is_utc)
      		setenv("TZ", "UTC", 1);
      	tzset();
      
      	/* read rtc and system clocks "at the same time", or as
      	 * precisely (+/- a second) as we can read them.
      	 */
      	if (ioctl(fd, RTC_RD_TIME, &rtc) < 0) {
      		perror("read rtc time");
      		return 0;
      	}
      	sys_time = time(0);
      	if (sys_time == (time_t)-1) {
      		perror("read system time");
      		return 0;
      	}
      
      	/* convert rtc_time to normal arithmetic-friendly form,
      	 * updating tm.tm_wday as used by asctime().
      	 */
      	memset(&tm, 0, sizeof tm);
      	tm.tm_sec = rtc.tm_sec;
      	tm.tm_min = rtc.tm_min;
      	tm.tm_hour = rtc.tm_hour;
      	tm.tm_mday = rtc.tm_mday;
      	tm.tm_mon = rtc.tm_mon;
      	tm.tm_year = rtc.tm_year;
      	tm.tm_isdst = rtc.tm_isdst;	/* stays unspecified? */
      	rtc_time = mktime(&tm);
      
      	if (rtc_time == (time_t)-1) {
      		perror("convert rtc time");
      		return 0;
      	}
      
      	if (verbose) {
      		if (!rtc_is_utc) {
      			printf("\ttzone   = %ld\n", timezone);
      			printf("\ttzname  = %s\n", tzname[daylight]);
      			gmtime_r(&rtc_time, &tm);
      		}
      		printf("\tsystime = %ld, (UTC) %s",
      				(long) sys_time, asctime(gmtime(&sys_time)));
      		printf("\trtctime = %ld, (UTC) %s",
      				(long) rtc_time, asctime(&tm));
      	}
      
      	return 1;
      }
      
      static int setup_alarm(int fd, time_t *wakeup)
      {
      	struct tm		*tm;
      	struct rtc_wkalrm	wake;
      
      	tm = gmtime(wakeup);
      
      	wake.time.tm_sec = tm->tm_sec;
      	wake.time.tm_min = tm->tm_min;
      	wake.time.tm_hour = tm->tm_hour;
      	wake.time.tm_mday = tm->tm_mday;
      	wake.time.tm_mon = tm->tm_mon;
      	wake.time.tm_year = tm->tm_year;
      	wake.time.tm_wday = tm->tm_wday;
      	wake.time.tm_yday = tm->tm_yday;
      	wake.time.tm_isdst = tm->tm_isdst;
      
      	/* many rtc alarms only support up to 24 hours from 'now' ... */
      	if ((rtc_time + (24 * 60 * 60)) > *wakeup) {
      		if (ioctl(fd, RTC_ALM_SET, &wake.time) < 0) {
      			perror("set rtc alarm");
      			return 0;
      		}
      		if (ioctl(fd, RTC_AIE_ON, 0) < 0) {
      			perror("enable rtc alarm");
      			return 0;
      		}
      
      	/* ... so use the "more than 24 hours" request only if we must */
      	} else {
      		/* avoid an extra AIE_ON call */
      		wake.enabled = 1;
      
      		if (ioctl(fd, RTC_WKALM_SET, &wake) < 0) {
      			perror("set rtc wake alarm");
      			return 0;
      		}
      	}
      
      	return 1;
      }
      
      static void suspend_system(const char *suspend)
      {
      	FILE	*f = fopen("/sys/power/state", "w");
      
      	if (!f) {
      		perror("/sys/power/state");
      		return;
      	}
      
      	fprintf(f, "%s\n", suspend);
      	fflush(f);
      
      	/* this executes after wake from suspend */
      	fclose(f);
      }
      
      int main(int argc, char **argv)
      {
      	static char		*devname = "rtc0";
      	static unsigned		seconds = 0;
      	static char		*suspend = "standby";
      
      	int		t;
      	int		fd;
      	time_t		alarm = 0;
      
      	progname = strrchr(argv[0], '/');
      	if (progname)
      		progname++;
      	else
      		progname = argv[0];
      	if (chdir("/dev/") < 0) {
      		perror("chdir /dev");
      		return 1;
      	}
      
      	while ((t = getopt(argc, argv, "d:lm:s:t:uVv")) != EOF) {
      		switch (t) {
      
      		case 'd':
      			devname = optarg;
      			break;
      
      		case 'l':
      			rtc_is_utc = 0;
      			break;
      
      		/* what system power mode to use?  for now handle only
      		 * standardized mode names; eventually when systems define
      		 * their own state names, parse /sys/power/state.
      		 *
      		 * "on" is used just to test the RTC alarm mechanism,
      		 * bypassing all the wakeup-from-sleep infrastructure.
      		 */
      		case 'm':
      			if (strcmp(optarg, "standby") == 0
      					|| strcmp(optarg, "mem") == 0
      					|| strcmp(optarg, "disk") == 0
      					|| strcmp(optarg, "on") == 0
      					) {
      				suspend = optarg;
      				break;
      			}
      			printf("%s: unrecognized suspend state '%s'\n",
      					progname, optarg);
      			goto usage;
      
      		/* alarm time, seconds-to-sleep (relative) */
      		case 's':
      			t = atoi(optarg);
      			if (t < 0) {
      				printf("%s: illegal interval %s seconds\n",
      						progname, optarg);
      				goto usage;
      			}
      			seconds = t;
      			break;
      
      		/* alarm time, time_t (absolute, seconds since 1/1 1970 UTC) */
      		case 't':
      			t = atoi(optarg);
      			if (t < 0) {
      				printf("%s: illegal time_t value %s\n",
      						progname, optarg);
      				goto usage;
      			}
      			alarm = t;
      			break;
      
      		case 'u':
      			rtc_is_utc = 1;
      			break;
      
      		case 'v':
      			verbose++;
      			break;
      
      		case 'V':
      			printf("%s: version %s\n", progname, VERSION);
      			break;
      
      		default:
      usage:
      			printf("usage: %s [options]"
      				"\n\t"
      				"-d rtc0|rtc1|...\t(select rtc)"
      				"\n\t"
      				"-l\t\t\t(RTC uses local timezone)"
      				"\n\t"
      				"-m standby|mem|...\t(sleep mode)"
      				"\n\t"
      				"-s seconds\t\t(seconds to sleep)"
      				"\n\t"
      				"-t time_t\t\t(time to wake)"
      				"\n\t"
      				"-u\t\t\t(RTC uses UTC)"
      				"\n\t"
      				"-v\t\t\t(verbose messages)"
      				"\n\t"
      				"-V\t\t\t(show version)"
      				"\n",
      				progname);
      			return 1;
      		}
      	}
      
      	if (!alarm && !seconds) {
      		printf("%s: must provide wake time\n", progname);
      		goto usage;
      	}
      
      	/* REVISIT:  if /etc/adjtime exists, read it to see what
      	 * the util-linux version of hwclock assumes.
      	 */
      	if (rtc_is_utc == -1) {
      		printf("%s: assuming RTC uses UTC ...\n", progname);
      		rtc_is_utc = 1;
      	}
      
      	/* this RTC must exist and (if we'll sleep) be wakeup-enabled */
      	fd = open(devname, O_RDONLY);
      	if (fd < 0) {
      		perror(devname);
      		return 1;
      	}
      	if (strcmp(suspend, "on") != 0 && !may_wakeup(devname)) {
      		printf("%s: %s not enabled for wakeup events\n",
      				progname, devname);
      		return 1;
      	}
      
      	/* relative or absolute alarm time, normalized to time_t */
      	if (!get_basetimes(fd))
      		return 1;
      	if (verbose)
      		printf("alarm %ld, sys_time %ld, rtc_time %ld, seconds %u\n",
      				alarm, sys_time, rtc_time, seconds);
      	if (alarm) {
      		if (alarm < sys_time) {
      			printf("%s: time doesn't go backward to %s",
      					progname, ctime(&alarm));
      			return 1;
      		}
      		alarm += sys_time - rtc_time;
      	} else
      		alarm = rtc_time + seconds + 1;
      	if (setup_alarm(fd, &alarm) < 0)
      		return 1;
      
      	sync();
      	printf("%s: wakeup from \"%s\" using %s at %s",
      			progname, suspend, devname,
      			ctime(&alarm));
      	fflush(stdout);
      	usleep(10 * 1000);
      
      	if (strcmp(suspend, "on") != 0)
      		suspend_system(suspend);
      	else {
      		unsigned long data;
      
      		do {
      			t = read(fd, &data, sizeof data);
      			if (t < 0) {
      				perror("rtc read");
      				break;
      			}
      			if (verbose)
      				printf("... %s: %03lx\n", devname, data);
      		} while (!(data & RTC_AF));
      	}
      
      	if (ioctl(fd, RTC_AIE_OFF, 0) < 0)
      		perror("disable rtc alarm interrupt");
      
      	close(fd);
      	return 0;
      }
      
      This patch:
      
      Make rtc-cmos do the relevant magic so this RTC can wake the system from a
      sleep state.  That magic comes in two basic flavors:
      
       - Straightforward:  enable_irq_wake(), the way it'd work on most SOC chips;
         or generally with system sleep states which don't disable core IRQ logic.
      
       - Roundabout, using non-IRQ platform hooks.  This is needed with ACPI and
         one almost-clone chip which uses a special wakeup-only alarm.  (That's
         the RTC used on Footbridge boards, FWIW, which don't do PM in Linux.)
      
      A separate patch implements those hooks for ACPI platforms, so that rtc_cmos
      can issue system wakeup events (and its sysfs "wakealarm" attribute works on
      at least some systems).
      Signed-off-by: NDavid Brownell <dbrownell@users.sourceforge.net>
      Cc: Alessandro Zummo <a.zummo@towertech.it>
      Cc: Len Brown <lenb@kernel.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      87ac84f4
    • D
      rtc: remove rest of class_device · cd966209
      David Brownell 提交于
      Finish converting the RTC framework so it no longer uses class_device.
      Signed-off-by: NDavid Brownell <dbrownell@users.sourceforge.net>
      Acked-by: NGreg Kroah-Hartman <gregkh@suse.de>
      Acked-By: NAlessandro Zummo <a.zummo@towertech.it>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      cd966209
    • D
      rtc: rtc interfaces don't use class_device · ab6a2d70
      David Brownell 提交于
      This patch removes class_device from the programming interface that the RTC
      framework exposes to the rest of the kernel.  Now an rtc_device is passed,
      which is more type-safe and streamlines all the relevant code.
      Signed-off-by: NDavid Brownell <dbrownell@users.sourceforge.net>
      Acked-by: NGreg Kroah-Hartman <gregkh@suse.de>
      Acked-By: NAlessandro Zummo <a.zummo@towertech.it>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      ab6a2d70
    • D
      rtc: remove /sys/class/rtc-dev/* · 5726fb20
      David Brownell 提交于
      This simplifies the /dev support by removing a superfluous class_device (the
      /sys/class/rtc-dev stuff) and the class_interface that hooks it into the rtc
      core.  Accordingly, if it's configured then /dev support is now part of the
      RTC core, and is never a separate module.
      
      It's another step towards being able to remove "struct class_device".
      
      [bunk@stusta.de: drivers/rtc/rtc-dev.c should #include "rtc-core.h"]
      Signed-off-by: NDavid Brownell <dbrownell@users.sourceforge.net>
      Acked-by: NGreg Kroah-Hartman <gregkh@suse.de>
      Acked-By: NAlessandro Zummo <a.zummo@towertech.it>
      Signed-off-by: NAdrian Bunk <bunk@stusta.de>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      5726fb20
    • U
      utimensat implementation · 1c710c89
      Ulrich Drepper 提交于
      Implement utimensat(2) which is an extension to futimesat(2) in that it
      
      a) supports nano-second resolution for the timestamps
      b) allows to selectively ignore the atime/mtime value
      c) allows to selectively use the current time for either atime or mtime
      d) supports changing the atime/mtime of a symlink itself along the lines
         of the BSD lutimes(3) functions
      
      For this change the internally used do_utimes() functions was changed to
      accept a timespec time value and an additional flags parameter.
      
      Additionally the sys_utime function was changed to match compat_sys_utime
      which already use do_utimes instead of duplicating the work.
      
      Also, the completely missing futimensat() functionality is added.  We have
      such a function in glibc but we have to resort to using /proc/self/fd/* which
      not everybody likes (chroot etc).
      
      Test application (the syscall number will need per-arch editing):
      
      #include <errno.h>
      #include <fcntl.h>
      #include <time.h>
      #include <sys/time.h>
      #include <stddef.h>
      #include <syscall.h>
      
      #define __NR_utimensat 280
      
      #define UTIME_NOW       ((1l << 30) - 1l)
      #define UTIME_OMIT      ((1l << 30) - 2l)
      
      int
      main(void)
      {
        int status = 0;
      
        int fd = open("ttt", O_RDWR|O_CREAT|O_EXCL, 0666);
        if (fd == -1)
          error (1, errno, "failed to create test file \"ttt\"");
      
        struct stat64 st1;
        if (fstat64 (fd, &st1) != 0)
          error (1, errno, "fstat failed");
      
        struct timespec t[2];
        t[0].tv_sec = 0;
        t[0].tv_nsec = 0;
        t[1].tv_sec = 0;
        t[1].tv_nsec = 0;
        if (syscall(__NR_utimensat, AT_FDCWD, "ttt", t, 0) != 0)
          error (1, errno, "utimensat failed");
      
        struct stat64 st2;
        if (fstat64 (fd, &st2) != 0)
          error (1, errno, "fstat failed");
      
        if (st2.st_atim.tv_sec != 0 || st2.st_atim.tv_nsec != 0)
          {
            puts ("atim not reset to zero");
            status = 1;
          }
        if (st2.st_mtim.tv_sec != 0 || st2.st_mtim.tv_nsec != 0)
          {
            puts ("mtim not reset to zero");
            status = 1;
          }
        if (status != 0)
          goto out;
      
        t[0] = st1.st_atim;
        t[1].tv_sec = 0;
        t[1].tv_nsec = UTIME_OMIT;
        if (syscall(__NR_utimensat, AT_FDCWD, "ttt", t, 0) != 0)
          error (1, errno, "utimensat failed");
      
        if (fstat64 (fd, &st2) != 0)
          error (1, errno, "fstat failed");
      
        if (st2.st_atim.tv_sec != st1.st_atim.tv_sec
            || st2.st_atim.tv_nsec != st1.st_atim.tv_nsec)
          {
            puts ("atim not set");
            status = 1;
          }
        if (st2.st_mtim.tv_sec != 0 || st2.st_mtim.tv_nsec != 0)
          {
            puts ("mtim changed from zero");
            status = 1;
          }
        if (status != 0)
          goto out;
      
        t[0].tv_sec = 0;
        t[0].tv_nsec = UTIME_OMIT;
        t[1] = st1.st_mtim;
        if (syscall(__NR_utimensat, AT_FDCWD, "ttt", t, 0) != 0)
          error (1, errno, "utimensat failed");
      
        if (fstat64 (fd, &st2) != 0)
          error (1, errno, "fstat failed");
      
        if (st2.st_atim.tv_sec != st1.st_atim.tv_sec
            || st2.st_atim.tv_nsec != st1.st_atim.tv_nsec)
          {
            puts ("mtim changed from original time");
            status = 1;
          }
        if (st2.st_mtim.tv_sec != st1.st_mtim.tv_sec
            || st2.st_mtim.tv_nsec != st1.st_mtim.tv_nsec)
          {
            puts ("mtim not set");
            status = 1;
          }
        if (status != 0)
          goto out;
      
        sleep (2);
      
        t[0].tv_sec = 0;
        t[0].tv_nsec = UTIME_NOW;
        t[1].tv_sec = 0;
        t[1].tv_nsec = UTIME_NOW;
        if (syscall(__NR_utimensat, AT_FDCWD, "ttt", t, 0) != 0)
          error (1, errno, "utimensat failed");
      
        if (fstat64 (fd, &st2) != 0)
          error (1, errno, "fstat failed");
      
        struct timeval tv;
        gettimeofday(&tv,NULL);
      
        if (st2.st_atim.tv_sec <= st1.st_atim.tv_sec
            || st2.st_atim.tv_sec > tv.tv_sec)
          {
            puts ("atim not set to NOW");
            status = 1;
          }
        if (st2.st_mtim.tv_sec <= st1.st_mtim.tv_sec
            || st2.st_mtim.tv_sec > tv.tv_sec)
          {
            puts ("mtim not set to NOW");
            status = 1;
          }
      
        if (symlink ("ttt", "tttsym") != 0)
          error (1, errno, "cannot create symlink");
      
        t[0].tv_sec = 0;
        t[0].tv_nsec = 0;
        t[1].tv_sec = 0;
        t[1].tv_nsec = 0;
        if (syscall(__NR_utimensat, AT_FDCWD, "tttsym", t, AT_SYMLINK_NOFOLLOW) != 0)
          error (1, errno, "utimensat failed");
      
        if (lstat64 ("tttsym", &st2) != 0)
          error (1, errno, "lstat failed");
      
        if (st2.st_atim.tv_sec != 0 || st2.st_atim.tv_nsec != 0)
          {
            puts ("symlink atim not reset to zero");
            status = 1;
          }
        if (st2.st_mtim.tv_sec != 0 || st2.st_mtim.tv_nsec != 0)
          {
            puts ("symlink mtim not reset to zero");
            status = 1;
          }
        if (status != 0)
          goto out;
      
        t[0].tv_sec = 1;
        t[0].tv_nsec = 0;
        t[1].tv_sec = 1;
        t[1].tv_nsec = 0;
        if (syscall(__NR_utimensat, fd, NULL, t, 0) != 0)
          error (1, errno, "utimensat failed");
      
        if (fstat64 (fd, &st2) != 0)
          error (1, errno, "fstat failed");
      
        if (st2.st_atim.tv_sec != 1 || st2.st_atim.tv_nsec != 0)
          {
            puts ("atim not reset to one");
            status = 1;
          }
        if (st2.st_mtim.tv_sec != 1 || st2.st_mtim.tv_nsec != 0)
          {
            puts ("mtim not reset to one");
            status = 1;
          }
      
        if (status == 0)
           puts ("all OK");
      
       out:
        close (fd);
        unlink ("ttt");
        unlink ("tttsym");
      
        return status;
      }
      
      [akpm@linux-foundation.org: add missing i386 syscall table entry]
      Signed-off-by: NUlrich Drepper <drepper@redhat.com>
      Cc: Alexey Dobriyan <adobriyan@openvz.org>
      Cc: Michael Kerrisk <mtk-manpages@gmx.net>
      Cc: <linux-arch@vger.kernel.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      1c710c89
    • E
      Speed up divides by cpu_power in scheduler · 5517d86b
      Eric Dumazet 提交于
      I noticed expensive divides done in try_to_wakeup() and
      find_busiest_group() on a bi dual core Opteron machine (total of 4 cores),
      moderatly loaded (15.000 context switch per second)
      
      oprofile numbers :
      
      CPU: AMD64 processors, speed 2600.05 MHz (estimated)
      Counted CPU_CLK_UNHALTED events (Cycles outside of halt state) with a unit
      mask of 0x00 (No unit mask) count 50000
      samples  %        symbol name
      ...
      613914    1.0498  try_to_wake_up
          834  0.0013 :ffffffff80227ae1:   div    %rcx
      77513  0.1191 :ffffffff80227ae4:   mov    %rax,%r11
      
      608893    1.0413  find_busiest_group
         1841  0.0031 :ffffffff802260bf:       div    %rdi
      140109  0.2394 :ffffffff802260c2:       test   %sil,%sil
      
      Some of these divides can use the reciprocal divides we introduced some
      time ago (currently used in slab AFAIK)
      
      We can assume a load will fit in a 32bits number, because with a
      SCHED_LOAD_SCALE=128 value, its still a theorical limit of 33554432
      
      When/if we reach this limit one day, probably cpus will have a fast
      hardware divide and we can zap the reciprocal divide trick.
      
      Ingo suggested to rename cpu_power to __cpu_power to make clear it should
      not be modified without changing its reciprocal value too.
      
      I did not convert the divide in cpu_avg_load_per_task(), because tracking
      nr_running changes may be not worth it ?  We could use a static table of 32
      reciprocal values but it would add a conditional branch and table lookup.
      
      [akpm@linux-foundation.org: !SMP build fix]
      Signed-off-by: NEric Dumazet <dada1@cosmosbay.com>
      Acked-by: NIngo Molnar <mingo@elte.hu>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      5517d86b
    • S
      sched: dynticks idle load balancing · 46cb4b7c
      Siddha, Suresh B 提交于
      Fix the process idle load balancing in the presence of dynticks.  cpus for
      which ticks are stopped will sleep till the next event wakes it up.
      Potentially these sleeps can be for large durations and during which today,
      there is no periodic idle load balancing being done.
      
      This patch nominates an owner among the idle cpus, which does the idle load
      balancing on behalf of the other idle cpus.  And once all the cpus are
      completely idle, then we can stop this idle load balancing too.  Checks added
      in fast path are minimized.  Whenever there are busy cpus in the system, there
      will be an owner(idle cpu) doing the system wide idle load balancing.
      
      Open items:
      1. Intelligent owner selection (like an idle core in a busy package).
      2. Merge with rcu's nohz_cpu_mask?
      Signed-off-by: NSuresh Siddha <suresh.b.siddha@intel.com>
      Acked-by: NIngo Molnar <mingo@elte.hu>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Nick Piggin <nickpiggin@yahoo.com.au>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      46cb4b7c
    • M
      sanitize linux/isdn_divertif.h for userspace · a7e27d5d
      Mike Frysinger 提交于
      the isdn_divertif contains kernel-only references so I've wrapped them in
      __KERNEL__ and add proper #include statements.
      Signed-off-by: NMike Frysinger <vapier@gentoo.org>
      Cc: Karsten Keil <kkeil@suse.de>
      Cc: David Woodhouse <dwmw2@infradead.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      a7e27d5d
    • A
    • J
      au1550 SPI controller driver · 63bd2359
      Jan Nikitenko 提交于
      Here is a driver for the Alchemy au1550 PSC (Programmable Serial
      Controller) in SPI master mode.
      
      It supports dma transfers using the Alchemy descriptor based dma controller
      for 4-8 bits per word SPI transfers.  For 9-24 bits per word transfers, pio
      irq based mode is used to avoid setup of dma channels from scratch on each
      number of bits per word change.
      
      Tested with au1550; this may also work on other MIPS Alchemy cpus, like
      au1200/au1210/au1250.  Used extensively with SD card connected via SPI;
      this handles 8.1MHz SPI clock transfers using dma without any problem (the
      highest SPI clock freq possible with au1550 running on 324MHz).
      
      The driver supports sharing of SPI bus by multiple devices.  All features
      of Alchemy SPI mode are supported (all SPI modes, msb/lsb first, bits per
      word in 4-24 range).
      
      As the SPI clock of the controller depends on main input clock that shall
      be configured externally, platform data structure for au1550 SPI controller
      driver contains mainclk_hz attribute to define the input clock rate.  From
      this value, dividers of the controller for SPI clock are set up for
      required frequency.
      Signed-off-by: NJan Nikitenko <jan.nikitenko@gmail.com>
      
      Whitespace and section fixups.  Remove partial workaround for platform
      setup bug in dma_mask setup; it couldn't work with multiple controllers.
      Signed-off-by: NDavid Brownell <dbrownell@users.sourceforge.net>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      63bd2359
    • D
      SPI kerneldoc · 33e34dc6
      David Brownell 提交于
      Various documentation updates for the SPI infrastructure, to clarify things
      that may not have been clear, to cope with lack of editing, and fix
      omissions.
      
      Also, plug SPI into the kernel-api DocBook template, and fix all the
      resulting glitches in document generation.
      Signed-off-by: NDavid Brownell <dbrownell@users.sourceforge.net>
      Cc: "Randy.Dunlap" <rdunlap@xenotime.net>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      33e34dc6
    • A
      /dev/spidevB.C interface · 814a8d50
      Andrea Paterniani 提交于
      Add a filesystem API for <linux/spi/spi.h> stack.  The initial version of
      this interface is purely synchronous.
      
      dbrownell@users.sourceforge.net:
      
       Cleaned up, bugfixed; much simplified; added preliminary documentation.
      
       Works with mdev given CONFIG_SYSFS_DEPRECATED; and presumably udev.
      
       Updated SPI_IOC_MESSAGE ioctl to full spi_message semantics, supporting
       groups of one or more transfers (each of which may be full duplex if
       desired).
      
       This is marked as EXPERIMENTAL with an explicit disclaimer that the API
       (notably the ioctls) is subject to change.
      Signed-off-by: NAndrea Paterniani <a.paterniani@swapp-eng.it>
      Signed-off-by: NDavid Brownell <dbrownell@users.sourceforge.net>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      814a8d50
    • S
      clockchips.h: kernel-doc fix · ce0be127
      Sergei Shtylyov 提交于
      Fix misnamed fields of 'struct clock_event_device' in the kernel-doc
      comment.  Convert the acronyms to uppercase, while at it...
      Signed-off-by: NSergei Shtylyov <sshtylyov@ru.mvista.com>
      Acked-by: NThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      ce0be127
    • M
      hide spinlock in linux/quota.h behind __KERNEL__ · acd64b73
      Mike Frysinger 提交于
      Signed-off-by: NMike Frysinger <vapier@gentoo.org>
      Acked-by: NJan Kara <jack@ucw.cz>
      Cc: David Woodhouse <dwmw2@infradead.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      acd64b73
    • D
      Add taskstats.h to kbuild · 6d4d8c0a
      David Woodhouse 提交于
      Add taskstats.h to include/linux/Kbuild, make headers_install would then
      pickup taskstats.h.  This needs to be done as taskstats.h is a user
      interface header.
      Signed-off-by: NBalbir Singh <balbir@linux.vnet.ibm.com>
      Signed-off-by: NDavid Woodhouse <dwmw2@infradead.org>
      Cc: Don Zickus <dzickus@redhat.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      6d4d8c0a
    • J
      Misc: add sensable phantom driver · cef2cf07
      Jiri Slaby 提交于
      Add sensable phantom driver
      Signed-off-by: NJiri Slaby <jirislaby@gmail.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      cef2cf07
    • A
      Driver for the Maxim DS1WM, a 1-wire bus master ASIC core · f19b121e
      akpm@linux-foundation.org 提交于
      Cc: Matt Reimer <mreimer@vpop.net>
      
      [akpm@linux-foundation.org: kconfig update]
      Signed-off-by: NMatt Reimer <mreimer@vpop.net>
      Signed-off-by: NEvgeniy Polyakov <johnpol@2ka.mipt.ru>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      f19b121e
    • R
      x86_64: kill 19000+ sparse warnings · 63f6564d
      Randy Dunlap 提交于
      Eliminate 19439 (!!) sparse warnings like:
      include/linux/mm.h:321:22: warning: constant 0xffff810000000000 is so big it is unsigned long
      
      Eliminate 56 sparse warnings like:
      arch/x86_64/kernel/setup.c:248:16: warning: constant 0xffffffff80000000 is so big it is unsigned long
      
      Eliminate 5 sparse warnings like:
      arch/x86_64/kernel/module.c:49:13: warning: constant 0xfffffffffff00000 is so big it is unsigned long
      
      Eliminate 23 sparse warnings like:
      arch/x86_64/mm/init.c:551:37: warning: constant 0xffffc20000000000 is so big it is unsigned long
      
      Eliminate 6 sparse warnings like:
      arch/x86_64/kernel/module.c:49:13: warning: constant 0xffffffff88000000 is so big it is unsigned long
      
      Eliminate 23 sparse warnings like:
      arch/x86_64/mm/init.c:552:6: warning: constant 0xffffe1ffffffffff is so big it is unsigned long
      
      Eliminate 3 sparse warnings like:
      arch/x86_64/kernel/e820.c:186:17: warning: constant 0x3fffffffffff is so big it is long
      Signed-off-by: NRandy Dunlap <randy.dunlap@oracle.com>
      Cc: Andi Kleen <ak@suse.de>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      63f6564d
    • R
      consolidate asm/const.h to linux/const.h · 6df95fd7
      Randy Dunlap 提交于
      Make a global linux/const.h header file instead of having multiple,
      per-arch files, and convert current users of asm/const.h to use
      linux/const.h.
      
      Built on x86_64 and sparc64.
      
      [akpm@linux-foundation.org: fix include/asm-x86_64/Kbuild]
      Signed-off-by: NRandy Dunlap <randy.dunlap@oracle.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      Cc: Andi Kleen <ak@suse.de>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      6df95fd7
    • O
      fat: don't use free_clusters for fat32 · 28ec039c
      OGAWA Hirofumi 提交于
      It seems that the recent Windows changed specification, and it's
      undocumented.  Windows doesn't update ->free_clusters correctly.
      
      This patch doesn't use ->free_clusters by default.  (instead, add "usefree"
      for forcing to use it)
      Signed-off-by: NOGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
      Cc: Juergen Beisert <juergen127@kreuzholzen.de>
      Cc: Andreas Schwab <schwab@suse.de>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      28ec039c
    • D
      Clean up mostly unused IOSPACE macros · 0bb5e19d
      David Gibson 提交于
      Most architectures defined three macros, MK_IOSPACE_PFN(), GET_IOSPACE()
      and GET_PFN() in pgtable.h.  However, the only callers of any of these
      macros are in Sparc specific code, either in arch/sparc, arch/sparc64 or
      drivers/sbus.
      
      This patch removes the redundant macros from all architectures except
      sparc and sparc64.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Cc: <linux-arch@vger.kernel.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      0bb5e19d
    • J
      ext3: copy i_flags to inode flags on write · 28be5abb
      Jan Kara 提交于
      A patch that stores inode flags such as S_IMMUTABLE, S_APPEND, etc.  from
      i_flags to EXT3_I(inode)->i_flags when inode is written to disk.  The same
      thing is done on GETFLAGS ioctl.
      
      Quota code changes these flags on quota files (to make it harder for
      sysadmin to screw himself) and these changes were not correctly propagated
      into the filesystem (especially, lsattr did not show them and users were
      wondering...).
      
      Propagate flags such as S_APPEND, S_IMMUTABLE, etc.  from i_flags into
      ext3-specific i_flags.  Hence, when someone sets these flags via a
      different interface than ioctl, they are stored correctly.
      Signed-off-by: NJan Kara <jack@suse.cz>
      Cc: <linux-ext4@vger.kernel.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      28be5abb
    • M
      Document SPIN_LOCK_UNLOCKED/RW_LOCK_UNLOCKED deprecation · d1ab824b
      Michael Ellerman 提交于
      Apparently it's not cool anymore to use SPIN/RW_LOCK_UNLOCKED.  There's
      some mention of this in Documentation/spinlocks.txt, but that only talks
      about dynamic initialisation.
      
      A comment in the code mentioning the preferred usage would be good IMHO.
      
      [akpm@linux-foundation.org: add reason for deprecation]
      Signed-off-by: NMichael Ellerman <michael@ellerman.id.au>
      Acked-by: NIngo Molnar <mingo@elte.hu>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      d1ab824b
    • P
      Introduce a handy list_first_entry macro · b5e61818
      Pavel Emelianov 提交于
      There are many places in the kernel where the construction like
      
         foo = list_entry(head->next, struct foo_struct, list);
      
      are used.
      The code might look more descriptive and neat if using the macro
      
         list_first_entry(head, type, member) \
                   list_entry((head)->next, type, member)
      
      Here is the macro itself and the examples of its usage in the generic code.
       If it will turn out to be useful, I can prepare the set of patches to
      inject in into arch-specific code, drivers, networking, etc.
      Signed-off-by: NPavel Emelianov <xemul@openvz.org>
      Signed-off-by: NKirill Korotaev <dev@openvz.org>
      Cc: Randy Dunlap <randy.dunlap@oracle.com>
      Cc: Andi Kleen <andi@firstfloor.org>
      Cc: Zach Brown <zach.brown@oracle.com>
      Cc: Davide Libenzi <davidel@xmailserver.org>
      Cc: John McCutchan <ttb@tentacle.dhs.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: john stultz <johnstul@us.ibm.com>
      Cc: Ram Pai <linuxram@us.ibm.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      b5e61818
    • M
      SPIN_LOCK_UNLOCKED cleanup in init_task.h · b32e41bb
      Milind Arun Choudhary 提交于
      SPIN_LOCK_UNLOCKED cleanup,use __SPIN_LOCK_UNLOCKED instead
      Signed-off-by: NMilind Arun Choudhary <milindchoudhary@gmail.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      b32e41bb
    • B
      EFI: warn only for pre-1.00 system tables · 873ec746
      Bjorn Helgaas 提交于
      We used to warn unless the EFI system table major revision was exactly 1.
      But EFI 2.00 firmware is starting to appear, and the 2.00 changes don't
      affect anything in Linux.
      Signed-off-by: NBjorn Helgaas <bjorn.helgaas@hp.com>
      Cc: Andi Kleen <ak@suse.de>
      Cc: "Luck, Tony" <tony.luck@intel.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      873ec746
    • D
      fix hotplug for legacy platform drivers · 49a4ec18
      David Brownell 提交于
      We've had various reports of some legacy "probe the hardware" style
      platform drivers having nasty problems with hotplug support.
      
      The core issue is that those legacy drivers don't fully conform to the
      driver model.  They assume a role that should be the responsibility of
      infrastructure code: creating device nodes.
      
      The "modprobe" step in hotplugging relies on drivers to have split those
      roles into different modules.  The lack of this split causes the problems.
      When a driver creates nodes for devices that don't exist (sending a hotplug
      event), then exits (aborting one modprobe) before the "modprobe $MODALIAS"
      step completes (by failing, since it's in the middle of a modprobe), the
      result can be an endless loop of modprobe invocations ...  badness.
      
      This fix uses the newish per-device flag controlling issuance of "add"
      events.  (A previous version of this patch used a per-device "driver can
      hotplug" flag, which only scrubbed $MODALIAS from the environment rather
      than suppressing the entire hotplug event.) It also shrinks that flag to
      one bit, saving a word in "struct device".
      
      So the net of this patch is removing some nasty failures with legacy
      drivers, while retaining hotplug capability for the majority of platform
      drivers.
      Signed-off-by: NDavid Brownell <dbrownell@users.sourceforge.net>
      Cc: Greg KH <gregkh@suse.de>
      Cc: Andres Salomon <dilinger@debian.org>
      Cc: Dominik Brodowski <linux@dominikbrodowski.net>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      49a4ec18
    • C
      cleanup compat ioctl handling · 6272e266
      Christoph Hellwig 提交于
      Merge all compat ioctl handling into compat_ioctl.c instead of splitting it
      over compat.c and compat_ioctl.c.  This also allows to get rid of ioctl32.h
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Looks-good-to: Andi Kleen <ak@suse.de>
      Acked-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      6272e266
    • R
      Pad irq_desc to internode cacheline size · e729aa16
      Ravikiran G Thirumalai 提交于
      We noticed a drop in n/w performance due to the irq_desc being cacheline
      aligned rather than internode aligned.  We see 50% of expected performance
      when two e1000 nics local to two different nodes have consecutive irq
      descriptors allocated, due to false sharing.
      
      Note that this patch does away with cacheline padding for the UP case, as
      it does not seem useful for UP configurations.
      Signed-off-by: NRavikiran Thirumalai <kiran@scalex86.org>
      Signed-off-by: NShai Fultheim <shai@scalex86.org>
      Cc: "Siddha, Suresh B" <suresh.b.siddha@intel.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      e729aa16
    • C
      merge compat_ioctl.h into compat_ioctl.c · 644fd4f5
      Christoph Hellwig 提交于
      Now that there is no arch-specific compat ioctl handling left there is not
      point in having a separate copat_ioctl.h, so merge it into compat_ioctl.c
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Acked-by: NArnd Bergmann <arnd@arndb.de>
      Acked-by: NDavid S. Miller <davem@davemloft.net>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      644fd4f5
    • A
      i386: sched.h inclusion from module.h is baack · 7e80d0d0
      Alexey Dobriyan 提交于
        linux/module.h
        -> linux/elf.h
           -> asm-i386/elf.h
              -> linux/utsname.h
                 -> linux/sched.h
      
      Noticeably cut the number of files which are rebuild upon touching sched.h
      and cut down pulled junk from every module.h inclusion.
      Signed-off-by: NAlexey Dobriyan <adobriyan@gmail.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      7e80d0d0
    • T
      Deprecate SA_xxx interrupt flags -V2 · 0e8638e2
      Thomas Gleixner 提交于
      The deprecation of the SA_xxx interrupt flags did not emit deprecated
      warnings. Andrew said about the removal of the deprecated flag defines:
      
      > This is going to break a lot of external stuff.  We should have found
      > a way to make usage of SA_* emit deprecated warnings (or _some_
      > warning) to warn people of impending doom.  But I can't immediately
      > find a way of doing that. if we _can_ find a way of doing this, I
      > suspect we'll need to do it, and give people another six months.  It's
      > going to get ugly out there.  We shall see...
      
      Define the deprecated flags as a call to a __deprecated inline function
      so a warning is emitted on compile time.
      
      Extend the reprieve of out of tree drivers to 9/2007.
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Acked-by: NIngo Molnar <mingo@elte.hu>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      0e8638e2
    • A
      Fix race between cat /proc/slab_allocators and rmmod · a5c43dae
      Alexey Dobriyan 提交于
      Same story as with cat /proc/*/wchan race vs rmmod race, only
      /proc/slab_allocators want more info than just symbol name.
      Signed-off-by: NAlexey Dobriyan <adobriyan@sw.ru>
      Acked-by: NRusty Russell <rusty@rustcorp.com.au>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      a5c43dae
    • A
      Fix race between cat /proc/*/wchan and rmmod et al · 9d65cb4a
      Alexey Dobriyan 提交于
      kallsyms_lookup() can go iterating over modules list unprotected which is OK
      for emergency situations (oops), but not OK for regular stuff like
      /proc/*/wchan.
      
      Introduce lookup_symbol_name()/lookup_module_symbol_name() which copy symbol
      name into caller-supplied buffer or return -ERANGE.  All copying is done with
      module_mutex held, so...
      Signed-off-by: NAlexey Dobriyan <adobriyan@sw.ru>
      Cc: Rusty Russell <rusty@rustcorp.com.au>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      9d65cb4a
    • A
      Fix race between rmmod and cat /proc/kallsyms · ea07890a
      Alexey Dobriyan 提交于
      module_get_kallsym() leaks "struct module *" outside of module_mutex which is
      no-no, because module can dissapear right after mutex unlock.
      
      Copy all needed information from inside module_mutex into caller-supplied
      space.
      
      [bunk@stusta.de: is_exported() can now become static]
      Signed-off-by: NAlexey Dobriyan <adobriyan@sw.ru>
      Cc: Rusty Russell <rusty@rustcorp.com.au>
      Signed-off-by: NAdrian Bunk <bunk@stusta.de>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      ea07890a
    • A
      Simplify module_get_kallsym() by dropping length arg · ae84e324
      Alexey Dobriyan 提交于
      module_get_kallsym() could in theory truncate module symbol name to fit in
      buffer, but nobody does this.  Always use KSYM_NAME_LEN + 1 bytes for name.
      
      Suggested by lg^WRusty.
      Signed-off-by: NAlexey Dobriyan <adobriyan@sw.ru>
      Acked-by: NRusty Russell <rusty@rustcorp.com.au>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      ae84e324
    • D
      PNPACPI sets pnpdev->dev.archdata · 55955aad
      David Brownell 提交于
      Teach PNPACPI how to hook up its devices to their ACPI nodes, so that
      pnpdev->dev.archdata points to the parallel acpi device node.  Previously
      this only worked for PCI, leaving a notable hole.
      
      Export "acpi_bus_type" so this can work.
      
      Remove some extraneous whitespace.
      Signed-off-by: NDavid Brownell <dbrownell@users.sourceforge.net>
      Cc: Adam Belay <ambx1@neo.rr.com>
      Cc: Bjorn Helgaas <bjorn.helgaas@hp.com>
      Cc: Len Brown <lenb@kernel.org>
      Cc: Greg KH <greg@kroah.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      55955aad
    • A
      Kprobes: print details of kretprobe on assertion failure · 0f95b7fc
      Ananth N Mavinakayanahalli 提交于
      In certain cases like when the real return address can't be found or when
      the number of tracked calls to a kretprobed function is less than the
      number of returns, we may not be able to find the correct return address
      after processing a kretprobe.  Currently we just do a BUG_ON, but no
      information is provided about the actual failing kretprobe.
      
      Print out details of the kretprobe before calling BUG().
      Signed-off-by: NAnanth N Mavinakayanahalli <ananth@in.ibm.com>
      Cc: Prasanna S Panchamukhi <prasanna@in.ibm.com>
      Cc: Jim Keniston <jkenisto@us.ibm.com>
      Cc: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
      Cc: Maneesh Soni <maneesh@in.ibm.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      0f95b7fc