Quoth Andrew: - Most of MM. Still waiting for the poweroc guys to get off their butts and review some threaded hugepages patches. - alpha - vfs bits - drivers/misc - a few core kerenl tweaks - printk() features - MAINTAINERS updates - backlight merge - leds merge - various lib/ updates - checkpatch updates * akpm: (127 commits) epoll: fix spurious lockdep warnings checkpatch: add a --strict check for utf-8 in commit logs kernel.h/checkpatch: mark strict_strto<foo> and simple_strto<foo> as obsolete llist-return-whether-list-is-empty-before-adding-in-llist_add-fix wireless: at76c50x: follow rename pack_hex_byte to hex_byte_pack fat: follow rename pack_hex_byte() to hex_byte_pack() security: follow rename pack_hex_byte() to hex_byte_pack() kgdb: follow rename pack_hex_byte() to hex_byte_pack() lib: rename pack_hex_byte() to hex_byte_pack() lib/string.c: fix strim() semantics for strings that have only blanks lib/idr.c: fix comment for ida_get_new_above() lib/percpu_counter.c: enclose hotplug only variables in hotplug ifdef lib/bitmap.c: quiet sparse noise about address space lib/spinlock_debug.c: print owner on spinlock lockup lib/kstrtox: common code between kstrto*() and simple_strto*() functions drivers/leds/leds-lp5521.c: check if reset is successful leds: turn the blink_timer off before starting to blink leds: save the delay values after a successful call to blink_set() drivers/leds/leds-gpio.c: use gpio_get_value_cansleep() when initializing drivers/leds/leds-lm3530.c: add __devexit_p where needed ...
Unified · Split
| @@ -973,6 +973,9 @@ bytes respectively. Such letter suffixes can also be entirely omitted. · 972 unmodified lines | ||
| 973 | 973 | ignore_loglevel [KNL] |
| 974 | 974 | Ignore loglevel setting - this will print /all/ |
| 975 | 975 | kernel messages to the console. Useful for debugging. |
| 976 | + We also add it as printk module parameter, so users | |
| 977 | + could change it dynamically, usually by | |
| 978 | + /sys/module/printk/parameters/ignore_loglevel. | |
| 976 | 979 | |
| 977 | 980 | ihash_entries= [KNL] |
| 978 | 981 | Set number of hash buckets for inode cache. |
| @@ -1666,6 +1669,11 @@ bytes respectively. Such letter suffixes can also be entirely omitted. · 687 unmodified lines | ||
| 1666 | 1669 | debugging driver suspend/resume hooks). This may |
| 1667 | 1670 | not work reliably with all consoles, but is known |
| 1668 | 1671 | to work with serial and VGA consoles. |
| 1672 | + To facilitate more flexible debugging, we also add | |
| 1673 | + console_suspend, a printk module parameter to control | |
| 1674 | + it. Users could use console_suspend (usually | |
| 1675 | + /sys/module/printk/parameters/console_suspend) to | |
| 1676 | + turn on/off it dynamically. | |
| 1669 | 1677 | |
| 1670 | 1678 | noaliencache [MM, NUMA, SLAB] Disables the allocation of alien |
| 1671 | 1679 | caches in the slab allocator. Saves per-node memory, |
| @@ -24,6 +24,7 @@ show up in /proc/sys/kernel: · 23 unmodified lines | ||
| 24 | 24 | - bootloader_type [ X86 only ] |
| 25 | 25 | - bootloader_version [ X86 only ] |
| 26 | 26 | - callhome [ S390 only ] |
| 27 | +- cap_last_cap | |
| 27 | 28 | - core_pattern |
| 28 | 29 | - core_pipe_limit |
| 29 | 30 | - core_uses_pid |
| @@ -155,6 +156,13 @@ on has a service contract with IBM. · 125 unmodified lines | ||
| 155 | 156 | |
| 156 | 157 | ============================================================== |
| 157 | 158 | |
| 159 | +cap_last_cap | |
| 160 | + | |
| 161 | +Highest valid capability of the running kernel. Exports | |
| 162 | +CAP_LAST_CAP from the kernel. | |
| 163 | + | |
| 164 | +============================================================== | |
| 165 | + | |
| 158 | 166 | core_pattern: |
| 159 | 167 | |
| 160 | 168 | core_pattern is used to specify a core dumpfile pattern name. |
| @@ -379,10 +379,10 @@ EVENT_PROCESS: · 378 unmodified lines | ||
| 379 | 379 | |
| 380 | 380 | # To closer match vmstat scanning statistics, only count isolate_both |
| 381 | 381 | # and isolate_inactive as scanning. isolate_active is rotation |
| 382 | − # isolate_inactive == 0 | |
| 383 | − # isolate_active == 1 | |
| 384 | − # isolate_both == 2 | |
| 385 | − if ($isolate_mode != 1) { | |
| 382 | + # isolate_inactive == 1 | |
| 383 | + # isolate_active == 2 | |
| 384 | + # isolate_both == 3 | |
| 385 | + if ($isolate_mode != 2) { | |
| 386 | 386 | $perprocesspid{$process_pid}->{HIGH_NR_SCANNED} += $nr_scanned; |
| 387 | 387 | } |
| 388 | 388 | $perprocesspid{$process_pid}->{HIGH_NR_CONTIG_DIRTY} += $nr_contig_dirty; |
| @@ -316,6 +316,10 @@ W: http://wiki.analog.com/AD7879 · 315 unmodified lines | ||
| 316 | 316 | S: Supported |
| 317 | 317 | F: drivers/input/touchscreen/ad7879.c |
| 318 | 318 | |
| 319 | +ADDRESS SPACE LAYOUT RANDOMIZATION (ASLR) | |
| 320 | +M: Jiri Kosina <jkosina@suse.cz> | |
| 321 | +S: Maintained | |
| 322 | + | |
| 319 | 323 | ADM1025 HARDWARE MONITOR DRIVER |
| 320 | 324 | M: Jean Delvare <khali@linux-fr.org> |
| 321 | 325 | L: lm-sensors@lm-sensors.org |
| @@ -4020,6 +4024,7 @@ M: Eric Piel <eric.piel@tremplin-utc.net> · 3698 unmodified lines | ||
| 4020 | 4024 | S: Maintained |
| 4021 | 4025 | F: Documentation/misc-devices/lis3lv02d |
| 4022 | 4026 | F: drivers/misc/lis3lv02d/ |
| 4027 | +F: drivers/platform/x86/hp_accel.c | |
| 4023 | 4028 | |
| 4024 | 4029 | LLC (802.2) |
| 4025 | 4030 | M: Arnaldo Carvalho de Melo <acme@ghostprotocols.net> |
| @@ -4974,7 +4979,7 @@ F: include/linux/i2c-algo-pca.h · 948 unmodified lines | ||
| 4974 | 4979 | F: include/linux/i2c-pca-platform.h |
| 4975 | 4980 | |
| 4976 | 4981 | PCI ERROR RECOVERY |
| 4977 | −M: Linas Vepstas <linas@austin.ibm.com> | |
| 4982 | +M: Linas Vepstas <linasvepstas@gmail.com> | |
| 4978 | 4983 | L: linux-pci@vger.kernel.org |
| 4979 | 4984 | S: Supported |
| 4980 | 4985 | F: Documentation/PCI/pci-error-recovery.txt |
| @@ -457,10 +457,12 @@ · 456 unmodified lines | ||
| 457 | 457 | #define __NR_clock_adjtime 499 |
| 458 | 458 | #define __NR_syncfs 500 |
| 459 | 459 | #define __NR_setns 501 |
| 460 | +#define __NR_accept4 502 | |
| 461 | +#define __NR_sendmmsg 503 | |
| 460 | 462 | |
| 461 | 463 | #ifdef __KERNEL__ |
| 462 | 464 | |
| 463 | −#define NR_SYSCALLS 502 | |
| 465 | +#define NR_SYSCALLS 504 | |
| 464 | 466 | |
| 465 | 467 | #define __ARCH_WANT_IPC_PARSE_VERSION |
| 466 | 468 | #define __ARCH_WANT_OLD_READDIR |
| @@ -520,6 +520,8 @@ sys_call_table: · 519 unmodified lines | ||
| 520 | 520 | .quad sys_clock_adjtime |
| 521 | 521 | .quad sys_syncfs /* 500 */ |
| 522 | 522 | .quad sys_setns |
| 523 | + .quad sys_accept4 | |
| 524 | + .quad sys_sendmmsg | |
| 523 | 525 | |
| 524 | 526 | .size sys_call_table, . - sys_call_table |
| 525 | 527 | .type sys_call_table, @object |
| @@ -241,7 +241,7 @@ static struct regulator_init_data gpo_init = { · 240 unmodified lines | ||
| 241 | 241 | }; |
| 242 | 242 | |
| 243 | 243 | static struct regulator_consumer_supply vmmc1_consumers[] = { |
| 244 | − REGULATOR_SUPPLY("lcd_2v8", NULL), | |
| 244 | + REGULATOR_SUPPLY("vcore", "spi0.0"), | |
| 245 | 245 | }; |
| 246 | 246 | |
| 247 | 247 | static struct regulator_init_data vmmc1_init = { |
| @@ -257,7 +257,7 @@ static struct regulator_init_data vmmc1_init = { · 9 unmodified lines | ||
| 257 | 257 | }; |
| 258 | 258 | |
| 259 | 259 | static struct regulator_consumer_supply vgen_consumers[] = { |
| 260 | − REGULATOR_SUPPLY("vdd_lcdio", NULL), | |
| 260 | + REGULATOR_SUPPLY("vdd", "spi0.0"), | |
| 261 | 261 | }; |
| 262 | 262 | |
| 263 | 263 | static struct regulator_init_data vgen_init = { |
| @@ -348,8 +348,6 @@ static const struct imx_fb_platform_data mx27_3ds_fb_data __initconst = { · 84 unmodified lines | ||
| 348 | 348 | static struct l4f00242t03_pdata mx27_3ds_lcd_pdata = { |
| 349 | 349 | .reset_gpio = LCD_RESET, |
| 350 | 350 | .data_enable_gpio = LCD_ENABLE, |
| 351 | − .core_supply = "lcd_2v8", | |
| 352 | − .io_supply = "vdd_lcdio", | |
| 353 | 351 | }; |
| 354 | 352 | |
| 355 | 353 | static struct spi_board_info mx27_3ds_spi_devs[] __initdata = { |
| @@ -285,8 +285,6 @@ static struct mx3fb_platform_data mx3fb_pdata __initdata = { · 284 unmodified lines | ||
| 285 | 285 | static struct l4f00242t03_pdata mx31_3ds_l4f00242t03_pdata = { |
| 286 | 286 | .reset_gpio = IOMUX_TO_GPIO(MX31_PIN_LCS1), |
| 287 | 287 | .data_enable_gpio = IOMUX_TO_GPIO(MX31_PIN_SER_RS), |
| 288 | − .core_supply = "lcd_2v8", | |
| 289 | − .io_supply = "vdd_lcdio", | |
| 290 | 288 | }; |
| 291 | 289 | |
| 292 | 290 | /* |
| @@ -411,7 +409,7 @@ static struct regulator_init_data vmmc2_init = { · 118 unmodified lines | ||
| 411 | 409 | }; |
| 412 | 410 | |
| 413 | 411 | static struct regulator_consumer_supply vmmc1_consumers[] = { |
| 414 | − REGULATOR_SUPPLY("lcd_2v8", NULL), | |
| 412 | + REGULATOR_SUPPLY("vcore", "spi0.0"), | |
| 415 | 413 | REGULATOR_SUPPLY("cmos_2v8", "soc-camera-pdrv.0"), |
| 416 | 414 | }; |
| 417 | 415 | |
| @@ -428,7 +426,7 @@ static struct regulator_init_data vmmc1_init = { · 10 unmodified lines | ||
| 428 | 426 | }; |
| 429 | 427 | |
| 430 | 428 | static struct regulator_consumer_supply vgen_consumers[] = { |
| 431 | − REGULATOR_SUPPLY("vdd_lcdio", NULL), | |
| 429 | + REGULATOR_SUPPLY("vdd", "spi0.0"), | |
| 432 | 430 | }; |
| 433 | 431 | |
| 434 | 432 | static struct regulator_init_data vgen_init = { |
| @@ -694,7 +694,7 @@ mem2hex(char *buf, unsigned char *mem, int count) · 693 unmodified lines | ||
| 694 | 694 | /* Valid mem address. */ |
| 695 | 695 | for (i = 0; i < count; i++) { |
| 696 | 696 | ch = *mem++; |
| 697 | − buf = pack_hex_byte(buf, ch); | |
| 697 | + buf = hex_byte_pack(buf, ch); | |
| 698 | 698 | } |
| 699 | 699 | } |
| 700 | 700 | |
| @@ -868,7 +868,7 @@ stub_is_stopped(int sigval) · 167 unmodified lines | ||
| 868 | 868 | /* Send trap type (converted to signal) */ |
| 869 | 869 | |
| 870 | 870 | *ptr++ = 'T'; |
| 871 | − ptr = pack_hex_byte(ptr, sigval); | |
| 871 | + ptr = hex_byte_pack(ptr, sigval); | |
| 872 | 872 | |
| 873 | 873 | /* Send register contents. We probably only need to send the |
| 874 | 874 | * PC, frame pointer and stack pointer here. Other registers will be |
| @@ -881,7 +881,7 @@ stub_is_stopped(int sigval) · 6 unmodified lines | ||
| 881 | 881 | status = read_register (regno, ®_cont); |
| 882 | 882 | |
| 883 | 883 | if (status == SUCCESS) { |
| 884 | − ptr = pack_hex_byte(ptr, regno); | |
| 884 | + ptr = hex_byte_pack(ptr, regno); | |
| 885 | 885 | *ptr++ = ':'; |
| 886 | 886 | |
| 887 | 887 | ptr = mem2hex(ptr, (unsigned char *)®_cont, |
| @@ -677,7 +677,7 @@ mem2hex(char *buf, unsigned char *mem, int count) · 676 unmodified lines | ||
| 677 | 677 | /* Valid mem address. */ |
| 678 | 678 | for (i = 0; i < count; i++) { |
| 679 | 679 | ch = *mem++; |
| 680 | − buf = pack_hex_byte(buf, ch); | |
| 680 | + buf = hex_byte_pack(buf, ch); | |
| 681 | 681 | } |
| 682 | 682 | } |
| 683 | 683 | /* Terminate properly. */ |
| @@ -695,7 +695,7 @@ mem2hex_nbo(char *buf, unsigned char *mem, int count) · 11 unmodified lines | ||
| 695 | 695 | mem += count - 1; |
| 696 | 696 | for (i = 0; i < count; i++) { |
| 697 | 697 | ch = *mem--; |
| 698 | − buf = pack_hex_byte(buf, ch); | |
| 698 | + buf = hex_byte_pack(buf, ch); | |
| 699 | 699 | } |
| 700 | 700 | |
| 701 | 701 | /* Terminate properly. */ |
| @@ -880,7 +880,7 @@ stub_is_stopped(int sigval) · 178 unmodified lines | ||
| 880 | 880 | /* Send trap type (converted to signal) */ |
| 881 | 881 | |
| 882 | 882 | *ptr++ = 'T'; |
| 883 | − ptr = pack_hex_byte(ptr, sigval); | |
| 883 | + ptr = hex_byte_pack(ptr, sigval); | |
| 884 | 884 | |
| 885 | 885 | if (((reg.exs & 0xff00) >> 8) == 0xc) { |
| 886 | 886 | |
| @@ -988,26 +988,26 @@ stub_is_stopped(int sigval) · 101 unmodified lines | ||
| 988 | 988 | } |
| 989 | 989 | /* Only send PC, frame and stack pointer. */ |
| 990 | 990 | read_register(PC, ®_cont); |
| 991 | − ptr = pack_hex_byte(ptr, PC); | |
| 991 | + ptr = hex_byte_pack(ptr, PC); | |
| 992 | 992 | *ptr++ = ':'; |
| 993 | 993 | ptr = mem2hex(ptr, (unsigned char *)®_cont, register_size[PC]); |
| 994 | 994 | *ptr++ = ';'; |
| 995 | 995 | |
| 996 | 996 | read_register(R8, ®_cont); |
| 997 | − ptr = pack_hex_byte(ptr, R8); | |
| 997 | + ptr = hex_byte_pack(ptr, R8); | |
| 998 | 998 | *ptr++ = ':'; |
| 999 | 999 | ptr = mem2hex(ptr, (unsigned char *)®_cont, register_size[R8]); |
| 1000 | 1000 | *ptr++ = ';'; |
| 1001 | 1001 | |
| 1002 | 1002 | read_register(SP, ®_cont); |
| 1003 | − ptr = pack_hex_byte(ptr, SP); | |
| 1003 | + ptr = hex_byte_pack(ptr, SP); | |
| 1004 | 1004 | *ptr++ = ':'; |
| 1005 | 1005 | ptr = mem2hex(ptr, (unsigned char *)®_cont, register_size[SP]); |
| 1006 | 1006 | *ptr++ = ';'; |
| 1007 | 1007 | |
| 1008 | 1008 | /* Send ERP as well; this will save us an entire register fetch in some cases. */ |
| 1009 | 1009 | read_register(ERP, ®_cont); |
| 1010 | − ptr = pack_hex_byte(ptr, ERP); | |
| 1010 | + ptr = hex_byte_pack(ptr, ERP); | |
| 1011 | 1011 | *ptr++ = ':'; |
| 1012 | 1012 | ptr = mem2hex(ptr, (unsigned char *)®_cont, register_size[ERP]); |
| 1013 | 1013 | *ptr++ = ';'; |
| @@ -672,7 +672,7 @@ static unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fa · 671 unmodified lines | ||
| 672 | 672 | if ((uint32_t)mem&1 && count>=1) { |
| 673 | 673 | if (!gdbstub_read_byte(mem,ch)) |
| 674 | 674 | return NULL; |
| 675 | − buf = pack_hex_byte(buf, ch[0]); | |
| 675 | + buf = hex_byte_pack(buf, ch[0]); | |
| 676 | 676 | mem++; |
| 677 | 677 | count--; |
| 678 | 678 | } |
| @@ -680,8 +680,8 @@ static unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fa · 1 unmodified line | ||
| 680 | 680 | if ((uint32_t)mem&3 && count>=2) { |
| 681 | 681 | if (!gdbstub_read_word(mem,(uint16_t *)ch)) |
| 682 | 682 | return NULL; |
| 683 | − buf = pack_hex_byte(buf, ch[0]); | |
| 684 | − buf = pack_hex_byte(buf, ch[1]); | |
| 683 | + buf = hex_byte_pack(buf, ch[0]); | |
| 684 | + buf = hex_byte_pack(buf, ch[1]); | |
| 685 | 685 | mem += 2; |
| 686 | 686 | count -= 2; |
| 687 | 687 | } |
| @@ -689,10 +689,10 @@ static unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fa · 1 unmodified line | ||
| 689 | 689 | while (count>=4) { |
| 690 | 690 | if (!gdbstub_read_dword(mem,(uint32_t *)ch)) |
| 691 | 691 | return NULL; |
| 692 | − buf = pack_hex_byte(buf, ch[0]); | |
| 693 | − buf = pack_hex_byte(buf, ch[1]); | |
| 694 | − buf = pack_hex_byte(buf, ch[2]); | |
| 695 | − buf = pack_hex_byte(buf, ch[3]); | |
| 692 | + buf = hex_byte_pack(buf, ch[0]); | |
| 693 | + buf = hex_byte_pack(buf, ch[1]); | |
| 694 | + buf = hex_byte_pack(buf, ch[2]); | |
| 695 | + buf = hex_byte_pack(buf, ch[3]); | |
| 696 | 696 | mem += 4; |
| 697 | 697 | count -= 4; |
| 698 | 698 | } |
| @@ -700,8 +700,8 @@ static unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fa · 1 unmodified line | ||
| 700 | 700 | if (count>=2) { |
| 701 | 701 | if (!gdbstub_read_word(mem,(uint16_t *)ch)) |
| 702 | 702 | return NULL; |
| 703 | − buf = pack_hex_byte(buf, ch[0]); | |
| 704 | − buf = pack_hex_byte(buf, ch[1]); | |
| 703 | + buf = hex_byte_pack(buf, ch[0]); | |
| 704 | + buf = hex_byte_pack(buf, ch[1]); | |
| 705 | 705 | mem += 2; |
| 706 | 706 | count -= 2; |
| 707 | 707 | } |
| @@ -709,7 +709,7 @@ static unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fa · 1 unmodified line | ||
| 709 | 709 | if (count>=1) { |
| 710 | 710 | if (!gdbstub_read_byte(mem,ch)) |
| 711 | 711 | return NULL; |
| 712 | − buf = pack_hex_byte(buf, ch[0]); | |
| 712 | + buf = hex_byte_pack(buf, ch[0]); | |
| 713 | 713 | } |
| 714 | 714 | |
| 715 | 715 | *buf = 0; |
| @@ -1498,21 +1498,21 @@ void gdbstub(int sigval) · 782 unmodified lines | ||
| 1498 | 1498 | ptr = mem2hex(title, ptr, sizeof(title) - 1,0); |
| 1499 | 1499 | |
| 1500 | 1500 | hx = hex_asc_hi(brr >> 24); |
| 1501 | − ptr = pack_hex_byte(ptr, hx); | |
| 1501 | + ptr = hex_byte_pack(ptr, hx); | |
| 1502 | 1502 | hx = hex_asc_lo(brr >> 24); |
| 1503 | − ptr = pack_hex_byte(ptr, hx); | |
| 1503 | + ptr = hex_byte_pack(ptr, hx); | |
| 1504 | 1504 | hx = hex_asc_hi(brr >> 16); |
| 1505 | − ptr = pack_hex_byte(ptr, hx); | |
| 1505 | + ptr = hex_byte_pack(ptr, hx); | |
| 1506 | 1506 | hx = hex_asc_lo(brr >> 16); |
| 1507 | − ptr = pack_hex_byte(ptr, hx); | |
| 1507 | + ptr = hex_byte_pack(ptr, hx); | |
| 1508 | 1508 | hx = hex_asc_hi(brr >> 8); |
| 1509 | − ptr = pack_hex_byte(ptr, hx); | |
| 1509 | + ptr = hex_byte_pack(ptr, hx); | |
| 1510 | 1510 | hx = hex_asc_lo(brr >> 8); |
| 1511 | − ptr = pack_hex_byte(ptr, hx); | |
| 1511 | + ptr = hex_byte_pack(ptr, hx); | |
| 1512 | 1512 | hx = hex_asc_hi(brr); |
| 1513 | − ptr = pack_hex_byte(ptr, hx); | |
| 1513 | + ptr = hex_byte_pack(ptr, hx); | |
| 1514 | 1514 | hx = hex_asc_lo(brr); |
| 1515 | − ptr = pack_hex_byte(ptr, hx); | |
| 1515 | + ptr = hex_byte_pack(ptr, hx); | |
| 1516 | 1516 | |
| 1517 | 1517 | ptr = mem2hex(crlf, ptr, sizeof(crlf) - 1, 0); |
| 1518 | 1518 | *ptr = 0; |
| @@ -1526,10 +1526,10 @@ void gdbstub(int sigval) · 7 unmodified lines | ||
| 1526 | 1526 | |
| 1527 | 1527 | /* Send trap type (converted to signal) */ |
| 1528 | 1528 | *ptr++ = 'T'; |
| 1529 | − ptr = pack_hex_byte(ptr, sigval); | |
| 1529 | + ptr = hex_byte_pack(ptr, sigval); | |
| 1530 | 1530 | |
| 1531 | 1531 | /* Send Error PC */ |
| 1532 | − ptr = pack_hex_byte(ptr, GDB_REG_PC); | |
| 1532 | + ptr = hex_byte_pack(ptr, GDB_REG_PC); | |
| 1533 | 1533 | *ptr++ = ':'; |
| 1534 | 1534 | ptr = mem2hex(&__debug_frame->pc, ptr, 4, 0); |
| 1535 | 1535 | *ptr++ = ';'; |
| @@ -1537,7 +1537,7 @@ void gdbstub(int sigval) · 1 unmodified line | ||
| 1537 | 1537 | /* |
| 1538 | 1538 | * Send frame pointer |
| 1539 | 1539 | */ |
| 1540 | − ptr = pack_hex_byte(ptr, GDB_REG_FP); | |
| 1540 | + ptr = hex_byte_pack(ptr, GDB_REG_FP); | |
| 1541 | 1541 | *ptr++ = ':'; |
| 1542 | 1542 | ptr = mem2hex(&__debug_frame->fp, ptr, 4, 0); |
| 1543 | 1543 | *ptr++ = ';'; |
| @@ -1545,7 +1545,7 @@ void gdbstub(int sigval) · 1 unmodified line | ||
| 1545 | 1545 | /* |
| 1546 | 1546 | * Send stack pointer |
| 1547 | 1547 | */ |
| 1548 | − ptr = pack_hex_byte(ptr, GDB_REG_SP); | |
| 1548 | + ptr = hex_byte_pack(ptr, GDB_REG_SP); | |
| 1549 | 1549 | *ptr++ = ':'; |
| 1550 | 1550 | ptr = mem2hex(&__debug_frame->sp, ptr, 4, 0); |
| 1551 | 1551 | *ptr++ = ';'; |
| @@ -798,7 +798,7 @@ unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fault) · 797 unmodified lines | ||
| 798 | 798 | if ((u32) mem & 1 && count >= 1) { |
| 799 | 799 | if (gdbstub_read_byte(mem, ch) != 0) |
| 800 | 800 | return 0; |
| 801 | − buf = pack_hex_byte(buf, ch[0]); | |
| 801 | + buf = hex_byte_pack(buf, ch[0]); | |
| 802 | 802 | mem++; |
| 803 | 803 | count--; |
| 804 | 804 | } |
| @@ -806,8 +806,8 @@ unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fault) · 1 unmodified line | ||
| 806 | 806 | if ((u32) mem & 3 && count >= 2) { |
| 807 | 807 | if (gdbstub_read_word(mem, ch) != 0) |
| 808 | 808 | return 0; |
| 809 | − buf = pack_hex_byte(buf, ch[0]); | |
| 810 | − buf = pack_hex_byte(buf, ch[1]); | |
| 809 | + buf = hex_byte_pack(buf, ch[0]); | |
| 810 | + buf = hex_byte_pack(buf, ch[1]); | |
| 811 | 811 | mem += 2; |
| 812 | 812 | count -= 2; |
| 813 | 813 | } |
| @@ -815,10 +815,10 @@ unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fault) · 1 unmodified line | ||
| 815 | 815 | while (count >= 4) { |
| 816 | 816 | if (gdbstub_read_dword(mem, ch) != 0) |
| 817 | 817 | return 0; |
| 818 | − buf = pack_hex_byte(buf, ch[0]); | |
| 819 | − buf = pack_hex_byte(buf, ch[1]); | |
| 820 | − buf = pack_hex_byte(buf, ch[2]); | |
| 821 | − buf = pack_hex_byte(buf, ch[3]); | |
| 818 | + buf = hex_byte_pack(buf, ch[0]); | |
| 819 | + buf = hex_byte_pack(buf, ch[1]); | |
| 820 | + buf = hex_byte_pack(buf, ch[2]); | |
| 821 | + buf = hex_byte_pack(buf, ch[3]); | |
| 822 | 822 | mem += 4; |
| 823 | 823 | count -= 4; |
| 824 | 824 | } |
| @@ -826,8 +826,8 @@ unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fault) · 1 unmodified line | ||
| 826 | 826 | if (count >= 2) { |
| 827 | 827 | if (gdbstub_read_word(mem, ch) != 0) |
| 828 | 828 | return 0; |
| 829 | − buf = pack_hex_byte(buf, ch[0]); | |
| 830 | − buf = pack_hex_byte(buf, ch[1]); | |
| 829 | + buf = hex_byte_pack(buf, ch[0]); | |
| 830 | + buf = hex_byte_pack(buf, ch[1]); | |
| 831 | 831 | mem += 2; |
| 832 | 832 | count -= 2; |
| 833 | 833 | } |
| @@ -835,7 +835,7 @@ unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fault) · 1 unmodified line | ||
| 835 | 835 | if (count >= 1) { |
| 836 | 836 | if (gdbstub_read_byte(mem, ch) != 0) |
| 837 | 837 | return 0; |
| 838 | − buf = pack_hex_byte(buf, ch[0]); | |
| 838 | + buf = hex_byte_pack(buf, ch[0]); | |
| 839 | 839 | } |
| 840 | 840 | |
| 841 | 841 | *buf = 0; |
| @@ -1273,13 +1273,13 @@ static int gdbstub(struct pt_regs *regs, enum exception_code excep) · 431 unmodified lines | ||
| 1273 | 1273 | ptr = mem2hex(title, ptr, sizeof(title) - 1, 0); |
| 1274 | 1274 | |
| 1275 | 1275 | hx = hex_asc_hi(excep >> 8); |
| 1276 | − ptr = pack_hex_byte(ptr, hx); | |
| 1276 | + ptr = hex_byte_pack(ptr, hx); | |
| 1277 | 1277 | hx = hex_asc_lo(excep >> 8); |
| 1278 | − ptr = pack_hex_byte(ptr, hx); | |
| 1278 | + ptr = hex_byte_pack(ptr, hx); | |
| 1279 | 1279 | hx = hex_asc_hi(excep); |
| 1280 | − ptr = pack_hex_byte(ptr, hx); | |
| 1280 | + ptr = hex_byte_pack(ptr, hx); | |
| 1281 | 1281 | hx = hex_asc_lo(excep); |
| 1282 | − ptr = pack_hex_byte(ptr, hx); | |
| 1282 | + ptr = hex_byte_pack(ptr, hx); | |
| 1283 | 1283 | |
| 1284 | 1284 | ptr = mem2hex(crlf, ptr, sizeof(crlf) - 1, 0); |
| 1285 | 1285 | *ptr = 0; |
| @@ -1291,21 +1291,21 @@ static int gdbstub(struct pt_regs *regs, enum exception_code excep) · 5 unmodified lines | ||
| 1291 | 1291 | ptr = mem2hex(tbcberr, ptr, sizeof(tbcberr) - 1, 0); |
| 1292 | 1292 | |
| 1293 | 1293 | hx = hex_asc_hi(bcberr >> 24); |
| 1294 | − ptr = pack_hex_byte(ptr, hx); | |
| 1294 | + ptr = hex_byte_pack(ptr, hx); | |
| 1295 | 1295 | hx = hex_asc_lo(bcberr >> 24); |
| 1296 | − ptr = pack_hex_byte(ptr, hx); | |
| 1296 | + ptr = hex_byte_pack(ptr, hx); | |
| 1297 | 1297 | hx = hex_asc_hi(bcberr >> 16); |
| 1298 | − ptr = pack_hex_byte(ptr, hx); | |
| 1298 | + ptr = hex_byte_pack(ptr, hx); | |
| 1299 | 1299 | hx = hex_asc_lo(bcberr >> 16); |
| 1300 | − ptr = pack_hex_byte(ptr, hx); | |
| 1300 | + ptr = hex_byte_pack(ptr, hx); | |
| 1301 | 1301 | hx = hex_asc_hi(bcberr >> 8); |
| 1302 | − ptr = pack_hex_byte(ptr, hx); | |
| 1302 | + ptr = hex_byte_pack(ptr, hx); | |
| 1303 | 1303 | hx = hex_asc_lo(bcberr >> 8); |
| 1304 | − ptr = pack_hex_byte(ptr, hx); | |
| 1304 | + ptr = hex_byte_pack(ptr, hx); | |
| 1305 | 1305 | hx = hex_asc_hi(bcberr); |
| 1306 | − ptr = pack_hex_byte(ptr, hx); | |
| 1306 | + ptr = hex_byte_pack(ptr, hx); | |
| 1307 | 1307 | hx = hex_asc_lo(bcberr); |
| 1308 | − ptr = pack_hex_byte(ptr, hx); | |
| 1308 | + ptr = hex_byte_pack(ptr, hx); | |
| 1309 | 1309 | |
| 1310 | 1310 | ptr = mem2hex(crlf, ptr, sizeof(crlf) - 1, 0); |
| 1311 | 1311 | *ptr = 0; |
| @@ -1321,12 +1321,12 @@ static int gdbstub(struct pt_regs *regs, enum exception_code excep) · 9 unmodified lines | ||
| 1321 | 1321 | * Send trap type (converted to signal) |
| 1322 | 1322 | */ |
| 1323 | 1323 | *ptr++ = 'T'; |
| 1324 | − ptr = pack_hex_byte(ptr, sigval); | |
| 1324 | + ptr = hex_byte_pack(ptr, sigval); | |
| 1325 | 1325 | |
| 1326 | 1326 | /* |
| 1327 | 1327 | * Send Error PC |
| 1328 | 1328 | */ |
| 1329 | − ptr = pack_hex_byte(ptr, GDB_REGID_PC); | |
| 1329 | + ptr = hex_byte_pack(ptr, GDB_REGID_PC); | |
| 1330 | 1330 | *ptr++ = ':'; |
| 1331 | 1331 | ptr = mem2hex(®s->pc, ptr, 4, 0); |
| 1332 | 1332 | *ptr++ = ';'; |
| @@ -1334,7 +1334,7 @@ static int gdbstub(struct pt_regs *regs, enum exception_code excep) · 1 unmodified line | ||
| 1334 | 1334 | /* |
| 1335 | 1335 | * Send frame pointer |
| 1336 | 1336 | */ |
| 1337 | − ptr = pack_hex_byte(ptr, GDB_REGID_FP); | |
| 1337 | + ptr = hex_byte_pack(ptr, GDB_REGID_FP); | |
| 1338 | 1338 | *ptr++ = ':'; |
| 1339 | 1339 | ptr = mem2hex(®s->a3, ptr, 4, 0); |
| 1340 | 1340 | *ptr++ = ';'; |
| @@ -1343,7 +1343,7 @@ static int gdbstub(struct pt_regs *regs, enum exception_code excep) · 2 unmodified lines | ||
| 1343 | 1343 | * Send stack pointer |
| 1344 | 1344 | */ |
| 1345 | 1345 | ssp = (unsigned long) (regs + 1); |
| 1346 | − ptr = pack_hex_byte(ptr, GDB_REGID_SP); | |
| 1346 | + ptr = hex_byte_pack(ptr, GDB_REGID_SP); | |
| 1347 | 1347 | *ptr++ = ':'; |
| 1348 | 1348 | ptr = mem2hex(&ssp, ptr, 4, 0); |
| 1349 | 1349 | *ptr++ = ';'; |
| @@ -354,3 +354,5 @@ COMPAT_SYS_SPU(clock_adjtime) · 353 unmodified lines | ||
| 354 | 354 | SYSCALL_SPU(syncfs) |
| 355 | 355 | COMPAT_SYS_SPU(sendmmsg) |
| 356 | 356 | SYSCALL_SPU(setns) |
| 357 | +COMPAT_SYS(process_vm_readv) | |
| 358 | +COMPAT_SYS(process_vm_writev) | |
| @@ -373,10 +373,12 @@ · 372 unmodified lines | ||
| 373 | 373 | #define __NR_syncfs 348 |
| 374 | 374 | #define __NR_sendmmsg 349 |
| 375 | 375 | #define __NR_setns 350 |
| 376 | +#define __NR_process_vm_readv 351 | |
| 377 | +#define __NR_process_vm_writev 352 | |
| 376 | 378 | |
| 377 | 379 | #ifdef __KERNEL__ |
| 378 | 380 | |
| 379 | −#define __NR_syscalls 351 | |
| 381 | +#define __NR_syscalls 353 | |
| 380 | 382 | |
| 381 | 383 | #define __NR__exit __NR_exit |
| 382 | 384 | #define NR_syscalls __NR_syscalls |
| @@ -850,4 +850,6 @@ ia32_sys_call_table: · 849 unmodified lines | ||
| 850 | 850 | .quad sys_syncfs |
| 851 | 851 | .quad compat_sys_sendmmsg /* 345 */ |
| 852 | 852 | .quad sys_setns |
| 853 | + .quad compat_sys_process_vm_readv | |
| 854 | + .quad compat_sys_process_vm_writev | |
| 853 | 855 | ia32_syscall_end: |
| @@ -352,10 +352,12 @@ · 351 unmodified lines | ||
| 352 | 352 | #define __NR_syncfs 344 |
| 353 | 353 | #define __NR_sendmmsg 345 |
| 354 | 354 | #define __NR_setns 346 |
| 355 | +#define __NR_process_vm_readv 347 | |
| 356 | +#define __NR_process_vm_writev 348 | |
| 355 | 357 | |
| 356 | 358 | #ifdef __KERNEL__ |
| 357 | 359 | |
| 358 | −#define NR_syscalls 347 | |
| 360 | +#define NR_syscalls 349 | |
| 359 | 361 | |
| 360 | 362 | #define __ARCH_WANT_IPC_PARSE_VERSION |
| 361 | 363 | #define __ARCH_WANT_OLD_READDIR |
| @@ -682,6 +682,10 @@ __SYSCALL(__NR_sendmmsg, sys_sendmmsg) · 681 unmodified lines | ||
| 682 | 682 | __SYSCALL(__NR_setns, sys_setns) |
| 683 | 683 | #define __NR_getcpu 309 |
| 684 | 684 | __SYSCALL(__NR_getcpu, sys_getcpu) |
| 685 | +#define __NR_process_vm_readv 310 | |
| 686 | +__SYSCALL(__NR_process_vm_readv, sys_process_vm_readv) | |
| 687 | +#define __NR_process_vm_writev 311 | |
| 688 | +__SYSCALL(__NR_process_vm_writev, sys_process_vm_writev) | |
| 685 | 689 | |
| 686 | 690 | #ifndef __NO_STUBS |
| 687 | 691 | #define __ARCH_WANT_OLD_READDIR |
| @@ -346,3 +346,5 @@ ENTRY(sys_call_table) · 345 unmodified lines | ||
| 346 | 346 | .long sys_syncfs |
| 347 | 347 | .long sys_sendmmsg /* 345 */ |
| 348 | 348 | .long sys_setns |
| 349 | + .long sys_process_vm_readv | |
| 350 | + .long sys_process_vm_writev | |
| @@ -27,8 +27,7 @@ · 26 unmodified lines | ||
| 27 | 27 | |
| 28 | 28 | static struct class *hwmon_class; |
| 29 | 29 | |
| 30 | −static DEFINE_IDR(hwmon_idr); | |
| 31 | −static DEFINE_SPINLOCK(idr_lock); | |
| 30 | +static DEFINE_IDA(hwmon_ida); | |
| 32 | 31 | |
| 33 | 32 | /** |
| 34 | 33 | * hwmon_device_register - register w/ hwmon |
| @@ -42,30 +41,17 @@ static DEFINE_SPINLOCK(idr_lock); · 7 unmodified lines | ||
| 42 | 41 | struct device *hwmon_device_register(struct device *dev) |
| 43 | 42 | { |
| 44 | 43 | struct device *hwdev; |
| 45 | − int id, err; | |
| 46 | − | |
| 47 | −again: | |
| 48 | − if (unlikely(idr_pre_get(&hwmon_idr, GFP_KERNEL) == 0)) | |
| 49 | − return ERR_PTR(-ENOMEM); | |
| 50 | − | |
| 51 | − spin_lock(&idr_lock); | |
| 52 | − err = idr_get_new(&hwmon_idr, NULL, &id); | |
| 53 | − spin_unlock(&idr_lock); | |
| 44 | + int id; | |
| 54 | 45 | |
| 55 | − if (unlikely(err == -EAGAIN)) | |
| 56 | − goto again; | |
| 57 | − else if (unlikely(err)) | |
| 58 | − return ERR_PTR(err); | |
| 46 | + id = ida_simple_get(&hwmon_ida, 0, 0, GFP_KERNEL); | |
| 47 | + if (id < 0) | |
| 48 | + return ERR_PTR(id); | |
| 59 | 49 | |
| 60 | − id = id & MAX_ID_MASK; | |
| 61 | 50 | hwdev = device_create(hwmon_class, dev, MKDEV(0, 0), NULL, |
| 62 | 51 | HWMON_ID_FORMAT, id); |
| 63 | 52 | |
| 64 | − if (IS_ERR(hwdev)) { | |
| 65 | − spin_lock(&idr_lock); | |
| 66 | − idr_remove(&hwmon_idr, id); | |
| 67 | − spin_unlock(&idr_lock); | |
| 68 | − } | |
| 53 | + if (IS_ERR(hwdev)) | |
| 54 | + ida_simple_remove(&hwmon_ida, id); | |
| 69 | 55 | |
| 70 | 56 | return hwdev; |
| 71 | 57 | } |
| @@ -81,9 +67,7 @@ void hwmon_device_unregister(struct device *dev) · 9 unmodified lines | ||
| 81 | 67 | |
| 82 | 68 | if (likely(sscanf(dev_name(dev), HWMON_ID_FORMAT, &id) == 1)) { |
| 83 | 69 | device_unregister(dev); |
| 84 | − spin_lock(&idr_lock); | |
| 85 | − idr_remove(&hwmon_idr, id); | |
| 86 | − spin_unlock(&idr_lock); | |
| 70 | + ida_simple_remove(&hwmon_ida, id); | |
| 87 | 71 | } else |
| 88 | 72 | dev_dbg(dev->parent, |
| 89 | 73 | "hwmon_device_unregister() failed: bad class ID!\n"); |
| @@ -88,8 +88,7 @@ · 87 unmodified lines | ||
| 88 | 88 | #define AEM_MIN_POWER_INTERVAL 200 |
| 89 | 89 | #define UJ_PER_MJ 1000L |
| 90 | 90 | |
| 91 | −static DEFINE_IDR(aem_idr); | |
| 92 | −static DEFINE_SPINLOCK(aem_idr_lock); | |
| 91 | +static DEFINE_IDA(aem_ida); | |
| 93 | 92 | |
| 94 | 93 | static struct platform_driver aem_driver = { |
| 95 | 94 | .driver = { |
| @@ -356,38 +355,6 @@ static void aem_msg_handler(struct ipmi_recv_msg *msg, void *user_msg_data) · 260 unmodified lines | ||
| 356 | 355 | complete(&data->read_complete); |
| 357 | 356 | } |
| 358 | 357 | |
| 359 | −/* ID functions */ | |
| 360 | − | |
| 361 | −/* Obtain an id */ | |
| 362 | −static int aem_idr_get(int *id) | |
| 363 | −{ | |
| 364 | − int i, err; | |
| 365 | − | |
| 366 | −again: | |
| 367 | − if (unlikely(!idr_pre_get(&aem_idr, GFP_KERNEL))) | |
| 368 | − return -ENOMEM; | |
| 369 | − | |
| 370 | − spin_lock(&aem_idr_lock); | |
| 371 | − err = idr_get_new(&aem_idr, NULL, &i); | |
| 372 | − spin_unlock(&aem_idr_lock); | |
| 373 | − | |
| 374 | − if (unlikely(err == -EAGAIN)) | |
| 375 | − goto again; | |
| 376 | − else if (unlikely(err)) | |
| 377 | − return err; | |
| 378 | − | |
| 379 | − *id = i & MAX_ID_MASK; | |
| 380 | − return 0; | |
| 381 | −} | |
| 382 | − | |
| 383 | −/* Release an object ID */ | |
| 384 | −static void aem_idr_put(int id) | |
| 385 | −{ | |
| 386 | − spin_lock(&aem_idr_lock); | |
| 387 | − idr_remove(&aem_idr, id); | |
| 388 | − spin_unlock(&aem_idr_lock); | |
| 389 | −} | |
| 390 | − | |
| 391 | 358 | /* Sensor support functions */ |
| 392 | 359 | |
| 393 | 360 | /* Read a sensor value */ |
| @@ -530,7 +497,7 @@ static void aem_delete(struct aem_data *data) · 136 unmodified lines | ||
| 530 | 497 | ipmi_destroy_user(data->ipmi.user); |
| 531 | 498 | platform_set_drvdata(data->pdev, NULL); |
| 532 | 499 | platform_device_unregister(data->pdev); |
| 533 | − aem_idr_put(data->id); | |
| 500 | + ida_simple_remove(&aem_ida, data->id); | |
| 534 | 501 | kfree(data); |
| 535 | 502 | } |
| 536 | 503 | |
| @@ -587,7 +554,8 @@ static int aem_init_aem1_inst(struct aem_ipmi_data *probe, u8 module_handle) · 50 unmodified lines | ||
| 587 | 554 | data->power_period[i] = AEM_DEFAULT_POWER_INTERVAL; |
| 588 | 555 | |
| 589 | 556 | /* Create sub-device for this fw instance */ |
| 590 | − if (aem_idr_get(&data->id)) | |
| 557 | + data->id = ida_simple_get(&aem_ida, 0, 0, GFP_KERNEL); | |
| 558 | + if (data->id < 0) | |
| 591 | 559 | goto id_err; |
| 592 | 560 | |
| 593 | 561 | data->pdev = platform_device_alloc(DRVNAME, data->id); |
| @@ -638,7 +606,7 @@ ipmi_err: · 44 unmodified lines | ||
| 638 | 606 | platform_set_drvdata(data->pdev, NULL); |
| 639 | 607 | platform_device_unregister(data->pdev); |
| 640 | 608 | dev_err: |
| 641 | − aem_idr_put(data->id); | |
| 609 | + ida_simple_remove(&aem_ida, data->id); | |
| 642 | 610 | id_err: |
| 643 | 611 | kfree(data); |
| 644 | 612 | |
| @@ -720,7 +688,8 @@ static int aem_init_aem2_inst(struct aem_ipmi_data *probe, · 75 unmodified lines | ||
| 720 | 688 | data->power_period[i] = AEM_DEFAULT_POWER_INTERVAL; |
| 721 | 689 | |
| 722 | 690 | /* Create sub-device for this fw instance */ |
| 723 | − if (aem_idr_get(&data->id)) | |
| 691 | + data->id = ida_simple_get(&aem_ida, 0, 0, GFP_KERNEL); | |
| 692 | + if (data->id < 0) | |
| 724 | 693 | goto id_err; |
| 725 | 694 | |
| 726 | 695 | data->pdev = platform_device_alloc(DRVNAME, data->id); |
| @@ -771,7 +740,7 @@ ipmi_err: · 44 unmodified lines | ||
| 771 | 740 | platform_set_drvdata(data->pdev, NULL); |
| 772 | 741 | platform_device_unregister(data->pdev); |
| 773 | 742 | dev_err: |
| 774 | − aem_idr_put(data->id); | |
| 743 | + ida_simple_remove(&aem_ida, data->id); | |
| 775 | 744 | id_err: |
| 776 | 745 | kfree(data); |
| 777 | 746 | |
| @@ -136,7 +136,7 @@ struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr, · 135 unmodified lines | ||
| 136 | 136 | |
| 137 | 137 | down_write(¤t->mm->mmap_sem); |
| 138 | 138 | |
| 139 | − locked = npages + current->mm->locked_vm; | |
| 139 | + locked = npages + current->mm->pinned_vm; | |
| 140 | 140 | lock_limit = rlimit(RLIMIT_MEMLOCK) >> PAGE_SHIFT; |
| 141 | 141 | |
| 142 | 142 | if ((locked > lock_limit) && !capable(CAP_IPC_LOCK)) { |
| @@ -206,7 +206,7 @@ out: · 63 unmodified lines | ||
| 206 | 206 | __ib_umem_release(context->device, umem, 0); |
| 207 | 207 | kfree(umem); |
| 208 | 208 | } else |
| 209 | − current->mm->locked_vm = locked; | |
| 209 | + current->mm->pinned_vm = locked; | |
| 210 | 210 | |
| 211 | 211 | up_write(¤t->mm->mmap_sem); |
| 212 | 212 | if (vma_list) |
| @@ -222,7 +222,7 @@ static void ib_umem_account(struct work_struct *work) · 9 unmodified lines | ||
| 222 | 222 | struct ib_umem *umem = container_of(work, struct ib_umem, work); |
| 223 | 223 | |
| 224 | 224 | down_write(&umem->mm->mmap_sem); |
| 225 | − umem->mm->locked_vm -= umem->diff; | |
| 225 | + umem->mm->pinned_vm -= umem->diff; | |
| 226 | 226 | up_write(&umem->mm->mmap_sem); |
| 227 | 227 | mmput(umem->mm); |
| 228 | 228 | kfree(umem); |
| @@ -79,7 +79,7 @@ static int __ipath_get_user_pages(unsigned long start_page, size_t num_pages, · 78 unmodified lines | ||
| 79 | 79 | goto bail_release; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | − current->mm->locked_vm += num_pages; | |
| 82 | + current->mm->pinned_vm += num_pages; | |
| 83 | 83 | |
| 84 | 84 | ret = 0; |
| 85 | 85 | goto bail; |
| @@ -178,7 +178,7 @@ void ipath_release_user_pages(struct page **p, size_t num_pages) · 92 unmodified lines | ||
| 178 | 178 | |
| 179 | 179 | __ipath_release_user_pages(p, num_pages, 1); |
| 180 | 180 | |
| 181 | − current->mm->locked_vm -= num_pages; | |
| 181 | + current->mm->pinned_vm -= num_pages; | |
| 182 | 182 | |
| 183 | 183 | up_write(¤t->mm->mmap_sem); |
| 184 | 184 | } |
| @@ -195,7 +195,7 @@ static void user_pages_account(struct work_struct *_work) · 10 unmodified lines | ||
| 195 | 195 | container_of(_work, struct ipath_user_pages_work, work); |
| 196 | 196 | |
| 197 | 197 | down_write(&work->mm->mmap_sem); |
| 198 | − work->mm->locked_vm -= work->num_pages; | |
| 198 | + work->mm->pinned_vm -= work->num_pages; | |
| 199 | 199 | up_write(&work->mm->mmap_sem); |
| 200 | 200 | mmput(work->mm); |
| 201 | 201 | kfree(work); |
| @@ -74,7 +74,7 @@ static int __qib_get_user_pages(unsigned long start_page, size_t num_pages, · 73 unmodified lines | ||
| 74 | 74 | goto bail_release; |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | − current->mm->locked_vm += num_pages; | |
| 77 | + current->mm->pinned_vm += num_pages; | |
| 78 | 78 | |
| 79 | 79 | ret = 0; |
| 80 | 80 | goto bail; |
| @@ -151,7 +151,7 @@ void qib_release_user_pages(struct page **p, size_t num_pages) · 70 unmodified lines | ||
| 151 | 151 | __qib_release_user_pages(p, num_pages, 1); |
| 152 | 152 | |
| 153 | 153 | if (current->mm) { |
| 154 | − current->mm->locked_vm -= num_pages; | |
| 154 | + current->mm->pinned_vm -= num_pages; | |
| 155 | 155 | up_write(¤t->mm->mmap_sem); |
| 156 | 156 | } |
| 157 | 157 | } |
| @@ -65,7 +65,7 @@ hisax_findcard(int driverid) · 64 unmodified lines | ||
| 65 | 65 | return (struct IsdnCardState *) 0; |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | −static __attribute__((format(printf, 3, 4))) void | |
| 68 | +static __printf(3, 4) void | |
| 69 | 69 | link_debug(struct Channel *chanp, int direction, char *fmt, ...) |
| 70 | 70 | { |
| 71 | 71 | va_list args; |
| @@ -1068,7 +1068,7 @@ init_d_st(struct Channel *chanp) · 996 unmodified lines | ||
| 1068 | 1068 | return 0; |
| 1069 | 1069 | } |
| 1070 | 1070 | |
| 1071 | −static __attribute__((format(printf, 2, 3))) void | |
| 1071 | +static __printf(2, 3) void | |
| 1072 | 1072 | callc_debug(struct FsmInst *fi, char *fmt, ...) |
| 1073 | 1073 | { |
| 1074 | 1074 | va_list args; |
| @@ -1287,9 +1287,9 @@ int jiftime(char *s, long mark); · 1286 unmodified lines | ||
| 1287 | 1287 | |
| 1288 | 1288 | int HiSax_command(isdn_ctrl * ic); |
| 1289 | 1289 | int HiSax_writebuf_skb(int id, int chan, int ack, struct sk_buff *skb); |
| 1290 | −__attribute__((format(printf, 3, 4))) | |
| 1290 | +__printf(3, 4) | |
| 1291 | 1291 | void HiSax_putstatus(struct IsdnCardState *cs, char *head, char *fmt, ...); |
| 1292 | −__attribute__((format(printf, 3, 0))) | |
| 1292 | +__printf(3, 0) | |
| 1293 | 1293 | void VHiSax_putstatus(struct IsdnCardState *cs, char *head, char *fmt, va_list args); |
| 1294 | 1294 | void HiSax_reportcard(int cardnr, int sel); |
| 1295 | 1295 | int QuickHex(char *txt, u_char * p, int cnt); |
| @@ -21,7 +21,7 @@ · 20 unmodified lines | ||
| 21 | 21 | #define B_XMTBUFREADY 1 |
| 22 | 22 | #define B_ACKPENDING 2 |
| 23 | 23 | |
| 24 | −__attribute__((format(printf, 2, 3))) | |
| 24 | +__printf(2, 3) | |
| 25 | 25 | void debugl1(struct IsdnCardState *cs, char *fmt, ...); |
| 26 | 26 | void DChannel_proc_xmt(struct IsdnCardState *cs); |
| 27 | 27 | void DChannel_proc_rcv(struct IsdnCardState *cs); |
| @@ -66,7 +66,7 @@ static char *strL3Event[] = · 65 unmodified lines | ||
| 66 | 66 | "EV_TIMEOUT", |
| 67 | 67 | }; |
| 68 | 68 | |
| 69 | −static __attribute__((format(printf, 2, 3))) void | |
| 69 | +static __printf(2, 3) void | |
| 70 | 70 | l3m_debug(struct FsmInst *fi, char *fmt, ...) |
| 71 | 71 | { |
| 72 | 72 | va_list args; |
| @@ -167,7 +167,7 @@ static struct FsmNode L1FnList[] __initdata = · 166 unmodified lines | ||
| 167 | 167 | {ST_L1_F8, EV_IND_RSY, l1_ignore}, |
| 168 | 168 | }; |
| 169 | 169 | |
| 170 | −static __attribute__((format(printf, 2, 3))) | |
| 170 | +static __printf(2, 3) | |
| 171 | 171 | void l1m_debug(struct FsmInst *fi, char *fmt, ...) |
| 172 | 172 | { |
| 173 | 173 | va_list args; |
| @@ -270,7 +270,7 @@ static char *strDoutEvent[] = · 96 unmodified lines | ||
| 270 | 270 | "EV_DOUT_UNDERRUN", |
| 271 | 271 | }; |
| 272 | 272 | |
| 273 | −static __attribute__((format(printf, 2, 3))) | |
| 273 | +static __printf(2, 3) | |
| 274 | 274 | void dout_debug(struct FsmInst *fi, char *fmt, ...) |
| 275 | 275 | { |
| 276 | 276 | va_list args; |
| @@ -375,6 +375,18 @@ config LEDS_ASIC3 · 374 unmodified lines | ||
| 375 | 375 | cannot be used. This driver supports hardware blinking with an on+off |
| 376 | 376 | period from 62ms to 125s. Say Y to enable LEDs on the HP iPAQ hx4700. |
| 377 | 377 | |
| 378 | +config LEDS_RENESAS_TPU | |
| 379 | + bool "LED support for Renesas TPU" | |
| 380 | + depends on LEDS_CLASS && HAVE_CLK && GENERIC_GPIO | |
| 381 | + help | |
| 382 | + This option enables build of the LED TPU platform driver, | |
| 383 | + suitable to drive any TPU channel on newer Renesas SoCs. | |
| 384 | + The driver controls the GPIO pin connected to the LED via | |
| 385 | + the GPIO framework and expects the LED to be connected to | |
| 386 | + a pin that can be driven in both GPIO mode and using TPU | |
| 387 | + pin function. The latter to support brightness control. | |
| 388 | + Brightness control is supported but hardware blinking is not. | |
| 389 | + | |
| 378 | 390 | config LEDS_TRIGGERS |
| 379 | 391 | bool "LED Trigger support" |
| 380 | 392 | depends on LEDS_CLASS |
| @@ -42,6 +42,7 @@ obj-$(CONFIG_LEDS_MC13783) += leds-mc13783.o · 41 unmodified lines | ||
| 42 | 42 | obj-$(CONFIG_LEDS_NS2) += leds-ns2.o |
| 43 | 43 | obj-$(CONFIG_LEDS_NETXBIG) += leds-netxbig.o |
| 44 | 44 | obj-$(CONFIG_LEDS_ASIC3) += leds-asic3.o |
| 45 | +obj-$(CONFIG_LEDS_RENESAS_TPU) += leds-renesas-tpu.o | |
| 45 | 46 | |
| 46 | 47 | # LED SPI Drivers |
| 47 | 48 | obj-$(CONFIG_LEDS_DAC124S085) += leds-dac124s085.o |
| @@ -267,9 +267,14 @@ void led_blink_set(struct led_classdev *led_cdev, · 266 unmodified lines | ||
| 267 | 267 | unsigned long *delay_on, |
| 268 | 268 | unsigned long *delay_off) |
| 269 | 269 | { |
| 270 | + del_timer_sync(&led_cdev->blink_timer); | |
| 271 | + | |
| 270 | 272 | if (led_cdev->blink_set && |
| 271 | − !led_cdev->blink_set(led_cdev, delay_on, delay_off)) | |
| 273 | + !led_cdev->blink_set(led_cdev, delay_on, delay_off)) { | |
| 274 | + led_cdev->blink_delay_on = *delay_on; | |
| 275 | + led_cdev->blink_delay_off = *delay_off; | |
| 272 | 276 | return; |
| 277 | + } | |
| 273 | 278 | |
| 274 | 279 | /* blink with 1 Hz as default if nothing specified */ |
| 275 | 280 | if (!*delay_on && !*delay_off) |
| @@ -261,9 +261,12 @@ void led_trigger_register_simple(const char *name, struct led_trigger **tp) · 260 unmodified lines | ||
| 261 | 261 | if (trigger) { |
| 262 | 262 | trigger->name = name; |
| 263 | 263 | err = led_trigger_register(trigger); |
| 264 | − if (err < 0) | |
| 264 | + if (err < 0) { | |
| 265 | + kfree(trigger); | |
| 266 | + trigger = NULL; | |
| 265 | 267 | printk(KERN_WARNING "LED trigger %s failed to register" |
| 266 | 268 | " (%d)\n", name, err); |
| 269 | + } | |
| 267 | 270 | } else |
| 268 | 271 | printk(KERN_WARNING "LED trigger %s failed to register" |
| 269 | 272 | " (no memory)\n", name); |
| @@ -121,7 +121,7 @@ static int __devinit create_gpio_led(const struct gpio_led *template, · 120 unmodified lines | ||
| 121 | 121 | } |
| 122 | 122 | led_dat->cdev.brightness_set = gpio_led_set; |
| 123 | 123 | if (template->default_state == LEDS_GPIO_DEFSTATE_KEEP) |
| 124 | − state = !!gpio_get_value(led_dat->gpio) ^ led_dat->active_low; | |
| 124 | + state = !!gpio_get_value_cansleep(led_dat->gpio) ^ led_dat->active_low; | |
| 125 | 125 | else |
| 126 | 126 | state = (template->default_state == LEDS_GPIO_DEFSTATE_ON); |
| 127 | 127 | led_dat->cdev.brightness = state ? LED_FULL : LED_OFF; |
| @@ -421,7 +421,6 @@ err_class_register: · 420 unmodified lines | ||
| 421 | 421 | err_reg_init: |
| 422 | 422 | regulator_put(drvdata->regulator); |
| 423 | 423 | err_regulator_get: |
| 424 | − i2c_set_clientdata(client, NULL); | |
| 425 | 424 | kfree(drvdata); |
| 426 | 425 | err_out: |
| 427 | 426 | return err; |
| @@ -449,7 +448,7 @@ MODULE_DEVICE_TABLE(i2c, lm3530_id); · 21 unmodified lines | ||
| 449 | 448 | |
| 450 | 449 | static struct i2c_driver lm3530_i2c_driver = { |
| 451 | 450 | .probe = lm3530_probe, |
| 452 | − .remove = lm3530_remove, | |
| 451 | + .remove = __devexit_p(lm3530_remove), | |
| 453 | 452 | .id_table = lm3530_id, |
| 454 | 453 | .driver = { |
| 455 | 454 | .name = LM3530_NAME, |
| @@ -97,6 +97,9 @@ · 96 unmodified lines | ||
| 97 | 97 | /* Status */ |
| 98 | 98 | #define LP5521_EXT_CLK_USED 0x08 |
| 99 | 99 | |
| 100 | +/* default R channel current register value */ | |
| 101 | +#define LP5521_REG_R_CURR_DEFAULT 0xAF | |
| 102 | + | |
| 100 | 103 | struct lp5521_engine { |
| 101 | 104 | int id; |
| 102 | 105 | u8 mode; |
| @@ -175,14 +178,14 @@ static int lp5521_set_engine_mode(struct lp5521_engine *engine, u8 mode) · 72 unmodified lines | ||
| 175 | 178 | mode = LP5521_CMD_DIRECT; |
| 176 | 179 | |
| 177 | 180 | ret = lp5521_read(client, LP5521_REG_OP_MODE, &engine_state); |
| 181 | + if (ret < 0) | |
| 182 | + return ret; | |
| 178 | 183 | |
| 179 | 184 | /* set mode only for this engine */ |
| 180 | 185 | engine_state &= ~(engine->engine_mask); |
| 181 | 186 | mode &= engine->engine_mask; |
| 182 | 187 | engine_state |= mode; |
| 183 | − ret |= lp5521_write(client, LP5521_REG_OP_MODE, engine_state); | |
| 184 | − | |
| 185 | − return ret; | |
| 188 | + return lp5521_write(client, LP5521_REG_OP_MODE, engine_state); | |
| 186 | 189 | } |
| 187 | 190 | |
| 188 | 191 | static int lp5521_load_program(struct lp5521_engine *eng, const u8 *pattern) |
| @@ -643,6 +646,7 @@ static int __devinit lp5521_probe(struct i2c_client *client, · 454 unmodified lines | ||
| 643 | 646 | struct lp5521_chip *chip; |
| 644 | 647 | struct lp5521_platform_data *pdata; |
| 645 | 648 | int ret, i, led; |
| 649 | + u8 buf; | |
| 646 | 650 | |
| 647 | 651 | chip = kzalloc(sizeof(*chip), GFP_KERNEL); |
| 648 | 652 | if (!chip) |
| @@ -681,6 +685,20 @@ static int __devinit lp5521_probe(struct i2c_client *client, · 32 unmodified lines | ||
| 681 | 685 | * Exact value is not available. 10 - 20ms |
| 682 | 686 | * appears to be enough for reset. |
| 683 | 687 | */ |
| 688 | + | |
| 689 | + /* | |
| 690 | + * Make sure that the chip is reset by reading back the r channel | |
| 691 | + * current reg. This is dummy read is required on some platforms - | |
| 692 | + * otherwise further access to the R G B channels in the | |
| 693 | + * LP5521_REG_ENABLE register will not have any effect - strange! | |
| 694 | + */ | |
| 695 | + lp5521_read(client, LP5521_REG_R_CURRENT, &buf); | |
| 696 | + if (buf != LP5521_REG_R_CURR_DEFAULT) { | |
| 697 | + dev_err(&client->dev, "error in reseting chip\n"); | |
| 698 | + goto fail2; | |
| 699 | + } | |
| 700 | + usleep_range(10000, 20000); | |
| 701 | + | |
| 684 | 702 | ret = lp5521_detect(client); |
| 685 | 703 | |
| 686 | 704 | if (ret) { |
| @@ -0,0 +1,357 @@ | ||
| 1 | +/* | |
| 2 | + * LED control using Renesas TPU | |
| 3 | + * | |
| 4 | + * Copyright (C) 2011 Magnus Damm | |
| 5 | + * | |
| 6 | + * This program is free software; you can redistribute it and/or modify | |
| 7 | + * it under the terms of the GNU General Public License as published by | |
| 8 | + * the Free Software Foundation; either version 2 of the License | |
| 9 | + * | |
| 10 | + * This program is distributed in the hope that it will be useful, | |
| 11 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 13 | + * GNU General Public License for more details. | |
| 14 | + * | |
| 15 | + * You should have received a copy of the GNU General Public License | |
| 16 | + * along with this program; if not, write to the Free Software | |
| 17 | + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 18 | + */ | |
| 19 | + | |
| 20 | +#include <linux/module.h> | |
| 21 | +#include <linux/init.h> | |
| 22 | +#include <linux/platform_device.h> | |
| 23 | +#include <linux/spinlock.h> | |
| 24 | +#include <linux/printk.h> | |
| 25 | +#include <linux/ioport.h> | |
| 26 | +#include <linux/io.h> | |
| 27 | +#include <linux/clk.h> | |
| 28 | +#include <linux/leds.h> | |
| 29 | +#include <linux/platform_data/leds-renesas-tpu.h> | |
| 30 | +#include <linux/gpio.h> | |
| 31 | +#include <linux/err.h> | |
| 32 | +#include <linux/slab.h> | |
| 33 | +#include <linux/pm_runtime.h> | |
| 34 | +#include <linux/workqueue.h> | |
| 35 | + | |
| 36 | +enum r_tpu_pin { R_TPU_PIN_UNUSED, R_TPU_PIN_GPIO, R_TPU_PIN_GPIO_FN }; | |
| 37 | +enum r_tpu_timer { R_TPU_TIMER_UNUSED, R_TPU_TIMER_ON }; | |
| 38 | + | |
| 39 | +struct r_tpu_priv { | |
| 40 | + struct led_classdev ldev; | |
| 41 | + void __iomem *mapbase; | |
| 42 | + struct clk *clk; | |
| 43 | + struct platform_device *pdev; | |
| 44 | + enum r_tpu_pin pin_state; | |
| 45 | + enum r_tpu_timer timer_state; | |
| 46 | + unsigned long min_rate; | |
| 47 | + unsigned int refresh_rate; | |
| 48 | + struct work_struct work; | |
| 49 | + enum led_brightness new_brightness; | |
| 50 | +}; | |
| 51 | + | |
| 52 | +static DEFINE_SPINLOCK(r_tpu_lock); | |
| 53 | + | |
| 54 | +#define TSTR -1 /* Timer start register (shared register) */ | |
| 55 | +#define TCR 0 /* Timer control register (+0x00) */ | |
| 56 | +#define TMDR 1 /* Timer mode register (+0x04) */ | |
| 57 | +#define TIOR 2 /* Timer I/O control register (+0x08) */ | |
| 58 | +#define TIER 3 /* Timer interrupt enable register (+0x0c) */ | |
| 59 | +#define TSR 4 /* Timer status register (+0x10) */ | |
| 60 | +#define TCNT 5 /* Timer counter (+0x14) */ | |
| 61 | +#define TGRA 6 /* Timer general register A (+0x18) */ | |
| 62 | +#define TGRB 7 /* Timer general register B (+0x1c) */ | |
| 63 | +#define TGRC 8 /* Timer general register C (+0x20) */ | |
| 64 | +#define TGRD 9 /* Timer general register D (+0x24) */ | |
| 65 | + | |
| 66 | +static inline unsigned short r_tpu_read(struct r_tpu_priv *p, int reg_nr) | |
| 67 | +{ | |
| 68 | + struct led_renesas_tpu_config *cfg = p->pdev->dev.platform_data; | |
| 69 | + void __iomem *base = p->mapbase; | |
| 70 | + unsigned long offs = reg_nr << 2; | |
| 71 | + | |
| 72 | + if (reg_nr == TSTR) | |
| 73 | + return ioread16(base - cfg->channel_offset); | |
| 74 | + | |
| 75 | + return ioread16(base + offs); | |
| 76 | +} | |
| 77 | + | |
| 78 | +static inline void r_tpu_write(struct r_tpu_priv *p, int reg_nr, | |
| 79 | + unsigned short value) | |
| 80 | +{ | |
| 81 | + struct led_renesas_tpu_config *cfg = p->pdev->dev.platform_data; | |
| 82 | + void __iomem *base = p->mapbase; | |
| 83 | + unsigned long offs = reg_nr << 2; | |
| 84 | + | |
| 85 | + if (reg_nr == TSTR) { | |
| 86 | + iowrite16(value, base - cfg->channel_offset); | |
| 87 | + return; | |
| 88 | + } | |
| 89 | + | |
| 90 | + iowrite16(value, base + offs); | |
| 91 | +} | |
| 92 | + | |
| 93 | +static void r_tpu_start_stop_ch(struct r_tpu_priv *p, int start) | |
| 94 | +{ | |
| 95 | + struct led_renesas_tpu_config *cfg = p->pdev->dev.platform_data; | |
| 96 | + unsigned long flags, value; | |
| 97 | + | |
| 98 | + /* start stop register shared by multiple timer channels */ | |
| 99 | + spin_lock_irqsave(&r_tpu_lock, flags); | |
| 100 | + value = r_tpu_read(p, TSTR); | |
| 101 | + | |
| 102 | + if (start) | |
| 103 | + value |= 1 << cfg->timer_bit; | |
| 104 | + else | |
| 105 | + value &= ~(1 << cfg->timer_bit); | |
| 106 | + | |
| 107 | + r_tpu_write(p, TSTR, value); | |
| 108 | + spin_unlock_irqrestore(&r_tpu_lock, flags); | |
| 109 | +} | |
| 110 | + | |
| 111 | +static int r_tpu_enable(struct r_tpu_priv *p, enum led_brightness brightness) | |
| 112 | +{ | |
| 113 | + struct led_renesas_tpu_config *cfg = p->pdev->dev.platform_data; | |
| 114 | + int prescaler[] = { 1, 4, 16, 64 }; | |
| 115 | + int k, ret; | |
| 116 | + unsigned long rate, tmp; | |
| 117 | + | |
| 118 | + if (p->timer_state == R_TPU_TIMER_ON) | |
| 119 | + return 0; | |
| 120 | + | |
| 121 | + /* wake up device and enable clock */ | |
| 122 | + pm_runtime_get_sync(&p->pdev->dev); | |
| 123 | + ret = clk_enable(p->clk); | |
| 124 | + if (ret) { | |
| 125 | + dev_err(&p->pdev->dev, "cannot enable clock\n"); | |
| 126 | + return ret; | |
| 127 | + } | |
| 128 | + | |
| 129 | + /* make sure channel is disabled */ | |
| 130 | + r_tpu_start_stop_ch(p, 0); | |
| 131 | + | |
| 132 | + /* get clock rate after enabling it */ | |
| 133 | + rate = clk_get_rate(p->clk); | |
| 134 | + | |
| 135 | + /* pick the lowest acceptable rate */ | |
| 136 | + for (k = 0; k < ARRAY_SIZE(prescaler); k++) | |
| 137 | + if ((rate / prescaler[k]) < p->min_rate) | |
| 138 | + break; | |
| 139 | + | |
| 140 | + if (!k) { | |
| 141 | + dev_err(&p->pdev->dev, "clock rate mismatch\n"); | |
| 142 | + goto err0; | |
| 143 | + } | |
| 144 | + dev_dbg(&p->pdev->dev, "rate = %lu, prescaler %u\n", | |
| 145 | + rate, prescaler[k - 1]); | |
| 146 | + | |
| 147 | + /* clear TCNT on TGRB match, count on rising edge, set prescaler */ | |
| 148 | + r_tpu_write(p, TCR, 0x0040 | (k - 1)); | |
| 149 | + | |
| 150 | + /* output 0 until TGRA, output 1 until TGRB */ | |
| 151 | + r_tpu_write(p, TIOR, 0x0002); | |
| 152 | + | |
| 153 | + rate /= prescaler[k - 1] * p->refresh_rate; | |
| 154 | + r_tpu_write(p, TGRB, rate); | |
| 155 | + dev_dbg(&p->pdev->dev, "TRGB = 0x%04lx\n", rate); | |
| 156 | + | |
| 157 | + tmp = (cfg->max_brightness - brightness) * rate; | |
| 158 | + r_tpu_write(p, TGRA, tmp / cfg->max_brightness); | |
| 159 | + dev_dbg(&p->pdev->dev, "TRGA = 0x%04lx\n", tmp / cfg->max_brightness); | |
| 160 | + | |
| 161 | + /* PWM mode */ | |
| 162 | + r_tpu_write(p, TMDR, 0x0002); | |
| 163 | + | |
| 164 | + /* enable channel */ | |
| 165 | + r_tpu_start_stop_ch(p, 1); | |
| 166 | + | |
| 167 | + p->timer_state = R_TPU_TIMER_ON; | |
| 168 | + return 0; | |
| 169 | + err0: | |
| 170 | + clk_disable(p->clk); | |
| 171 | + pm_runtime_put_sync(&p->pdev->dev); | |
| 172 | + return -ENOTSUPP; | |
| 173 | +} | |
| 174 | + | |
| 175 | +static void r_tpu_disable(struct r_tpu_priv *p) | |
| 176 | +{ | |
| 177 | + if (p->timer_state == R_TPU_TIMER_UNUSED) | |
| 178 | + return; | |
| 179 | + | |
| 180 | + /* disable channel */ | |
| 181 | + r_tpu_start_stop_ch(p, 0); | |
| 182 | + | |
| 183 | + /* stop clock and mark device as idle */ | |
| 184 | + clk_disable(p->clk); | |
| 185 | + pm_runtime_put_sync(&p->pdev->dev); | |
| 186 | + | |
| 187 | + p->timer_state = R_TPU_TIMER_UNUSED; | |
| 188 | +} | |
| 189 | + | |
| 190 | +static void r_tpu_set_pin(struct r_tpu_priv *p, enum r_tpu_pin new_state, | |
| 191 | + enum led_brightness brightness) | |
| 192 | +{ | |
| 193 | + struct led_renesas_tpu_config *cfg = p->pdev->dev.platform_data; | |
| 194 | + | |
| 195 | + if (p->pin_state == new_state) { | |
| 196 | + if (p->pin_state == R_TPU_PIN_GPIO) | |
| 197 | + gpio_set_value(cfg->pin_gpio, brightness); | |
| 198 | + return; | |
| 199 | + } | |
| 200 | + | |
| 201 | + if (p->pin_state == R_TPU_PIN_GPIO) | |
| 202 | + gpio_free(cfg->pin_gpio); | |
| 203 | + | |
| 204 | + if (p->pin_state == R_TPU_PIN_GPIO_FN) | |
| 205 | + gpio_free(cfg->pin_gpio_fn); | |
| 206 | + | |
| 207 | + if (new_state == R_TPU_PIN_GPIO) { | |
| 208 | + gpio_request(cfg->pin_gpio, cfg->name); | |
| 209 | + gpio_direction_output(cfg->pin_gpio, !!brightness); | |
| 210 | + } | |
| 211 | + if (new_state == R_TPU_PIN_GPIO_FN) | |
| 212 | + gpio_request(cfg->pin_gpio_fn, cfg->name); | |
| 213 | + | |
| 214 | + p->pin_state = new_state; | |
| 215 | +} | |
| 216 | + | |
| 217 | +static void r_tpu_work(struct work_struct *work) | |
| 218 | +{ | |
| 219 | + struct r_tpu_priv *p = container_of(work, struct r_tpu_priv, work); | |
| 220 | + enum led_brightness brightness = p->new_brightness; | |
| 221 | + | |
| 222 | + r_tpu_disable(p); | |
| 223 | + | |
| 224 | + /* off and maximum are handled as GPIO pins, in between PWM */ | |
| 225 | + if ((brightness == 0) || (brightness == p->ldev.max_brightness)) | |
| 226 | + r_tpu_set_pin(p, R_TPU_PIN_GPIO, brightness); | |
| 227 | + else { | |
| 228 | + r_tpu_set_pin(p, R_TPU_PIN_GPIO_FN, 0); | |
| 229 | + r_tpu_enable(p, brightness); | |
| 230 | + } | |
| 231 | +} | |
| 232 | + | |
| 233 | +static void r_tpu_set_brightness(struct led_classdev *ldev, | |
| 234 | + enum led_brightness brightness) | |
| 235 | +{ | |
| 236 | + struct r_tpu_priv *p = container_of(ldev, struct r_tpu_priv, ldev); | |
| 237 | + p->new_brightness = brightness; | |
| 238 | + schedule_work(&p->work); | |
| 239 | +} | |
| 240 | + | |
| 241 | +static int __devinit r_tpu_probe(struct platform_device *pdev) | |
| 242 | +{ | |
| 243 | + struct led_renesas_tpu_config *cfg = pdev->dev.platform_data; | |
| 244 | + struct r_tpu_priv *p; | |
| 245 | + struct resource *res; | |
| 246 | + int ret = -ENXIO; | |
| 247 | + | |
| 248 | + if (!cfg) { | |
| 249 | + dev_err(&pdev->dev, "missing platform data\n"); | |
| 250 | + goto err0; | |
| 251 | + } | |
| 252 | + | |
| 253 | + p = kzalloc(sizeof(*p), GFP_KERNEL); | |
| 254 | + if (p == NULL) { | |
| 255 | + dev_err(&pdev->dev, "failed to allocate driver data\n"); | |
| 256 | + ret = -ENOMEM; | |
| 257 | + goto err0; | |
| 258 | + } | |
| 259 | + | |
| 260 | + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | |
| 261 | + if (!res) { | |
| 262 | + dev_err(&pdev->dev, "failed to get I/O memory\n"); | |
| 263 | + goto err1; | |
| 264 | + } | |
| 265 | + | |
| 266 | + /* map memory, let mapbase point to our channel */ | |
| 267 | + p->mapbase = ioremap_nocache(res->start, resource_size(res)); | |
| 268 | + if (p->mapbase == NULL) { | |
| 269 | + dev_err(&pdev->dev, "failed to remap I/O memory\n"); | |
| 270 | + goto err1; | |
| 271 | + } | |
| 272 | + | |
| 273 | + /* get hold of clock */ | |
| 274 | + p->clk = clk_get(&pdev->dev, NULL); | |
| 275 | + if (IS_ERR(p->clk)) { | |
| 276 | + dev_err(&pdev->dev, "cannot get clock\n"); | |
| 277 | + ret = PTR_ERR(p->clk); | |
| 278 | + goto err2; | |
| 279 | + } | |
| 280 | + | |
| 281 | + p->pdev = pdev; | |
| 282 | + p->pin_state = R_TPU_PIN_UNUSED; | |
| 283 | + p->timer_state = R_TPU_TIMER_UNUSED; | |
| 284 | + p->refresh_rate = cfg->refresh_rate ? cfg->refresh_rate : 100; | |
| 285 | + r_tpu_set_pin(p, R_TPU_PIN_GPIO, LED_OFF); | |
| 286 | + platform_set_drvdata(pdev, p); | |
| 287 | + | |
| 288 | + INIT_WORK(&p->work, r_tpu_work); | |
| 289 | + | |
| 290 | + p->ldev.name = cfg->name; | |
| 291 | + p->ldev.brightness = LED_OFF; | |
| 292 | + p->ldev.max_brightness = cfg->max_brightness; | |
| 293 | + p->ldev.brightness_set = r_tpu_set_brightness; | |
| 294 | + p->ldev.flags |= LED_CORE_SUSPENDRESUME; | |
| 295 | + ret = led_classdev_register(&pdev->dev, &p->ldev); | |
| 296 | + if (ret < 0) | |
| 297 | + goto err3; | |
| 298 | + | |
| 299 | + /* max_brightness may be updated by the LED core code */ | |
| 300 | + p->min_rate = p->ldev.max_brightness * p->refresh_rate; | |
| 301 | + | |
| 302 | + pm_runtime_enable(&pdev->dev); | |
| 303 | + return 0; | |
| 304 | + | |
| 305 | + err3: | |
| 306 | + r_tpu_set_pin(p, R_TPU_PIN_UNUSED, LED_OFF); | |
| 307 | + clk_put(p->clk); | |
| 308 | + err2: | |
| 309 | + iounmap(p->mapbase); | |
| 310 | + err1: | |
| 311 | + kfree(p); | |
| 312 | + err0: | |
| 313 | + return ret; | |
| 314 | +} | |
| 315 | + | |
| 316 | +static int __devexit r_tpu_remove(struct platform_device *pdev) | |
| 317 | +{ | |
| 318 | + struct r_tpu_priv *p = platform_get_drvdata(pdev); | |
| 319 | + | |
| 320 | + r_tpu_set_brightness(&p->ldev, LED_OFF); | |
| 321 | + led_classdev_unregister(&p->ldev); | |
| 322 | + cancel_work_sync(&p->work); | |
| 323 | + r_tpu_disable(p); | |
| 324 | + r_tpu_set_pin(p, R_TPU_PIN_UNUSED, LED_OFF); | |
| 325 | + | |
| 326 | + pm_runtime_disable(&pdev->dev); | |
| 327 | + clk_put(p->clk); | |
| 328 | + | |
| 329 | + iounmap(p->mapbase); | |
| 330 | + kfree(p); | |
| 331 | + return 0; | |
| 332 | +} | |
| 333 | + | |
| 334 | +static struct platform_driver r_tpu_device_driver = { | |
| 335 | + .probe = r_tpu_probe, | |
| 336 | + .remove = __devexit_p(r_tpu_remove), | |
| 337 | + .driver = { | |
| 338 | + .name = "leds-renesas-tpu", | |
| 339 | + } | |
| 340 | +}; | |
| 341 | + | |
| 342 | +static int __init r_tpu_init(void) | |
| 343 | +{ | |
| 344 | + return platform_driver_register(&r_tpu_device_driver); | |
| 345 | +} | |
| 346 | + | |
| 347 | +static void __exit r_tpu_exit(void) | |
| 348 | +{ | |
| 349 | + platform_driver_unregister(&r_tpu_device_driver); | |
| 350 | +} | |
| 351 | + | |
| 352 | +module_init(r_tpu_init); | |
| 353 | +module_exit(r_tpu_exit); | |
| 354 | + | |
| 355 | +MODULE_AUTHOR("Magnus Damm"); | |
| 356 | +MODULE_DESCRIPTION("Renesas TPU LED Driver"); | |
| 357 | +MODULE_LICENSE("GPL v2"); | |
| @@ -98,6 +98,7 @@ static const struct i2c_device_id ad_dpot_id[] = { · 97 unmodified lines | ||
| 98 | 98 | {"ad5282", AD5282_ID}, |
| 99 | 99 | {"adn2860", ADN2860_ID}, |
| 100 | 100 | {"ad5273", AD5273_ID}, |
| 101 | + {"ad5161", AD5161_ID}, | |
| 101 | 102 | {"ad5171", AD5171_ID}, |
| 102 | 103 | {"ad5170", AD5170_ID}, |
| 103 | 104 | {"ad5172", AD5172_ID}, |
| @@ -400,7 +400,8 @@ static int fsa9480_irq_init(struct fsa9480_usbsw *usbsw) · 399 unmodified lines | ||
| 400 | 400 | return ret; |
| 401 | 401 | } |
| 402 | 402 | |
| 403 | − device_init_wakeup(&client->dev, pdata->wakeup); | |
| 403 | + if (pdata) | |
| 404 | + device_init_wakeup(&client->dev, pdata->wakeup); | |
| 404 | 405 | } |
| 405 | 406 | |
| 406 | 407 | return 0; |
| @@ -163,7 +163,7 @@ static void lis3lv02d_get_xyz(struct lis3lv02d *lis3, int *x, int *y, int *z) · 162 unmodified lines | ||
| 163 | 163 | int i; |
| 164 | 164 | |
| 165 | 165 | if (lis3->blkread) { |
| 166 | − if (lis3_dev.whoami == WAI_12B) { | |
| 166 | + if (lis3->whoami == WAI_12B) { | |
| 167 | 167 | u16 data[3]; |
| 168 | 168 | lis3->blkread(lis3, OUTX_L, 6, (u8 *)data); |
| 169 | 169 | for (i = 0; i < 3; i++) |
| @@ -195,18 +195,30 @@ static int lis3_8_rates[2] = {100, 400}; · 25 unmodified lines | ||
| 195 | 195 | static int lis3_3dc_rates[16] = {0, 1, 10, 25, 50, 100, 200, 400, 1600, 5000}; |
| 196 | 196 | |
| 197 | 197 | /* ODR is Output Data Rate */ |
| 198 | −static int lis3lv02d_get_odr(void) | |
| 198 | +static int lis3lv02d_get_odr(struct lis3lv02d *lis3) | |
| 199 | 199 | { |
| 200 | 200 | u8 ctrl; |
| 201 | 201 | int shift; |
| 202 | 202 | |
| 203 | − lis3_dev.read(&lis3_dev, CTRL_REG1, &ctrl); | |
| 204 | − ctrl &= lis3_dev.odr_mask; | |
| 205 | − shift = ffs(lis3_dev.odr_mask) - 1; | |
| 206 | − return lis3_dev.odrs[(ctrl >> shift)]; | |
| 203 | + lis3->read(lis3, CTRL_REG1, &ctrl); | |
| 204 | + ctrl &= lis3->odr_mask; | |
| 205 | + shift = ffs(lis3->odr_mask) - 1; | |
| 206 | + return lis3->odrs[(ctrl >> shift)]; | |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | −static int lis3lv02d_set_odr(int rate) | |
| 209 | +static int lis3lv02d_get_pwron_wait(struct lis3lv02d *lis3) | |
| 210 | +{ | |
| 211 | + int div = lis3lv02d_get_odr(lis3); | |
| 212 | + | |
| 213 | + if (WARN_ONCE(div == 0, "device returned spurious data")) | |
| 214 | + return -ENXIO; | |
| 215 | + | |
| 216 | + /* LIS3 power on delay is quite long */ | |
| 217 | + msleep(lis3->pwron_delay / div); | |
| 218 | + return 0; | |
| 219 | +} | |
| 220 | + | |
| 221 | +static int lis3lv02d_set_odr(struct lis3lv02d *lis3, int rate) | |
| 210 | 222 | { |
| 211 | 223 | u8 ctrl; |
| 212 | 224 | int i, len, shift; |
| @@ -214,14 +226,14 @@ static int lis3lv02d_set_odr(int rate) · 1 unmodified line | ||
| 214 | 226 | if (!rate) |
| 215 | 227 | return -EINVAL; |
| 216 | 228 | |
| 217 | − lis3_dev.read(&lis3_dev, CTRL_REG1, &ctrl); | |
| 218 | − ctrl &= ~lis3_dev.odr_mask; | |
| 219 | − len = 1 << hweight_long(lis3_dev.odr_mask); /* # of possible values */ | |
| 220 | − shift = ffs(lis3_dev.odr_mask) - 1; | |
| 229 | + lis3->read(lis3, CTRL_REG1, &ctrl); | |
| 230 | + ctrl &= ~lis3->odr_mask; | |
| 231 | + len = 1 << hweight_long(lis3->odr_mask); /* # of possible values */ | |
| 232 | + shift = ffs(lis3->odr_mask) - 1; | |
| 221 | 233 | |
| 222 | 234 | for (i = 0; i < len; i++) |
| 223 | − if (lis3_dev.odrs[i] == rate) { | |
| 224 | − lis3_dev.write(&lis3_dev, CTRL_REG1, | |
| 235 | + if (lis3->odrs[i] == rate) { | |
| 236 | + lis3->write(lis3, CTRL_REG1, | |
| 225 | 237 | ctrl | (i << shift)); |
| 226 | 238 | return 0; |
| 227 | 239 | } |
| @@ -240,12 +252,12 @@ static int lis3lv02d_selftest(struct lis3lv02d *lis3, s16 results[3]) · 12 unmodified lines | ||
| 240 | 252 | mutex_lock(&lis3->mutex); |
| 241 | 253 | |
| 242 | 254 | irq_cfg = lis3->irq_cfg; |
| 243 | − if (lis3_dev.whoami == WAI_8B) { | |
| 255 | + if (lis3->whoami == WAI_8B) { | |
| 244 | 256 | lis3->data_ready_count[IRQ_LINE0] = 0; |
| 245 | 257 | lis3->data_ready_count[IRQ_LINE1] = 0; |
| 246 | 258 | |
| 247 | 259 | /* Change interrupt cfg to data ready for selftest */ |
| 248 | − atomic_inc(&lis3_dev.wake_thread); | |
| 260 | + atomic_inc(&lis3->wake_thread); | |
| 249 | 261 | lis3->irq_cfg = LIS3_IRQ1_DATA_READY | LIS3_IRQ2_DATA_READY; |
| 250 | 262 | lis3->read(lis3, CTRL_REG3, &ctrl_reg_data); |
| 251 | 263 | lis3->write(lis3, CTRL_REG3, (ctrl_reg_data & |
| @@ -253,12 +265,12 @@ static int lis3lv02d_selftest(struct lis3lv02d *lis3, s16 results[3]) · 1 unmodified line | ||
| 253 | 265 | (LIS3_IRQ1_DATA_READY | LIS3_IRQ2_DATA_READY)); |
| 254 | 266 | } |
| 255 | 267 | |
| 256 | − if (lis3_dev.whoami == WAI_3DC) { | |
| 268 | + if (lis3->whoami == WAI_3DC) { | |
| 257 | 269 | ctlreg = CTRL_REG4; |
| 258 | 270 | selftest = CTRL4_ST0; |
| 259 | 271 | } else { |
| 260 | 272 | ctlreg = CTRL_REG1; |
| 261 | − if (lis3_dev.whoami == WAI_12B) | |
| 273 | + if (lis3->whoami == WAI_12B) | |
| 262 | 274 | selftest = CTRL1_ST; |
| 263 | 275 | else |
| 264 | 276 | selftest = CTRL1_STP; |
| @@ -266,7 +278,9 @@ static int lis3lv02d_selftest(struct lis3lv02d *lis3, s16 results[3]) · 1 unmodified line | ||
| 266 | 278 | |
| 267 | 279 | lis3->read(lis3, ctlreg, ®); |
| 268 | 280 | lis3->write(lis3, ctlreg, (reg | selftest)); |
| 269 | − msleep(lis3->pwron_delay / lis3lv02d_get_odr()); | |
| 281 | + ret = lis3lv02d_get_pwron_wait(lis3); | |
| 282 | + if (ret) | |
| 283 | + goto fail; | |
| 270 | 284 | |
| 271 | 285 | /* Read directly to avoid axis remap */ |
| 272 | 286 | x = lis3->read_data(lis3, OUTX); |
| @@ -275,7 +289,9 @@ static int lis3lv02d_selftest(struct lis3lv02d *lis3, s16 results[3]) · 2 unmodified lines | ||
| 275 | 289 | |
| 276 | 290 | /* back to normal settings */ |
| 277 | 291 | lis3->write(lis3, ctlreg, reg); |
| 278 | − msleep(lis3->pwron_delay / lis3lv02d_get_odr()); | |
| 292 | + ret = lis3lv02d_get_pwron_wait(lis3); | |
| 293 | + if (ret) | |
| 294 | + goto fail; | |
| 279 | 295 | |
| 280 | 296 | results[0] = x - lis3->read_data(lis3, OUTX); |
| 281 | 297 | results[1] = y - lis3->read_data(lis3, OUTY); |
| @@ -283,9 +299,9 @@ static int lis3lv02d_selftest(struct lis3lv02d *lis3, s16 results[3]) · 1 unmodified line | ||
| 283 | 299 | |
| 284 | 300 | ret = 0; |
| 285 | 301 | |
| 286 | − if (lis3_dev.whoami == WAI_8B) { | |
| 302 | + if (lis3->whoami == WAI_8B) { | |
| 287 | 303 | /* Restore original interrupt configuration */ |
| 288 | − atomic_dec(&lis3_dev.wake_thread); | |
| 304 | + atomic_dec(&lis3->wake_thread); | |
| 289 | 305 | lis3->write(lis3, CTRL_REG3, ctrl_reg_data); |
| 290 | 306 | lis3->irq_cfg = irq_cfg; |
| 291 | 307 | |
| @@ -363,8 +379,9 @@ void lis3lv02d_poweroff(struct lis3lv02d *lis3) · 71 unmodified lines | ||
| 363 | 379 | } |
| 364 | 380 | EXPORT_SYMBOL_GPL(lis3lv02d_poweroff); |
| 365 | 381 | |
| 366 | −void lis3lv02d_poweron(struct lis3lv02d *lis3) | |
| 382 | +int lis3lv02d_poweron(struct lis3lv02d *lis3) | |
| 367 | 383 | { |
| 384 | + int err; | |
| 368 | 385 | u8 reg; |
| 369 | 386 | |
| 370 | 387 | lis3->init(lis3); |
| @@ -384,35 +401,41 @@ void lis3lv02d_poweron(struct lis3lv02d *lis3) · 13 unmodified lines | ||
| 384 | 401 | lis3->write(lis3, CTRL_REG2, reg); |
| 385 | 402 | } |
| 386 | 403 | |
| 387 | − /* LIS3 power on delay is quite long */ | |
| 388 | − msleep(lis3->pwron_delay / lis3lv02d_get_odr()); | |
| 404 | + err = lis3lv02d_get_pwron_wait(lis3); | |
| 405 | + if (err) | |
| 406 | + return err; | |
| 389 | 407 | |
| 390 | 408 | if (lis3->reg_ctrl) |
| 391 | 409 | lis3_context_restore(lis3); |
| 410 | + | |
| 411 | + return 0; | |
| 392 | 412 | } |
| 393 | 413 | EXPORT_SYMBOL_GPL(lis3lv02d_poweron); |
| 394 | 414 | |
| 395 | 415 | |
| 396 | 416 | static void lis3lv02d_joystick_poll(struct input_polled_dev *pidev) |
| 397 | 417 | { |
| 418 | + struct lis3lv02d *lis3 = pidev->private; | |
| 398 | 419 | int x, y, z; |
| 399 | 420 | |
| 400 | − mutex_lock(&lis3_dev.mutex); | |
| 401 | − lis3lv02d_get_xyz(&lis3_dev, &x, &y, &z); | |
| 421 | + mutex_lock(&lis3->mutex); | |
| 422 | + lis3lv02d_get_xyz(lis3, &x, &y, &z); | |
| 402 | 423 | input_report_abs(pidev->input, ABS_X, x); |
| 403 | 424 | input_report_abs(pidev->input, ABS_Y, y); |
| 404 | 425 | input_report_abs(pidev->input, ABS_Z, z); |
| 405 | 426 | input_sync(pidev->input); |
| 406 | − mutex_unlock(&lis3_dev.mutex); | |
| 427 | + mutex_unlock(&lis3->mutex); | |
| 407 | 428 | } |
| 408 | 429 | |
| 409 | 430 | static void lis3lv02d_joystick_open(struct input_polled_dev *pidev) |
| 410 | 431 | { |
| 411 | − if (lis3_dev.pm_dev) | |
| 412 | − pm_runtime_get_sync(lis3_dev.pm_dev); | |
| 432 | + struct lis3lv02d *lis3 = pidev->private; | |
| 413 | 433 | |
| 414 | − if (lis3_dev.pdata && lis3_dev.whoami == WAI_8B && lis3_dev.idev) | |
| 415 | − atomic_set(&lis3_dev.wake_thread, 1); | |
| 434 | + if (lis3->pm_dev) | |
| 435 | + pm_runtime_get_sync(lis3->pm_dev); | |
| 436 | + | |
| 437 | + if (lis3->pdata && lis3->whoami == WAI_8B && lis3->idev) | |
| 438 | + atomic_set(&lis3->wake_thread, 1); | |
| 416 | 439 | /* |
| 417 | 440 | * Update coordinates for the case where poll interval is 0 and |
| 418 | 441 | * the chip in running purely under interrupt control |
| @@ -422,14 +445,18 @@ static void lis3lv02d_joystick_open(struct input_polled_dev *pidev) · 3 unmodified lines | ||
| 422 | 445 | |
| 423 | 446 | static void lis3lv02d_joystick_close(struct input_polled_dev *pidev) |
| 424 | 447 | { |
| 425 | − atomic_set(&lis3_dev.wake_thread, 0); | |
| 426 | − if (lis3_dev.pm_dev) | |
| 427 | − pm_runtime_put(lis3_dev.pm_dev); | |
| 448 | + struct lis3lv02d *lis3 = pidev->private; | |
| 449 | + | |
| 450 | + atomic_set(&lis3->wake_thread, 0); | |
| 451 | + if (lis3->pm_dev) | |
| 452 | + pm_runtime_put(lis3->pm_dev); | |
| 428 | 453 | } |
| 429 | 454 | |
| 430 | −static irqreturn_t lis302dl_interrupt(int irq, void *dummy) | |
| 455 | +static irqreturn_t lis302dl_interrupt(int irq, void *data) | |
| 431 | 456 | { |
| 432 | − if (!test_bit(0, &lis3_dev.misc_opened)) | |
| 457 | + struct lis3lv02d *lis3 = data; | |
| 458 | + | |
| 459 | + if (!test_bit(0, &lis3->misc_opened)) | |
| 433 | 460 | goto out; |
| 434 | 461 | |
| 435 | 462 | /* |
| @@ -437,12 +464,12 @@ static irqreturn_t lis302dl_interrupt(int irq, void *dummy) · 1 unmodified line | ||
| 437 | 464 | * the lid is closed. This leads to interrupts as soon as a little move |
| 438 | 465 | * is done. |
| 439 | 466 | */ |
| 440 | − atomic_inc(&lis3_dev.count); | |
| 467 | + atomic_inc(&lis3->count); | |
| 441 | 468 | |
| 442 | − wake_up_interruptible(&lis3_dev.misc_wait); | |
| 443 | − kill_fasync(&lis3_dev.async_queue, SIGIO, POLL_IN); | |
| 469 | + wake_up_interruptible(&lis3->misc_wait); | |
| 470 | + kill_fasync(&lis3->async_queue, SIGIO, POLL_IN); | |
| 444 | 471 | out: |
| 445 | − if (atomic_read(&lis3_dev.wake_thread)) | |
| 472 | + if (atomic_read(&lis3->wake_thread)) | |
| 446 | 473 | return IRQ_WAKE_THREAD; |
| 447 | 474 | return IRQ_HANDLED; |
| 448 | 475 | } |
| @@ -514,28 +541,37 @@ static irqreturn_t lis302dl_interrupt_thread2_8b(int irq, void *data) · 65 unmodified lines | ||
| 514 | 541 | |
| 515 | 542 | static int lis3lv02d_misc_open(struct inode *inode, struct file *file) |
| 516 | 543 | { |
| 517 | − if (test_and_set_bit(0, &lis3_dev.misc_opened)) | |
| 544 | + struct lis3lv02d *lis3 = container_of(file->private_data, | |
| 545 | + struct lis3lv02d, miscdev); | |
| 546 | + | |
| 547 | + if (test_and_set_bit(0, &lis3->misc_opened)) | |
| 518 | 548 | return -EBUSY; /* already open */ |
| 519 | 549 | |
| 520 | − if (lis3_dev.pm_dev) | |
| 521 | − pm_runtime_get_sync(lis3_dev.pm_dev); | |
| 550 | + if (lis3->pm_dev) | |
| 551 | + pm_runtime_get_sync(lis3->pm_dev); | |
| 522 | 552 | |
| 523 | − atomic_set(&lis3_dev.count, 0); | |
| 553 | + atomic_set(&lis3->count, 0); | |
| 524 | 554 | return 0; |
| 525 | 555 | } |
| 526 | 556 | |
| 527 | 557 | static int lis3lv02d_misc_release(struct inode *inode, struct file *file) |
| 528 | 558 | { |
| 529 | − fasync_helper(-1, file, 0, &lis3_dev.async_queue); | |
| 530 | − clear_bit(0, &lis3_dev.misc_opened); /* release the device */ | |
| 531 | − if (lis3_dev.pm_dev) | |
| 532 | − pm_runtime_put(lis3_dev.pm_dev); | |
| 559 | + struct lis3lv02d *lis3 = container_of(file->private_data, | |
| 560 | + struct lis3lv02d, miscdev); | |
| 561 | + | |
| 562 | + fasync_helper(-1, file, 0, &lis3->async_queue); | |
| 563 | + clear_bit(0, &lis3->misc_opened); /* release the device */ | |
| 564 | + if (lis3->pm_dev) | |
| 565 | + pm_runtime_put(lis3->pm_dev); | |
| 533 | 566 | return 0; |
| 534 | 567 | } |
| 535 | 568 | |
| 536 | 569 | static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf, |
| 537 | 570 | size_t count, loff_t *pos) |
| 538 | 571 | { |
| 572 | + struct lis3lv02d *lis3 = container_of(file->private_data, | |
| 573 | + struct lis3lv02d, miscdev); | |
| 574 | + | |
| 539 | 575 | DECLARE_WAITQUEUE(wait, current); |
| 540 | 576 | u32 data; |
| 541 | 577 | unsigned char byte_data; |
| @@ -544,10 +580,10 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf, · 2 unmodified lines | ||
| 544 | 580 | if (count < 1) |
| 545 | 581 | return -EINVAL; |
| 546 | 582 | |
| 547 | − add_wait_queue(&lis3_dev.misc_wait, &wait); | |
| 583 | + add_wait_queue(&lis3->misc_wait, &wait); | |
| 548 | 584 | while (true) { |
| 549 | 585 | set_current_state(TASK_INTERRUPTIBLE); |
| 550 | − data = atomic_xchg(&lis3_dev.count, 0); | |
| 586 | + data = atomic_xchg(&lis3->count, 0); | |
| 551 | 587 | if (data) |
| 552 | 588 | break; |
| 553 | 589 | |
| @@ -577,22 +613,28 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf, · 23 unmodified lines | ||
| 577 | 613 | |
| 578 | 614 | out: |
| 579 | 615 | __set_current_state(TASK_RUNNING); |
| 580 | − remove_wait_queue(&lis3_dev.misc_wait, &wait); | |
| 616 | + remove_wait_queue(&lis3->misc_wait, &wait); | |
| 581 | 617 | |
| 582 | 618 | return retval; |
| 583 | 619 | } |
| 584 | 620 | |
| 585 | 621 | static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait) |
| 586 | 622 | { |
| 587 | − poll_wait(file, &lis3_dev.misc_wait, wait); | |
| 588 | − if (atomic_read(&lis3_dev.count)) | |
| 623 | + struct lis3lv02d *lis3 = container_of(file->private_data, | |
| 624 | + struct lis3lv02d, miscdev); | |
| 625 | + | |
| 626 | + poll_wait(file, &lis3->misc_wait, wait); | |
| 627 | + if (atomic_read(&lis3->count)) | |
| 589 | 628 | return POLLIN | POLLRDNORM; |
| 590 | 629 | return 0; |
| 591 | 630 | } |
| 592 | 631 | |
| 593 | 632 | static int lis3lv02d_misc_fasync(int fd, struct file *file, int on) |
| 594 | 633 | { |
| 595 | − return fasync_helper(fd, file, on, &lis3_dev.async_queue); | |
| 634 | + struct lis3lv02d *lis3 = container_of(file->private_data, | |
| 635 | + struct lis3lv02d, miscdev); | |
| 636 | + | |
| 637 | + return fasync_helper(fd, file, on, &lis3->async_queue); | |
| 596 | 638 | } |
| 597 | 639 | |
| 598 | 640 | static const struct file_operations lis3lv02d_misc_fops = { |
| @@ -605,85 +647,80 @@ static const struct file_operations lis3lv02d_misc_fops = { · 6 unmodified lines | ||
| 605 | 647 | .fasync = lis3lv02d_misc_fasync, |
| 606 | 648 | }; |
| 607 | 649 | |
| 608 | −static struct miscdevice lis3lv02d_misc_device = { | |
| 609 | − .minor = MISC_DYNAMIC_MINOR, | |
| 610 | − .name = "freefall", | |
| 611 | − .fops = &lis3lv02d_misc_fops, | |
| 612 | −}; | |
| 613 | − | |
| 614 | −int lis3lv02d_joystick_enable(void) | |
| 650 | +int lis3lv02d_joystick_enable(struct lis3lv02d *lis3) | |
| 615 | 651 | { |
| 616 | 652 | struct input_dev *input_dev; |
| 617 | 653 | int err; |
| 618 | 654 | int max_val, fuzz, flat; |
| 619 | 655 | int btns[] = {BTN_X, BTN_Y, BTN_Z}; |
| 620 | 656 | |
| 621 | − if (lis3_dev.idev) | |
| 657 | + if (lis3->idev) | |
| 622 | 658 | return -EINVAL; |
| 623 | 659 | |
| 624 | − lis3_dev.idev = input_allocate_polled_device(); | |
| 625 | − if (!lis3_dev.idev) | |
| 660 | + lis3->idev = input_allocate_polled_device(); | |
| 661 | + if (!lis3->idev) | |
| 626 | 662 | return -ENOMEM; |
| 627 | 663 | |
| 628 | − lis3_dev.idev->poll = lis3lv02d_joystick_poll; | |
| 629 | − lis3_dev.idev->open = lis3lv02d_joystick_open; | |
| 630 | − lis3_dev.idev->close = lis3lv02d_joystick_close; | |
| 631 | − lis3_dev.idev->poll_interval = MDPS_POLL_INTERVAL; | |
| 632 | − lis3_dev.idev->poll_interval_min = MDPS_POLL_MIN; | |
| 633 | − lis3_dev.idev->poll_interval_max = MDPS_POLL_MAX; | |
| 634 | − input_dev = lis3_dev.idev->input; | |
| 664 | + lis3->idev->poll = lis3lv02d_joystick_poll; | |
| 665 | + lis3->idev->open = lis3lv02d_joystick_open; | |
| 666 | + lis3->idev->close = lis3lv02d_joystick_close; | |
| 667 | + lis3->idev->poll_interval = MDPS_POLL_INTERVAL; | |
| 668 | + lis3->idev->poll_interval_min = MDPS_POLL_MIN; | |
| 669 | + lis3->idev->poll_interval_max = MDPS_POLL_MAX; | |
| 670 | + lis3->idev->private = lis3; | |
| 671 | + input_dev = lis3->idev->input; | |
| 635 | 672 | |
| 636 | 673 | input_dev->name = "ST LIS3LV02DL Accelerometer"; |
| 637 | 674 | input_dev->phys = DRIVER_NAME "/input0"; |
| 638 | 675 | input_dev->id.bustype = BUS_HOST; |
| 639 | 676 | input_dev->id.vendor = 0; |
| 640 | − input_dev->dev.parent = &lis3_dev.pdev->dev; | |
| 677 | + input_dev->dev.parent = &lis3->pdev->dev; | |
| 641 | 678 | |
| 642 | 679 | set_bit(EV_ABS, input_dev->evbit); |
| 643 | − max_val = (lis3_dev.mdps_max_val * lis3_dev.scale) / LIS3_ACCURACY; | |
| 644 | − if (lis3_dev.whoami == WAI_12B) { | |
| 680 | + max_val = (lis3->mdps_max_val * lis3->scale) / LIS3_ACCURACY; | |
| 681 | + if (lis3->whoami == WAI_12B) { | |
| 645 | 682 | fuzz = LIS3_DEFAULT_FUZZ_12B; |
| 646 | 683 | flat = LIS3_DEFAULT_FLAT_12B; |
| 647 | 684 | } else { |
| 648 | 685 | fuzz = LIS3_DEFAULT_FUZZ_8B; |
| 649 | 686 | flat = LIS3_DEFAULT_FLAT_8B; |
| 650 | 687 | } |
| 651 | − fuzz = (fuzz * lis3_dev.scale) / LIS3_ACCURACY; | |
| 652 | − flat = (flat * lis3_dev.scale) / LIS3_ACCURACY; | |
| 688 | + fuzz = (fuzz * lis3->scale) / LIS3_ACCURACY; | |
| 689 | + flat = (flat * lis3->scale) / LIS3_ACCURACY; | |
| 653 | 690 | |
| 654 | 691 | input_set_abs_params(input_dev, ABS_X, -max_val, max_val, fuzz, flat); |
| 655 | 692 | input_set_abs_params(input_dev, ABS_Y, -max_val, max_val, fuzz, flat); |
| 656 | 693 | input_set_abs_params(input_dev, ABS_Z, -max_val, max_val, fuzz, flat); |
| 657 | 694 | |
| 658 | − lis3_dev.mapped_btns[0] = lis3lv02d_get_axis(abs(lis3_dev.ac.x), btns); | |
| 659 | − lis3_dev.mapped_btns[1] = lis3lv02d_get_axis(abs(lis3_dev.ac.y), btns); | |
| 660 | − lis3_dev.mapped_btns[2] = lis3lv02d_get_axis(abs(lis3_dev.ac.z), btns); | |
| 695 | + lis3->mapped_btns[0] = lis3lv02d_get_axis(abs(lis3->ac.x), btns); | |
| 696 | + lis3->mapped_btns[1] = lis3lv02d_get_axis(abs(lis3->ac.y), btns); | |
| 697 | + lis3->mapped_btns[2] = lis3lv02d_get_axis(abs(lis3->ac.z), btns); | |
| 661 | 698 | |
| 662 | − err = input_register_polled_device(lis3_dev.idev); | |
| 699 | + err = input_register_polled_device(lis3->idev); | |
| 663 | 700 | if (err) { |
| 664 | − input_free_polled_device(lis3_dev.idev); | |
| 665 | − lis3_dev.idev = NULL; | |
| 701 | + input_free_polled_device(lis3->idev); | |
| 702 | + lis3->idev = NULL; | |
| 666 | 703 | } |
| 667 | 704 | |
| 668 | 705 | return err; |
| 669 | 706 | } |
| 670 | 707 | EXPORT_SYMBOL_GPL(lis3lv02d_joystick_enable); |
| 671 | 708 | |
| 672 | −void lis3lv02d_joystick_disable(void) | |
| 709 | +void lis3lv02d_joystick_disable(struct lis3lv02d *lis3) | |
| 673 | 710 | { |
| 674 | − if (lis3_dev.irq) | |
| 675 | − free_irq(lis3_dev.irq, &lis3_dev); | |
| 676 | − if (lis3_dev.pdata && lis3_dev.pdata->irq2) | |
| 677 | − free_irq(lis3_dev.pdata->irq2, &lis3_dev); | |
| 711 | + if (lis3->irq) | |
| 712 | + free_irq(lis3->irq, lis3); | |
| 713 | + if (lis3->pdata && lis3->pdata->irq2) | |
| 714 | + free_irq(lis3->pdata->irq2, lis3); | |
| 678 | 715 | |
| 679 | − if (!lis3_dev.idev) | |
| 716 | + if (!lis3->idev) | |
| 680 | 717 | return; |
| 681 | 718 | |
| 682 | − if (lis3_dev.irq) | |
| 683 | − misc_deregister(&lis3lv02d_misc_device); | |
| 684 | − input_unregister_polled_device(lis3_dev.idev); | |
| 685 | − input_free_polled_device(lis3_dev.idev); | |
| 686 | − lis3_dev.idev = NULL; | |
| 719 | + if (lis3->irq) | |
| 720 | + misc_deregister(&lis3->miscdev); | |
| 721 | + input_unregister_polled_device(lis3->idev); | |
| 722 | + input_free_polled_device(lis3->idev); | |
| 723 | + lis3->idev = NULL; | |
| 687 | 724 | } |
| 688 | 725 | EXPORT_SYMBOL_GPL(lis3lv02d_joystick_disable); |
| 689 | 726 | |
| @@ -708,6 +745,7 @@ static void lis3lv02d_sysfs_poweron(struct lis3lv02d *lis3) · 18 unmodified lines | ||
| 708 | 745 | static ssize_t lis3lv02d_selftest_show(struct device *dev, |
| 709 | 746 | struct device_attribute *attr, char *buf) |
| 710 | 747 | { |
| 748 | + struct lis3lv02d *lis3 = dev_get_drvdata(dev); | |
| 711 | 749 | s16 values[3]; |
| 712 | 750 | |
| 713 | 751 | static const char ok[] = "OK"; |
| @@ -715,8 +753,8 @@ static ssize_t lis3lv02d_selftest_show(struct device *dev, · 1 unmodified line | ||
| 715 | 753 | static const char irq[] = "FAIL_IRQ"; |
| 716 | 754 | const char *res; |
| 717 | 755 | |
| 718 | − lis3lv02d_sysfs_poweron(&lis3_dev); | |
| 719 | − switch (lis3lv02d_selftest(&lis3_dev, values)) { | |
| 756 | + lis3lv02d_sysfs_poweron(lis3); | |
| 757 | + switch (lis3lv02d_selftest(lis3, values)) { | |
| 720 | 758 | case SELFTEST_FAIL: |
| 721 | 759 | res = fail; |
| 722 | 760 | break; |
| @@ -735,33 +773,37 @@ static ssize_t lis3lv02d_selftest_show(struct device *dev, · 12 unmodified lines | ||
| 735 | 773 | static ssize_t lis3lv02d_position_show(struct device *dev, |
| 736 | 774 | struct device_attribute *attr, char *buf) |
| 737 | 775 | { |
| 776 | + struct lis3lv02d *lis3 = dev_get_drvdata(dev); | |
| 738 | 777 | int x, y, z; |
| 739 | 778 | |
| 740 | − lis3lv02d_sysfs_poweron(&lis3_dev); | |
| 741 | − mutex_lock(&lis3_dev.mutex); | |
| 742 | − lis3lv02d_get_xyz(&lis3_dev, &x, &y, &z); | |
| 743 | − mutex_unlock(&lis3_dev.mutex); | |
| 779 | + lis3lv02d_sysfs_poweron(lis3); | |
| 780 | + mutex_lock(&lis3->mutex); | |
| 781 | + lis3lv02d_get_xyz(lis3, &x, &y, &z); | |
| 782 | + mutex_unlock(&lis3->mutex); | |
| 744 | 783 | return sprintf(buf, "(%d,%d,%d)\n", x, y, z); |
| 745 | 784 | } |
| 746 | 785 | |
| 747 | 786 | static ssize_t lis3lv02d_rate_show(struct device *dev, |
| 748 | 787 | struct device_attribute *attr, char *buf) |
| 749 | 788 | { |
| 750 | − lis3lv02d_sysfs_poweron(&lis3_dev); | |
| 751 | − return sprintf(buf, "%d\n", lis3lv02d_get_odr()); | |
| 789 | + struct lis3lv02d *lis3 = dev_get_drvdata(dev); | |
| 790 | + | |
| 791 | + lis3lv02d_sysfs_poweron(lis3); | |
| 792 | + return sprintf(buf, "%d\n", lis3lv02d_get_odr(lis3)); | |
| 752 | 793 | } |
| 753 | 794 | |
| 754 | 795 | static ssize_t lis3lv02d_rate_set(struct device *dev, |
| 755 | 796 | struct device_attribute *attr, const char *buf, |
| 756 | 797 | size_t count) |
| 757 | 798 | { |
| 799 | + struct lis3lv02d *lis3 = dev_get_drvdata(dev); | |
| 758 | 800 | unsigned long rate; |
| 759 | 801 | |
| 760 | 802 | if (strict_strtoul(buf, 0, &rate)) |
| 761 | 803 | return -EINVAL; |
| 762 | 804 | |
| 763 | − lis3lv02d_sysfs_poweron(&lis3_dev); | |
| 764 | − if (lis3lv02d_set_odr(rate)) | |
| 805 | + lis3lv02d_sysfs_poweron(lis3); | |
| 806 | + if (lis3lv02d_set_odr(lis3, rate)) | |
| 765 | 807 | return -EINVAL; |
| 766 | 808 | |
| 767 | 809 | return count; |
| @@ -790,6 +832,7 @@ static int lis3lv02d_add_fs(struct lis3lv02d *lis3) · 22 unmodified lines | ||
| 790 | 832 | if (IS_ERR(lis3->pdev)) |
| 791 | 833 | return PTR_ERR(lis3->pdev); |
| 792 | 834 | |
| 835 | + platform_set_drvdata(lis3->pdev, lis3); | |
| 793 | 836 | return sysfs_create_group(&lis3->pdev->dev.kobj, &lis3lv02d_attribute_group); |
| 794 | 837 | } |
| 795 | 838 | |
| @@ -803,7 +846,7 @@ int lis3lv02d_remove_fs(struct lis3lv02d *lis3) · 7 unmodified lines | ||
| 803 | 846 | |
| 804 | 847 | /* SYSFS may have left chip running. Turn off if necessary */ |
| 805 | 848 | if (!pm_runtime_suspended(lis3->pm_dev)) |
| 806 | − lis3lv02d_poweroff(&lis3_dev); | |
| 849 | + lis3lv02d_poweroff(lis3); | |
| 807 | 850 | |
| 808 | 851 | pm_runtime_disable(lis3->pm_dev); |
| 809 | 852 | pm_runtime_set_suspended(lis3->pm_dev); |
| @@ -813,24 +856,24 @@ int lis3lv02d_remove_fs(struct lis3lv02d *lis3) · 3 unmodified lines | ||
| 813 | 856 | } |
| 814 | 857 | EXPORT_SYMBOL_GPL(lis3lv02d_remove_fs); |
| 815 | 858 | |
| 816 | −static void lis3lv02d_8b_configure(struct lis3lv02d *dev, | |
| 859 | +static void lis3lv02d_8b_configure(struct lis3lv02d *lis3, | |
| 817 | 860 | struct lis3lv02d_platform_data *p) |
| 818 | 861 | { |
| 819 | 862 | int err; |
| 820 | 863 | int ctrl2 = p->hipass_ctrl; |
| 821 | 864 | |
| 822 | 865 | if (p->click_flags) { |
| 823 | − dev->write(dev, CLICK_CFG, p->click_flags); | |
| 824 | − dev->write(dev, CLICK_TIMELIMIT, p->click_time_limit); | |
| 825 | − dev->write(dev, CLICK_LATENCY, p->click_latency); | |
| 826 | − dev->write(dev, CLICK_WINDOW, p->click_window); | |
| 827 | − dev->write(dev, CLICK_THSZ, p->click_thresh_z & 0xf); | |
| 828 | − dev->write(dev, CLICK_THSY_X, | |
| 866 | + lis3->write(lis3, CLICK_CFG, p->click_flags); | |
| 867 | + lis3->write(lis3, CLICK_TIMELIMIT, p->click_time_limit); | |
| 868 | + lis3->write(lis3, CLICK_LATENCY, p->click_latency); | |
| 869 | + lis3->write(lis3, CLICK_WINDOW, p->click_window); | |
| 870 | + lis3->write(lis3, CLICK_THSZ, p->click_thresh_z & 0xf); | |
| 871 | + lis3->write(lis3, CLICK_THSY_X, | |
| 829 | 872 | (p->click_thresh_x & 0xf) | |
| 830 | 873 | (p->click_thresh_y << 4)); |
| 831 | 874 | |
| 832 | − if (dev->idev) { | |
| 833 | − struct input_dev *input_dev = lis3_dev.idev->input; | |
| 875 | + if (lis3->idev) { | |
| 876 | + struct input_dev *input_dev = lis3->idev->input; | |
| 834 | 877 | input_set_capability(input_dev, EV_KEY, BTN_X); |
| 835 | 878 | input_set_capability(input_dev, EV_KEY, BTN_Y); |
| 836 | 879 | input_set_capability(input_dev, EV_KEY, BTN_Z); |
| @@ -838,22 +881,22 @@ static void lis3lv02d_8b_configure(struct lis3lv02d *dev, · 1 unmodified line | ||
| 838 | 881 | } |
| 839 | 882 | |
| 840 | 883 | if (p->wakeup_flags) { |
| 841 | − dev->write(dev, FF_WU_CFG_1, p->wakeup_flags); | |
| 842 | − dev->write(dev, FF_WU_THS_1, p->wakeup_thresh & 0x7f); | |
| 884 | + lis3->write(lis3, FF_WU_CFG_1, p->wakeup_flags); | |
| 885 | + lis3->write(lis3, FF_WU_THS_1, p->wakeup_thresh & 0x7f); | |
| 843 | 886 | /* pdata value + 1 to keep this backward compatible*/ |
| 844 | − dev->write(dev, FF_WU_DURATION_1, p->duration1 + 1); | |
| 887 | + lis3->write(lis3, FF_WU_DURATION_1, p->duration1 + 1); | |
| 845 | 888 | ctrl2 ^= HP_FF_WU1; /* Xor to keep compatible with old pdata*/ |
| 846 | 889 | } |
| 847 | 890 | |
| 848 | 891 | if (p->wakeup_flags2) { |
| 849 | − dev->write(dev, FF_WU_CFG_2, p->wakeup_flags2); | |
| 850 | − dev->write(dev, FF_WU_THS_2, p->wakeup_thresh2 & 0x7f); | |
| 892 | + lis3->write(lis3, FF_WU_CFG_2, p->wakeup_flags2); | |
| 893 | + lis3->write(lis3, FF_WU_THS_2, p->wakeup_thresh2 & 0x7f); | |
| 851 | 894 | /* pdata value + 1 to keep this backward compatible*/ |
| 852 | − dev->write(dev, FF_WU_DURATION_2, p->duration2 + 1); | |
| 895 | + lis3->write(lis3, FF_WU_DURATION_2, p->duration2 + 1); | |
| 853 | 896 | ctrl2 ^= HP_FF_WU2; /* Xor to keep compatible with old pdata*/ |
| 854 | 897 | } |
| 855 | 898 | /* Configure hipass filters */ |
| 856 | − dev->write(dev, CTRL_REG2, ctrl2); | |
| 899 | + lis3->write(lis3, CTRL_REG2, ctrl2); | |
| 857 | 900 | |
| 858 | 901 | if (p->irq2) { |
| 859 | 902 | err = request_threaded_irq(p->irq2, |
| @@ -861,7 +904,7 @@ static void lis3lv02d_8b_configure(struct lis3lv02d *dev, · 1 unmodified line | ||
| 861 | 904 | lis302dl_interrupt_thread2_8b, |
| 862 | 905 | IRQF_TRIGGER_RISING | IRQF_ONESHOT | |
| 863 | 906 | (p->irq_flags2 & IRQF_TRIGGER_MASK), |
| 864 | − DRIVER_NAME, &lis3_dev); | |
| 907 | + DRIVER_NAME, lis3); | |
| 865 | 908 | if (err < 0) |
| 866 | 909 | pr_err("No second IRQ. Limited functionality\n"); |
| 867 | 910 | } |
| @@ -871,93 +914,97 @@ static void lis3lv02d_8b_configure(struct lis3lv02d *dev, · 3 unmodified lines | ||
| 871 | 914 | * Initialise the accelerometer and the various subsystems. |
| 872 | 915 | * Should be rather independent of the bus system. |
| 873 | 916 | */ |
| 874 | −int lis3lv02d_init_device(struct lis3lv02d *dev) | |
| 917 | +int lis3lv02d_init_device(struct lis3lv02d *lis3) | |
| 875 | 918 | { |
| 876 | 919 | int err; |
| 877 | 920 | irq_handler_t thread_fn; |
| 878 | 921 | int irq_flags = 0; |
| 879 | 922 | |
| 880 | − dev->whoami = lis3lv02d_read_8(dev, WHO_AM_I); | |
| 923 | + lis3->whoami = lis3lv02d_read_8(lis3, WHO_AM_I); | |
| 881 | 924 | |
| 882 | − switch (dev->whoami) { | |
| 925 | + switch (lis3->whoami) { | |
| 883 | 926 | case WAI_12B: |
| 884 | 927 | pr_info("12 bits sensor found\n"); |
| 885 | − dev->read_data = lis3lv02d_read_12; | |
| 886 | − dev->mdps_max_val = 2048; | |
| 887 | − dev->pwron_delay = LIS3_PWRON_DELAY_WAI_12B; | |
| 888 | − dev->odrs = lis3_12_rates; | |
| 889 | − dev->odr_mask = CTRL1_DF0 | CTRL1_DF1; | |
| 890 | − dev->scale = LIS3_SENSITIVITY_12B; | |
| 891 | − dev->regs = lis3_wai12_regs; | |
| 892 | − dev->regs_size = ARRAY_SIZE(lis3_wai12_regs); | |
| 928 | + lis3->read_data = lis3lv02d_read_12; | |
| 929 | + lis3->mdps_max_val = 2048; | |
| 930 | + lis3->pwron_delay = LIS3_PWRON_DELAY_WAI_12B; | |
| 931 | + lis3->odrs = lis3_12_rates; | |
| 932 | + lis3->odr_mask = CTRL1_DF0 | CTRL1_DF1; | |
| 933 | + lis3->scale = LIS3_SENSITIVITY_12B; | |
| 934 | + lis3->regs = lis3_wai12_regs; | |
| 935 | + lis3->regs_size = ARRAY_SIZE(lis3_wai12_regs); | |
| 893 | 936 | break; |
| 894 | 937 | case WAI_8B: |
| 895 | 938 | pr_info("8 bits sensor found\n"); |
| 896 | − dev->read_data = lis3lv02d_read_8; | |
| 897 | − dev->mdps_max_val = 128; | |
| 898 | − dev->pwron_delay = LIS3_PWRON_DELAY_WAI_8B; | |
| 899 | − dev->odrs = lis3_8_rates; | |
| 900 | − dev->odr_mask = CTRL1_DR; | |
| 901 | − dev->scale = LIS3_SENSITIVITY_8B; | |
| 902 | − dev->regs = lis3_wai8_regs; | |
| 903 | − dev->regs_size = ARRAY_SIZE(lis3_wai8_regs); | |
| 939 | + lis3->read_data = lis3lv02d_read_8; | |
| 940 | + lis3->mdps_max_val = 128; | |
| 941 | + lis3->pwron_delay = LIS3_PWRON_DELAY_WAI_8B; | |
| 942 | + lis3->odrs = lis3_8_rates; | |
| 943 | + lis3->odr_mask = CTRL1_DR; | |
| 944 | + lis3->scale = LIS3_SENSITIVITY_8B; | |
| 945 | + lis3->regs = lis3_wai8_regs; | |
| 946 | + lis3->regs_size = ARRAY_SIZE(lis3_wai8_regs); | |
| 904 | 947 | break; |
| 905 | 948 | case WAI_3DC: |
| 906 | 949 | pr_info("8 bits 3DC sensor found\n"); |
| 907 | − dev->read_data = lis3lv02d_read_8; | |
| 908 | − dev->mdps_max_val = 128; | |
| 909 | − dev->pwron_delay = LIS3_PWRON_DELAY_WAI_8B; | |
| 910 | − dev->odrs = lis3_3dc_rates; | |
| 911 | − dev->odr_mask = CTRL1_ODR0|CTRL1_ODR1|CTRL1_ODR2|CTRL1_ODR3; | |
| 912 | − dev->scale = LIS3_SENSITIVITY_8B; | |
| 950 | + lis3->read_data = lis3lv02d_read_8; | |
| 951 | + lis3->mdps_max_val = 128; | |
| 952 | + lis3->pwron_delay = LIS3_PWRON_DELAY_WAI_8B; | |
| 953 | + lis3->odrs = lis3_3dc_rates; | |
| 954 | + lis3->odr_mask = CTRL1_ODR0|CTRL1_ODR1|CTRL1_ODR2|CTRL1_ODR3; | |
| 955 | + lis3->scale = LIS3_SENSITIVITY_8B; | |
| 913 | 956 | break; |
| 914 | 957 | default: |
| 915 | − pr_err("unknown sensor type 0x%X\n", dev->whoami); | |
| 958 | + pr_err("unknown sensor type 0x%X\n", lis3->whoami); | |
| 916 | 959 | return -EINVAL; |
| 917 | 960 | } |
| 918 | 961 | |
| 919 | − dev->reg_cache = kzalloc(max(sizeof(lis3_wai8_regs), | |
| 962 | + lis3->reg_cache = kzalloc(max(sizeof(lis3_wai8_regs), | |
| 920 | 963 | sizeof(lis3_wai12_regs)), GFP_KERNEL); |
| 921 | 964 | |
| 922 | − if (dev->reg_cache == NULL) { | |
| 965 | + if (lis3->reg_cache == NULL) { | |
| 923 | 966 | printk(KERN_ERR DRIVER_NAME "out of memory\n"); |
| 924 | 967 | return -ENOMEM; |
| 925 | 968 | } |
| 926 | 969 | |
| 927 | − mutex_init(&dev->mutex); | |
| 928 | − atomic_set(&dev->wake_thread, 0); | |
| 970 | + mutex_init(&lis3->mutex); | |
| 971 | + atomic_set(&lis3->wake_thread, 0); | |
| 929 | 972 | |
| 930 | − lis3lv02d_add_fs(dev); | |
| 931 | − lis3lv02d_poweron(dev); | |
| 973 | + lis3lv02d_add_fs(lis3); | |
| 974 | + err = lis3lv02d_poweron(lis3); | |
| 975 | + if (err) { | |
| 976 | + lis3lv02d_remove_fs(lis3); | |
| 977 | + return err; | |
| 978 | + } | |
| 932 | 979 | |
| 933 | − if (dev->pm_dev) { | |
| 934 | − pm_runtime_set_active(dev->pm_dev); | |
| 935 | − pm_runtime_enable(dev->pm_dev); | |
| 980 | + if (lis3->pm_dev) { | |
| 981 | + pm_runtime_set_active(lis3->pm_dev); | |
| 982 | + pm_runtime_enable(lis3->pm_dev); | |
| 936 | 983 | } |
| 937 | 984 | |
| 938 | − if (lis3lv02d_joystick_enable()) | |
| 985 | + if (lis3lv02d_joystick_enable(lis3)) | |
| 939 | 986 | pr_err("joystick initialization failed\n"); |
| 940 | 987 | |
| 941 | 988 | /* passing in platform specific data is purely optional and only |
| 942 | 989 | * used by the SPI transport layer at the moment */ |
| 943 | − if (dev->pdata) { | |
| 944 | − struct lis3lv02d_platform_data *p = dev->pdata; | |
| 990 | + if (lis3->pdata) { | |
| 991 | + struct lis3lv02d_platform_data *p = lis3->pdata; | |
| 945 | 992 | |
| 946 | − if (dev->whoami == WAI_8B) | |
| 947 | − lis3lv02d_8b_configure(dev, p); | |
| 993 | + if (lis3->whoami == WAI_8B) | |
| 994 | + lis3lv02d_8b_configure(lis3, p); | |
| 948 | 995 | |
| 949 | 996 | irq_flags = p->irq_flags1 & IRQF_TRIGGER_MASK; |
| 950 | 997 | |
| 951 | − dev->irq_cfg = p->irq_cfg; | |
| 998 | + lis3->irq_cfg = p->irq_cfg; | |
| 952 | 999 | if (p->irq_cfg) |
| 953 | − dev->write(dev, CTRL_REG3, p->irq_cfg); | |
| 1000 | + lis3->write(lis3, CTRL_REG3, p->irq_cfg); | |
| 954 | 1001 | |
| 955 | 1002 | if (p->default_rate) |
| 956 | − lis3lv02d_set_odr(p->default_rate); | |
| 1003 | + lis3lv02d_set_odr(lis3, p->default_rate); | |
| 957 | 1004 | } |
| 958 | 1005 | |
| 959 | 1006 | /* bail if we did not get an IRQ from the bus layer */ |
| 960 | − if (!dev->irq) { | |
| 1007 | + if (!lis3->irq) { | |
| 961 | 1008 | pr_debug("No IRQ. Disabling /dev/freefall\n"); |
| 962 | 1009 | goto out; |
| 963 | 1010 | } |
| @@ -973,23 +1020,27 @@ int lis3lv02d_init_device(struct lis3lv02d *dev) · 9 unmodified lines | ||
| 973 | 1020 | * io-apic is not configurable (and generates a warning) but I keep it |
| 974 | 1021 | * in case of support for other hardware. |
| 975 | 1022 | */ |
| 976 | − if (dev->pdata && dev->whoami == WAI_8B) | |
| 1023 | + if (lis3->pdata && lis3->whoami == WAI_8B) | |
| 977 | 1024 | thread_fn = lis302dl_interrupt_thread1_8b; |
| 978 | 1025 | else |
| 979 | 1026 | thread_fn = NULL; |
| 980 | 1027 | |
| 981 | − err = request_threaded_irq(dev->irq, lis302dl_interrupt, | |
| 1028 | + err = request_threaded_irq(lis3->irq, lis302dl_interrupt, | |
| 982 | 1029 | thread_fn, |
| 983 | 1030 | IRQF_TRIGGER_RISING | IRQF_ONESHOT | |
| 984 | 1031 | irq_flags, |
| 985 | − DRIVER_NAME, &lis3_dev); | |
| 1032 | + DRIVER_NAME, lis3); | |
| 986 | 1033 | |
| 987 | 1034 | if (err < 0) { |
| 988 | 1035 | pr_err("Cannot get IRQ\n"); |
| 989 | 1036 | goto out; |
| 990 | 1037 | } |
| 991 | 1038 | |
| 992 | − if (misc_register(&lis3lv02d_misc_device)) | |
| 1039 | + lis3->miscdev.minor = MISC_DYNAMIC_MINOR; | |
| 1040 | + lis3->miscdev.name = "freefall"; | |
| 1041 | + lis3->miscdev.fops = &lis3lv02d_misc_fops; | |
| 1042 | + | |
| 1043 | + if (misc_register(&lis3->miscdev)) | |
| 993 | 1044 | pr_err("misc_register failed\n"); |
| 994 | 1045 | out: |
| 995 | 1046 | return 0; |
| @@ -21,6 +21,7 @@ · 20 unmodified lines | ||
| 21 | 21 | #include <linux/platform_device.h> |
| 22 | 22 | #include <linux/input-polldev.h> |
| 23 | 23 | #include <linux/regulator/consumer.h> |
| 24 | +#include <linux/miscdevice.h> | |
| 24 | 25 | |
| 25 | 26 | /* |
| 26 | 27 | * This driver tries to support the "digital" accelerometer chips from |
| @@ -273,6 +274,8 @@ struct lis3lv02d { · 246 unmodified lines | ||
| 273 | 274 | struct fasync_struct *async_queue; /* queue for the misc device */ |
| 274 | 275 | wait_queue_head_t misc_wait; /* Wait queue for the misc device */ |
| 275 | 276 | unsigned long misc_opened; /* bit0: whether the device is open */ |
| 277 | + struct miscdevice miscdev; | |
| 278 | + | |
| 276 | 279 | int data_ready_count[2]; |
| 277 | 280 | atomic_t wake_thread; |
| 278 | 281 | unsigned char irq_cfg; |
| @@ -282,10 +285,10 @@ struct lis3lv02d { · 3 unmodified lines | ||
| 282 | 285 | }; |
| 283 | 286 | |
| 284 | 287 | int lis3lv02d_init_device(struct lis3lv02d *lis3); |
| 285 | −int lis3lv02d_joystick_enable(void); | |
| 286 | −void lis3lv02d_joystick_disable(void); | |
| 288 | +int lis3lv02d_joystick_enable(struct lis3lv02d *lis3); | |
| 289 | +void lis3lv02d_joystick_disable(struct lis3lv02d *lis3); | |
| 287 | 290 | void lis3lv02d_poweroff(struct lis3lv02d *lis3); |
| 288 | −void lis3lv02d_poweron(struct lis3lv02d *lis3); | |
| 291 | +int lis3lv02d_poweron(struct lis3lv02d *lis3); | |
| 289 | 292 | int lis3lv02d_remove_fs(struct lis3lv02d *lis3); |
| 290 | 293 | |
| 291 | 294 | extern struct lis3lv02d lis3_dev; |
| @@ -79,8 +79,7 @@ static int lis3_i2c_init(struct lis3lv02d *lis3) · 78 unmodified lines | ||
| 79 | 79 | u8 reg; |
| 80 | 80 | int ret; |
| 81 | 81 | |
| 82 | − if (lis3->reg_ctrl) | |
| 83 | − lis3_reg_ctrl(lis3, LIS3_REG_ON); | |
| 82 | + lis3_reg_ctrl(lis3, LIS3_REG_ON); | |
| 84 | 83 | |
| 85 | 84 | lis3->read(lis3, WHO_AM_I, ®); |
| 86 | 85 | if (reg != lis3->whoami) |
| @@ -106,10 +105,6 @@ static int __devinit lis3lv02d_i2c_probe(struct i2c_client *client, · 19 unmodified lines | ||
| 106 | 105 | struct lis3lv02d_platform_data *pdata = client->dev.platform_data; |
| 107 | 106 | |
| 108 | 107 | if (pdata) { |
| 109 | − /* Regulator control is optional */ | |
| 110 | − if (pdata->driver_features & LIS3_USE_REGULATOR_CTRL) | |
| 111 | − lis3_dev.reg_ctrl = lis3_reg_ctrl; | |
| 112 | − | |
| 113 | 108 | if ((pdata->driver_features & LIS3_USE_BLOCK_READ) && |
| 114 | 109 | (i2c_check_functionality(client->adapter, |
| 115 | 110 | I2C_FUNC_SMBUS_I2C_BLOCK))) |
| @@ -131,15 +126,13 @@ static int __devinit lis3lv02d_i2c_probe(struct i2c_client *client, · 15 unmodified lines | ||
| 131 | 126 | goto fail; |
| 132 | 127 | } |
| 133 | 128 | |
| 134 | − if (lis3_dev.reg_ctrl) { | |
| 135 | − lis3_dev.regulators[0].supply = reg_vdd; | |
| 136 | − lis3_dev.regulators[1].supply = reg_vdd_io; | |
| 137 | − ret = regulator_bulk_get(&client->dev, | |
| 138 | − ARRAY_SIZE(lis3_dev.regulators), | |
| 139 | − lis3_dev.regulators); | |
| 140 | − if (ret < 0) | |
| 141 | − goto fail; | |
| 142 | − } | |
| 129 | + lis3_dev.regulators[0].supply = reg_vdd; | |
| 130 | + lis3_dev.regulators[1].supply = reg_vdd_io; | |
| 131 | + ret = regulator_bulk_get(&client->dev, | |
| 132 | + ARRAY_SIZE(lis3_dev.regulators), | |
| 133 | + lis3_dev.regulators); | |
| 134 | + if (ret < 0) | |
| 135 | + goto fail; | |
| 143 | 136 | |
| 144 | 137 | lis3_dev.pdata = pdata; |
| 145 | 138 | lis3_dev.bus_priv = client; |
| @@ -153,16 +146,19 @@ static int __devinit lis3lv02d_i2c_probe(struct i2c_client *client, · 7 unmodified lines | ||
| 153 | 146 | i2c_set_clientdata(client, &lis3_dev); |
| 154 | 147 | |
| 155 | 148 | /* Provide power over the init call */ |
| 156 | − if (lis3_dev.reg_ctrl) | |
| 157 | − lis3_reg_ctrl(&lis3_dev, LIS3_REG_ON); | |
| 149 | + lis3_reg_ctrl(&lis3_dev, LIS3_REG_ON); | |
| 158 | 150 | |
| 159 | 151 | ret = lis3lv02d_init_device(&lis3_dev); |
| 160 | 152 | |
| 161 | − if (lis3_dev.reg_ctrl) | |
| 162 | − lis3_reg_ctrl(&lis3_dev, LIS3_REG_OFF); | |
| 153 | + lis3_reg_ctrl(&lis3_dev, LIS3_REG_OFF); | |
| 163 | 154 | |
| 164 | − if (ret == 0) | |
| 165 | − return 0; | |
| 155 | + if (ret) | |
| 156 | + goto fail2; | |
| 157 | + return 0; | |
| 158 | + | |
| 159 | +fail2: | |
| 160 | + regulator_bulk_free(ARRAY_SIZE(lis3_dev.regulators), | |
| 161 | + lis3_dev.regulators); | |
| 166 | 162 | fail: |
| 167 | 163 | if (pdata && pdata->release_resources) |
| 168 | 164 | pdata->release_resources(); |
| @@ -177,12 +173,11 @@ static int __devexit lis3lv02d_i2c_remove(struct i2c_client *client) · 8 unmodified lines | ||
| 177 | 173 | if (pdata && pdata->release_resources) |
| 178 | 174 | pdata->release_resources(); |
| 179 | 175 | |
| 180 | − lis3lv02d_joystick_disable(); | |
| 176 | + lis3lv02d_joystick_disable(lis3); | |
| 181 | 177 | lis3lv02d_remove_fs(&lis3_dev); |
| 182 | 178 | |
| 183 | − if (lis3_dev.reg_ctrl) | |
| 184 | − regulator_bulk_free(ARRAY_SIZE(lis3->regulators), | |
| 185 | − lis3_dev.regulators); | |
| 179 | + regulator_bulk_free(ARRAY_SIZE(lis3->regulators), | |
| 180 | + lis3_dev.regulators); | |
| 186 | 181 | return 0; |
| 187 | 182 | } |
| 188 | 183 | |
| @@ -83,7 +83,7 @@ static int __devinit lis302dl_spi_probe(struct spi_device *spi) · 82 unmodified lines | ||
| 83 | 83 | static int __devexit lis302dl_spi_remove(struct spi_device *spi) |
| 84 | 84 | { |
| 85 | 85 | struct lis3lv02d *lis3 = spi_get_drvdata(spi); |
| 86 | − lis3lv02d_joystick_disable(); | |
| 86 | + lis3lv02d_joystick_disable(lis3); | |
| 87 | 87 | lis3lv02d_poweroff(lis3); |
| 88 | 88 | |
| 89 | 89 | return lis3lv02d_remove_fs(&lis3_dev); |
| @@ -581,8 +581,9 @@ extern const struct ethtool_ops mlx4_en_ethtool_ops; · 580 unmodified lines | ||
| 581 | 581 | * printk / logging functions |
| 582 | 582 | */ |
| 583 | 583 | |
| 584 | +__printf(3, 4) | |
| 584 | 585 | int en_print(const char *level, const struct mlx4_en_priv *priv, |
| 585 | − const char *format, ...) __attribute__ ((format (printf, 3, 4))); | |
| 586 | + const char *format, ...); | |
| 586 | 587 | |
| 587 | 588 | #define en_dbg(mlevel, priv, format, arg...) \ |
| 588 | 589 | do { \ |
| @@ -517,7 +517,7 @@ static char *hex2str(void *buf, size_t len) · 516 unmodified lines | ||
| 517 | 517 | goto exit; |
| 518 | 518 | |
| 519 | 519 | while (len--) { |
| 520 | − obuf = pack_hex_byte(obuf, *ibuf++); | |
| 520 | + obuf = hex_byte_pack(obuf, *ibuf++); | |
| 521 | 521 | *obuf++ = '-'; |
| 522 | 522 | } |
| 523 | 523 | obuf--; |
| @@ -173,8 +173,7 @@ bool ath_hw_keyreset(struct ath_common *common, u16 entry); · 172 unmodified lines | ||
| 173 | 173 | void ath_hw_cycle_counters_update(struct ath_common *common); |
| 174 | 174 | int32_t ath_hw_get_listen_time(struct ath_common *common); |
| 175 | 175 | |
| 176 | −extern __attribute__((format (printf, 2, 3))) | |
| 177 | −void ath_printk(const char *level, const char *fmt, ...); | |
| 176 | +extern __printf(2, 3) void ath_printk(const char *level, const char *fmt, ...); | |
| 178 | 177 | |
| 179 | 178 | #define _ath_printk(level, common, fmt, ...) \ |
| 180 | 179 | do { \ |
| @@ -258,7 +257,7 @@ do { \ · 77 unmodified lines | ||
| 258 | 257 | |
| 259 | 258 | #else |
| 260 | 259 | |
| 261 | −static inline __attribute__((format (printf, 3, 4))) | |
| 260 | +static inline __attribute__ ((format (printf, 3, 4))) | |
| 262 | 261 | void ath_dbg(struct ath_common *common, enum ATH_DEBUG dbg_mask, |
| 263 | 262 | const char *fmt, ...) |
| 264 | 263 | { |
| @@ -141,10 +141,10 @@ ath5k_debug_printtxbuf(struct ath5k_hw *ah, struct ath5k_buf *bf); · 140 unmodified lines | ||
| 141 | 141 | |
| 142 | 142 | #include <linux/compiler.h> |
| 143 | 143 | |
| 144 | −static inline void __attribute__ ((format (printf, 3, 4))) | |
| 144 | +static inline __printf(3, 4) void | |
| 145 | 145 | ATH5K_DBG(struct ath5k_hw *ah, unsigned int m, const char *fmt, ...) {} |
| 146 | 146 | |
| 147 | −static inline void __attribute__ ((format (printf, 3, 4))) | |
| 147 | +static inline __printf(3, 4) void | |
| 148 | 148 | ATH5K_DBG_UNLIMIT(struct ath5k_hw *ah, unsigned int m, const char *fmt, ...) |
| 149 | 149 | {} |
| 150 | 150 | |
| @@ -44,8 +44,8 @@ enum ATH6K_DEBUG_MASK { · 43 unmodified lines | ||
| 44 | 44 | }; |
| 45 | 45 | |
| 46 | 46 | extern unsigned int debug_mask; |
| 47 | −extern int ath6kl_printk(const char *level, const char *fmt, ...) | |
| 48 | − __attribute__ ((format (printf, 2, 3))); | |
| 47 | +extern __printf(2, 3) | |
| 48 | +int ath6kl_printk(const char *level, const char *fmt, ...); | |
| 49 | 49 | |
| 50 | 50 | #define ath6kl_info(fmt, ...) \ |
| 51 | 51 | ath6kl_printk(KERN_INFO, fmt, ##__VA_ARGS__) |
| @@ -1011,14 +1011,10 @@ static inline bool b43_using_pio_transfers(struct b43_wldev *dev) · 1010 unmodified lines | ||
| 1011 | 1011 | } |
| 1012 | 1012 | |
| 1013 | 1013 | /* Message printing */ |
| 1014 | −void b43info(struct b43_wl *wl, const char *fmt, ...) | |
| 1015 | − __attribute__ ((format(printf, 2, 3))); | |
| 1016 | −void b43err(struct b43_wl *wl, const char *fmt, ...) | |
| 1017 | − __attribute__ ((format(printf, 2, 3))); | |
| 1018 | −void b43warn(struct b43_wl *wl, const char *fmt, ...) | |
| 1019 | − __attribute__ ((format(printf, 2, 3))); | |
| 1020 | −void b43dbg(struct b43_wl *wl, const char *fmt, ...) | |
| 1021 | − __attribute__ ((format(printf, 2, 3))); | |
| 1014 | +__printf(2, 3) void b43info(struct b43_wl *wl, const char *fmt, ...); | |
| 1015 | +__printf(2, 3) void b43err(struct b43_wl *wl, const char *fmt, ...); | |
| 1016 | +__printf(2, 3) void b43warn(struct b43_wl *wl, const char *fmt, ...); | |
| 1017 | +__printf(2, 3) void b43dbg(struct b43_wl *wl, const char *fmt, ...); | |
| 1022 | 1018 | |
| 1023 | 1019 | |
| 1024 | 1020 | /* A WARN_ON variant that vanishes when b43 debugging is disabled. |
| @@ -810,15 +810,15 @@ struct b43legacy_lopair *b43legacy_get_lopair(struct b43legacy_phy *phy, · 809 unmodified lines | ||
| 810 | 810 | |
| 811 | 811 | |
| 812 | 812 | /* Message printing */ |
| 813 | −void b43legacyinfo(struct b43legacy_wl *wl, const char *fmt, ...) | |
| 814 | − __attribute__((format(printf, 2, 3))); | |
| 815 | −void b43legacyerr(struct b43legacy_wl *wl, const char *fmt, ...) | |
| 816 | − __attribute__((format(printf, 2, 3))); | |
| 817 | −void b43legacywarn(struct b43legacy_wl *wl, const char *fmt, ...) | |
| 818 | − __attribute__((format(printf, 2, 3))); | |
| 813 | +__printf(2, 3) | |
| 814 | +void b43legacyinfo(struct b43legacy_wl *wl, const char *fmt, ...); | |
| 815 | +__printf(2, 3) | |
| 816 | +void b43legacyerr(struct b43legacy_wl *wl, const char *fmt, ...); | |
| 817 | +__printf(2, 3) | |
| 818 | +void b43legacywarn(struct b43legacy_wl *wl, const char *fmt, ...); | |
| 819 | 819 | #if B43legacy_DEBUG |
| 820 | −void b43legacydbg(struct b43legacy_wl *wl, const char *fmt, ...) | |
| 821 | − __attribute__((format(printf, 2, 3))); | |
| 820 | +__printf(2, 3) | |
| 821 | +void b43legacydbg(struct b43legacy_wl *wl, const char *fmt, ...); | |
| 822 | 822 | #else /* DEBUG */ |
| 823 | 823 | # define b43legacydbg(wl, fmt...) do { /* nothing */ } while (0) |
| 824 | 824 | #endif /* DEBUG */ |
| @@ -210,6 +210,8 @@ static struct dmi_system_id lis3lv02d_dmi_ids[] = { · 209 unmodified lines | ||
| 210 | 210 | AXIS_DMI_MATCH("NC6715x", "HP Compaq 6715", y_inverted), |
| 211 | 211 | AXIS_DMI_MATCH("NC693xx", "HP EliteBook 693", xy_rotated_right), |
| 212 | 212 | AXIS_DMI_MATCH("NC693xx", "HP EliteBook 853", xy_swap), |
| 213 | + AXIS_DMI_MATCH("NC854xx", "HP EliteBook 854", y_inverted), | |
| 214 | + AXIS_DMI_MATCH("NC273xx", "HP EliteBook 273", y_inverted), | |
| 213 | 215 | /* Intel-based HP Pavilion dv5 */ |
| 214 | 216 | AXIS_DMI_MATCH2("HPDV5_I", |
| 215 | 217 | PRODUCT_NAME, "HP Pavilion dv5", |
| @@ -228,6 +230,7 @@ static struct dmi_system_id lis3lv02d_dmi_ids[] = { · 12 unmodified lines | ||
| 228 | 230 | AXIS_DMI_MATCH("HPB452x", "HP ProBook 452", y_inverted), |
| 229 | 231 | AXIS_DMI_MATCH("HPB522x", "HP ProBook 522", xy_swap), |
| 230 | 232 | AXIS_DMI_MATCH("HPB532x", "HP ProBook 532", y_inverted), |
| 233 | + AXIS_DMI_MATCH("HPB655x", "HP ProBook 655", xy_swap_inverted), | |
| 231 | 234 | AXIS_DMI_MATCH("Mini510x", "HP Mini 510", xy_rotated_left_usd), |
| 232 | 235 | AXIS_DMI_MATCH("HPB63xx", "HP ProBook 63", xy_swap), |
| 233 | 236 | AXIS_DMI_MATCH("HPB64xx", "HP ProBook 64", xy_swap), |
| @@ -325,7 +328,7 @@ static int lis3lv02d_add(struct acpi_device *device) · 91 unmodified lines | ||
| 325 | 328 | INIT_WORK(&hpled_led.work, delayed_set_status_worker); |
| 326 | 329 | ret = led_classdev_register(NULL, &hpled_led.led_classdev); |
| 327 | 330 | if (ret) { |
| 328 | − lis3lv02d_joystick_disable(); | |
| 331 | + lis3lv02d_joystick_disable(&lis3_dev); | |
| 329 | 332 | lis3lv02d_poweroff(&lis3_dev); |
| 330 | 333 | flush_work(&hpled_led.work); |
| 331 | 334 | return ret; |
| @@ -339,7 +342,7 @@ static int lis3lv02d_remove(struct acpi_device *device, int type) · 7 unmodified lines | ||
| 339 | 342 | if (!device) |
| 340 | 343 | return -EINVAL; |
| 341 | 344 | |
| 342 | − lis3lv02d_joystick_disable(); | |
| 345 | + lis3lv02d_joystick_disable(&lis3_dev); | |
| 343 | 346 | lis3lv02d_poweroff(&lis3_dev); |
| 344 | 347 | |
| 345 | 348 | led_classdev_unregister(&hpled_led.led_classdev); |
| @@ -359,8 +362,7 @@ static int lis3lv02d_suspend(struct acpi_device *device, pm_message_t state) · 13 unmodified lines | ||
| 359 | 362 | |
| 360 | 363 | static int lis3lv02d_resume(struct acpi_device *device) |
| 361 | 364 | { |
| 362 | − lis3lv02d_poweron(&lis3_dev); | |
| 363 | − return 0; | |
| 365 | + return lis3lv02d_poweron(&lis3_dev); | |
| 364 | 366 | } |
| 365 | 367 | #else |
| 366 | 368 | #define lis3lv02d_suspend NULL |
| @@ -115,8 +115,7 @@ void iio_trigger_poll_chained(struct iio_trigger *trig, s64 time); · 114 unmodified lines | ||
| 115 | 115 | |
| 116 | 116 | irqreturn_t iio_trigger_generic_data_rdy_poll(int irq, void *private); |
| 117 | 117 | |
| 118 | −struct iio_trigger *iio_allocate_trigger(const char *fmt, ...) | |
| 119 | − __attribute__((format(printf, 1, 2))); | |
| 118 | +__printf(1, 2) struct iio_trigger *iio_allocate_trigger(const char *fmt, ...); | |
| 120 | 119 | void iio_free_trigger(struct iio_trigger *trig); |
| 121 | 120 | |
| 122 | 121 | #endif /* _IIO_TRIGGER_H_ */ |
| @@ -931,7 +931,6 @@ out: · 930 unmodified lines | ||
| 931 | 931 | out1: |
| 932 | 932 | backlight_device_unregister(bl); |
| 933 | 933 | out2: |
| 934 | − i2c_set_clientdata(client, NULL); | |
| 935 | 934 | kfree(data); |
| 936 | 935 | |
| 937 | 936 | return ret; |
| @@ -951,7 +950,6 @@ static int __devexit adp8870_remove(struct i2c_client *client) · 13 unmodified lines | ||
| 951 | 950 | &adp8870_bl_attr_group); |
| 952 | 951 | |
| 953 | 952 | backlight_device_unregister(data->bl); |
| 954 | − i2c_set_clientdata(client, NULL); | |
| 955 | 953 | kfree(data); |
| 956 | 954 | |
| 957 | 955 | return 0; |
| @@ -56,7 +56,7 @@ static int genericbl_get_intensity(struct backlight_device *bd) · 55 unmodified lines | ||
| 56 | 56 | * Called when the battery is low to limit the backlight intensity. |
| 57 | 57 | * If limit==0 clear any limit, otherwise limit the intensity |
| 58 | 58 | */ |
| 59 | −void corgibl_limit_intensity(int limit) | |
| 59 | +void genericbl_limit_intensity(int limit) | |
| 60 | 60 | { |
| 61 | 61 | struct backlight_device *bd = generic_backlight_device; |
| 62 | 62 | |
| @@ -68,7 +68,7 @@ void corgibl_limit_intensity(int limit) · 5 unmodified lines | ||
| 68 | 68 | backlight_update_status(generic_backlight_device); |
| 69 | 69 | mutex_unlock(&bd->ops_lock); |
| 70 | 70 | } |
| 71 | −EXPORT_SYMBOL(corgibl_limit_intensity); | |
| 71 | +EXPORT_SYMBOL(genericbl_limit_intensity); | |
| 72 | 72 | |
| 73 | 73 | static const struct backlight_ops genericbl_ops = { |
| 74 | 74 | .options = BL_CORE_SUSPENDRESUME, |
| @@ -52,15 +52,11 @@ static void l4f00242t03_lcd_init(struct spi_device *spi) · 51 unmodified lines | ||
| 52 | 52 | |
| 53 | 53 | dev_dbg(&spi->dev, "initializing LCD\n"); |
| 54 | 54 | |
| 55 | − if (priv->io_reg) { | |
| 56 | − regulator_set_voltage(priv->io_reg, 1800000, 1800000); | |
| 57 | − regulator_enable(priv->io_reg); | |
| 58 | − } | |
| 55 | + regulator_set_voltage(priv->io_reg, 1800000, 1800000); | |
| 56 | + regulator_enable(priv->io_reg); | |
| 59 | 57 | |
| 60 | − if (priv->core_reg) { | |
| 61 | − regulator_set_voltage(priv->core_reg, 2800000, 2800000); | |
| 62 | − regulator_enable(priv->core_reg); | |
| 63 | − } | |
| 58 | + regulator_set_voltage(priv->core_reg, 2800000, 2800000); | |
| 59 | + regulator_enable(priv->core_reg); | |
| 64 | 60 | |
| 65 | 61 | l4f00242t03_reset(pdata->reset_gpio); |
| 66 | 62 | |
| @@ -78,11 +74,8 @@ static void l4f00242t03_lcd_powerdown(struct spi_device *spi) · 11 unmodified lines | ||
| 78 | 74 | |
| 79 | 75 | gpio_set_value(pdata->data_enable_gpio, 0); |
| 80 | 76 | |
| 81 | − if (priv->io_reg) | |
| 82 | − regulator_disable(priv->io_reg); | |
| 83 | − | |
| 84 | − if (priv->core_reg) | |
| 85 | − regulator_disable(priv->core_reg); | |
| 77 | + regulator_disable(priv->io_reg); | |
| 78 | + regulator_disable(priv->core_reg); | |
| 86 | 79 | } |
| 87 | 80 | |
| 88 | 81 | static int l4f00242t03_lcd_power_get(struct lcd_device *ld) |
| @@ -178,47 +171,34 @@ static int __devinit l4f00242t03_probe(struct spi_device *spi) · 89 unmodified lines | ||
| 178 | 171 | |
| 179 | 172 | priv->spi = spi; |
| 180 | 173 | |
| 181 | − ret = gpio_request(pdata->reset_gpio, "lcd l4f00242t03 reset"); | |
| 174 | + ret = gpio_request_one(pdata->reset_gpio, GPIOF_OUT_INIT_HIGH, | |
| 175 | + "lcd l4f00242t03 reset"); | |
| 182 | 176 | if (ret) { |
| 183 | 177 | dev_err(&spi->dev, |
| 184 | 178 | "Unable to get the lcd l4f00242t03 reset gpio.\n"); |
| 185 | 179 | goto err; |
| 186 | 180 | } |
| 187 | 181 | |
| 188 | − ret = gpio_direction_output(pdata->reset_gpio, 1); | |
| 189 | − if (ret) | |
| 190 | − goto err2; | |
| 191 | − | |
| 192 | − ret = gpio_request(pdata->data_enable_gpio, | |
| 193 | − "lcd l4f00242t03 data enable"); | |
| 182 | + ret = gpio_request_one(pdata->data_enable_gpio, GPIOF_OUT_INIT_LOW, | |
| 183 | + "lcd l4f00242t03 data enable"); | |
| 194 | 184 | if (ret) { |
| 195 | 185 | dev_err(&spi->dev, |
| 196 | 186 | "Unable to get the lcd l4f00242t03 data en gpio.\n"); |
| 197 | 187 | goto err2; |
| 198 | 188 | } |
| 199 | 189 | |
| 200 | − ret = gpio_direction_output(pdata->data_enable_gpio, 0); | |
| 201 | − if (ret) | |
| 190 | + priv->io_reg = regulator_get(&spi->dev, "vdd"); | |
| 191 | + if (IS_ERR(priv->io_reg)) { | |
| 192 | + dev_err(&spi->dev, "%s: Unable to get the IO regulator\n", | |
| 193 | + __func__); | |
| 202 | 194 | goto err3; |
| 203 | − | |
| 204 | − if (pdata->io_supply) { | |
| 205 | − priv->io_reg = regulator_get(NULL, pdata->io_supply); | |
| 206 | − | |
| 207 | − if (IS_ERR(priv->io_reg)) { | |
| 208 | − pr_err("%s: Unable to get the IO regulator\n", | |
| 209 | − __func__); | |
| 210 | − goto err3; | |
| 211 | − } | |
| 212 | 195 | } |
| 213 | 196 | |
| 214 | − if (pdata->core_supply) { | |
| 215 | − priv->core_reg = regulator_get(NULL, pdata->core_supply); | |
| 216 | − | |
| 217 | − if (IS_ERR(priv->core_reg)) { | |
| 218 | − pr_err("%s: Unable to get the core regulator\n", | |
| 219 | − __func__); | |
| 220 | − goto err4; | |
| 221 | − } | |
| 197 | + priv->core_reg = regulator_get(&spi->dev, "vcore"); | |
| 198 | + if (IS_ERR(priv->core_reg)) { | |
| 199 | + dev_err(&spi->dev, "%s: Unable to get the core regulator\n", | |
| 200 | + __func__); | |
| 201 | + goto err4; | |
| 222 | 202 | } |
| 223 | 203 | |
| 224 | 204 | priv->ld = lcd_device_register("l4f00242t03", |
| @@ -238,11 +218,9 @@ static int __devinit l4f00242t03_probe(struct spi_device *spi) · 13 unmodified lines | ||
| 238 | 218 | return 0; |
| 239 | 219 | |
| 240 | 220 | err5: |
| 241 | − if (priv->core_reg) | |
| 242 | − regulator_put(priv->core_reg); | |
| 221 | + regulator_put(priv->core_reg); | |
| 243 | 222 | err4: |
| 244 | − if (priv->io_reg) | |
| 245 | − regulator_put(priv->io_reg); | |
| 223 | + regulator_put(priv->io_reg); | |
| 246 | 224 | err3: |
| 247 | 225 | gpio_free(pdata->data_enable_gpio); |
| 248 | 226 | err2: |
| @@ -266,10 +244,8 @@ static int __devexit l4f00242t03_remove(struct spi_device *spi) · 17 unmodified lines | ||
| 266 | 244 | gpio_free(pdata->data_enable_gpio); |
| 267 | 245 | gpio_free(pdata->reset_gpio); |
| 268 | 246 | |
| 269 | − if (priv->io_reg) | |
| 270 | − regulator_put(priv->io_reg); | |
| 271 | − if (priv->core_reg) | |
| 272 | − regulator_put(priv->core_reg); | |
| 247 | + regulator_put(priv->io_reg); | |
| 248 | + regulator_put(priv->core_reg); | |
| 273 | 249 | |
| 274 | 250 | kfree(priv); |
| 275 | 251 | |
| @@ -109,7 +109,7 @@ source "fs/proc/Kconfig" · 108 unmodified lines | ||
| 109 | 109 | source "fs/sysfs/Kconfig" |
| 110 | 110 | |
| 111 | 111 | config TMPFS |
| 112 | − bool "Virtual memory file system support (former shm fs)" | |
| 112 | + bool "Tmpfs virtual memory file system support (former shm fs)" | |
| 113 | 113 | depends on SHMEM |
| 114 | 114 | help |
| 115 | 115 | Tmpfs is a file system which keeps all files in virtual memory. |
| @@ -1387,13 +1387,13 @@ static ssize_t aio_setup_vectored_rw(int type, struct kiocb *kiocb, bool compat) · 1386 unmodified lines | ||
| 1387 | 1387 | ret = compat_rw_copy_check_uvector(type, |
| 1388 | 1388 | (struct compat_iovec __user *)kiocb->ki_buf, |
| 1389 | 1389 | kiocb->ki_nbytes, 1, &kiocb->ki_inline_vec, |
| 1390 | − &kiocb->ki_iovec); | |
| 1390 | + &kiocb->ki_iovec, 1); | |
| 1391 | 1391 | else |
| 1392 | 1392 | #endif |
| 1393 | 1393 | ret = rw_copy_check_uvector(type, |
| 1394 | 1394 | (struct iovec __user *)kiocb->ki_buf, |
| 1395 | 1395 | kiocb->ki_nbytes, 1, &kiocb->ki_inline_vec, |
| 1396 | − &kiocb->ki_iovec); | |
| 1396 | + &kiocb->ki_iovec, 1); | |
| 1397 | 1397 | if (ret < 0) |
| 1398 | 1398 | goto out; |
| 1399 | 1399 | |
| @@ -213,13 +213,16 @@ __find_get_block_slow(struct block_device *bdev, sector_t block) · 212 unmodified lines | ||
| 213 | 213 | * elsewhere, don't buffer_error if we had some unmapped buffers |
| 214 | 214 | */ |
| 215 | 215 | if (all_mapped) { |
| 216 | + char b[BDEVNAME_SIZE]; | |
| 217 | + | |
| 216 | 218 | printk("__find_get_block_slow() failed. " |
| 217 | 219 | "block=%llu, b_blocknr=%llu\n", |
| 218 | 220 | (unsigned long long)block, |
| 219 | 221 | (unsigned long long)bh->b_blocknr); |
| 220 | 222 | printk("b_state=0x%08lx, b_size=%zu\n", |
| 221 | 223 | bh->b_state, bh->b_size); |
| 222 | − printk("device blocksize: %d\n", 1 << bd_inode->i_blkbits); | |
| 224 | + printk("device %s blocksize: %d\n", bdevname(bdev, b), | |
| 225 | + 1 << bd_inode->i_blkbits); | |
| 223 | 226 | } |
| 224 | 227 | out_unlock: |
| 225 | 228 | spin_unlock(&bd_mapping->private_lock); |
| @@ -546,7 +546,7 @@ out: · 545 unmodified lines | ||
| 546 | 546 | ssize_t compat_rw_copy_check_uvector(int type, |
| 547 | 547 | const struct compat_iovec __user *uvector, unsigned long nr_segs, |
| 548 | 548 | unsigned long fast_segs, struct iovec *fast_pointer, |
| 549 | − struct iovec **ret_pointer) | |
| 549 | + struct iovec **ret_pointer, int check_access) | |
| 550 | 550 | { |
| 551 | 551 | compat_ssize_t tot_len; |
| 552 | 552 | struct iovec *iov = *ret_pointer = fast_pointer; |
| @@ -593,7 +593,8 @@ ssize_t compat_rw_copy_check_uvector(int type, · 40 unmodified lines | ||
| 593 | 593 | } |
| 594 | 594 | if (len < 0) /* size_t not fitting in compat_ssize_t .. */ |
| 595 | 595 | goto out; |
| 596 | − if (!access_ok(vrfy_dir(type), compat_ptr(buf), len)) { | |
| 596 | + if (check_access && | |
| 597 | + !access_ok(vrfy_dir(type), compat_ptr(buf), len)) { | |
| 597 | 598 | ret = -EFAULT; |
| 598 | 599 | goto out; |
| 599 | 600 | } |
| @@ -1107,7 +1108,7 @@ static ssize_t compat_do_readv_writev(int type, struct file *file, · 507 unmodified lines | ||
| 1107 | 1108 | goto out; |
| 1108 | 1109 | |
| 1109 | 1110 | tot_len = compat_rw_copy_check_uvector(type, uvector, nr_segs, |
| 1110 | − UIO_FASTIOV, iovstack, &iov); | |
| 1111 | + UIO_FASTIOV, iovstack, &iov, 1); | |
| 1111 | 1112 | if (tot_len == 0) { |
| 1112 | 1113 | ret = 0; |
| 1113 | 1114 | goto out; |
| @@ -514,7 +514,7 @@ ecryptfs_set_dentry_lower_mnt(struct dentry *dentry, struct vfsmount *lower_mnt) · 513 unmodified lines | ||
| 514 | 514 | |
| 515 | 515 | #define ecryptfs_printk(type, fmt, arg...) \ |
| 516 | 516 | __ecryptfs_printk(type "%s: " fmt, __func__, ## arg); |
| 517 | −__attribute__ ((format(printf, 1, 2))) | |
| 517 | +__printf(1, 2) | |
| 518 | 518 | void __ecryptfs_printk(const char *fmt, ...); |
| 519 | 519 | |
| 520 | 520 | extern const struct file_operations ecryptfs_main_fops; |
| @@ -70,6 +70,15 @@ · 69 unmodified lines | ||
| 70 | 70 | * simultaneous inserts (A into B and B into A) from racing and |
| 71 | 71 | * constructing a cycle without either insert observing that it is |
| 72 | 72 | * going to. |
| 73 | + * It is necessary to acquire multiple "ep->mtx"es at once in the | |
| 74 | + * case when one epoll fd is added to another. In this case, we | |
| 75 | + * always acquire the locks in the order of nesting (i.e. after | |
| 76 | + * epoll_ctl(e1, EPOLL_CTL_ADD, e2), e1->mtx will always be acquired | |
| 77 | + * before e2->mtx). Since we disallow cycles of epoll file | |
| 78 | + * descriptors, this ensures that the mutexes are well-ordered. In | |
| 79 | + * order to communicate this nesting to lockdep, when walking a tree | |
| 80 | + * of epoll file descriptors, we use the current recursion depth as | |
| 81 | + * the lockdep subkey. | |
| 73 | 82 | * It is possible to drop the "ep->mtx" and to use the global |
| 74 | 83 | * mutex "epmutex" (together with "ep->lock") to have it working, |
| 75 | 84 | * but having "ep->mtx" will make the interface more scalable. |
| @@ -464,13 +473,15 @@ static void ep_unregister_pollwait(struct eventpoll *ep, struct epitem *epi) · 388 unmodified lines | ||
| 464 | 473 | * @ep: Pointer to the epoll private data structure. |
| 465 | 474 | * @sproc: Pointer to the scan callback. |
| 466 | 475 | * @priv: Private opaque data passed to the @sproc callback. |
| 476 | + * @depth: The current depth of recursive f_op->poll calls. | |
| 467 | 477 | * |
| 468 | 478 | * Returns: The same integer error code returned by the @sproc callback. |
| 469 | 479 | */ |
| 470 | 480 | static int ep_scan_ready_list(struct eventpoll *ep, |
| 471 | 481 | int (*sproc)(struct eventpoll *, |
| 472 | 482 | struct list_head *, void *), |
| 473 | − void *priv) | |
| 483 | + void *priv, | |
| 484 | + int depth) | |
| 474 | 485 | { |
| 475 | 486 | int error, pwake = 0; |
| 476 | 487 | unsigned long flags; |
| @@ -481,7 +492,7 @@ static int ep_scan_ready_list(struct eventpoll *ep, · 4 unmodified lines | ||
| 481 | 492 | * We need to lock this because we could be hit by |
| 482 | 493 | * eventpoll_release_file() and epoll_ctl(). |
| 483 | 494 | */ |
| 484 | − mutex_lock(&ep->mtx); | |
| 495 | + mutex_lock_nested(&ep->mtx, depth); | |
| 485 | 496 | |
| 486 | 497 | /* |
| 487 | 498 | * Steal the ready list, and re-init the original one to the |
| @@ -670,7 +681,7 @@ static int ep_read_events_proc(struct eventpoll *ep, struct list_head *head, · 182 unmodified lines | ||
| 670 | 681 | |
| 671 | 682 | static int ep_poll_readyevents_proc(void *priv, void *cookie, int call_nests) |
| 672 | 683 | { |
| 673 | − return ep_scan_ready_list(priv, ep_read_events_proc, NULL); | |
| 684 | + return ep_scan_ready_list(priv, ep_read_events_proc, NULL, call_nests + 1); | |
| 674 | 685 | } |
| 675 | 686 | |
| 676 | 687 | static unsigned int ep_eventpoll_poll(struct file *file, poll_table *wait) |
| @@ -737,7 +748,7 @@ void eventpoll_release_file(struct file *file) · 60 unmodified lines | ||
| 737 | 748 | |
| 738 | 749 | ep = epi->ep; |
| 739 | 750 | list_del_init(&epi->fllink); |
| 740 | − mutex_lock(&ep->mtx); | |
| 751 | + mutex_lock_nested(&ep->mtx, 0); | |
| 741 | 752 | ep_remove(ep, epi); |
| 742 | 753 | mutex_unlock(&ep->mtx); |
| 743 | 754 | } |
| @@ -1134,7 +1145,7 @@ static int ep_send_events(struct eventpoll *ep, · 390 unmodified lines | ||
| 1134 | 1145 | esed.maxevents = maxevents; |
| 1135 | 1146 | esed.events = events; |
| 1136 | 1147 | |
| 1137 | − return ep_scan_ready_list(ep, ep_send_events_proc, &esed); | |
| 1148 | + return ep_scan_ready_list(ep, ep_send_events_proc, &esed, 0); | |
| 1138 | 1149 | } |
| 1139 | 1150 | |
| 1140 | 1151 | static inline struct timespec ep_set_mstimeout(long ms) |
| @@ -1267,7 +1278,7 @@ static int ep_loop_check_proc(void *priv, void *cookie, int call_nests) · 126 unmodified lines | ||
| 1267 | 1278 | struct rb_node *rbp; |
| 1268 | 1279 | struct epitem *epi; |
| 1269 | 1280 | |
| 1270 | − mutex_lock(&ep->mtx); | |
| 1281 | + mutex_lock_nested(&ep->mtx, call_nests + 1); | |
| 1271 | 1282 | for (rbp = rb_first(&ep->rbr); rbp; rbp = rb_next(rbp)) { |
| 1272 | 1283 | epi = rb_entry(rbp, struct epitem, rbn); |
| 1273 | 1284 | if (unlikely(is_file_epoll(epi->ffd.file))) { |
| @@ -1409,7 +1420,7 @@ SYSCALL_DEFINE4(epoll_ctl, int, epfd, int, op, int, fd, · 135 unmodified lines | ||
| 1409 | 1420 | } |
| 1410 | 1421 | |
| 1411 | 1422 | |
| 1412 | − mutex_lock(&ep->mtx); | |
| 1423 | + mutex_lock_nested(&ep->mtx, 0); | |
| 1413 | 1424 | |
| 1414 | 1425 | /* |
| 1415 | 1426 | * Try to lookup the file inside our RB tree, Since we grabbed "mtx" |
| @@ -841,10 +841,6 @@ static int exec_mmap(struct mm_struct *mm) · 840 unmodified lines | ||
| 841 | 841 | tsk->mm = mm; |
| 842 | 842 | tsk->active_mm = mm; |
| 843 | 843 | activate_mm(active_mm, mm); |
| 844 | − if (old_mm && tsk->signal->oom_score_adj == OOM_SCORE_ADJ_MIN) { | |
| 845 | − atomic_dec(&old_mm->oom_disable_count); | |
| 846 | − atomic_inc(&tsk->mm->oom_disable_count); | |
| 847 | − } | |
| 848 | 844 | task_unlock(tsk); |
| 849 | 845 | arch_pick_mmap_layout(mm); |
| 850 | 846 | if (old_mm) { |
| @@ -135,10 +135,10 @@ extern long ext2_compat_ioctl(struct file *, unsigned int, unsigned long); · 134 unmodified lines | ||
| 135 | 135 | struct dentry *ext2_get_parent(struct dentry *child); |
| 136 | 136 | |
| 137 | 137 | /* super.c */ |
| 138 | −extern void ext2_error (struct super_block *, const char *, const char *, ...) | |
| 139 | − __attribute__ ((format (printf, 3, 4))); | |
| 140 | −extern void ext2_msg(struct super_block *, const char *, const char *, ...) | |
| 141 | − __attribute__ ((format (printf, 3, 4))); | |
| 138 | +extern __printf(3, 4) | |
| 139 | +void ext2_error(struct super_block *, const char *, const char *, ...); | |
| 140 | +extern __printf(3, 4) | |
| 141 | +void ext2_msg(struct super_block *, const char *, const char *, ...); | |
| 142 | 142 | extern void ext2_update_dynamic_rev (struct super_block *sb); |
| 143 | 143 | extern void ext2_write_super (struct super_block *); |
| 144 | 144 | |
| @@ -1878,40 +1878,40 @@ extern int ext4_group_extend(struct super_block *sb, · 1877 unmodified lines | ||
| 1878 | 1878 | extern void *ext4_kvmalloc(size_t size, gfp_t flags); |
| 1879 | 1879 | extern void *ext4_kvzalloc(size_t size, gfp_t flags); |
| 1880 | 1880 | extern void ext4_kvfree(void *ptr); |
| 1881 | −extern void __ext4_error(struct super_block *, const char *, unsigned int, | |
| 1882 | − const char *, ...) | |
| 1883 | − __attribute__ ((format (printf, 4, 5))); | |
| 1881 | +extern __printf(4, 5) | |
| 1882 | +void __ext4_error(struct super_block *, const char *, unsigned int, | |
| 1883 | + const char *, ...); | |
| 1884 | 1884 | #define ext4_error(sb, message...) __ext4_error(sb, __func__, \ |
| 1885 | 1885 | __LINE__, ## message) |
| 1886 | −extern void ext4_error_inode(struct inode *, const char *, unsigned int, | |
| 1887 | − ext4_fsblk_t, const char *, ...) | |
| 1888 | − __attribute__ ((format (printf, 5, 6))); | |
| 1889 | −extern void ext4_error_file(struct file *, const char *, unsigned int, | |
| 1890 | − ext4_fsblk_t, const char *, ...) | |
| 1891 | − __attribute__ ((format (printf, 5, 6))); | |
| 1886 | +extern __printf(5, 6) | |
| 1887 | +void ext4_error_inode(struct inode *, const char *, unsigned int, ext4_fsblk_t, | |
| 1888 | + const char *, ...); | |
| 1889 | +extern __printf(5, 6) | |
| 1890 | +void ext4_error_file(struct file *, const char *, unsigned int, ext4_fsblk_t, | |
| 1891 | + const char *, ...); | |
| 1892 | 1892 | extern void __ext4_std_error(struct super_block *, const char *, |
| 1893 | 1893 | unsigned int, int); |
| 1894 | −extern void __ext4_abort(struct super_block *, const char *, unsigned int, | |
| 1895 | − const char *, ...) | |
| 1896 | − __attribute__ ((format (printf, 4, 5))); | |
| 1894 | +extern __printf(4, 5) | |
| 1895 | +void __ext4_abort(struct super_block *, const char *, unsigned int, | |
| 1896 | + const char *, ...); | |
| 1897 | 1897 | #define ext4_abort(sb, message...) __ext4_abort(sb, __func__, \ |
| 1898 | 1898 | __LINE__, ## message) |
| 1899 | −extern void __ext4_warning(struct super_block *, const char *, unsigned int, | |
| 1900 | − const char *, ...) | |
| 1901 | − __attribute__ ((format (printf, 4, 5))); | |
| 1899 | +extern __printf(4, 5) | |
| 1900 | +void __ext4_warning(struct super_block *, const char *, unsigned int, | |
| 1901 | + const char *, ...); | |
| 1902 | 1902 | #define ext4_warning(sb, message...) __ext4_warning(sb, __func__, \ |
| 1903 | 1903 | __LINE__, ## message) |
| 1904 | −extern void ext4_msg(struct super_block *, const char *, const char *, ...) | |
| 1905 | − __attribute__ ((format (printf, 3, 4))); | |
| 1904 | +extern __printf(3, 4) | |
| 1905 | +void ext4_msg(struct super_block *, const char *, const char *, ...); | |
| 1906 | 1906 | extern void __dump_mmp_msg(struct super_block *, struct mmp_struct *mmp, |
| 1907 | 1907 | const char *, unsigned int, const char *); |
| 1908 | 1908 | #define dump_mmp_msg(sb, mmp, msg) __dump_mmp_msg(sb, mmp, __func__, \ |
| 1909 | 1909 | __LINE__, msg) |
| 1910 | −extern void __ext4_grp_locked_error(const char *, unsigned int, \ | |
| 1911 | − struct super_block *, ext4_group_t, \ | |
| 1912 | − unsigned long, ext4_fsblk_t, \ | |
| 1913 | − const char *, ...) | |
| 1914 | − __attribute__ ((format (printf, 7, 8))); | |
| 1910 | +extern __printf(7, 8) | |
| 1911 | +void __ext4_grp_locked_error(const char *, unsigned int, | |
| 1912 | + struct super_block *, ext4_group_t, | |
| 1913 | + unsigned long, ext4_fsblk_t, | |
| 1914 | + const char *, ...); | |
| 1915 | 1915 | #define ext4_grp_locked_error(sb, grp, message...) \ |
| 1916 | 1916 | __ext4_grp_locked_error(__func__, __LINE__, (sb), (grp), ## message) |
| 1917 | 1917 | extern void ext4_update_dynamic_rev(struct super_block *sb); |
| @@ -1811,8 +1811,12 @@ static int ext4_writepage(struct page *page, · 1810 unmodified lines | ||
| 1811 | 1811 | * We don't want to do block allocation, so redirty |
| 1812 | 1812 | * the page and return. We may reach here when we do |
| 1813 | 1813 | * a journal commit via journal_submit_inode_data_buffers. |
| 1814 | − * We can also reach here via shrink_page_list | |
| 1814 | + * We can also reach here via shrink_page_list but it | |
| 1815 | + * should never be for direct reclaim so warn if that | |
| 1816 | + * happens | |
| 1815 | 1817 | */ |
| 1818 | + WARN_ON_ONCE((current->flags & (PF_MEMALLOC|PF_KSWAPD)) == | |
| 1819 | + PF_MEMALLOC); | |
| 1816 | 1820 | goto redirty_page; |
| 1817 | 1821 | } |
| 1818 | 1822 | if (commit_write) |
| @@ -156,8 +156,8 @@ static int uni16_to_x8(struct super_block *sb, unsigned char *ascii, · 155 unmodified lines | ||
| 156 | 156 | } else { |
| 157 | 157 | if (uni_xlate == 1) { |
| 158 | 158 | *op++ = ':'; |
| 159 | − op = pack_hex_byte(op, ec >> 8); | |
| 160 | − op = pack_hex_byte(op, ec); | |
| 159 | + op = hex_byte_pack(op, ec >> 8); | |
| 160 | + op = hex_byte_pack(op, ec); | |
| 161 | 161 | len -= 5; |
| 162 | 162 | } else { |
| 163 | 163 | *op++ = '?'; |
| @@ -326,15 +326,14 @@ extern int fat_fill_super(struct super_block *sb, void *data, int silent, · 325 unmodified lines | ||
| 326 | 326 | extern int fat_flush_inodes(struct super_block *sb, struct inode *i1, |
| 327 | 327 | struct inode *i2); |
| 328 | 328 | /* fat/misc.c */ |
| 329 | −extern void | |
| 330 | −__fat_fs_error(struct super_block *sb, int report, const char *fmt, ...) | |
| 331 | − __attribute__ ((format (printf, 3, 4))) __cold; | |
| 329 | +extern __printf(3, 4) __cold | |
| 330 | +void __fat_fs_error(struct super_block *sb, int report, const char *fmt, ...); | |
| 332 | 331 | #define fat_fs_error(sb, fmt, args...) \ |
| 333 | 332 | __fat_fs_error(sb, 1, fmt , ## args) |
| 334 | 333 | #define fat_fs_error_ratelimit(sb, fmt, args...) \ |
| 335 | 334 | __fat_fs_error(sb, __ratelimit(&MSDOS_SB(sb)->ratelimit), fmt , ## args) |
| 336 | −void fat_msg(struct super_block *sb, const char *level, const char *fmt, ...) | |
| 337 | − __attribute__ ((format (printf, 3, 4))) __cold; | |
| 335 | +__printf(3, 4) __cold | |
| 336 | +void fat_msg(struct super_block *sb, const char *level, const char *fmt, ...); | |
| 338 | 337 | extern int fat_clusters_flush(struct super_block *sb); |
| 339 | 338 | extern int fat_chain_add(struct inode *inode, int new_dclus, int nr_cluster); |
| 340 | 339 | extern void fat_time_fat2unix(struct msdos_sb_info *sbi, struct timespec *ts, |
| @@ -201,7 +201,7 @@ int gfs2_glock_nq_m(unsigned int num_gh, struct gfs2_holder *ghs); · 200 unmodified lines | ||
| 201 | 201 | void gfs2_glock_dq_m(unsigned int num_gh, struct gfs2_holder *ghs); |
| 202 | 202 | void gfs2_glock_dq_uninit_m(unsigned int num_gh, struct gfs2_holder *ghs); |
| 203 | 203 | |
| 204 | −__attribute__ ((format(printf, 2, 3))) | |
| 204 | +__printf(2, 3) | |
| 205 | 205 | void gfs2_print_dbg(struct seq_file *seq, const char *fmt, ...); |
| 206 | 206 | |
| 207 | 207 | /** |
| @@ -311,8 +311,8 @@ static inline struct hpfs_sb_info *hpfs_sb(struct super_block *sb) · 310 unmodified lines | ||
| 311 | 311 | |
| 312 | 312 | /* super.c */ |
| 313 | 313 | |
| 314 | −void hpfs_error(struct super_block *, const char *, ...) | |
| 315 | − __attribute__((format (printf, 2, 3))); | |
| 314 | +__printf(2, 3) | |
| 315 | +void hpfs_error(struct super_block *, const char *, ...); | |
| 316 | 316 | int hpfs_stop_cycles(struct super_block *, int, int *, int *, char *); |
| 317 | 317 | unsigned hpfs_count_one_bitmap(struct super_block *, secno); |
| 318 | 318 | |
| @@ -618,7 +618,6 @@ static inline int logfs_buf_recover(struct logfs_area *area, u64 ofs, · 617 unmodified lines | ||
| 618 | 618 | struct page *emergency_read_begin(struct address_space *mapping, pgoff_t index); |
| 619 | 619 | void emergency_read_end(struct page *page); |
| 620 | 620 | void logfs_crash_dump(struct super_block *sb); |
| 621 | −void *memchr_inv(const void *s, int c, size_t n); | |
| 622 | 621 | int logfs_statfs(struct dentry *dentry, struct kstatfs *stats); |
| 623 | 622 | int logfs_check_ds(struct logfs_disk_super *ds); |
| 624 | 623 | int logfs_write_sb(struct super_block *sb); |
| @@ -90,28 +90,6 @@ void logfs_crash_dump(struct super_block *sb) · 89 unmodified lines | ||
| 90 | 90 | dump_segfile(sb); |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | −/* | |
| 94 | − * TODO: move to lib/string.c | |
| 95 | − */ | |
| 96 | −/** | |
| 97 | − * memchr_inv - Find a character in an area of memory. | |
| 98 | − * @s: The memory area | |
| 99 | − * @c: The byte to search for | |
| 100 | − * @n: The size of the area. | |
| 101 | − * | |
| 102 | − * returns the address of the first character other than @c, or %NULL | |
| 103 | − * if the whole buffer contains just @c. | |
| 104 | − */ | |
| 105 | −void *memchr_inv(const void *s, int c, size_t n) | |
| 106 | −{ | |
| 107 | − const unsigned char *p = s; | |
| 108 | − while (n-- != 0) | |
| 109 | − if ((unsigned char)c != *p++) | |
| 110 | − return (void *)(p - 1); | |
| 111 | − | |
| 112 | − return NULL; | |
| 113 | −} | |
| 114 | − | |
| 115 | 93 | /* |
| 116 | 94 | * FIXME: There should be a reserve for root, similar to ext2. |
| 117 | 95 | */ |
| @@ -276,10 +276,10 @@ int nilfs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, · 275 unmodified lines | ||
| 276 | 276 | /* super.c */ |
| 277 | 277 | extern struct inode *nilfs_alloc_inode(struct super_block *); |
| 278 | 278 | extern void nilfs_destroy_inode(struct inode *); |
| 279 | −extern void nilfs_error(struct super_block *, const char *, const char *, ...) | |
| 280 | − __attribute__ ((format (printf, 3, 4))); | |
| 281 | −extern void nilfs_warning(struct super_block *, const char *, const char *, ...) | |
| 282 | − __attribute__ ((format (printf, 3, 4))); | |
| 279 | +extern __printf(3, 4) | |
| 280 | +void nilfs_error(struct super_block *, const char *, const char *, ...); | |
| 281 | +extern __printf(3, 4) | |
| 282 | +void nilfs_warning(struct super_block *, const char *, const char *, ...); | |
| 283 | 283 | extern struct nilfs_super_block * |
| 284 | 284 | nilfs_read_super_block(struct super_block *, u64, int, struct buffer_head **); |
| 285 | 285 | extern int nilfs_store_magic_and_option(struct super_block *, |
| @@ -30,8 +30,9 @@ · 29 unmodified lines | ||
| 30 | 30 | |
| 31 | 31 | extern int debug_msgs; |
| 32 | 32 | |
| 33 | −extern void __ntfs_debug(const char *file, int line, const char *function, | |
| 34 | − const char *format, ...) __attribute__ ((format (printf, 4, 5))); | |
| 33 | +extern __printf(4, 5) | |
| 34 | +void __ntfs_debug(const char *file, int line, const char *function, | |
| 35 | + const char *format, ...); | |
| 35 | 36 | /** |
| 36 | 37 | * ntfs_debug - write a debug level message to syslog |
| 37 | 38 | * @f: a printf format string containing the message |
| @@ -52,12 +53,14 @@ extern void ntfs_debug_dump_runlist(const runlist_element *rl); · 14 unmodified lines | ||
| 52 | 53 | |
| 53 | 54 | #endif /* !DEBUG */ |
| 54 | 55 | |
| 55 | −extern void __ntfs_warning(const char *function, const struct super_block *sb, | |
| 56 | − const char *fmt, ...) __attribute__ ((format (printf, 3, 4))); | |
| 56 | +extern __printf(3, 4) | |
| 57 | +void __ntfs_warning(const char *function, const struct super_block *sb, | |
| 58 | + const char *fmt, ...); | |
| 57 | 59 | #define ntfs_warning(sb, f, a...) __ntfs_warning(__func__, sb, f, ##a) |
| 58 | 60 | |
| 59 | −extern void __ntfs_error(const char *function, const struct super_block *sb, | |
| 60 | − const char *fmt, ...) __attribute__ ((format (printf, 3, 4))); | |
| 61 | +extern __printf(3, 4) | |
| 62 | +void __ntfs_error(const char *function, const struct super_block *sb, | |
| 63 | + const char *fmt, ...); | |
| 61 | 64 | #define ntfs_error(sb, f, a...) __ntfs_error(__func__, sb, f, ##a) |
| 62 | 65 | |
| 63 | 66 | #endif /* _LINUX_NTFS_DEBUG_H */ |
| @@ -31,17 +31,15 @@ extern struct workqueue_struct *ocfs2_wq; · 30 unmodified lines | ||
| 31 | 31 | int ocfs2_publish_get_mount_state(struct ocfs2_super *osb, |
| 32 | 32 | int node_num); |
| 33 | 33 | |
| 34 | −void __ocfs2_error(struct super_block *sb, | |
| 35 | − const char *function, | |
| 36 | − const char *fmt, ...) | |
| 37 | − __attribute__ ((format (printf, 3, 4))); | |
| 34 | +__printf(3, 4) | |
| 35 | +void __ocfs2_error(struct super_block *sb, const char *function, | |
| 36 | + const char *fmt, ...); | |
| 38 | 37 | |
| 39 | 38 | #define ocfs2_error(sb, fmt, args...) __ocfs2_error(sb, __PRETTY_FUNCTION__, fmt, ##args) |
| 40 | 39 | |
| 41 | −void __ocfs2_abort(struct super_block *sb, | |
| 42 | − const char *function, | |
| 43 | − const char *fmt, ...) | |
| 44 | − __attribute__ ((format (printf, 3, 4))); | |
| 40 | +__printf(3, 4) | |
| 41 | +void __ocfs2_abort(struct super_block *sb, const char *function, | |
| 42 | + const char *fmt, ...); | |
| 45 | 43 | |
| 46 | 44 | #define ocfs2_abort(sb, fmt, args...) __ocfs2_abort(sb, __PRETTY_FUNCTION__, fmt, ##args) |
| 47 | 45 | |
| @@ -49,18 +49,20 @@ · 48 unmodified lines | ||
| 49 | 49 | #define ldm_error(f, a...) _ldm_printk (KERN_ERR, __func__, f, ##a) |
| 50 | 50 | #define ldm_info(f, a...) _ldm_printk (KERN_INFO, __func__, f, ##a) |
| 51 | 51 | |
| 52 | −__attribute__ ((format (printf, 3, 4))) | |
| 53 | −static void _ldm_printk (const char *level, const char *function, | |
| 54 | − const char *fmt, ...) | |
| 52 | +static __printf(3, 4) | |
| 53 | +void _ldm_printk(const char *level, const char *function, const char *fmt, ...) | |
| 55 | 54 | { |
| 56 | − static char buf[128]; | |
| 55 | + struct va_format vaf; | |
| 57 | 56 | va_list args; |
| 58 | 57 | |
| 59 | 58 | va_start (args, fmt); |
| 60 | − vsnprintf (buf, sizeof (buf), fmt, args); | |
| 61 | − va_end (args); | |
| 62 | 59 | |
| 63 | − printk ("%s%s(): %s\n", level, function, buf); | |
| 60 | + vaf.fmt = fmt; | |
| 61 | + vaf.va = &args; | |
| 62 | + | |
| 63 | + printk("%s%s(): %pV\n", level, function, &vaf); | |
| 64 | + | |
| 65 | + va_end(args); | |
| 64 | 66 | } |
| 65 | 67 | |
| 66 | 68 | /** |
| @@ -1254,6 +1254,7 @@ out: · 1253 unmodified lines | ||
| 1254 | 1254 | |
| 1255 | 1255 | static const struct super_operations pipefs_ops = { |
| 1256 | 1256 | .destroy_inode = free_inode_nonrcu, |
| 1257 | + .statfs = simple_statfs, | |
| 1257 | 1258 | }; |
| 1258 | 1259 | |
| 1259 | 1260 | /* |
| @@ -1107,13 +1107,6 @@ static ssize_t oom_adjust_write(struct file *file, const char __user *buf, · 1106 unmodified lines | ||
| 1107 | 1107 | goto err_sighand; |
| 1108 | 1108 | } |
| 1109 | 1109 | |
| 1110 | − if (oom_adjust != task->signal->oom_adj) { | |
| 1111 | − if (oom_adjust == OOM_DISABLE) | |
| 1112 | − atomic_inc(&task->mm->oom_disable_count); | |
| 1113 | − if (task->signal->oom_adj == OOM_DISABLE) | |
| 1114 | − atomic_dec(&task->mm->oom_disable_count); | |
| 1115 | − } | |
| 1116 | − | |
| 1117 | 1110 | /* |
| 1118 | 1111 | * Warn that /proc/pid/oom_adj is deprecated, see |
| 1119 | 1112 | * Documentation/feature-removal-schedule.txt. |
| @@ -1215,12 +1208,6 @@ static ssize_t oom_score_adj_write(struct file *file, const char __user *buf, · 95 unmodified lines | ||
| 1215 | 1208 | goto err_sighand; |
| 1216 | 1209 | } |
| 1217 | 1210 | |
| 1218 | − if (oom_score_adj != task->signal->oom_score_adj) { | |
| 1219 | − if (oom_score_adj == OOM_SCORE_ADJ_MIN) | |
| 1220 | − atomic_inc(&task->mm->oom_disable_count); | |
| 1221 | − if (task->signal->oom_score_adj == OOM_SCORE_ADJ_MIN) | |
| 1222 | − atomic_dec(&task->mm->oom_disable_count); | |
| 1223 | − } | |
| 1224 | 1211 | task->signal->oom_score_adj = oom_score_adj; |
| 1225 | 1212 | if (has_capability_noaudit(current, CAP_SYS_RESOURCE)) |
| 1226 | 1213 | task->signal->oom_score_adj_min = oom_score_adj; |
| @@ -44,6 +44,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm) · 43 unmodified lines | ||
| 44 | 44 | "VmPeak:\t%8lu kB\n" |
| 45 | 45 | "VmSize:\t%8lu kB\n" |
| 46 | 46 | "VmLck:\t%8lu kB\n" |
| 47 | + "VmPin:\t%8lu kB\n" | |
| 47 | 48 | "VmHWM:\t%8lu kB\n" |
| 48 | 49 | "VmRSS:\t%8lu kB\n" |
| 49 | 50 | "VmData:\t%8lu kB\n" |
| @@ -55,6 +56,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm) · 5 unmodified lines | ||
| 55 | 56 | hiwater_vm << (PAGE_SHIFT-10), |
| 56 | 57 | (total_vm - mm->reserved_vm) << (PAGE_SHIFT-10), |
| 57 | 58 | mm->locked_vm << (PAGE_SHIFT-10), |
| 59 | + mm->pinned_vm << (PAGE_SHIFT-10), | |
| 58 | 60 | hiwater_rss << (PAGE_SHIFT-10), |
| 59 | 61 | total_rss << (PAGE_SHIFT-10), |
| 60 | 62 | data << (PAGE_SHIFT-10), |
| @@ -1039,6 +1041,9 @@ static int show_numa_map(struct seq_file *m, void *v) · 978 unmodified lines | ||
| 1039 | 1041 | seq_printf(m, " stack"); |
| 1040 | 1042 | } |
| 1041 | 1043 | |
| 1044 | + if (is_vm_hugetlb_page(vma)) | |
| 1045 | + seq_printf(m, " huge"); | |
| 1046 | + | |
| 1042 | 1047 | walk_page_range(vma->vm_start, vma->vm_end, &walk); |
| 1043 | 1048 | |
| 1044 | 1049 | if (!md->pages) |
| @@ -633,7 +633,8 @@ ssize_t do_loop_readv_writev(struct file *filp, struct iovec *iov, · 632 unmodified lines | ||
| 633 | 633 | ssize_t rw_copy_check_uvector(int type, const struct iovec __user * uvector, |
| 634 | 634 | unsigned long nr_segs, unsigned long fast_segs, |
| 635 | 635 | struct iovec *fast_pointer, |
| 636 | − struct iovec **ret_pointer) | |
| 636 | + struct iovec **ret_pointer, | |
| 637 | + int check_access) | |
| 637 | 638 | { |
| 638 | 639 | unsigned long seg; |
| 639 | 640 | ssize_t ret; |
| @@ -689,7 +690,8 @@ ssize_t rw_copy_check_uvector(int type, const struct iovec __user * uvector, · 49 unmodified lines | ||
| 689 | 690 | ret = -EINVAL; |
| 690 | 691 | goto out; |
| 691 | 692 | } |
| 692 | − if (unlikely(!access_ok(vrfy_dir(type), buf, len))) { | |
| 693 | + if (check_access | |
| 694 | + && unlikely(!access_ok(vrfy_dir(type), buf, len))) { | |
| 693 | 695 | ret = -EFAULT; |
| 694 | 696 | goto out; |
| 695 | 697 | } |
| @@ -721,7 +723,7 @@ static ssize_t do_readv_writev(int type, struct file *file, · 25 unmodified lines | ||
| 721 | 723 | } |
| 722 | 724 | |
| 723 | 725 | ret = rw_copy_check_uvector(type, uvector, nr_segs, |
| 724 | − ARRAY_SIZE(iovstack), iovstack, &iov); | |
| 726 | + ARRAY_SIZE(iovstack), iovstack, &iov, 1); | |
| 725 | 727 | if (ret <= 0) |
| 726 | 728 | goto out; |
| 727 | 729 | |
| @@ -61,7 +61,7 @@ static int prune_super(struct shrinker *shrink, struct shrink_control *sc) · 60 unmodified lines | ||
| 61 | 61 | return -1; |
| 62 | 62 | |
| 63 | 63 | if (!grab_super_passive(sb)) |
| 64 | − return -1; | |
| 64 | + return !sc->nr_to_scan ? 0 : -1; | |
| 65 | 65 | |
| 66 | 66 | if (sb->s_op && sb->s_op->nr_cached_objects) |
| 67 | 67 | fs_objects = sb->s_op->nr_cached_objects(sb); |
| @@ -112,8 +112,8 @@ struct extent_position { · 111 unmodified lines | ||
| 112 | 112 | |
| 113 | 113 | /* super.c */ |
| 114 | 114 | |
| 115 | −__attribute__((format(printf, 3, 4))) | |
| 116 | −extern void udf_warning(struct super_block *, const char *, const char *, ...); | |
| 115 | +extern __printf(3, 4) void udf_warning(struct super_block *, const char *, | |
| 116 | + const char *, ...); | |
| 117 | 117 | static inline void udf_updated_lvid(struct super_block *sb) |
| 118 | 118 | { |
| 119 | 119 | struct buffer_head *bh = UDF_SB(sb)->s_lvid_bh; |
| @@ -117,9 +117,12 @@ extern int ufs_getfrag_block (struct inode *inode, sector_t fragment, struct buf · 116 unmodified lines | ||
| 117 | 117 | extern const struct file_operations ufs_dir_operations; |
| 118 | 118 | |
| 119 | 119 | /* super.c */ |
| 120 | −extern void ufs_warning (struct super_block *, const char *, const char *, ...) __attribute__ ((format (printf, 3, 4))); | |
| 121 | −extern void ufs_error (struct super_block *, const char *, const char *, ...) __attribute__ ((format (printf, 3, 4))); | |
| 122 | −extern void ufs_panic (struct super_block *, const char *, const char *, ...) __attribute__ ((format (printf, 3, 4))); | |
| 120 | +extern __printf(3, 4) | |
| 121 | +void ufs_warning(struct super_block *, const char *, const char *, ...); | |
| 122 | +extern __printf(3, 4) | |
| 123 | +void ufs_error(struct super_block *, const char *, const char *, ...); | |
| 124 | +extern __printf(3, 4) | |
| 125 | +void ufs_panic(struct super_block *, const char *, const char *, ...); | |
| 123 | 126 | |
| 124 | 127 | /* symlink.c */ |
| 125 | 128 | extern const struct inode_operations ufs_fast_symlink_inode_operations; |
| @@ -902,11 +902,11 @@ xfs_vm_writepage( · 901 unmodified lines | ||
| 902 | 902 | * random callers for direct reclaim or memcg reclaim. We explicitly |
| 903 | 903 | * allow reclaim from kswapd as the stack usage there is relatively low. |
| 904 | 904 | * |
| 905 | − * This should really be done by the core VM, but until that happens | |
| 906 | − * filesystems like XFS, btrfs and ext4 have to take care of this | |
| 907 | − * by themselves. | |
| 905 | + * This should never happen except in the case of a VM regression so | |
| 906 | + * warn about it. | |
| 908 | 907 | */ |
| 909 | − if ((current->flags & (PF_MEMALLOC|PF_KSWAPD)) == PF_MEMALLOC) | |
| 908 | + if (WARN_ON_ONCE((current->flags & (PF_MEMALLOC|PF_KSWAPD)) == | |
| 909 | + PF_MEMALLOC)) | |
| 910 | 910 | goto redirty; |
| 911 | 911 | |
| 912 | 912 | /* |
| @@ -3,31 +3,29 @@ · 2 unmodified lines | ||
| 3 | 3 | |
| 4 | 4 | struct xfs_mount; |
| 5 | 5 | |
| 6 | −extern void xfs_emerg(const struct xfs_mount *mp, const char *fmt, ...) | |
| 7 | − __attribute__ ((format (printf, 2, 3))); | |
| 8 | −extern void xfs_alert(const struct xfs_mount *mp, const char *fmt, ...) | |
| 9 | − __attribute__ ((format (printf, 2, 3))); | |
| 10 | −extern void xfs_alert_tag(const struct xfs_mount *mp, int tag, | |
| 11 | − const char *fmt, ...) | |
| 12 | − __attribute__ ((format (printf, 3, 4))); | |
| 13 | −extern void xfs_crit(const struct xfs_mount *mp, const char *fmt, ...) | |
| 14 | − __attribute__ ((format (printf, 2, 3))); | |
| 15 | −extern void xfs_err(const struct xfs_mount *mp, const char *fmt, ...) | |
| 16 | − __attribute__ ((format (printf, 2, 3))); | |
| 17 | −extern void xfs_warn(const struct xfs_mount *mp, const char *fmt, ...) | |
| 18 | − __attribute__ ((format (printf, 2, 3))); | |
| 19 | −extern void xfs_notice(const struct xfs_mount *mp, const char *fmt, ...) | |
| 20 | − __attribute__ ((format (printf, 2, 3))); | |
| 21 | −extern void xfs_info(const struct xfs_mount *mp, const char *fmt, ...) | |
| 22 | − __attribute__ ((format (printf, 2, 3))); | |
| 6 | +extern __printf(2, 3) | |
| 7 | +void xfs_emerg(const struct xfs_mount *mp, const char *fmt, ...); | |
| 8 | +extern __printf(2, 3) | |
| 9 | +void xfs_alert(const struct xfs_mount *mp, const char *fmt, ...); | |
| 10 | +extern __printf(3, 4) | |
| 11 | +void xfs_alert_tag(const struct xfs_mount *mp, int tag, const char *fmt, ...); | |
| 12 | +extern __printf(2, 3) | |
| 13 | +void xfs_crit(const struct xfs_mount *mp, const char *fmt, ...); | |
| 14 | +extern __printf(2, 3) | |
| 15 | +void xfs_err(const struct xfs_mount *mp, const char *fmt, ...); | |
| 16 | +extern __printf(2, 3) | |
| 17 | +void xfs_warn(const struct xfs_mount *mp, const char *fmt, ...); | |
| 18 | +extern __printf(2, 3) | |
| 19 | +void xfs_notice(const struct xfs_mount *mp, const char *fmt, ...); | |
| 20 | +extern __printf(2, 3) | |
| 21 | +void xfs_info(const struct xfs_mount *mp, const char *fmt, ...); | |
| 23 | 22 | |
| 24 | 23 | #ifdef DEBUG |
| 25 | −extern void xfs_debug(const struct xfs_mount *mp, const char *fmt, ...) | |
| 26 | − __attribute__ ((format (printf, 2, 3))); | |
| 24 | +extern __printf(2, 3) | |
| 25 | +void xfs_debug(const struct xfs_mount *mp, const char *fmt, ...); | |
| 27 | 26 | #else |
| 28 | −static inline void | |
| 29 | −__attribute__ ((format (printf, 2, 3))) | |
| 30 | −xfs_debug(const struct xfs_mount *mp, const char *fmt, ...) | |
| 27 | +static inline __printf(2, 3) | |
| 28 | +void xfs_debug(const struct xfs_mount *mp, const char *fmt, ...) | |
| 31 | 29 | { |
| 32 | 30 | } |
| 33 | 31 | #endif |
| @@ -61,11 +61,12 @@ struct bug_entry { · 60 unmodified lines | ||
| 61 | 61 | */ |
| 62 | 62 | #ifndef __WARN_TAINT |
| 63 | 63 | #ifndef __ASSEMBLY__ |
| 64 | −extern void warn_slowpath_fmt(const char *file, const int line, | |
| 65 | − const char *fmt, ...) __attribute__((format(printf, 3, 4))); | |
| 66 | −extern void warn_slowpath_fmt_taint(const char *file, const int line, | |
| 67 | − unsigned taint, const char *fmt, ...) | |
| 68 | − __attribute__((format(printf, 4, 5))); | |
| 64 | +extern __printf(3, 4) | |
| 65 | +void warn_slowpath_fmt(const char *file, const int line, | |
| 66 | + const char *fmt, ...); | |
| 67 | +extern __printf(4, 5) | |
| 68 | +void warn_slowpath_fmt_taint(const char *file, const int line, unsigned taint, | |
| 69 | + const char *fmt, ...); | |
| 69 | 70 | extern void warn_slowpath_null(const char *file, const int line); |
| 70 | 71 | #define WANT_WARN_ON_SLOWPATH |
| 71 | 72 | #endif |
| @@ -123,7 +123,12 @@ static inline void dma_sync_single_range_for_cpu(struct device *dev, · 122 unmodified lines | ||
| 123 | 123 | size_t size, |
| 124 | 124 | enum dma_data_direction dir) |
| 125 | 125 | { |
| 126 | − dma_sync_single_for_cpu(dev, addr + offset, size, dir); | |
| 126 | + const struct dma_map_ops *ops = get_dma_ops(dev); | |
| 127 | + | |
| 128 | + BUG_ON(!valid_dma_direction(dir)); | |
| 129 | + if (ops->sync_single_for_cpu) | |
| 130 | + ops->sync_single_for_cpu(dev, addr + offset, size, dir); | |
| 131 | + debug_dma_sync_single_range_for_cpu(dev, addr, offset, size, dir); | |
| 127 | 132 | } |
| 128 | 133 | |
| 129 | 134 | static inline void dma_sync_single_range_for_device(struct device *dev, |
| @@ -132,7 +137,12 @@ static inline void dma_sync_single_range_for_device(struct device *dev, · 2 unmodified lines | ||
| 132 | 137 | size_t size, |
| 133 | 138 | enum dma_data_direction dir) |
| 134 | 139 | { |
| 135 | − dma_sync_single_for_device(dev, addr + offset, size, dir); | |
| 140 | + const struct dma_map_ops *ops = get_dma_ops(dev); | |
| 141 | + | |
| 142 | + BUG_ON(!valid_dma_direction(dir)); | |
| 143 | + if (ops->sync_single_for_device) | |
| 144 | + ops->sync_single_for_device(dev, addr + offset, size, dir); | |
| 145 | + debug_dma_sync_single_range_for_device(dev, addr, offset, size, dir); | |
| 136 | 146 | } |
| 137 | 147 | |
| 138 | 148 | static inline void |
| @@ -79,8 +79,8 @@ extern unsigned long memory_end; · 78 unmodified lines | ||
| 79 | 79 | #define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT) |
| 80 | 80 | #define pfn_to_virt(pfn) __va((pfn) << PAGE_SHIFT) |
| 81 | 81 | |
| 82 | −#define virt_to_page(addr) (mem_map + (((unsigned long)(addr)-PAGE_OFFSET) >> PAGE_SHIFT)) | |
| 83 | −#define page_to_virt(page) ((((page) - mem_map) << PAGE_SHIFT) + PAGE_OFFSET) | |
| 82 | +#define virt_to_page(addr) pfn_to_page(virt_to_pfn(addr)) | |
| 83 | +#define page_to_virt(page) pfn_to_virt(page_to_pfn(page)) | |
| 84 | 84 | |
| 85 | 85 | #ifndef page_to_phys |
| 86 | 86 | #define page_to_phys(page) ((dma_addr_t)page_to_pfn(page) << PAGE_SHIFT) |
| @@ -122,12 +122,12 @@ struct drm_device; · 121 unmodified lines | ||
| 122 | 122 | * using the DRM_DEBUG_KMS and DRM_DEBUG. |
| 123 | 123 | */ |
| 124 | 124 | |
| 125 | −extern __attribute__((format (printf, 4, 5))) | |
| 125 | +extern __printf(4, 5) | |
| 126 | 126 | void drm_ut_debug_printk(unsigned int request_level, |
| 127 | − const char *prefix, | |
| 128 | − const char *function_name, | |
| 129 | − const char *format, ...); | |
| 130 | −extern __attribute__((format (printf, 2, 3))) | |
| 127 | + const char *prefix, | |
| 128 | + const char *function_name, | |
| 129 | + const char *format, ...); | |
| 130 | +extern __printf(2, 3) | |
| 131 | 131 | int drm_err(const char *func, const char *format, ...); |
| 132 | 132 | |
| 133 | 133 | /***********************************************************************/ |
| @@ -584,14 +584,13 @@ extern int audit_signals; · 583 unmodified lines | ||
| 584 | 584 | #ifdef CONFIG_AUDIT |
| 585 | 585 | /* These are defined in audit.c */ |
| 586 | 586 | /* Public API */ |
| 587 | −extern void audit_log(struct audit_context *ctx, gfp_t gfp_mask, | |
| 588 | − int type, const char *fmt, ...) | |
| 589 | − __attribute__((format(printf,4,5))); | |
| 587 | +extern __printf(4, 5) | |
| 588 | +void audit_log(struct audit_context *ctx, gfp_t gfp_mask, int type, | |
| 589 | + const char *fmt, ...); | |
| 590 | 590 | |
| 591 | 591 | extern struct audit_buffer *audit_log_start(struct audit_context *ctx, gfp_t gfp_mask, int type); |
| 592 | −extern void audit_log_format(struct audit_buffer *ab, | |
| 593 | − const char *fmt, ...) | |
| 594 | − __attribute__((format(printf,2,3))); | |
| 592 | +extern __printf(2, 3) | |
| 593 | +void audit_log_format(struct audit_buffer *ab, const char *fmt, ...); | |
| 595 | 594 | extern void audit_log_end(struct audit_buffer *ab); |
| 596 | 595 | extern int audit_string_contains_control(const char *string, |
| 597 | 596 | size_t len); |
| @@ -170,7 +170,7 @@ extern void blk_trace_shutdown(struct request_queue *); · 169 unmodified lines | ||
| 170 | 170 | extern int do_blk_trace_setup(struct request_queue *q, char *name, |
| 171 | 171 | dev_t dev, struct block_device *bdev, |
| 172 | 172 | struct blk_user_trace_setup *buts); |
| 173 | −extern __attribute__((format(printf, 2, 3))) | |
| 173 | +extern __printf(2, 3) | |
| 174 | 174 | void __trace_note_message(struct blk_trace *, const char *fmt, ...); |
| 175 | 175 | |
| 176 | 176 | /** |
| @@ -24,8 +24,6 @@ extern unsigned long try_to_compact_pages(struct zonelist *zonelist, · 23 unmodified lines | ||
| 24 | 24 | int order, gfp_t gfp_mask, nodemask_t *mask, |
| 25 | 25 | bool sync); |
| 26 | 26 | extern unsigned long compaction_suitable(struct zone *zone, int order); |
| 27 | −extern unsigned long compact_zone_order(struct zone *zone, int order, | |
| 28 | − gfp_t gfp_mask, bool sync); | |
| 29 | 27 | |
| 30 | 28 | /* Do not skip compaction more than 64 times */ |
| 31 | 29 | #define COMPACT_MAX_DEFER_SHIFT 6 |
| @@ -69,12 +67,6 @@ static inline unsigned long compaction_suitable(struct zone *zone, int order) · 37 unmodified lines | ||
| 69 | 67 | return COMPACT_SKIPPED; |
| 70 | 68 | } |
| 71 | 69 | |
| 72 | −static inline unsigned long compact_zone_order(struct zone *zone, int order, | |
| 73 | − gfp_t gfp_mask, bool sync) | |
| 74 | −{ | |
| 75 | − return COMPACT_CONTINUE; | |
| 76 | −} | |
| 77 | − | |
| 78 | 70 | static inline void defer_compaction(struct zone *zone) |
| 79 | 71 | { |
| 80 | 72 | } |
| @@ -547,7 +547,8 @@ extern ssize_t compat_rw_copy_check_uvector(int type, · 546 unmodified lines | ||
| 547 | 547 | const struct compat_iovec __user *uvector, |
| 548 | 548 | unsigned long nr_segs, |
| 549 | 549 | unsigned long fast_segs, struct iovec *fast_pointer, |
| 550 | − struct iovec **ret_pointer); | |
| 550 | + struct iovec **ret_pointer, | |
| 551 | + int check_access); | |
| 551 | 552 | |
| 552 | 553 | extern void __user *compat_alloc_user_space(unsigned long len); |
| 553 | 554 | |
| @@ -622,8 +622,8 @@ static inline const char *dev_name(const struct device *dev) · 621 unmodified lines | ||
| 622 | 622 | return kobject_name(&dev->kobj); |
| 623 | 623 | } |
| 624 | 624 | |
| 625 | −extern int dev_set_name(struct device *dev, const char *name, ...) | |
| 626 | − __attribute__((format(printf, 2, 3))); | |
| 625 | +extern __printf(2, 3) | |
| 626 | +int dev_set_name(struct device *dev, const char *name, ...); | |
| 627 | 627 | |
| 628 | 628 | #ifdef CONFIG_NUMA |
| 629 | 629 | static inline int dev_to_node(struct device *dev) |
| @@ -753,10 +753,10 @@ extern struct device *device_create_vargs(struct class *cls, · 123 unmodified lines | ||
| 753 | 753 | void *drvdata, |
| 754 | 754 | const char *fmt, |
| 755 | 755 | va_list vargs); |
| 756 | −extern struct device *device_create(struct class *cls, struct device *parent, | |
| 757 | − dev_t devt, void *drvdata, | |
| 758 | − const char *fmt, ...) | |
| 759 | − __attribute__((format(printf, 5, 6))); | |
| 756 | +extern __printf(5, 6) | |
| 757 | +struct device *device_create(struct class *cls, struct device *parent, | |
| 758 | + dev_t devt, void *drvdata, | |
| 759 | + const char *fmt, ...); | |
| 760 | 760 | extern void device_destroy(struct class *cls, dev_t devt); |
| 761 | 761 | |
| 762 | 762 | /* |
| @@ -800,64 +800,56 @@ extern const char *dev_driver_string(const struct device *dev); · 37 unmodified lines | ||
| 800 | 800 | |
| 801 | 801 | extern int __dev_printk(const char *level, const struct device *dev, |
| 802 | 802 | struct va_format *vaf); |
| 803 | −extern int dev_printk(const char *level, const struct device *dev, | |
| 804 | − const char *fmt, ...) | |
| 805 | − __attribute__ ((format (printf, 3, 4))); | |
| 806 | −extern int dev_emerg(const struct device *dev, const char *fmt, ...) | |
| 807 | − __attribute__ ((format (printf, 2, 3))); | |
| 808 | −extern int dev_alert(const struct device *dev, const char *fmt, ...) | |
| 809 | − __attribute__ ((format (printf, 2, 3))); | |
| 810 | −extern int dev_crit(const struct device *dev, const char *fmt, ...) | |
| 811 | − __attribute__ ((format (printf, 2, 3))); | |
| 812 | −extern int dev_err(const struct device *dev, const char *fmt, ...) | |
| 813 | − __attribute__ ((format (printf, 2, 3))); | |
| 814 | −extern int dev_warn(const struct device *dev, const char *fmt, ...) | |
| 815 | − __attribute__ ((format (printf, 2, 3))); | |
| 816 | −extern int dev_notice(const struct device *dev, const char *fmt, ...) | |
| 817 | − __attribute__ ((format (printf, 2, 3))); | |
| 818 | −extern int _dev_info(const struct device *dev, const char *fmt, ...) | |
| 819 | − __attribute__ ((format (printf, 2, 3))); | |
| 803 | +extern __printf(3, 4) | |
| 804 | +int dev_printk(const char *level, const struct device *dev, | |
| 805 | + const char *fmt, ...) | |
| 806 | + ; | |
| 807 | +extern __printf(2, 3) | |
| 808 | +int dev_emerg(const struct device *dev, const char *fmt, ...); | |
| 809 | +extern __printf(2, 3) | |
| 810 | +int dev_alert(const struct device *dev, const char *fmt, ...); | |
| 811 | +extern __printf(2, 3) | |
| 812 | +int dev_crit(const struct device *dev, const char *fmt, ...); | |
| 813 | +extern __printf(2, 3) | |
| 814 | +int dev_err(const struct device *dev, const char *fmt, ...); | |
| 815 | +extern __printf(2, 3) | |
| 816 | +int dev_warn(const struct device *dev, const char *fmt, ...); | |
| 817 | +extern __printf(2, 3) | |
| 818 | +int dev_notice(const struct device *dev, const char *fmt, ...); | |
| 819 | +extern __printf(2, 3) | |
| 820 | +int _dev_info(const struct device *dev, const char *fmt, ...); | |
| 820 | 821 | |
| 821 | 822 | #else |
| 822 | 823 | |
| 823 | 824 | static inline int __dev_printk(const char *level, const struct device *dev, |
| 824 | 825 | struct va_format *vaf) |
| 825 | − { return 0; } | |
| 826 | −static inline int dev_printk(const char *level, const struct device *dev, | |
| 827 | − const char *fmt, ...) | |
| 828 | − __attribute__ ((format (printf, 3, 4))); | |
| 829 | −static inline int dev_printk(const char *level, const struct device *dev, | |
| 830 | − const char *fmt, ...) | |
| 831 | − { return 0; } | |
| 832 | − | |
| 833 | −static inline int dev_emerg(const struct device *dev, const char *fmt, ...) | |
| 834 | − __attribute__ ((format (printf, 2, 3))); | |
| 835 | −static inline int dev_emerg(const struct device *dev, const char *fmt, ...) | |
| 836 | − { return 0; } | |
| 837 | −static inline int dev_crit(const struct device *dev, const char *fmt, ...) | |
| 838 | − __attribute__ ((format (printf, 2, 3))); | |
| 839 | −static inline int dev_crit(const struct device *dev, const char *fmt, ...) | |
| 840 | − { return 0; } | |
| 841 | −static inline int dev_alert(const struct device *dev, const char *fmt, ...) | |
| 842 | − __attribute__ ((format (printf, 2, 3))); | |
| 843 | −static inline int dev_alert(const struct device *dev, const char *fmt, ...) | |
| 844 | − { return 0; } | |
| 845 | −static inline int dev_err(const struct device *dev, const char *fmt, ...) | |
| 846 | − __attribute__ ((format (printf, 2, 3))); | |
| 847 | −static inline int dev_err(const struct device *dev, const char *fmt, ...) | |
| 848 | − { return 0; } | |
| 849 | −static inline int dev_warn(const struct device *dev, const char *fmt, ...) | |
| 850 | − __attribute__ ((format (printf, 2, 3))); | |
| 851 | −static inline int dev_warn(const struct device *dev, const char *fmt, ...) | |
| 852 | − { return 0; } | |
| 853 | −static inline int dev_notice(const struct device *dev, const char *fmt, ...) | |
| 854 | − __attribute__ ((format (printf, 2, 3))); | |
| 855 | −static inline int dev_notice(const struct device *dev, const char *fmt, ...) | |
| 856 | − { return 0; } | |
| 857 | −static inline int _dev_info(const struct device *dev, const char *fmt, ...) | |
| 858 | − __attribute__ ((format (printf, 2, 3))); | |
| 859 | −static inline int _dev_info(const struct device *dev, const char *fmt, ...) | |
| 860 | − { return 0; } | |
| 826 | +{ return 0; } | |
| 827 | +static inline __printf(3, 4) | |
| 828 | +int dev_printk(const char *level, const struct device *dev, | |
| 829 | + const char *fmt, ...) | |
| 830 | +{ return 0; } | |
| 831 | + | |
| 832 | +static inline __printf(2, 3) | |
| 833 | +int dev_emerg(const struct device *dev, const char *fmt, ...) | |
| 834 | +{ return 0; } | |
| 835 | +static inline __printf(2, 3) | |
| 836 | +int dev_crit(const struct device *dev, const char *fmt, ...) | |
| 837 | +{ return 0; } | |
| 838 | +static inline __printf(2, 3) | |
| 839 | +int dev_alert(const struct device *dev, const char *fmt, ...) | |
| 840 | +{ return 0; } | |
| 841 | +static inline __printf(2, 3) | |
| 842 | +int dev_err(const struct device *dev, const char *fmt, ...) | |
| 843 | +{ return 0; } | |
| 844 | +static inline __printf(2, 3) | |
| 845 | +int dev_warn(const struct device *dev, const char *fmt, ...) | |
| 846 | +{ return 0; } | |
| 847 | +static inline __printf(2, 3) | |
| 848 | +int dev_notice(const struct device *dev, const char *fmt, ...) | |
| 849 | +{ return 0; } | |
| 850 | +static inline __printf(2, 3) | |
| 851 | +int _dev_info(const struct device *dev, const char *fmt, ...) | |
| 852 | +{ return 0; } | |
| 861 | 853 | |
| 862 | 854 | #endif |
| 863 | 855 | |
| @@ -26,6 +26,8 @@ · 25 unmodified lines | ||
| 26 | 26 | #include <linux/msi.h> |
| 27 | 27 | #include <linux/irqreturn.h> |
| 28 | 28 | |
| 29 | +struct acpi_dmar_header; | |
| 30 | + | |
| 29 | 31 | /* DMAR Flags */ |
| 30 | 32 | #define DMAR_INTR_REMAP 0x1 |
| 31 | 33 | #define DMAR_X2APIC_OPT_OUT 0x2 |
| @@ -37,22 +37,21 @@ int ddebug_add_module(struct _ddebug *tab, unsigned int n, · 36 unmodified lines | ||
| 37 | 37 | |
| 38 | 38 | #if defined(CONFIG_DYNAMIC_DEBUG) |
| 39 | 39 | extern int ddebug_remove_module(const char *mod_name); |
| 40 | −extern int __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...) | |
| 41 | − __attribute__ ((format (printf, 2, 3))); | |
| 40 | +extern __printf(2, 3) | |
| 41 | +int __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...); | |
| 42 | 42 | |
| 43 | 43 | struct device; |
| 44 | 44 | |
| 45 | −extern int __dynamic_dev_dbg(struct _ddebug *descriptor, | |
| 46 | − const struct device *dev, | |
| 47 | − const char *fmt, ...) | |
| 48 | − __attribute__ ((format (printf, 3, 4))); | |
| 45 | +extern __printf(3, 4) | |
| 46 | +int __dynamic_dev_dbg(struct _ddebug *descriptor, const struct device *dev, | |
| 47 | + const char *fmt, ...); | |
| 49 | 48 | |
| 50 | 49 | struct net_device; |
| 51 | 50 | |
| 52 | −extern int __dynamic_netdev_dbg(struct _ddebug *descriptor, | |
| 53 | − const struct net_device *dev, | |
| 54 | − const char *fmt, ...) | |
| 55 | − __attribute__ ((format (printf, 3, 4))); | |
| 51 | +extern __printf(3, 4) | |
| 52 | +int __dynamic_netdev_dbg(struct _ddebug *descriptor, | |
| 53 | + const struct net_device *dev, | |
| 54 | + const char *fmt, ...); | |
| 56 | 55 | |
| 57 | 56 | #define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt) \ |
| 58 | 57 | static struct _ddebug __used __aligned(8) \ |
| @@ -937,15 +937,15 @@ extern int ext3_group_extend(struct super_block *sb, · 936 unmodified lines | ||
| 937 | 937 | ext3_fsblk_t n_blocks_count); |
| 938 | 938 | |
| 939 | 939 | /* super.c */ |
| 940 | −extern void ext3_error (struct super_block *, const char *, const char *, ...) | |
| 941 | − __attribute__ ((format (printf, 3, 4))); | |
| 940 | +extern __printf(3, 4) | |
| 941 | +void ext3_error(struct super_block *, const char *, const char *, ...); | |
| 942 | 942 | extern void __ext3_std_error (struct super_block *, const char *, int); |
| 943 | −extern void ext3_abort (struct super_block *, const char *, const char *, ...) | |
| 944 | − __attribute__ ((format (printf, 3, 4))); | |
| 945 | −extern void ext3_warning (struct super_block *, const char *, const char *, ...) | |
| 946 | − __attribute__ ((format (printf, 3, 4))); | |
| 947 | −extern void ext3_msg(struct super_block *, const char *, const char *, ...) | |
| 948 | − __attribute__ ((format (printf, 3, 4))); | |
| 943 | +extern __printf(3, 4) | |
| 944 | +void ext3_abort(struct super_block *, const char *, const char *, ...); | |
| 945 | +extern __printf(3, 4) | |
| 946 | +void ext3_warning(struct super_block *, const char *, const char *, ...); | |
| 947 | +extern __printf(3, 4) | |
| 948 | +void ext3_msg(struct super_block *, const char *, const char *, ...); | |
| 949 | 949 | extern void ext3_update_dynamic_rev (struct super_block *sb); |
| 950 | 950 | |
| 951 | 951 | #define ext3_std_error(sb, errno) \ |
| @@ -1633,9 +1633,10 @@ struct inode_operations { · 1632 unmodified lines | ||
| 1633 | 1633 | struct seq_file; |
| 1634 | 1634 | |
| 1635 | 1635 | ssize_t rw_copy_check_uvector(int type, const struct iovec __user * uvector, |
| 1636 | − unsigned long nr_segs, unsigned long fast_segs, | |
| 1637 | − struct iovec *fast_pointer, | |
| 1638 | − struct iovec **ret_pointer); | |
| 1636 | + unsigned long nr_segs, unsigned long fast_segs, | |
| 1637 | + struct iovec *fast_pointer, | |
| 1638 | + struct iovec **ret_pointer, | |
| 1639 | + int check_access); | |
| 1639 | 1640 | |
| 1640 | 1641 | extern ssize_t vfs_read(struct file *, char __user *, size_t, loff_t *); |
| 1641 | 1642 | extern ssize_t vfs_write(struct file *, const char __user *, size_t, loff_t *); |
| @@ -2634,8 +2635,8 @@ static const struct file_operations __fops = { \ · 992 unmodified lines | ||
| 2634 | 2635 | .llseek = generic_file_llseek, \ |
| 2635 | 2636 | }; |
| 2636 | 2637 | |
| 2637 | −static inline void __attribute__((format(printf, 1, 2))) | |
| 2638 | −__simple_attr_check_format(const char *fmt, ...) | |
| 2638 | +static inline __printf(1, 2) | |
| 2639 | +void __simple_attr_check_format(const char *fmt, ...) | |
| 2639 | 2640 | { |
| 2640 | 2641 | /* don't do anything, just let the compiler check the arguments; */ |
| 2641 | 2642 | } |
| @@ -492,10 +492,10 @@ static inline void fscache_end_io(struct fscache_retrieval *op, · 491 unmodified lines | ||
| 492 | 492 | /* |
| 493 | 493 | * out-of-line cache backend functions |
| 494 | 494 | */ |
| 495 | −extern void fscache_init_cache(struct fscache_cache *cache, | |
| 496 | − const struct fscache_cache_ops *ops, | |
| 497 | − const char *idfmt, | |
| 498 | − ...) __attribute__ ((format (printf, 3, 4))); | |
| 495 | +extern __printf(3, 4) | |
| 496 | +void fscache_init_cache(struct fscache_cache *cache, | |
| 497 | + const struct fscache_cache_ops *ops, | |
| 498 | + const char *idfmt, ...); | |
| 499 | 499 | |
| 500 | 500 | extern int fscache_add_cache(struct fscache_cache *cache, |
| 501 | 501 | struct fscache_object *fsdef, |
| @@ -78,8 +78,8 @@ static inline void gameport_register_port(struct gameport *gameport) · 77 unmodified lines | ||
| 78 | 78 | |
| 79 | 79 | void gameport_unregister_port(struct gameport *gameport); |
| 80 | 80 | |
| 81 | −void gameport_set_phys(struct gameport *gameport, const char *fmt, ...) | |
| 82 | − __attribute__ ((format (printf, 2, 3))); | |
| 81 | +__printf(2, 3) | |
| 82 | +void gameport_set_phys(struct gameport *gameport, const char *fmt, ...); | |
| 83 | 83 | |
| 84 | 84 | #else |
| 85 | 85 | |
| @@ -93,8 +93,8 @@ static inline void gameport_unregister_port(struct gameport *gameport) · 7 unmodified lines | ||
| 93 | 93 | return; |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | −static inline void gameport_set_phys(struct gameport *gameport, | |
| 97 | − const char *fmt, ...) | |
| 96 | +static inline __printf(2, 3) | |
| 97 | +void gameport_set_phys(struct gameport *gameport, const char *fmt, ...) | |
| 98 | 98 | { |
| 99 | 99 | return; |
| 100 | 100 | } |
| @@ -22,6 +22,11 @@ extern int zap_huge_pmd(struct mmu_gather *tlb, · 21 unmodified lines | ||
| 22 | 22 | extern int mincore_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd, |
| 23 | 23 | unsigned long addr, unsigned long end, |
| 24 | 24 | unsigned char *vec); |
| 25 | +extern int move_huge_pmd(struct vm_area_struct *vma, | |
| 26 | + struct vm_area_struct *new_vma, | |
| 27 | + unsigned long old_addr, | |
| 28 | + unsigned long new_addr, unsigned long old_end, | |
| 29 | + pmd_t *old_pmd, pmd_t *new_pmd); | |
| 25 | 30 | extern int change_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd, |
| 26 | 31 | unsigned long addr, pgprot_t newprot); |
| 27 | 32 | |
| @@ -101,9 +101,8 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u · 100 unmodified lines | ||
| 101 | 101 | #endif /*CONFIG_KALLSYMS*/ |
| 102 | 102 | |
| 103 | 103 | /* This macro allows us to keep printk typechecking */ |
| 104 | −static void __check_printsym_format(const char *fmt, ...) | |
| 105 | −__attribute__((format(printf,1,2))); | |
| 106 | −static inline void __check_printsym_format(const char *fmt, ...) | |
| 104 | +static __printf(1, 2) | |
| 105 | +void __check_printsym_format(const char *fmt, ...) | |
| 107 | 106 | { |
| 108 | 107 | } |
| 109 | 108 | |
| @@ -114,12 +114,9 @@ typedef enum { · 113 unmodified lines | ||
| 114 | 114 | } kdb_reason_t; |
| 115 | 115 | |
| 116 | 116 | extern int kdb_trap_printk; |
| 117 | −extern int vkdb_printf(const char *fmt, va_list args) | |
| 118 | − __attribute__ ((format (printf, 1, 0))); | |
| 119 | −extern int kdb_printf(const char *, ...) | |
| 120 | − __attribute__ ((format (printf, 1, 2))); | |
| 121 | −typedef int (*kdb_printf_t)(const char *, ...) | |
| 122 | − __attribute__ ((format (printf, 1, 2))); | |
| 117 | +extern __printf(1, 0) int vkdb_printf(const char *fmt, va_list args); | |
| 118 | +extern __printf(1, 2) int kdb_printf(const char *, ...); | |
| 119 | +typedef __printf(1, 2) int (*kdb_printf_t)(const char *, ...); | |
| 123 | 120 | |
| 124 | 121 | extern void kdb_init(int level); |
| 125 | 122 | |
| @@ -287,6 +287,8 @@ static inline int __must_check kstrtos32_from_user(const char __user *s, size_t · 286 unmodified lines | ||
| 287 | 287 | return kstrtoint_from_user(s, count, base, res); |
| 288 | 288 | } |
| 289 | 289 | |
| 290 | +/* Obsolete, do not use. Use kstrto<foo> instead */ | |
| 291 | + | |
| 290 | 292 | extern unsigned long simple_strtoul(const char *,char **,unsigned int); |
| 291 | 293 | extern long simple_strtol(const char *,char **,unsigned int); |
| 292 | 294 | extern unsigned long long simple_strtoull(const char *,char **,unsigned int); |
| @@ -296,20 +298,20 @@ extern long long simple_strtoll(const char *,char **,unsigned int); · 3 unmodified lines | ||
| 296 | 298 | #define strict_strtoull kstrtoull |
| 297 | 299 | #define strict_strtoll kstrtoll |
| 298 | 300 | |
| 299 | −extern int sprintf(char * buf, const char * fmt, ...) | |
| 300 | − __attribute__ ((format (printf, 2, 3))); | |
| 301 | −extern int vsprintf(char *buf, const char *, va_list) | |
| 302 | − __attribute__ ((format (printf, 2, 0))); | |
| 303 | −extern int snprintf(char * buf, size_t size, const char * fmt, ...) | |
| 304 | − __attribute__ ((format (printf, 3, 4))); | |
| 305 | −extern int vsnprintf(char *buf, size_t size, const char *fmt, va_list args) | |
| 306 | − __attribute__ ((format (printf, 3, 0))); | |
| 307 | −extern int scnprintf(char * buf, size_t size, const char * fmt, ...) | |
| 308 | − __attribute__ ((format (printf, 3, 4))); | |
| 309 | −extern int vscnprintf(char *buf, size_t size, const char *fmt, va_list args) | |
| 310 | − __attribute__ ((format (printf, 3, 0))); | |
| 311 | −extern char *kasprintf(gfp_t gfp, const char *fmt, ...) | |
| 312 | − __attribute__ ((format (printf, 2, 3))); | |
| 301 | +/* lib/printf utilities */ | |
| 302 | + | |
| 303 | +extern __printf(2, 3) int sprintf(char *buf, const char * fmt, ...); | |
| 304 | +extern __printf(2, 0) int vsprintf(char *buf, const char *, va_list); | |
| 305 | +extern __printf(3, 4) | |
| 306 | +int snprintf(char *buf, size_t size, const char *fmt, ...); | |
| 307 | +extern __printf(3, 0) | |
| 308 | +int vsnprintf(char *buf, size_t size, const char *fmt, va_list args); | |
| 309 | +extern __printf(3, 4) | |
| 310 | +int scnprintf(char *buf, size_t size, const char *fmt, ...); | |
| 311 | +extern __printf(3, 0) | |
| 312 | +int vscnprintf(char *buf, size_t size, const char *fmt, va_list args); | |
| 313 | +extern __printf(2, 3) | |
| 314 | +char *kasprintf(gfp_t gfp, const char *fmt, ...); | |
| 313 | 315 | extern char *kvasprintf(gfp_t gfp, const char *fmt, va_list args); |
| 314 | 316 | |
| 315 | 317 | extern int sscanf(const char *, const char *, ...) |
| @@ -374,13 +376,18 @@ extern const char hex_asc[]; · 58 unmodified lines | ||
| 374 | 376 | #define hex_asc_lo(x) hex_asc[((x) & 0x0f)] |
| 375 | 377 | #define hex_asc_hi(x) hex_asc[((x) & 0xf0) >> 4] |
| 376 | 378 | |
| 377 | −static inline char *pack_hex_byte(char *buf, u8 byte) | |
| 379 | +static inline char *hex_byte_pack(char *buf, u8 byte) | |
| 378 | 380 | { |
| 379 | 381 | *buf++ = hex_asc_hi(byte); |
| 380 | 382 | *buf++ = hex_asc_lo(byte); |
| 381 | 383 | return buf; |
| 382 | 384 | } |
| 383 | 385 | |
| 386 | +static inline char * __deprecated pack_hex_byte(char *buf, u8 byte) | |
| 387 | +{ | |
| 388 | + return hex_byte_pack(buf, byte); | |
| 389 | +} | |
| 390 | + | |
| 384 | 391 | extern int hex_to_bin(char ch); |
| 385 | 392 | extern int __must_check hex2bin(u8 *dst, const char *src, size_t count); |
| 386 | 393 | |
| @@ -427,8 +434,8 @@ extern void tracing_start(void); · 40 unmodified lines | ||
| 427 | 434 | extern void tracing_stop(void); |
| 428 | 435 | extern void ftrace_off_permanent(void); |
| 429 | 436 | |
| 430 | −static inline void __attribute__ ((format (printf, 1, 2))) | |
| 431 | −____trace_printk_check_format(const char *fmt, ...) | |
| 437 | +static inline __printf(1, 2) | |
| 438 | +void ____trace_printk_check_format(const char *fmt, ...) | |
| 432 | 439 | { |
| 433 | 440 | } |
| 434 | 441 | #define __trace_printk_check_format(fmt, args...) \ |
| @@ -467,13 +474,11 @@ do { \ · 32 unmodified lines | ||
| 467 | 474 | __trace_printk(_THIS_IP_, fmt, ##args); \ |
| 468 | 475 | } while (0) |
| 469 | 476 | |
| 470 | −extern int | |
| 471 | −__trace_bprintk(unsigned long ip, const char *fmt, ...) | |
| 472 | − __attribute__ ((format (printf, 2, 3))); | |
| 477 | +extern __printf(2, 3) | |
| 478 | +int __trace_bprintk(unsigned long ip, const char *fmt, ...); | |
| 473 | 479 | |
| 474 | −extern int | |
| 475 | −__trace_printk(unsigned long ip, const char *fmt, ...) | |
| 476 | − __attribute__ ((format (printf, 2, 3))); | |
| 480 | +extern __printf(2, 3) | |
| 481 | +int __trace_printk(unsigned long ip, const char *fmt, ...); | |
| 477 | 482 | |
| 478 | 483 | extern void trace_dump_stack(void); |
| 479 | 484 | |
| @@ -502,8 +507,8 @@ __ftrace_vprintk(unsigned long ip, const char *fmt, va_list ap); · 22 unmodified lines | ||
| 502 | 507 | |
| 503 | 508 | extern void ftrace_dump(enum ftrace_dump_mode oops_dump_mode); |
| 504 | 509 | #else |
| 505 | −static inline int | |
| 506 | −trace_printk(const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); | |
| 510 | +static inline __printf(1, 2) | |
| 511 | +int trace_printk(const char *fmt, ...); | |
| 507 | 512 | |
| 508 | 513 | static inline void tracing_start(void) { } |
| 509 | 514 | static inline void tracing_stop(void) { } |
| @@ -140,8 +140,8 @@ void crash_save_vmcoreinfo(void); · 139 unmodified lines | ||
| 140 | 140 | void crash_map_reserved_pages(void); |
| 141 | 141 | void crash_unmap_reserved_pages(void); |
| 142 | 142 | void arch_crash_save_vmcoreinfo(void); |
| 143 | −void vmcoreinfo_append_str(const char *fmt, ...) | |
| 144 | − __attribute__ ((format (printf, 1, 2))); | |
| 143 | +__printf(1, 2) | |
| 144 | +void vmcoreinfo_append_str(const char *fmt, ...); | |
| 145 | 145 | unsigned long paddr_vmcoreinfo_note(void); |
| 146 | 146 | |
| 147 | 147 | #define VMCOREINFO_OSRELEASE(value) \ |
| @@ -32,8 +32,8 @@ · 31 unmodified lines | ||
| 32 | 32 | extern char modprobe_path[]; /* for sysctl */ |
| 33 | 33 | /* modprobe exit status on success, -ve on error. Return value |
| 34 | 34 | * usually useless though. */ |
| 35 | −extern int __request_module(bool wait, const char *name, ...) \ | |
| 36 | − __attribute__((format(printf, 2, 3))); | |
| 35 | +extern __printf(2, 3) | |
| 36 | +int __request_module(bool wait, const char *name, ...); | |
| 37 | 37 | #define request_module(mod...) __request_module(true, mod) |
| 38 | 38 | #define request_module_nowait(mod...) __request_module(false, mod) |
| 39 | 39 | #define try_then_request_module(x, mod...) \ |
| @@ -72,8 +72,8 @@ struct kobject { · 71 unmodified lines | ||
| 72 | 72 | unsigned int uevent_suppress:1; |
| 73 | 73 | }; |
| 74 | 74 | |
| 75 | −extern int kobject_set_name(struct kobject *kobj, const char *name, ...) | |
| 76 | − __attribute__((format(printf, 2, 3))); | |
| 75 | +extern __printf(2, 3) | |
| 76 | +int kobject_set_name(struct kobject *kobj, const char *name, ...); | |
| 77 | 77 | extern int kobject_set_name_vargs(struct kobject *kobj, const char *fmt, |
| 78 | 78 | va_list vargs); |
| 79 | 79 | |
| @@ -83,15 +83,13 @@ static inline const char *kobject_name(const struct kobject *kobj) · 3 unmodified lines | ||
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | extern void kobject_init(struct kobject *kobj, struct kobj_type *ktype); |
| 86 | −extern int __must_check kobject_add(struct kobject *kobj, | |
| 87 | − struct kobject *parent, | |
| 88 | − const char *fmt, ...) | |
| 89 | − __attribute__((format(printf, 3, 4))); | |
| 90 | −extern int __must_check kobject_init_and_add(struct kobject *kobj, | |
| 91 | − struct kobj_type *ktype, | |
| 92 | − struct kobject *parent, | |
| 93 | − const char *fmt, ...) | |
| 94 | − __attribute__((format(printf, 4, 5))); | |
| 86 | +extern __printf(3, 4) __must_check | |
| 87 | +int kobject_add(struct kobject *kobj, struct kobject *parent, | |
| 88 | + const char *fmt, ...); | |
| 89 | +extern __printf(4, 5) __must_check | |
| 90 | +int kobject_init_and_add(struct kobject *kobj, | |
| 91 | + struct kobj_type *ktype, struct kobject *parent, | |
| 92 | + const char *fmt, ...); | |
| 95 | 93 | |
| 96 | 94 | extern void kobject_del(struct kobject *kobj); |
| 97 | 95 | |
| @@ -212,8 +210,8 @@ int kobject_uevent(struct kobject *kobj, enum kobject_action action); · 114 unmodified lines | ||
| 212 | 210 | int kobject_uevent_env(struct kobject *kobj, enum kobject_action action, |
| 213 | 211 | char *envp[]); |
| 214 | 212 | |
| 215 | −int add_uevent_var(struct kobj_uevent_env *env, const char *format, ...) | |
| 216 | − __attribute__((format (printf, 2, 3))); | |
| 213 | +__printf(2, 3) | |
| 214 | +int add_uevent_var(struct kobj_uevent_env *env, const char *format, ...); | |
| 217 | 215 | |
| 218 | 216 | int kobject_action_type(const char *buf, size_t count, |
| 219 | 217 | enum kobject_action *type); |
| @@ -226,7 +224,7 @@ static inline int kobject_uevent_env(struct kobject *kobj, · 6 unmodified lines | ||
| 226 | 224 | char *envp[]) |
| 227 | 225 | { return 0; } |
| 228 | 226 | |
| 229 | −static inline __attribute__((format(printf, 2, 3))) | |
| 227 | +static inline __printf(2, 3) | |
| 230 | 228 | int add_uevent_var(struct kobj_uevent_env *env, const char *format, ...) |
| 231 | 229 | { return 0; } |
| 232 | 230 | |
| @@ -4,11 +4,11 @@ · 3 unmodified lines | ||
| 4 | 4 | #include <linux/err.h> |
| 5 | 5 | #include <linux/sched.h> |
| 6 | 6 | |
| 7 | +__printf(4, 5) | |
| 7 | 8 | struct task_struct *kthread_create_on_node(int (*threadfn)(void *data), |
| 8 | 9 | void *data, |
| 9 | 10 | int node, |
| 10 | − const char namefmt[], ...) | |
| 11 | − __attribute__((format(printf, 4, 5))); | |
| 11 | + const char namefmt[], ...); | |
| 12 | 12 | |
| 13 | 13 | #define kthread_create(threadfn, data, namefmt, arg...) \ |
| 14 | 14 | kthread_create_on_node(threadfn, data, -1, namefmt, ##arg) |
| @@ -1256,13 +1256,13 @@ static inline int sata_srst_pmp(struct ata_link *link) · 1255 unmodified lines | ||
| 1256 | 1256 | /* |
| 1257 | 1257 | * printk helpers |
| 1258 | 1258 | */ |
| 1259 | −__attribute__((format (printf, 3, 4))) | |
| 1259 | +__printf(3, 4) | |
| 1260 | 1260 | int ata_port_printk(const struct ata_port *ap, const char *level, |
| 1261 | 1261 | const char *fmt, ...); |
| 1262 | −__attribute__((format (printf, 3, 4))) | |
| 1262 | +__printf(3, 4) | |
| 1263 | 1263 | int ata_link_printk(const struct ata_link *link, const char *level, |
| 1264 | 1264 | const char *fmt, ...); |
| 1265 | −__attribute__((format (printf, 3, 4))) | |
| 1265 | +__printf(3, 4) | |
| 1266 | 1266 | int ata_dev_printk(const struct ata_device *dev, const char *level, |
| 1267 | 1267 | const char *fmt, ...); |
| 1268 | 1268 | |
| @@ -1304,10 +1304,10 @@ void ata_print_version(const struct device *dev, const char *version); · 35 unmodified lines | ||
| 1304 | 1304 | /* |
| 1305 | 1305 | * ata_eh_info helpers |
| 1306 | 1306 | */ |
| 1307 | −extern void __ata_ehi_push_desc(struct ata_eh_info *ehi, const char *fmt, ...) | |
| 1308 | − __attribute__ ((format (printf, 2, 3))); | |
| 1309 | −extern void ata_ehi_push_desc(struct ata_eh_info *ehi, const char *fmt, ...) | |
| 1310 | − __attribute__ ((format (printf, 2, 3))); | |
| 1307 | +extern __printf(2, 3) | |
| 1308 | +void __ata_ehi_push_desc(struct ata_eh_info *ehi, const char *fmt, ...); | |
| 1309 | +extern __printf(2, 3) | |
| 1310 | +void ata_ehi_push_desc(struct ata_eh_info *ehi, const char *fmt, ...); | |
| 1311 | 1311 | extern void ata_ehi_clear_desc(struct ata_eh_info *ehi); |
| 1312 | 1312 | |
| 1313 | 1313 | static inline void ata_ehi_hotplugged(struct ata_eh_info *ehi) |
| @@ -1321,8 +1321,8 @@ static inline void ata_ehi_hotplugged(struct ata_eh_info *ehi) · 7 unmodified lines | ||
| 1321 | 1321 | /* |
| 1322 | 1322 | * port description helpers |
| 1323 | 1323 | */ |
| 1324 | −extern void ata_port_desc(struct ata_port *ap, const char *fmt, ...) | |
| 1325 | − __attribute__ ((format (printf, 2, 3))); | |
| 1324 | +extern __printf(2, 3) | |
| 1325 | +void ata_port_desc(struct ata_port *ap, const char *fmt, ...); | |
| 1326 | 1326 | #ifdef CONFIG_PCI |
| 1327 | 1327 | extern void ata_port_pbar_desc(struct ata_port *ap, int bar, ssize_t offset, |
| 1328 | 1328 | const char *name); |
| @@ -113,7 +113,6 @@ struct lis3lv02d_platform_data { · 112 unmodified lines | ||
| 113 | 113 | s8 axis_x; |
| 114 | 114 | s8 axis_y; |
| 115 | 115 | s8 axis_z; |
| 116 | −#define LIS3_USE_REGULATOR_CTRL 0x01 | |
| 117 | 116 | #define LIS3_USE_BLOCK_READ 0x02 |
| 118 | 117 | u16 driver_features; |
| 119 | 118 | int default_rate; |
| @@ -148,7 +148,7 @@ static inline struct llist_node *llist_next(struct llist_node *node) · 147 unmodified lines | ||
| 148 | 148 | * @new: new entry to be added |
| 149 | 149 | * @head: the head for your lock-less list |
| 150 | 150 | * |
| 151 | − * Return whether list is empty before adding. | |
| 151 | + * Returns true if the list was empty prior to adding this entry. | |
| 152 | 152 | */ |
| 153 | 153 | static inline bool llist_add(struct llist_node *new, struct llist_head *head) |
| 154 | 154 | { |
| @@ -80,6 +80,7 @@ extern phys_addr_t __memblock_alloc_base(phys_addr_t size, · 79 unmodified lines | ||
| 80 | 80 | phys_addr_t align, |
| 81 | 81 | phys_addr_t max_addr); |
| 82 | 82 | extern phys_addr_t memblock_phys_mem_size(void); |
| 83 | +extern phys_addr_t memblock_start_of_DRAM(void); | |
| 83 | 84 | extern phys_addr_t memblock_end_of_DRAM(void); |
| 84 | 85 | extern void memblock_enforce_memory_limit(phys_addr_t memory_limit); |
| 85 | 86 | extern int memblock_is_memory(phys_addr_t addr); |
| @@ -35,7 +35,8 @@ enum mem_cgroup_page_stat_item { · 34 unmodified lines | ||
| 35 | 35 | extern unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan, |
| 36 | 36 | struct list_head *dst, |
| 37 | 37 | unsigned long *scanned, int order, |
| 38 | − int mode, struct zone *z, | |
| 38 | + isolate_mode_t mode, | |
| 39 | + struct zone *z, | |
| 39 | 40 | struct mem_cgroup *mem_cont, |
| 40 | 41 | int active, int file); |
| 41 | 42 | |
| @@ -1334,7 +1334,8 @@ extern void si_meminfo(struct sysinfo * val); · 1333 unmodified lines | ||
| 1334 | 1334 | extern void si_meminfo_node(struct sysinfo *val, int nid); |
| 1335 | 1335 | extern int after_bootmem; |
| 1336 | 1336 | |
| 1337 | −extern void warn_alloc_failed(gfp_t gfp_mask, int order, const char *fmt, ...); | |
| 1337 | +extern __printf(3, 4) | |
| 1338 | +void warn_alloc_failed(gfp_t gfp_mask, int order, const char *fmt, ...); | |
| 1338 | 1339 | |
| 1339 | 1340 | extern void setup_per_cpu_pageset(void); |
| 1340 | 1341 | |
| @@ -304,8 +304,15 @@ struct mm_struct { · 303 unmodified lines | ||
| 304 | 304 | unsigned long hiwater_rss; /* High-watermark of RSS usage */ |
| 305 | 305 | unsigned long hiwater_vm; /* High-water virtual memory usage */ |
| 306 | 306 | |
| 307 | − unsigned long total_vm, locked_vm, shared_vm, exec_vm; | |
| 308 | − unsigned long stack_vm, reserved_vm, def_flags, nr_ptes; | |
| 307 | + unsigned long total_vm; /* Total pages mapped */ | |
| 308 | + unsigned long locked_vm; /* Pages that have PG_mlocked set */ | |
| 309 | + unsigned long pinned_vm; /* Refcount permanently increased */ | |
| 310 | + unsigned long shared_vm; /* Shared pages (files) */ | |
| 311 | + unsigned long exec_vm; /* VM_EXEC & ~VM_WRITE */ | |
| 312 | + unsigned long stack_vm; /* VM_GROWSUP/DOWN */ | |
| 313 | + unsigned long reserved_vm; /* VM_RESERVED|VM_IO pages */ | |
| 314 | + unsigned long def_flags; | |
| 315 | + unsigned long nr_ptes; /* Page table pages */ | |
| 309 | 316 | unsigned long start_code, end_code, start_data, end_data; |
| 310 | 317 | unsigned long start_brk, brk, start_stack; |
| 311 | 318 | unsigned long arg_start, arg_end, env_start, env_end; |
| @@ -336,9 +343,6 @@ struct mm_struct { · 24 unmodified lines | ||
| 336 | 343 | unsigned int token_priority; |
| 337 | 344 | unsigned int last_interval; |
| 338 | 345 | |
| 339 | − /* How many tasks sharing this mm are OOM_DISABLE */ | |
| 340 | − atomic_t oom_disable_count; | |
| 341 | − | |
| 342 | 346 | unsigned long flags; /* Must use atomic bitops to access the bits */ |
| 343 | 347 | |
| 344 | 348 | struct core_state *core_state; /* coredumping support */ |
| @@ -49,8 +49,7 @@ extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size, · 48 unmodified lines | ||
| 49 | 49 | extern void mmiotrace_iounmap(volatile void __iomem *addr); |
| 50 | 50 | |
| 51 | 51 | /* For anyone to insert markers. Remember trailing newline. */ |
| 52 | −extern int mmiotrace_printk(const char *fmt, ...) | |
| 53 | − __attribute__ ((format (printf, 1, 2))); | |
| 52 | +extern __printf(1, 2) int mmiotrace_printk(const char *fmt, ...); | |
| 54 | 53 | #else /* !CONFIG_MMIOTRACE: */ |
| 55 | 54 | static inline int is_kmmio_active(void) |
| 56 | 55 | { |
| @@ -71,10 +70,7 @@ static inline void mmiotrace_iounmap(volatile void __iomem *addr) · 14 unmodified lines | ||
| 71 | 70 | { |
| 72 | 71 | } |
| 73 | 72 | |
| 74 | −static inline int mmiotrace_printk(const char *fmt, ...) | |
| 75 | − __attribute__ ((format (printf, 1, 0))); | |
| 76 | − | |
| 77 | −static inline int mmiotrace_printk(const char *fmt, ...) | |
| 73 | +static inline __printf(1, 2) int mmiotrace_printk(const char *fmt, ...) | |
| 78 | 74 | { |
| 79 | 75 | return 0; |
| 80 | 76 | } |
| @@ -100,6 +100,7 @@ enum zone_stat_item { · 99 unmodified lines | ||
| 100 | 100 | NR_UNSTABLE_NFS, /* NFS unstable pages */ |
| 101 | 101 | NR_BOUNCE, |
| 102 | 102 | NR_VMSCAN_WRITE, |
| 103 | + NR_VMSCAN_IMMEDIATE, /* Prioritise for reclaim when writeback ends */ | |
| 103 | 104 | NR_WRITEBACK_TEMP, /* Writeback using temporary buffers */ |
| 104 | 105 | NR_ISOLATED_ANON, /* Temporary isolated pages from anon lru */ |
| 105 | 106 | NR_ISOLATED_FILE, /* Temporary isolated pages from file lru */ |
| @@ -164,6 +165,18 @@ static inline int is_unevictable_lru(enum lru_list l) · 58 unmodified lines | ||
| 164 | 165 | #define LRU_ALL_EVICTABLE (LRU_ALL_FILE | LRU_ALL_ANON) |
| 165 | 166 | #define LRU_ALL ((1 << NR_LRU_LISTS) - 1) |
| 166 | 167 | |
| 168 | +/* Isolate inactive pages */ | |
| 169 | +#define ISOLATE_INACTIVE ((__force isolate_mode_t)0x1) | |
| 170 | +/* Isolate active pages */ | |
| 171 | +#define ISOLATE_ACTIVE ((__force isolate_mode_t)0x2) | |
| 172 | +/* Isolate clean file */ | |
| 173 | +#define ISOLATE_CLEAN ((__force isolate_mode_t)0x4) | |
| 174 | +/* Isolate unmapped file */ | |
| 175 | +#define ISOLATE_UNMAPPED ((__force isolate_mode_t)0x8) | |
| 176 | + | |
| 177 | +/* LRU Isolation modes. */ | |
| 178 | +typedef unsigned __bitwise__ isolate_mode_t; | |
| 179 | + | |
| 167 | 180 | enum zone_watermarks { |
| 168 | 181 | WMARK_MIN, |
| 169 | 182 | WMARK_LOW, |
| @@ -2622,23 +2622,23 @@ static inline const char *netdev_name(const struct net_device *dev) · 2621 unmodified lines | ||
| 2622 | 2622 | extern int __netdev_printk(const char *level, const struct net_device *dev, |
| 2623 | 2623 | struct va_format *vaf); |
| 2624 | 2624 | |
| 2625 | −extern int netdev_printk(const char *level, const struct net_device *dev, | |
| 2626 | − const char *format, ...) | |
| 2627 | − __attribute__ ((format (printf, 3, 4))); | |
| 2628 | −extern int netdev_emerg(const struct net_device *dev, const char *format, ...) | |
| 2629 | − __attribute__ ((format (printf, 2, 3))); | |
| 2630 | −extern int netdev_alert(const struct net_device *dev, const char *format, ...) | |
| 2631 | − __attribute__ ((format (printf, 2, 3))); | |
| 2632 | −extern int netdev_crit(const struct net_device *dev, const char *format, ...) | |
| 2633 | − __attribute__ ((format (printf, 2, 3))); | |
| 2634 | −extern int netdev_err(const struct net_device *dev, const char *format, ...) | |
| 2635 | − __attribute__ ((format (printf, 2, 3))); | |
| 2636 | −extern int netdev_warn(const struct net_device *dev, const char *format, ...) | |
| 2637 | − __attribute__ ((format (printf, 2, 3))); | |
| 2638 | −extern int netdev_notice(const struct net_device *dev, const char *format, ...) | |
| 2639 | − __attribute__ ((format (printf, 2, 3))); | |
| 2640 | −extern int netdev_info(const struct net_device *dev, const char *format, ...) | |
| 2641 | − __attribute__ ((format (printf, 2, 3))); | |
| 2625 | +extern __printf(3, 4) | |
| 2626 | +int netdev_printk(const char *level, const struct net_device *dev, | |
| 2627 | + const char *format, ...); | |
| 2628 | +extern __printf(2, 3) | |
| 2629 | +int netdev_emerg(const struct net_device *dev, const char *format, ...); | |
| 2630 | +extern __printf(2, 3) | |
| 2631 | +int netdev_alert(const struct net_device *dev, const char *format, ...); | |
| 2632 | +extern __printf(2, 3) | |
| 2633 | +int netdev_crit(const struct net_device *dev, const char *format, ...); | |
| 2634 | +extern __printf(2, 3) | |
| 2635 | +int netdev_err(const struct net_device *dev, const char *format, ...); | |
| 2636 | +extern __printf(2, 3) | |
| 2637 | +int netdev_warn(const struct net_device *dev, const char *format, ...); | |
| 2638 | +extern __printf(2, 3) | |
| 2639 | +int netdev_notice(const struct net_device *dev, const char *format, ...); | |
| 2640 | +extern __printf(2, 3) | |
| 2641 | +int netdev_info(const struct net_device *dev, const char *format, ...); | |
| 2642 | 2642 | |
| 2643 | 2643 | #define MODULE_ALIAS_NETDEV(device) \ |
| 2644 | 2644 | MODULE_ALIAS("netdev-" device) |
| @@ -40,6 +40,7 @@ enum oom_constraint { · 39 unmodified lines | ||
| 40 | 40 | CONSTRAINT_MEMCG, |
| 41 | 41 | }; |
| 42 | 42 | |
| 43 | +extern void compare_swap_oom_score_adj(int old_val, int new_val); | |
| 43 | 44 | extern int test_set_oom_score_adj(int new_val); |
| 44 | 45 | |
| 45 | 46 | extern unsigned int oom_badness(struct task_struct *p, struct mem_cgroup *mem, |
| @@ -0,0 +1,14 @@ | ||
| 1 | +#ifndef __LEDS_RENESAS_TPU_H__ | |
| 2 | +#define __LEDS_RENESAS_TPU_H__ | |
| 3 | + | |
| 4 | +struct led_renesas_tpu_config { | |
| 5 | + char *name; | |
| 6 | + unsigned pin_gpio_fn; | |
| 7 | + unsigned pin_gpio; | |
| 8 | + unsigned int channel_offset; | |
| 9 | + unsigned int timer_bit; | |
| 10 | + unsigned int max_brightness; | |
| 11 | + unsigned int refresh_rate; | |
| 12 | +}; | |
| 13 | + | |
| 14 | +#endif /* __LEDS_RENESAS_TPU_H__ */ | |
| @@ -82,22 +82,22 @@ struct va_format { · 81 unmodified lines | ||
| 82 | 82 | * Dummy printk for disabled debugging statements to use whilst maintaining |
| 83 | 83 | * gcc's format and side-effect checking. |
| 84 | 84 | */ |
| 85 | −static inline __attribute__ ((format (printf, 1, 2))) | |
| 85 | +static inline __printf(1, 2) | |
| 86 | 86 | int no_printk(const char *fmt, ...) |
| 87 | 87 | { |
| 88 | 88 | return 0; |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | −extern asmlinkage __attribute__ ((format (printf, 1, 2))) | |
| 91 | +extern asmlinkage __printf(1, 2) | |
| 92 | 92 | void early_printk(const char *fmt, ...); |
| 93 | 93 | |
| 94 | 94 | extern int printk_needs_cpu(int cpu); |
| 95 | 95 | extern void printk_tick(void); |
| 96 | 96 | |
| 97 | 97 | #ifdef CONFIG_PRINTK |
| 98 | −asmlinkage __attribute__ ((format (printf, 1, 0))) | |
| 98 | +asmlinkage __printf(1, 0) | |
| 99 | 99 | int vprintk(const char *fmt, va_list args); |
| 100 | −asmlinkage __attribute__ ((format (printf, 1, 2))) __cold | |
| 100 | +asmlinkage __printf(1, 2) __cold | |
| 101 | 101 | int printk(const char *fmt, ...); |
| 102 | 102 | |
| 103 | 103 | /* |
| @@ -117,12 +117,12 @@ extern int kptr_restrict; · 13 unmodified lines | ||
| 117 | 117 | void log_buf_kexec_setup(void); |
| 118 | 118 | void __init setup_log_buf(int early); |
| 119 | 119 | #else |
| 120 | −static inline __attribute__ ((format (printf, 1, 0))) | |
| 120 | +static inline __printf(1, 0) | |
| 121 | 121 | int vprintk(const char *s, va_list args) |
| 122 | 122 | { |
| 123 | 123 | return 0; |
| 124 | 124 | } |
| 125 | −static inline __attribute__ ((format (printf, 1, 2))) __cold | |
| 125 | +static inline __printf(1, 2) __cold | |
| 126 | 126 | int printk(const char *s, ...) |
| 127 | 127 | { |
| 128 | 128 | return 0; |
| @@ -31,7 +31,7 @@ static inline bool is_quota_modification(struct inode *inode, struct iattr *ia) · 30 unmodified lines | ||
| 31 | 31 | #define quota_error(sb, fmt, args...) \ |
| 32 | 32 | __quota_error((sb), __func__, fmt , ## args) |
| 33 | 33 | |
| 34 | −extern __attribute__((format (printf, 3, 4))) | |
| 34 | +extern __printf(3, 4) | |
| 35 | 35 | void __quota_error(struct super_block *sb, const char *func, |
| 36 | 36 | const char *fmt, ...); |
| 37 | 37 | |
| @@ -84,8 +84,7 @@ int seq_putc(struct seq_file *m, char c); · 83 unmodified lines | ||
| 84 | 84 | int seq_puts(struct seq_file *m, const char *s); |
| 85 | 85 | int seq_write(struct seq_file *seq, const void *data, size_t len); |
| 86 | 86 | |
| 87 | −int seq_printf(struct seq_file *, const char *, ...) | |
| 88 | − __attribute__ ((format (printf,2,3))); | |
| 87 | +__printf(2, 3) int seq_printf(struct seq_file *, const char *, ...); | |
| 89 | 88 | |
| 90 | 89 | int seq_path(struct seq_file *, struct path *, char *); |
| 91 | 90 | int seq_dentry(struct seq_file *, struct dentry *, char *); |
| @@ -20,6 +20,7 @@ struct shrink_control { · 19 unmodified lines | ||
| 20 | 20 | * 'nr_to_scan' entries and attempt to free them up. It should return |
| 21 | 21 | * the number of objects which remain in the cache. If it returns -1, it means |
| 22 | 22 | * it cannot do any scanning at this time (eg. there is a risk of deadlock). |
| 23 | + * The callback must not return -1 if nr_to_scan is zero. | |
| 23 | 24 | * |
| 24 | 25 | * The 'gfpmask' refers to the allocation we are currently trying to |
| 25 | 26 | * fulfil. |
| @@ -24,8 +24,6 @@ · 23 unmodified lines | ||
| 24 | 24 | struct l4f00242t03_pdata { |
| 25 | 25 | unsigned int reset_gpio; |
| 26 | 26 | unsigned int data_enable_gpio; |
| 27 | − const char *io_supply; /* will be set to 1.8 V */ | |
| 28 | − const char *core_supply; /* will be set to 2.8 V */ | |
| 29 | 27 | }; |
| 30 | 28 | |
| 31 | 29 | #endif /* _INCLUDE_LINUX_SPI_L4F00242T03_H_ */ |
| @@ -114,6 +114,7 @@ extern int memcmp(const void *,const void *,__kernel_size_t); · 113 unmodified lines | ||
| 114 | 114 | #ifndef __HAVE_ARCH_MEMCHR |
| 115 | 115 | extern void * memchr(const void *,int,__kernel_size_t); |
| 116 | 116 | #endif |
| 117 | +void *memchr_inv(const void *s, int c, size_t n); | |
| 117 | 118 | |
| 118 | 119 | extern char *kstrdup(const char *s, gfp_t gfp); |
| 119 | 120 | extern char *kstrndup(const char *s, size_t len, gfp_t gfp); |
| @@ -243,15 +243,10 @@ static inline void lru_cache_add_file(struct page *page) · 242 unmodified lines | ||
| 243 | 243 | __lru_cache_add(page, LRU_INACTIVE_FILE); |
| 244 | 244 | } |
| 245 | 245 | |
| 246 | −/* LRU Isolation modes. */ | |
| 247 | −#define ISOLATE_INACTIVE 0 /* Isolate inactive pages. */ | |
| 248 | −#define ISOLATE_ACTIVE 1 /* Isolate active pages. */ | |
| 249 | −#define ISOLATE_BOTH 2 /* Isolate both active and inactive pages. */ | |
| 250 | − | |
| 251 | 246 | /* linux/mm/vmscan.c */ |
| 252 | 247 | extern unsigned long try_to_free_pages(struct zonelist *zonelist, int order, |
| 253 | 248 | gfp_t gfp_mask, nodemask_t *mask); |
| 254 | −extern int __isolate_lru_page(struct page *page, int mode, int file); | |
| 249 | +extern int __isolate_lru_page(struct page *page, isolate_mode_t mode, int file); | |
| 255 | 250 | extern unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem, |
| 256 | 251 | gfp_t gfp_mask, bool noswap); |
| 257 | 252 | extern unsigned long mem_cgroup_shrink_node_zone(struct mem_cgroup *mem, |
| @@ -844,4 +844,17 @@ asmlinkage long sys_open_by_handle_at(int mountdirfd, · 843 unmodified lines | ||
| 844 | 844 | struct file_handle __user *handle, |
| 845 | 845 | int flags); |
| 846 | 846 | asmlinkage long sys_setns(int fd, int nstype); |
| 847 | +asmlinkage long sys_process_vm_readv(pid_t pid, | |
| 848 | + const struct iovec __user *lvec, | |
| 849 | + unsigned long liovcnt, | |
| 850 | + const struct iovec __user *rvec, | |
| 851 | + unsigned long riovcnt, | |
| 852 | + unsigned long flags); | |
| 853 | +asmlinkage long sys_process_vm_writev(pid_t pid, | |
| 854 | + const struct iovec __user *lvec, | |
| 855 | + unsigned long liovcnt, | |
| 856 | + const struct iovec __user *rvec, | |
| 857 | + unsigned long riovcnt, | |
| 858 | + unsigned long flags); | |
| 859 | + | |
| 847 | 860 | #endif |
| @@ -29,10 +29,10 @@ trace_seq_init(struct trace_seq *s) · 28 unmodified lines | ||
| 29 | 29 | * Currently only defined when tracing is enabled. |
| 30 | 30 | */ |
| 31 | 31 | #ifdef CONFIG_TRACING |
| 32 | −extern int trace_seq_printf(struct trace_seq *s, const char *fmt, ...) | |
| 33 | − __attribute__ ((format (printf, 2, 3))); | |
| 34 | −extern int trace_seq_vprintf(struct trace_seq *s, const char *fmt, va_list args) | |
| 35 | − __attribute__ ((format (printf, 2, 0))); | |
| 32 | +extern __printf(2, 3) | |
| 33 | +int trace_seq_printf(struct trace_seq *s, const char *fmt, ...); | |
| 34 | +extern __printf(2, 0) | |
| 35 | +int trace_seq_vprintf(struct trace_seq *s, const char *fmt, va_list args); | |
| 36 | 36 | extern int |
| 37 | 37 | trace_seq_bprintf(struct trace_seq *s, const char *fmt, const u32 *binary); |
| 38 | 38 | extern int trace_print_seq(struct seq_file *m, struct trace_seq *s); |
| @@ -13,6 +13,7 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */ · 12 unmodified lines | ||
| 13 | 13 | #define VM_MAP 0x00000004 /* vmap()ed pages */ |
| 14 | 14 | #define VM_USERMAP 0x00000008 /* suitable for remap_vmalloc_range */ |
| 15 | 15 | #define VM_VPAGES 0x00000010 /* buffer for pages was vmalloc'ed */ |
| 16 | +#define VM_UNLIST 0x00000020 /* vm_struct is not listed in vmlist */ | |
| 16 | 17 | /* bits [20..32] reserved for arch specific ioremap internals */ |
| 17 | 18 | |
| 18 | 19 | /* |
| @@ -77,7 +77,7 @@ struct bt_power { · 76 unmodified lines | ||
| 77 | 77 | #define BT_POWER_FORCE_ACTIVE_OFF 0 |
| 78 | 78 | #define BT_POWER_FORCE_ACTIVE_ON 1 |
| 79 | 79 | |
| 80 | −__attribute__((format (printf, 2, 3))) | |
| 80 | +__printf(2, 3) | |
| 81 | 81 | int bt_printk(const char *level, const char *fmt, ...); |
| 82 | 82 | |
| 83 | 83 | #define BT_INFO(fmt, arg...) bt_printk(KERN_INFO, pr_fmt(fmt), ##arg) |
| @@ -53,12 +53,13 @@ int nf_log_bind_pf(u_int8_t pf, const struct nf_logger *logger); · 52 unmodified lines | ||
| 53 | 53 | void nf_log_unbind_pf(u_int8_t pf); |
| 54 | 54 | |
| 55 | 55 | /* Calls the registered backend logging function */ |
| 56 | +__printf(7, 8) | |
| 56 | 57 | void nf_log_packet(u_int8_t pf, |
| 57 | 58 | unsigned int hooknum, |
| 58 | 59 | const struct sk_buff *skb, |
| 59 | 60 | const struct net_device *in, |
| 60 | 61 | const struct net_device *out, |
| 61 | 62 | const struct nf_loginfo *li, |
| 62 | − const char *fmt, ...) __attribute__ ((format(printf,7,8))); | |
| 63 | + const char *fmt, ...); | |
| 63 | 64 | |
| 64 | 65 | #endif /* _NF_LOG_H */ |
| @@ -76,8 +76,8 @@ · 75 unmodified lines | ||
| 76 | 76 | printk(KERN_DEBUG msg); } while (0) |
| 77 | 77 | #else |
| 78 | 78 | /* Validate arguments and do nothing */ |
| 79 | −static inline void __attribute__ ((format (printf, 2, 3))) | |
| 80 | −SOCK_DEBUG(struct sock *sk, const char *msg, ...) | |
| 79 | +static inline __printf(2, 3) | |
| 80 | +void SOCK_DEBUG(struct sock *sk, const char *msg, ...) | |
| 81 | 81 | { |
| 82 | 82 | } |
| 83 | 83 | #endif |
| @@ -326,9 +326,9 @@ void release_and_free_resource(struct resource *res); · 325 unmodified lines | ||
| 326 | 326 | /* --- */ |
| 327 | 327 | |
| 328 | 328 | #if defined(CONFIG_SND_DEBUG) || defined(CONFIG_SND_VERBOSE_PRINTK) |
| 329 | +__printf(4, 5) | |
| 329 | 330 | void __snd_printk(unsigned int level, const char *file, int line, |
| 330 | − const char *format, ...) | |
| 331 | − __attribute__ ((format (printf, 4, 5))); | |
| 331 | + const char *format, ...); | |
| 332 | 332 | #else |
| 333 | 333 | #define __snd_printk(level, file, line, format, args...) \ |
| 334 | 334 | printk(format, ##args) |
| @@ -110,8 +110,8 @@ void snd_card_info_read_oss(struct snd_info_buffer *buffer); · 109 unmodified lines | ||
| 110 | 110 | static inline void snd_card_info_read_oss(struct snd_info_buffer *buffer) {} |
| 111 | 111 | #endif |
| 112 | 112 | |
| 113 | −int snd_iprintf(struct snd_info_buffer *buffer, const char *fmt, ...) \ | |
| 114 | − __attribute__ ((format (printf, 2, 3))); | |
| 113 | +__printf(2, 3) | |
| 114 | +int snd_iprintf(struct snd_info_buffer *buffer, const char *fmt, ...); | |
| 115 | 115 | int snd_info_init(void); |
| 116 | 116 | int snd_info_done(void); |
| 117 | 117 | |
| @@ -75,9 +75,9 @@ struct snd_seq_port_callback { · 74 unmodified lines | ||
| 75 | 75 | }; |
| 76 | 76 | |
| 77 | 77 | /* interface for kernel client */ |
| 78 | +__printf(3, 4) | |
| 78 | 79 | int snd_seq_create_kernel_client(struct snd_card *card, int client_index, |
| 79 | − const char *name_fmt, ...) | |
| 80 | − __attribute__ ((format (printf, 3, 4))); | |
| 80 | + const char *name_fmt, ...); | |
| 81 | 81 | int snd_seq_delete_kernel_client(int client); |
| 82 | 82 | int snd_seq_kernel_client_enqueue(int client, struct snd_seq_event *ev, int atomic, int hop); |
| 83 | 83 | int snd_seq_kernel_client_dispatch(int client, struct snd_seq_event *ev, int atomic, int hop); |
| @@ -266,7 +266,7 @@ DECLARE_EVENT_CLASS(mm_vmscan_lru_isolate_template, · 265 unmodified lines | ||
| 266 | 266 | unsigned long nr_lumpy_taken, |
| 267 | 267 | unsigned long nr_lumpy_dirty, |
| 268 | 268 | unsigned long nr_lumpy_failed, |
| 269 | − int isolate_mode), | |
| 269 | + isolate_mode_t isolate_mode), | |
| 270 | 270 | |
| 271 | 271 | TP_ARGS(order, nr_requested, nr_scanned, nr_taken, nr_lumpy_taken, nr_lumpy_dirty, nr_lumpy_failed, isolate_mode), |
| 272 | 272 | |
| @@ -278,7 +278,7 @@ DECLARE_EVENT_CLASS(mm_vmscan_lru_isolate_template, · 5 unmodified lines | ||
| 278 | 278 | __field(unsigned long, nr_lumpy_taken) |
| 279 | 279 | __field(unsigned long, nr_lumpy_dirty) |
| 280 | 280 | __field(unsigned long, nr_lumpy_failed) |
| 281 | − __field(int, isolate_mode) | |
| 281 | + __field(isolate_mode_t, isolate_mode) | |
| 282 | 282 | ), |
| 283 | 283 | |
| 284 | 284 | TP_fast_assign( |
| @@ -312,7 +312,7 @@ DEFINE_EVENT(mm_vmscan_lru_isolate_template, mm_vmscan_lru_isolate, · 27 unmodified lines | ||
| 312 | 312 | unsigned long nr_lumpy_taken, |
| 313 | 313 | unsigned long nr_lumpy_dirty, |
| 314 | 314 | unsigned long nr_lumpy_failed, |
| 315 | − int isolate_mode), | |
| 315 | + isolate_mode_t isolate_mode), | |
| 316 | 316 | |
| 317 | 317 | TP_ARGS(order, nr_requested, nr_scanned, nr_taken, nr_lumpy_taken, nr_lumpy_dirty, nr_lumpy_failed, isolate_mode) |
| 318 | 318 | |
| @@ -327,7 +327,7 @@ DEFINE_EVENT(mm_vmscan_lru_isolate_template, mm_vmscan_memcg_isolate, · 8 unmodified lines | ||
| 327 | 327 | unsigned long nr_lumpy_taken, |
| 328 | 328 | unsigned long nr_lumpy_dirty, |
| 329 | 329 | unsigned long nr_lumpy_failed, |
| 330 | − int isolate_mode), | |
| 330 | + isolate_mode_t isolate_mode), | |
| 331 | 331 | |
| 332 | 332 | TP_ARGS(order, nr_requested, nr_scanned, nr_taken, nr_lumpy_taken, nr_lumpy_dirty, nr_lumpy_failed, isolate_mode) |
| 333 | 333 | |
| @@ -6,12 +6,12 @@ extern struct console xenboot_console; · 5 unmodified lines | ||
| 6 | 6 | #ifdef CONFIG_HVC_XEN |
| 7 | 7 | void xen_console_resume(void); |
| 8 | 8 | void xen_raw_console_write(const char *str); |
| 9 | −__attribute__((format(printf, 1, 2))) | |
| 9 | +__printf(1, 2) | |
| 10 | 10 | void xen_raw_printk(const char *fmt, ...); |
| 11 | 11 | #else |
| 12 | 12 | static inline void xen_console_resume(void) { } |
| 13 | 13 | static inline void xen_raw_console_write(const char *str) { } |
| 14 | −static inline __attribute__((format(printf, 1, 2))) | |
| 14 | +static inline __printf(1, 2) | |
| 15 | 15 | void xen_raw_printk(const char *fmt, ...) { } |
| 16 | 16 | #endif |
| 17 | 17 | |
| @@ -156,9 +156,9 @@ int xenbus_scanf(struct xenbus_transaction t, · 155 unmodified lines | ||
| 156 | 156 | __attribute__((format(scanf, 4, 5))); |
| 157 | 157 | |
| 158 | 158 | /* Single printf and write: returns -errno or 0. */ |
| 159 | +__printf(4, 5) | |
| 159 | 160 | int xenbus_printf(struct xenbus_transaction t, |
| 160 | − const char *dir, const char *node, const char *fmt, ...) | |
| 161 | − __attribute__((format(printf, 4, 5))); | |
| 161 | + const char *dir, const char *node, const char *fmt, ...); | |
| 162 | 162 | |
| 163 | 163 | /* Generic read function: NULL-terminated triples of name, |
| 164 | 164 | * sprintf-style type string, and pointer. Returns 0 or errno.*/ |
| @@ -200,11 +200,11 @@ int xenbus_watch_path(struct xenbus_device *dev, const char *path, · 35 unmodified lines | ||
| 200 | 200 | struct xenbus_watch *watch, |
| 201 | 201 | void (*callback)(struct xenbus_watch *, |
| 202 | 202 | const char **, unsigned int)); |
| 203 | +__printf(4, 5) | |
| 203 | 204 | int xenbus_watch_pathfmt(struct xenbus_device *dev, struct xenbus_watch *watch, |
| 204 | 205 | void (*callback)(struct xenbus_watch *, |
| 205 | 206 | const char **, unsigned int), |
| 206 | − const char *pathfmt, ...) | |
| 207 | − __attribute__ ((format (printf, 4, 5))); | |
| 207 | + const char *pathfmt, ...); | |
| 208 | 208 | |
| 209 | 209 | int xenbus_switch_state(struct xenbus_device *dev, enum xenbus_state new_state); |
| 210 | 210 | int xenbus_grant_ring(struct xenbus_device *dev, unsigned long ring_mfn); |
| @@ -223,9 +223,9 @@ int xenbus_free_evtchn(struct xenbus_device *dev, int port); · 12 unmodified lines | ||
| 223 | 223 | |
| 224 | 224 | enum xenbus_state xenbus_read_driver_state(const char *path); |
| 225 | 225 | |
| 226 | −__attribute__((format(printf, 3, 4))) | |
| 226 | +__printf(3, 4) | |
| 227 | 227 | void xenbus_dev_error(struct xenbus_device *dev, int err, const char *fmt, ...); |
| 228 | −__attribute__((format(printf, 3, 4))) | |
| 228 | +__printf(3, 4) | |
| 229 | 229 | void xenbus_dev_fatal(struct xenbus_device *dev, int err, const char *fmt, ...); |
| 230 | 230 | |
| 231 | 231 | const char *xenbus_strstate(enum xenbus_state state); |
| @@ -449,8 +449,8 @@ static int wq_sleep(struct mqueue_inode_info *info, int sr, · 448 unmodified lines | ||
| 449 | 449 | set_current_state(TASK_INTERRUPTIBLE); |
| 450 | 450 | |
| 451 | 451 | spin_unlock(&info->lock); |
| 452 | − time = schedule_hrtimeout_range_clock(timeout, | |
| 453 | − HRTIMER_MODE_ABS, 0, CLOCK_REALTIME); | |
| 452 | + time = schedule_hrtimeout_range_clock(timeout, 0, | |
| 453 | + HRTIMER_MODE_ABS, CLOCK_REALTIME); | |
| 454 | 454 | |
| 455 | 455 | while (ewp->state == STATE_PENDING) |
| 456 | 456 | cpu_relax(); |
| @@ -217,7 +217,7 @@ void gdbstub_msg_write(const char *s, int len) · 216 unmodified lines | ||
| 217 | 217 | |
| 218 | 218 | /* Pack in hex chars */ |
| 219 | 219 | for (i = 0; i < wcount; i++) |
| 220 | − bufptr = pack_hex_byte(bufptr, s[i]); | |
| 220 | + bufptr = hex_byte_pack(bufptr, s[i]); | |
| 221 | 221 | *bufptr = '\0'; |
| 222 | 222 | |
| 223 | 223 | /* Move up */ |
| @@ -249,7 +249,7 @@ char *kgdb_mem2hex(char *mem, char *buf, int count) · 25 unmodified lines | ||
| 249 | 249 | if (err) |
| 250 | 250 | return NULL; |
| 251 | 251 | while (count > 0) { |
| 252 | − buf = pack_hex_byte(buf, *tmp); | |
| 252 | + buf = hex_byte_pack(buf, *tmp); | |
| 253 | 253 | tmp++; |
| 254 | 254 | count--; |
| 255 | 255 | } |
| @@ -411,14 +411,14 @@ static char *pack_threadid(char *pkt, unsigned char *id) · 155 unmodified lines | ||
| 411 | 411 | limit = id + (BUF_THREAD_ID_SIZE / 2); |
| 412 | 412 | while (id < limit) { |
| 413 | 413 | if (!lzero || *id != 0) { |
| 414 | − pkt = pack_hex_byte(pkt, *id); | |
| 414 | + pkt = hex_byte_pack(pkt, *id); | |
| 415 | 415 | lzero = 0; |
| 416 | 416 | } |
| 417 | 417 | id++; |
| 418 | 418 | } |
| 419 | 419 | |
| 420 | 420 | if (lzero) |
| 421 | − pkt = pack_hex_byte(pkt, 0); | |
| 421 | + pkt = hex_byte_pack(pkt, 0); | |
| 422 | 422 | |
| 423 | 423 | return pkt; |
| 424 | 424 | } |
| @@ -486,7 +486,7 @@ static void gdb_cmd_status(struct kgdb_state *ks) · 61 unmodified lines | ||
| 486 | 486 | dbg_remove_all_break(); |
| 487 | 487 | |
| 488 | 488 | remcom_out_buffer[0] = 'S'; |
| 489 | − pack_hex_byte(&remcom_out_buffer[1], ks->signo); | |
| 489 | + hex_byte_pack(&remcom_out_buffer[1], ks->signo); | |
| 490 | 490 | } |
| 491 | 491 | |
| 492 | 492 | static void gdb_get_regs_helper(struct kgdb_state *ks) |
| @@ -954,7 +954,7 @@ int gdb_serial_stub(struct kgdb_state *ks) · 461 unmodified lines | ||
| 954 | 954 | /* Reply to host that an exception has occurred */ |
| 955 | 955 | ptr = remcom_out_buffer; |
| 956 | 956 | *ptr++ = 'T'; |
| 957 | − ptr = pack_hex_byte(ptr, ks->signo); | |
| 957 | + ptr = hex_byte_pack(ptr, ks->signo); | |
| 958 | 958 | ptr += strlen(strcpy(ptr, "thread:")); |
| 959 | 959 | int_to_threadref(thref, shadow_pid(current->pid)); |
| 960 | 960 | ptr = pack_threadid(ptr, thref); |
| @@ -3544,7 +3544,7 @@ static void perf_mmap_close(struct vm_area_struct *vma) · 3543 unmodified lines | ||
| 3544 | 3544 | struct ring_buffer *rb = event->rb; |
| 3545 | 3545 | |
| 3546 | 3546 | atomic_long_sub((size >> PAGE_SHIFT) + 1, &user->locked_vm); |
| 3547 | − vma->vm_mm->locked_vm -= event->mmap_locked; | |
| 3547 | + vma->vm_mm->pinned_vm -= event->mmap_locked; | |
| 3548 | 3548 | rcu_assign_pointer(event->rb, NULL); |
| 3549 | 3549 | mutex_unlock(&event->mmap_mutex); |
| 3550 | 3550 | |
| @@ -3625,7 +3625,7 @@ static int perf_mmap(struct file *file, struct vm_area_struct *vma) · 74 unmodified lines | ||
| 3625 | 3625 | |
| 3626 | 3626 | lock_limit = rlimit(RLIMIT_MEMLOCK); |
| 3627 | 3627 | lock_limit >>= PAGE_SHIFT; |
| 3628 | − locked = vma->vm_mm->locked_vm + extra; | |
| 3628 | + locked = vma->vm_mm->pinned_vm + extra; | |
| 3629 | 3629 | |
| 3630 | 3630 | if ((locked > lock_limit) && perf_paranoid_tracepoint_raw() && |
| 3631 | 3631 | !capable(CAP_IPC_LOCK)) { |
| @@ -3651,7 +3651,7 @@ static int perf_mmap(struct file *file, struct vm_area_struct *vma) · 19 unmodified lines | ||
| 3651 | 3651 | atomic_long_add(user_extra, &user->locked_vm); |
| 3652 | 3652 | event->mmap_locked = extra; |
| 3653 | 3653 | event->mmap_user = get_current_user(); |
| 3654 | − vma->vm_mm->locked_vm += event->mmap_locked; | |
| 3654 | + vma->vm_mm->pinned_vm += event->mmap_locked; | |
| 3655 | 3655 | |
| 3656 | 3656 | unlock: |
| 3657 | 3657 | if (!ret) |
| @@ -681,8 +681,6 @@ static void exit_mm(struct task_struct * tsk) · 680 unmodified lines | ||
| 681 | 681 | enter_lazy_tlb(mm, current); |
| 682 | 682 | /* We don't want this task to be frozen prematurely */ |
| 683 | 683 | clear_freeze_flag(tsk); |
| 684 | − if (tsk->signal->oom_score_adj == OOM_SCORE_ADJ_MIN) | |
| 685 | − atomic_dec(&mm->oom_disable_count); | |
| 686 | 684 | task_unlock(tsk); |
| 687 | 685 | mm_update_next_owner(mm); |
| 688 | 686 | mmput(mm); |
| @@ -501,7 +501,6 @@ static struct mm_struct *mm_init(struct mm_struct *mm, struct task_struct *p) · 500 unmodified lines | ||
| 501 | 501 | mm->cached_hole_size = ~0UL; |
| 502 | 502 | mm_init_aio(mm); |
| 503 | 503 | mm_init_owner(mm, p); |
| 504 | − atomic_set(&mm->oom_disable_count, 0); | |
| 505 | 504 | |
| 506 | 505 | if (likely(!mm_alloc_pgd(mm))) { |
| 507 | 506 | mm->def_flags = 0; |
| @@ -816,8 +815,6 @@ good_mm: · 308 unmodified lines | ||
| 816 | 815 | /* Initializing for Swap token stuff */ |
| 817 | 816 | mm->token_priority = 0; |
| 818 | 817 | mm->last_interval = 0; |
| 819 | − if (tsk->signal->oom_score_adj == OOM_SCORE_ADJ_MIN) | |
| 820 | − atomic_inc(&mm->oom_disable_count); | |
| 821 | 818 | |
| 822 | 819 | tsk->mm = mm; |
| 823 | 820 | tsk->active_mm = mm; |
| @@ -1391,13 +1388,8 @@ bad_fork_cleanup_io: · 567 unmodified lines | ||
| 1391 | 1388 | bad_fork_cleanup_namespaces: |
| 1392 | 1389 | exit_task_namespaces(p); |
| 1393 | 1390 | bad_fork_cleanup_mm: |
| 1394 | − if (p->mm) { | |
| 1395 | − task_lock(p); | |
| 1396 | − if (p->signal->oom_score_adj == OOM_SCORE_ADJ_MIN) | |
| 1397 | − atomic_dec(&p->mm->oom_disable_count); | |
| 1398 | − task_unlock(p); | |
| 1391 | + if (p->mm) | |
| 1399 | 1392 | mmput(p->mm); |
| 1400 | − } | |
| 1401 | 1393 | bad_fork_cleanup_signal: |
| 1402 | 1394 | if (!(clone_flags & CLONE_THREAD)) |
| 1403 | 1395 | free_signal_struct(p->signal); |
| @@ -532,6 +532,9 @@ static int __init ignore_loglevel_setup(char *str) · 531 unmodified lines | ||
| 532 | 532 | } |
| 533 | 533 | |
| 534 | 534 | early_param("ignore_loglevel", ignore_loglevel_setup); |
| 535 | +module_param_named(ignore_loglevel, ignore_loglevel, bool, S_IRUGO | S_IWUSR); | |
| 536 | +MODULE_PARM_DESC(ignore_loglevel, "ignore loglevel setting, to" | |
| 537 | + "print all kernel messages to the console."); | |
| 535 | 538 | |
| 536 | 539 | /* |
| 537 | 540 | * Write out chars from start to end - 1 inclusive |
| @@ -592,9 +595,6 @@ static size_t log_prefix(const char *p, unsigned int *level, char *special) · 54 unmodified lines | ||
| 592 | 595 | /* multi digit including the level and facility number */ |
| 593 | 596 | char *endp = NULL; |
| 594 | 597 | |
| 595 | − if (p[1] < '0' && p[1] > '9') | |
| 596 | − return 0; | |
| 597 | − | |
| 598 | 598 | lev = (simple_strtoul(&p[1], &endp, 10) & 7); |
| 599 | 599 | if (endp == NULL || endp[0] != '>') |
| 600 | 600 | return 0; |
| @@ -1108,6 +1108,10 @@ static int __init console_suspend_disable(char *str) · 507 unmodified lines | ||
| 1108 | 1108 | return 1; |
| 1109 | 1109 | } |
| 1110 | 1110 | __setup("no_console_suspend", console_suspend_disable); |
| 1111 | +module_param_named(console_suspend, console_suspend_enabled, | |
| 1112 | + bool, S_IRUGO | S_IWUSR); | |
| 1113 | +MODULE_PARM_DESC(console_suspend, "suspend console during suspend" | |
| 1114 | + " and hibernate operations"); | |
| 1111 | 1115 | |
| 1112 | 1116 | /** |
| 1113 | 1117 | * suspend_console - suspend the console subsystem |
| @@ -41,6 +41,7 @@ struct cpu_stopper { · 40 unmodified lines | ||
| 41 | 41 | }; |
| 42 | 42 | |
| 43 | 43 | static DEFINE_PER_CPU(struct cpu_stopper, cpu_stopper); |
| 44 | +static bool stop_machine_initialized = false; | |
| 44 | 45 | |
| 45 | 46 | static void cpu_stop_init_done(struct cpu_stop_done *done, unsigned int nr_todo) |
| 46 | 47 | { |
| @@ -386,6 +387,8 @@ static int __init cpu_stop_init(void) · 339 unmodified lines | ||
| 386 | 387 | cpu_stop_cpu_callback(&cpu_stop_cpu_notifier, CPU_ONLINE, bcpu); |
| 387 | 388 | register_cpu_notifier(&cpu_stop_cpu_notifier); |
| 388 | 389 | |
| 390 | + stop_machine_initialized = true; | |
| 391 | + | |
| 389 | 392 | return 0; |
| 390 | 393 | } |
| 391 | 394 | early_initcall(cpu_stop_init); |
| @@ -485,6 +488,25 @@ int __stop_machine(int (*fn)(void *), void *data, const struct cpumask *cpus) · 93 unmodified lines | ||
| 485 | 488 | .num_threads = num_online_cpus(), |
| 486 | 489 | .active_cpus = cpus }; |
| 487 | 490 | |
| 491 | + if (!stop_machine_initialized) { | |
| 492 | + /* | |
| 493 | + * Handle the case where stop_machine() is called | |
| 494 | + * early in boot before stop_machine() has been | |
| 495 | + * initialized. | |
| 496 | + */ | |
| 497 | + unsigned long flags; | |
| 498 | + int ret; | |
| 499 | + | |
| 500 | + WARN_ON_ONCE(smdata.num_threads != 1); | |
| 501 | + | |
| 502 | + local_irq_save(flags); | |
| 503 | + hard_irq_disable(); | |
| 504 | + ret = (*fn)(data); | |
| 505 | + local_irq_restore(flags); | |
| 506 | + | |
| 507 | + return ret; | |
| 508 | + } | |
| 509 | + | |
| 488 | 510 | /* Set the initial state and stop all online cpus. */ |
| 489 | 511 | set_state(&smdata, STOPMACHINE_PREPARE); |
| 490 | 512 | return stop_cpus(cpu_online_mask, stop_machine_cpu_stop, &smdata); |
| @@ -145,6 +145,10 @@ cond_syscall(sys_io_submit); · 144 unmodified lines | ||
| 145 | 145 | cond_syscall(sys_io_cancel); |
| 146 | 146 | cond_syscall(sys_io_getevents); |
| 147 | 147 | cond_syscall(sys_syslog); |
| 148 | +cond_syscall(sys_process_vm_readv); | |
| 149 | +cond_syscall(sys_process_vm_writev); | |
| 150 | +cond_syscall(compat_sys_process_vm_readv); | |
| 151 | +cond_syscall(compat_sys_process_vm_writev); | |
| 148 | 152 | |
| 149 | 153 | /* arch-specific weak syscall entries */ |
| 150 | 154 | cond_syscall(sys_pciconfig_read); |
| @@ -57,6 +57,7 @@ · 56 unmodified lines | ||
| 57 | 57 | #include <linux/pipe_fs_i.h> |
| 58 | 58 | #include <linux/oom.h> |
| 59 | 59 | #include <linux/kmod.h> |
| 60 | +#include <linux/capability.h> | |
| 60 | 61 | |
| 61 | 62 | #include <asm/uaccess.h> |
| 62 | 63 | #include <asm/processor.h> |
| @@ -134,6 +135,7 @@ static int minolduid; · 71 unmodified lines | ||
| 134 | 135 | static int min_percpu_pagelist_fract = 8; |
| 135 | 136 | |
| 136 | 137 | static int ngroups_max = NGROUPS_MAX; |
| 138 | +static const int cap_last_cap = CAP_LAST_CAP; | |
| 137 | 139 | |
| 138 | 140 | #ifdef CONFIG_INOTIFY_USER |
| 139 | 141 | #include <linux/inotify.h> |
| @@ -732,6 +734,13 @@ static struct ctl_table kern_table[] = { · 592 unmodified lines | ||
| 732 | 734 | .mode = 0444, |
| 733 | 735 | .proc_handler = proc_dointvec, |
| 734 | 736 | }, |
| 737 | + { | |
| 738 | + .procname = "cap_last_cap", | |
| 739 | + .data = (void *)&cap_last_cap, | |
| 740 | + .maxlen = sizeof(int), | |
| 741 | + .mode = 0444, | |
| 742 | + .proc_handler = proc_dointvec, | |
| 743 | + }, | |
| 735 | 744 | #if defined(CONFIG_LOCKUP_DETECTOR) |
| 736 | 745 | { |
| 737 | 746 | .procname = "watchdog", |
| @@ -481,6 +481,8 @@ static void watchdog_disable(int cpu) · 480 unmodified lines | ||
| 481 | 481 | } |
| 482 | 482 | } |
| 483 | 483 | |
| 484 | +/* sysctl functions */ | |
| 485 | +#ifdef CONFIG_SYSCTL | |
| 484 | 486 | static void watchdog_enable_all_cpus(void) |
| 485 | 487 | { |
| 486 | 488 | int cpu; |
| @@ -510,8 +512,6 @@ static void watchdog_disable_all_cpus(void) · 23 unmodified lines | ||
| 510 | 512 | } |
| 511 | 513 | |
| 512 | 514 | |
| 513 | −/* sysctl functions */ | |
| 514 | −#ifdef CONFIG_SYSCTL | |
| 515 | 515 | /* |
| 516 | 516 | * proc handler for /proc/sys/kernel/nmi_watchdog,watchdog_thresh |
| 517 | 517 | */ |
| @@ -248,8 +248,9 @@ config DEFAULT_HUNG_TASK_TIMEOUT · 247 unmodified lines | ||
| 248 | 248 | to determine when a task has become non-responsive and should |
| 249 | 249 | be considered hung. |
| 250 | 250 | |
| 251 | − It can be adjusted at runtime via the kernel.hung_task_timeout | |
| 252 | − sysctl or by writing a value to /proc/sys/kernel/hung_task_timeout. | |
| 251 | + It can be adjusted at runtime via the kernel.hung_task_timeout_secs | |
| 252 | + sysctl or by writing a value to | |
| 253 | + /proc/sys/kernel/hung_task_timeout_secs. | |
| 253 | 254 | |
| 254 | 255 | A timeout of 0 disables the check. The default is two minutes. |
| 255 | 256 | Keeping the default should be fine in most cases. |
| @@ -419,7 +419,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen, · 418 unmodified lines | ||
| 419 | 419 | { |
| 420 | 420 | int c, old_c, totaldigits, ndigits, nchunks, nbits; |
| 421 | 421 | u32 chunk; |
| 422 | − const char __user *ubuf = buf; | |
| 422 | + const char __user __force *ubuf = (const char __user __force *)buf; | |
| 423 | 423 | |
| 424 | 424 | bitmap_zero(maskp, nmaskbits); |
| 425 | 425 | |
| @@ -504,7 +504,9 @@ int bitmap_parse_user(const char __user *ubuf, · 78 unmodified lines | ||
| 504 | 504 | { |
| 505 | 505 | if (!access_ok(VERIFY_READ, ubuf, ulen)) |
| 506 | 506 | return -EFAULT; |
| 507 | − return __bitmap_parse((const char *)ubuf, ulen, 1, maskp, nmaskbits); | |
| 507 | + return __bitmap_parse((const char __force *)ubuf, | |
| 508 | + ulen, 1, maskp, nmaskbits); | |
| 509 | + | |
| 508 | 510 | } |
| 509 | 511 | EXPORT_SYMBOL(bitmap_parse_user); |
| 510 | 512 | |
| @@ -594,7 +596,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen, · 83 unmodified lines | ||
| 594 | 596 | { |
| 595 | 597 | unsigned a, b; |
| 596 | 598 | int c, old_c, totaldigits; |
| 597 | − const char __user *ubuf = buf; | |
| 599 | + const char __user __force *ubuf = (const char __user __force *)buf; | |
| 598 | 600 | int exp_digit, in_range; |
| 599 | 601 | |
| 600 | 602 | totaldigits = c = 0; |
| @@ -694,7 +696,7 @@ int bitmap_parselist_user(const char __user *ubuf, · 93 unmodified lines | ||
| 694 | 696 | { |
| 695 | 697 | if (!access_ok(VERIFY_READ, ubuf, ulen)) |
| 696 | 698 | return -EFAULT; |
| 697 | − return __bitmap_parselist((const char *)ubuf, | |
| 699 | + return __bitmap_parselist((const char __force *)ubuf, | |
| 698 | 700 | ulen, 1, maskp, nmaskbits); |
| 699 | 701 | } |
| 700 | 702 | EXPORT_SYMBOL(bitmap_parselist_user); |
| @@ -767,8 +767,8 @@ EXPORT_SYMBOL(ida_pre_get); · 766 unmodified lines | ||
| 767 | 767 | * @starting_id: id to start search at |
| 768 | 768 | * @p_id: pointer to the allocated handle |
| 769 | 769 | * |
| 770 | − * Allocate new ID above or equal to @ida. It should be called with | |
| 771 | − * any required locks. | |
| 770 | + * Allocate new ID above or equal to @starting_id. It should be called | |
| 771 | + * with any required locks. | |
| 772 | 772 | * |
| 773 | 773 | * If memory is required, it will return %-EAGAIN, you should unlock |
| 774 | 774 | * and go back to the ida_pre_get() call. If the ida is full, it will |
| @@ -18,26 +18,40 @@ · 17 unmodified lines | ||
| 18 | 18 | #include <linux/module.h> |
| 19 | 19 | #include <linux/types.h> |
| 20 | 20 | #include <asm/uaccess.h> |
| 21 | +#include "kstrtox.h" | |
| 21 | 22 | |
| 22 | −static int _kstrtoull(const char *s, unsigned int base, unsigned long long *res) | |
| 23 | +const char *_parse_integer_fixup_radix(const char *s, unsigned int *base) | |
| 23 | 24 | { |
| 24 | − unsigned long long acc; | |
| 25 | − int ok; | |
| 26 | − | |
| 27 | − if (base == 0) { | |
| 25 | + if (*base == 0) { | |
| 28 | 26 | if (s[0] == '0') { |
| 29 | 27 | if (_tolower(s[1]) == 'x' && isxdigit(s[2])) |
| 30 | − base = 16; | |
| 28 | + *base = 16; | |
| 31 | 29 | else |
| 32 | − base = 8; | |
| 30 | + *base = 8; | |
| 33 | 31 | } else |
| 34 | − base = 10; | |
| 32 | + *base = 10; | |
| 35 | 33 | } |
| 36 | − if (base == 16 && s[0] == '0' && _tolower(s[1]) == 'x') | |
| 34 | + if (*base == 16 && s[0] == '0' && _tolower(s[1]) == 'x') | |
| 37 | 35 | s += 2; |
| 36 | + return s; | |
| 37 | +} | |
| 38 | 38 | |
| 39 | − acc = 0; | |
| 40 | − ok = 0; | |
| 39 | +/* | |
| 40 | + * Convert non-negative integer string representation in explicitly given radix | |
| 41 | + * to an integer. | |
| 42 | + * Return number of characters consumed maybe or-ed with overflow bit. | |
| 43 | + * If overflow occurs, result integer (incorrect) is still returned. | |
| 44 | + * | |
| 45 | + * Don't you dare use this function. | |
| 46 | + */ | |
| 47 | +unsigned int _parse_integer(const char *s, unsigned int base, unsigned long long *res) | |
| 48 | +{ | |
| 49 | + unsigned int rv; | |
| 50 | + int overflow; | |
| 51 | + | |
| 52 | + *res = 0; | |
| 53 | + rv = 0; | |
| 54 | + overflow = 0; | |
| 41 | 55 | while (*s) { |
| 42 | 56 | unsigned int val; |
| 43 | 57 | |
| @@ -45,23 +59,40 @@ static int _kstrtoull(const char *s, unsigned int base, unsigned long long *res) · 1 unmodified line | ||
| 45 | 59 | val = *s - '0'; |
| 46 | 60 | else if ('a' <= _tolower(*s) && _tolower(*s) <= 'f') |
| 47 | 61 | val = _tolower(*s) - 'a' + 10; |
| 48 | − else if (*s == '\n' && *(s + 1) == '\0') | |
| 49 | − break; | |
| 50 | 62 | else |
| 51 | − return -EINVAL; | |
| 63 | + break; | |
| 52 | 64 | |
| 53 | 65 | if (val >= base) |
| 54 | − return -EINVAL; | |
| 55 | − if (acc > div_u64(ULLONG_MAX - val, base)) | |
| 56 | − return -ERANGE; | |
| 57 | − acc = acc * base + val; | |
| 58 | − ok = 1; | |
| 59 | − | |
| 66 | + break; | |
| 67 | + if (*res > div_u64(ULLONG_MAX - val, base)) | |
| 68 | + overflow = 1; | |
| 69 | + *res = *res * base + val; | |
| 70 | + rv++; | |
| 60 | 71 | s++; |
| 61 | 72 | } |
| 62 | − if (!ok) | |
| 73 | + if (overflow) | |
| 74 | + rv |= KSTRTOX_OVERFLOW; | |
| 75 | + return rv; | |
| 76 | +} | |
| 77 | + | |
| 78 | +static int _kstrtoull(const char *s, unsigned int base, unsigned long long *res) | |
| 79 | +{ | |
| 80 | + unsigned long long _res; | |
| 81 | + unsigned int rv; | |
| 82 | + | |
| 83 | + s = _parse_integer_fixup_radix(s, &base); | |
| 84 | + rv = _parse_integer(s, base, &_res); | |
| 85 | + if (rv & KSTRTOX_OVERFLOW) | |
| 86 | + return -ERANGE; | |
| 87 | + rv &= ~KSTRTOX_OVERFLOW; | |
| 88 | + if (rv == 0) | |
| 89 | + return -EINVAL; | |
| 90 | + s += rv; | |
| 91 | + if (*s == '\n') | |
| 92 | + s++; | |
| 93 | + if (*s) | |
| 63 | 94 | return -EINVAL; |
| 64 | − *res = acc; | |
| 95 | + *res = _res; | |
| 65 | 96 | return 0; |
| 66 | 97 | } |
| 67 | 98 | |
| @@ -0,0 +1,8 @@ | ||
| 1 | +#ifndef _LIB_KSTRTOX_H | |
| 2 | +#define _LIB_KSTRTOX_H | |
| 3 | + | |
| 4 | +#define KSTRTOX_OVERFLOW (1U << 31) | |
| 5 | +const char *_parse_integer_fixup_radix(const char *s, unsigned int *base); | |
| 6 | +unsigned int _parse_integer(const char *s, unsigned int base, unsigned long long *res); | |
| 7 | + | |
| 8 | +#endif | |
| @@ -10,8 +10,10 @@ · 9 unmodified lines | ||
| 10 | 10 | #include <linux/module.h> |
| 11 | 11 | #include <linux/debugobjects.h> |
| 12 | 12 | |
| 13 | +#ifdef CONFIG_HOTPLUG_CPU | |
| 13 | 14 | static LIST_HEAD(percpu_counters); |
| 14 | 15 | static DEFINE_MUTEX(percpu_counters_lock); |
| 16 | +#endif | |
| 15 | 17 | |
| 16 | 18 | #ifdef CONFIG_DEBUG_OBJECTS_PERCPU_COUNTER |
| 17 | 19 | |
| @@ -576,7 +576,6 @@ int radix_tree_tag_get(struct radix_tree_root *root, · 575 unmodified lines | ||
| 576 | 576 | { |
| 577 | 577 | unsigned int height, shift; |
| 578 | 578 | struct radix_tree_node *node; |
| 579 | − int saw_unset_tag = 0; | |
| 580 | 579 | |
| 581 | 580 | /* check the root's tag bit */ |
| 582 | 581 | if (!root_tag_get(root, tag)) |
| @@ -603,15 +602,10 @@ int radix_tree_tag_get(struct radix_tree_root *root, · 20 unmodified lines | ||
| 603 | 602 | return 0; |
| 604 | 603 | |
| 605 | 604 | offset = (index >> shift) & RADIX_TREE_MAP_MASK; |
| 606 | − | |
| 607 | − /* | |
| 608 | − * This is just a debug check. Later, we can bale as soon as | |
| 609 | − * we see an unset tag. | |
| 610 | − */ | |
| 611 | 605 | if (!tag_get(node, tag, offset)) |
| 612 | − saw_unset_tag = 1; | |
| 606 | + return 0; | |
| 613 | 607 | if (height == 1) |
| 614 | − return !!tag_get(node, tag, offset); | |
| 608 | + return 1; | |
| 615 | 609 | node = rcu_dereference_raw(node->slots[offset]); |
| 616 | 610 | shift -= RADIX_TREE_MAP_SHIFT; |
| 617 | 611 | height--; |
| @@ -49,13 +49,10 @@ void __rwlock_init(rwlock_t *lock, const char *name, · 48 unmodified lines | ||
| 49 | 49 | |
| 50 | 50 | EXPORT_SYMBOL(__rwlock_init); |
| 51 | 51 | |
| 52 | −static void spin_bug(raw_spinlock_t *lock, const char *msg) | |
| 52 | +static void spin_dump(raw_spinlock_t *lock, const char *msg) | |
| 53 | 53 | { |
| 54 | 54 | struct task_struct *owner = NULL; |
| 55 | 55 | |
| 56 | − if (!debug_locks_off()) | |
| 57 | − return; | |
| 58 | − | |
| 59 | 56 | if (lock->owner && lock->owner != SPINLOCK_OWNER_INIT) |
| 60 | 57 | owner = lock->owner; |
| 61 | 58 | printk(KERN_EMERG "BUG: spinlock %s on CPU#%d, %s/%d\n", |
| @@ -70,6 +67,14 @@ static void spin_bug(raw_spinlock_t *lock, const char *msg) · 8 unmodified lines | ||
| 70 | 67 | dump_stack(); |
| 71 | 68 | } |
| 72 | 69 | |
| 70 | +static void spin_bug(raw_spinlock_t *lock, const char *msg) | |
| 71 | +{ | |
| 72 | + if (!debug_locks_off()) | |
| 73 | + return; | |
| 74 | + | |
| 75 | + spin_dump(lock, msg); | |
| 76 | +} | |
| 77 | + | |
| 73 | 78 | #define SPIN_BUG_ON(cond, lock, msg) if (unlikely(cond)) spin_bug(lock, msg) |
| 74 | 79 | |
| 75 | 80 | static inline void |
| @@ -113,11 +118,7 @@ static void __spin_lock_debug(raw_spinlock_t *lock) · 37 unmodified lines | ||
| 113 | 118 | /* lockup suspected: */ |
| 114 | 119 | if (print_once) { |
| 115 | 120 | print_once = 0; |
| 116 | − printk(KERN_EMERG "BUG: spinlock lockup on CPU#%d, " | |
| 117 | − "%s/%d, %p\n", | |
| 118 | − raw_smp_processor_id(), current->comm, | |
| 119 | − task_pid_nr(current), lock); | |
| 120 | − dump_stack(); | |
| 121 | + spin_dump(lock, "lockup"); | |
| 121 | 122 | #ifdef CONFIG_SMP |
| 122 | 123 | trigger_all_cpu_backtrace(); |
| 123 | 124 | #endif |
| @@ -360,7 +360,6 @@ char *strim(char *s) · 359 unmodified lines | ||
| 360 | 360 | size_t size; |
| 361 | 361 | char *end; |
| 362 | 362 | |
| 363 | − s = skip_spaces(s); | |
| 364 | 363 | size = strlen(s); |
| 365 | 364 | if (!size) |
| 366 | 365 | return s; |
| @@ -370,7 +369,7 @@ char *strim(char *s) · 3 unmodified lines | ||
| 370 | 369 | end--; |
| 371 | 370 | *(end + 1) = '\0'; |
| 372 | 371 | |
| 373 | − return s; | |
| 372 | + return skip_spaces(s); | |
| 374 | 373 | } |
| 375 | 374 | EXPORT_SYMBOL(strim); |
| 376 | 375 | |
| @@ -756,3 +755,57 @@ void *memchr(const void *s, int c, size_t n) · 379 unmodified lines | ||
| 756 | 755 | } |
| 757 | 756 | EXPORT_SYMBOL(memchr); |
| 758 | 757 | #endif |
| 758 | + | |
| 759 | +static void *check_bytes8(const u8 *start, u8 value, unsigned int bytes) | |
| 760 | +{ | |
| 761 | + while (bytes) { | |
| 762 | + if (*start != value) | |
| 763 | + return (void *)start; | |
| 764 | + start++; | |
| 765 | + bytes--; | |
| 766 | + } | |
| 767 | + return NULL; | |
| 768 | +} | |
| 769 | + | |
| 770 | +/** | |
| 771 | + * memchr_inv - Find an unmatching character in an area of memory. | |
| 772 | + * @start: The memory area | |
| 773 | + * @c: Find a character other than c | |
| 774 | + * @bytes: The size of the area. | |
| 775 | + * | |
| 776 | + * returns the address of the first character other than @c, or %NULL | |
| 777 | + * if the whole buffer contains just @c. | |
| 778 | + */ | |
| 779 | +void *memchr_inv(const void *start, int c, size_t bytes) | |
| 780 | +{ | |
| 781 | + u8 value = c; | |
| 782 | + u64 value64; | |
| 783 | + unsigned int words, prefix; | |
| 784 | + | |
| 785 | + if (bytes <= 16) | |
| 786 | + return check_bytes8(start, value, bytes); | |
| 787 | + | |
| 788 | + value64 = value | value << 8 | value << 16 | value << 24; | |
| 789 | + value64 = (value64 & 0xffffffff) | value64 << 32; | |
| 790 | + prefix = 8 - ((unsigned long)start) % 8; | |
| 791 | + | |
| 792 | + if (prefix) { | |
| 793 | + u8 *r = check_bytes8(start, value, prefix); | |
| 794 | + if (r) | |
| 795 | + return r; | |
| 796 | + start += prefix; | |
| 797 | + bytes -= prefix; | |
| 798 | + } | |
| 799 | + | |
| 800 | + words = bytes / 8; | |
| 801 | + | |
| 802 | + while (words) { | |
| 803 | + if (*(u64 *)start != value64) | |
| 804 | + return check_bytes8(start, value, 8); | |
| 805 | + start += 8; | |
| 806 | + words--; | |
| 807 | + } | |
| 808 | + | |
| 809 | + return check_bytes8(start, value, bytes % 8); | |
| 810 | +} | |
| 811 | +EXPORT_SYMBOL(memchr_inv); | |
| @@ -31,17 +31,7 @@ · 30 unmodified lines | ||
| 31 | 31 | #include <asm/div64.h> |
| 32 | 32 | #include <asm/sections.h> /* for dereference_function_descriptor() */ |
| 33 | 33 | |
| 34 | −static unsigned int simple_guess_base(const char *cp) | |
| 35 | −{ | |
| 36 | − if (cp[0] == '0') { | |
| 37 | − if (_tolower(cp[1]) == 'x' && isxdigit(cp[2])) | |
| 38 | − return 16; | |
| 39 | − else | |
| 40 | − return 8; | |
| 41 | − } else { | |
| 42 | − return 10; | |
| 43 | − } | |
| 44 | −} | |
| 34 | +#include "kstrtox.h" | |
| 45 | 35 | |
| 46 | 36 | /** |
| 47 | 37 | * simple_strtoull - convert a string to an unsigned long long |
| @@ -51,23 +41,14 @@ static unsigned int simple_guess_base(const char *cp) · 3 unmodified lines | ||
| 51 | 41 | */ |
| 52 | 42 | unsigned long long simple_strtoull(const char *cp, char **endp, unsigned int base) |
| 53 | 43 | { |
| 54 | − unsigned long long result = 0; | |
| 44 | + unsigned long long result; | |
| 45 | + unsigned int rv; | |
| 55 | 46 | |
| 56 | − if (!base) | |
| 57 | − base = simple_guess_base(cp); | |
| 47 | + cp = _parse_integer_fixup_radix(cp, &base); | |
| 48 | + rv = _parse_integer(cp, base, &result); | |
| 49 | + /* FIXME */ | |
| 50 | + cp += (rv & ~KSTRTOX_OVERFLOW); | |
| 58 | 51 | |
| 59 | − if (base == 16 && cp[0] == '0' && _tolower(cp[1]) == 'x') | |
| 60 | − cp += 2; | |
| 61 | − | |
| 62 | − while (isxdigit(*cp)) { | |
| 63 | − unsigned int value; | |
| 64 | − | |
| 65 | − value = isdigit(*cp) ? *cp - '0' : _tolower(*cp) - 'a' + 10; | |
| 66 | − if (value >= base) | |
| 67 | − break; | |
| 68 | − result = result * base + value; | |
| 69 | − cp++; | |
| 70 | − } | |
| 71 | 52 | if (endp) |
| 72 | 53 | *endp = (char *)cp; |
| 73 | 54 | |
| @@ -566,7 +547,7 @@ char *mac_address_string(char *buf, char *end, u8 *addr, · 492 unmodified lines | ||
| 566 | 547 | } |
| 567 | 548 | |
| 568 | 549 | for (i = 0; i < 6; i++) { |
| 569 | − p = pack_hex_byte(p, addr[i]); | |
| 550 | + p = hex_byte_pack(p, addr[i]); | |
| 570 | 551 | if (fmt[0] == 'M' && i != 5) |
| 571 | 552 | *p++ = separator; |
| 572 | 553 | } |
| @@ -686,13 +667,13 @@ char *ip6_compressed_string(char *p, const char *addr) · 113 unmodified lines | ||
| 686 | 667 | lo = word & 0xff; |
| 687 | 668 | if (hi) { |
| 688 | 669 | if (hi > 0x0f) |
| 689 | − p = pack_hex_byte(p, hi); | |
| 670 | + p = hex_byte_pack(p, hi); | |
| 690 | 671 | else |
| 691 | 672 | *p++ = hex_asc_lo(hi); |
| 692 | − p = pack_hex_byte(p, lo); | |
| 673 | + p = hex_byte_pack(p, lo); | |
| 693 | 674 | } |
| 694 | 675 | else if (lo > 0x0f) |
| 695 | − p = pack_hex_byte(p, lo); | |
| 676 | + p = hex_byte_pack(p, lo); | |
| 696 | 677 | else |
| 697 | 678 | *p++ = hex_asc_lo(lo); |
| 698 | 679 | needcolon = true; |
| @@ -714,8 +695,8 @@ char *ip6_string(char *p, const char *addr, const char *fmt) · 15 unmodified lines | ||
| 714 | 695 | int i; |
| 715 | 696 | |
| 716 | 697 | for (i = 0; i < 8; i++) { |
| 717 | − p = pack_hex_byte(p, *addr++); | |
| 718 | − p = pack_hex_byte(p, *addr++); | |
| 698 | + p = hex_byte_pack(p, *addr++); | |
| 699 | + p = hex_byte_pack(p, *addr++); | |
| 719 | 700 | if (fmt[0] == 'I' && i != 7) |
| 720 | 701 | *p++ = ':'; |
| 721 | 702 | } |
| @@ -773,7 +754,7 @@ char *uuid_string(char *buf, char *end, const u8 *addr, · 51 unmodified lines | ||
| 773 | 754 | } |
| 774 | 755 | |
| 775 | 756 | for (i = 0; i < 16; i++) { |
| 776 | − p = pack_hex_byte(p, addr[index[i]]); | |
| 757 | + p = hex_byte_pack(p, addr[index[i]]); | |
| 777 | 758 | switch (i) { |
| 778 | 759 | case 3: |
| 779 | 760 | case 5: |
| @@ -131,6 +131,9 @@ config SPARSEMEM_VMEMMAP · 130 unmodified lines | ||
| 131 | 131 | config HAVE_MEMBLOCK |
| 132 | 132 | boolean |
| 133 | 133 | |
| 134 | +config NO_BOOTMEM | |
| 135 | + boolean | |
| 136 | + | |
| 134 | 137 | # eventually, we can have this option just 'select SPARSEMEM' |
| 135 | 138 | config MEMORY_HOTPLUG |
| 136 | 139 | bool "Allow for memory hot-add" |
| @@ -5,7 +5,8 @@ · 4 unmodified lines | ||
| 5 | 5 | mmu-y := nommu.o |
| 6 | 6 | mmu-$(CONFIG_MMU) := fremap.o highmem.o madvise.o memory.o mincore.o \ |
| 7 | 7 | mlock.o mmap.o mprotect.o mremap.o msync.o rmap.o \ |
| 8 | − vmalloc.o pagewalk.o pgtable-generic.o | |
| 8 | + vmalloc.o pagewalk.o pgtable-generic.o \ | |
| 9 | + process_vm_access.o | |
| 9 | 10 | |
| 10 | 11 | obj-y := filemap.o mempool.o oom_kill.o fadvise.o \ |
| 11 | 12 | maccess.o page_alloc.o page-writeback.o \ |
| @@ -404,9 +404,8 @@ static int bdi_forker_thread(void *ptr) · 403 unmodified lines | ||
| 404 | 404 | /* |
| 405 | 405 | * In the following loop we are going to check whether we have |
| 406 | 406 | * some work to do without any synchronization with tasks |
| 407 | − * waking us up to do work for them. So we have to set task | |
| 408 | − * state already here so that we don't miss wakeups coming | |
| 409 | − * after we verify some condition. | |
| 407 | + * waking us up to do work for them. Set the task state here | |
| 408 | + * so that we don't miss wakeups after verifying conditions. | |
| 410 | 409 | */ |
| 411 | 410 | set_current_state(TASK_INTERRUPTIBLE); |
| 412 | 411 | |
| @@ -35,10 +35,6 @@ struct compact_control { · 34 unmodified lines | ||
| 35 | 35 | unsigned long migrate_pfn; /* isolate_migratepages search base */ |
| 36 | 36 | bool sync; /* Synchronous migration */ |
| 37 | 37 | |
| 38 | − /* Account for isolated anon and file pages */ | |
| 39 | − unsigned long nr_anon; | |
| 40 | − unsigned long nr_file; | |
| 41 | − | |
| 42 | 38 | unsigned int order; /* order a direct compactor needs */ |
| 43 | 39 | int migratetype; /* MOVABLE, RECLAIMABLE etc */ |
| 44 | 40 | struct zone *zone; |
| @@ -223,17 +219,13 @@ static void isolate_freepages(struct zone *zone, · 178 unmodified lines | ||
| 223 | 219 | static void acct_isolated(struct zone *zone, struct compact_control *cc) |
| 224 | 220 | { |
| 225 | 221 | struct page *page; |
| 226 | − unsigned int count[NR_LRU_LISTS] = { 0, }; | |
| 222 | + unsigned int count[2] = { 0, }; | |
| 227 | 223 | |
| 228 | − list_for_each_entry(page, &cc->migratepages, lru) { | |
| 229 | − int lru = page_lru_base_type(page); | |
| 230 | − count[lru]++; | |
| 231 | − } | |
| 224 | + list_for_each_entry(page, &cc->migratepages, lru) | |
| 225 | + count[!!page_is_file_cache(page)]++; | |
| 232 | 226 | |
| 233 | − cc->nr_anon = count[LRU_ACTIVE_ANON] + count[LRU_INACTIVE_ANON]; | |
| 234 | − cc->nr_file = count[LRU_ACTIVE_FILE] + count[LRU_INACTIVE_FILE]; | |
| 235 | − __mod_zone_page_state(zone, NR_ISOLATED_ANON, cc->nr_anon); | |
| 236 | − __mod_zone_page_state(zone, NR_ISOLATED_FILE, cc->nr_file); | |
| 227 | + __mod_zone_page_state(zone, NR_ISOLATED_ANON, count[0]); | |
| 228 | + __mod_zone_page_state(zone, NR_ISOLATED_FILE, count[1]); | |
| 237 | 229 | } |
| 238 | 230 | |
| 239 | 231 | /* Similar to reclaim, but different enough that they don't share logic */ |
| @@ -269,6 +261,7 @@ static isolate_migrate_t isolate_migratepages(struct zone *zone, · 29 unmodified lines | ||
| 269 | 261 | unsigned long last_pageblock_nr = 0, pageblock_nr; |
| 270 | 262 | unsigned long nr_scanned = 0, nr_isolated = 0; |
| 271 | 263 | struct list_head *migratelist = &cc->migratepages; |
| 264 | + isolate_mode_t mode = ISOLATE_ACTIVE|ISOLATE_INACTIVE; | |
| 272 | 265 | |
| 273 | 266 | /* Do not scan outside zone boundaries */ |
| 274 | 267 | low_pfn = max(cc->migrate_pfn, zone->zone_start_pfn); |
| @@ -356,8 +349,11 @@ static isolate_migrate_t isolate_migratepages(struct zone *zone, · 81 unmodified lines | ||
| 356 | 349 | continue; |
| 357 | 350 | } |
| 358 | 351 | |
| 352 | + if (!cc->sync) | |
| 353 | + mode |= ISOLATE_CLEAN; | |
| 354 | + | |
| 359 | 355 | /* Try isolate the page */ |
| 360 | − if (__isolate_lru_page(page, ISOLATE_BOTH, 0) != 0) | |
| 356 | + if (__isolate_lru_page(page, mode, 0) != 0) | |
| 361 | 357 | continue; |
| 362 | 358 | |
| 363 | 359 | VM_BUG_ON(PageTransCompound(page)); |
| @@ -586,7 +582,7 @@ out: · 222 unmodified lines | ||
| 586 | 582 | return ret; |
| 587 | 583 | } |
| 588 | 584 | |
| 589 | −unsigned long compact_zone_order(struct zone *zone, | |
| 585 | +static unsigned long compact_zone_order(struct zone *zone, | |
| 590 | 586 | int order, gfp_t gfp_mask, |
| 591 | 587 | bool sync) |
| 592 | 588 | { |
| @@ -1,7 +1,10 @@ | ||
| 1 | 1 | #include <linux/kernel.h> |
| 2 | +#include <linux/string.h> | |
| 2 | 3 | #include <linux/mm.h> |
| 4 | +#include <linux/highmem.h> | |
| 3 | 5 | #include <linux/page-debug-flags.h> |
| 4 | 6 | #include <linux/poison.h> |
| 7 | +#include <linux/ratelimit.h> | |
| 5 | 8 | |
| 6 | 9 | static inline void set_page_poison(struct page *page) |
| 7 | 10 | { |
| @@ -18,28 +21,13 @@ static inline bool page_poison(struct page *page) · 10 unmodified lines | ||
| 18 | 21 | return test_bit(PAGE_DEBUG_FLAG_POISON, &page->debug_flags); |
| 19 | 22 | } |
| 20 | 23 | |
| 21 | −static void poison_highpage(struct page *page) | |
| 22 | −{ | |
| 23 | − /* | |
| 24 | − * Page poisoning for highmem pages is not implemented. | |
| 25 | − * | |
| 26 | − * This can be called from interrupt contexts. | |
| 27 | − * So we need to create a new kmap_atomic slot for this | |
| 28 | − * application and it will need interrupt protection. | |
| 29 | − */ | |
| 30 | −} | |
| 31 | − | |
| 32 | 24 | static void poison_page(struct page *page) |
| 33 | 25 | { |
| 34 | − void *addr; | |
| 26 | + void *addr = kmap_atomic(page); | |
| 35 | 27 | |
| 36 | − if (PageHighMem(page)) { | |
| 37 | − poison_highpage(page); | |
| 38 | − return; | |
| 39 | − } | |
| 40 | 28 | set_page_poison(page); |
| 41 | − addr = page_address(page); | |
| 42 | 29 | memset(addr, PAGE_POISON, PAGE_SIZE); |
| 30 | + kunmap_atomic(addr); | |
| 43 | 31 | } |
| 44 | 32 | |
| 45 | 33 | static void poison_pages(struct page *page, int n) |
| @@ -59,14 +47,12 @@ static bool single_bit_flip(unsigned char a, unsigned char b) · 13 unmodified lines | ||
| 59 | 47 | |
| 60 | 48 | static void check_poison_mem(unsigned char *mem, size_t bytes) |
| 61 | 49 | { |
| 50 | + static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 10); | |
| 62 | 51 | unsigned char *start; |
| 63 | 52 | unsigned char *end; |
| 64 | 53 | |
| 65 | − for (start = mem; start < mem + bytes; start++) { | |
| 66 | − if (*start != PAGE_POISON) | |
| 67 | − break; | |
| 68 | − } | |
| 69 | − if (start == mem + bytes) | |
| 54 | + start = memchr_inv(mem, PAGE_POISON, bytes); | |
| 55 | + if (!start) | |
| 70 | 56 | return; |
| 71 | 57 | |
| 72 | 58 | for (end = mem + bytes - 1; end > start; end--) { |
| @@ -74,7 +60,7 @@ static void check_poison_mem(unsigned char *mem, size_t bytes) · 1 unmodified line | ||
| 74 | 60 | break; |
| 75 | 61 | } |
| 76 | 62 | |
| 77 | − if (!printk_ratelimit()) | |
| 63 | + if (!__ratelimit(&ratelimit)) | |
| 78 | 64 | return; |
| 79 | 65 | else if (start == end && single_bit_flip(*start, PAGE_POISON)) |
| 80 | 66 | printk(KERN_ERR "pagealloc: single bit error\n"); |
| @@ -86,27 +72,17 @@ static void check_poison_mem(unsigned char *mem, size_t bytes) · 5 unmodified lines | ||
| 86 | 72 | dump_stack(); |
| 87 | 73 | } |
| 88 | 74 | |
| 89 | −static void unpoison_highpage(struct page *page) | |
| 90 | −{ | |
| 91 | − /* | |
| 92 | − * See comment in poison_highpage(). | |
| 93 | − * Highmem pages should not be poisoned for now | |
| 94 | − */ | |
| 95 | − BUG_ON(page_poison(page)); | |
| 96 | −} | |
| 97 | − | |
| 98 | 75 | static void unpoison_page(struct page *page) |
| 99 | 76 | { |
| 100 | − if (PageHighMem(page)) { | |
| 101 | − unpoison_highpage(page); | |
| 77 | + void *addr; | |
| 78 | + | |
| 79 | + if (!page_poison(page)) | |
| 102 | 80 | return; |
| 103 | − } | |
| 104 | − if (page_poison(page)) { | |
| 105 | − void *addr = page_address(page); | |
| 106 | 81 | |
| 107 | − check_poison_mem(addr, PAGE_SIZE); | |
| 108 | − clear_page_poison(page); | |
| 109 | − } | |
| 82 | + addr = kmap_atomic(page); | |
| 83 | + check_poison_mem(addr, PAGE_SIZE); | |
| 84 | + clear_page_poison(page); | |
| 85 | + kunmap_atomic(addr); | |
| 110 | 86 | } |
| 111 | 87 | |
| 112 | 88 | static void unpoison_pages(struct page *page, int n) |
| @@ -250,7 +250,7 @@ void *kmap_high_get(struct page *page) · 249 unmodified lines | ||
| 250 | 250 | #endif |
| 251 | 251 | |
| 252 | 252 | /** |
| 253 | − * kunmap_high - map a highmem page into memory | |
| 253 | + * kunmap_high - unmap a highmem page into memory | |
| 254 | 254 | * @page: &struct page to unmap |
| 255 | 255 | * |
| 256 | 256 | * If ARCH_NEEDS_KMAP_HIGH_GET is not defined then this may be called |
| @@ -89,7 +89,8 @@ struct khugepaged_scan { · 88 unmodified lines | ||
| 89 | 89 | struct list_head mm_head; |
| 90 | 90 | struct mm_slot *mm_slot; |
| 91 | 91 | unsigned long address; |
| 92 | −} khugepaged_scan = { | |
| 92 | +}; | |
| 93 | +static struct khugepaged_scan khugepaged_scan = { | |
| 93 | 94 | .mm_head = LIST_HEAD_INIT(khugepaged_scan.mm_head), |
| 94 | 95 | }; |
| 95 | 96 | |
| @@ -829,7 +830,7 @@ static int do_huge_pmd_wp_page_fallback(struct mm_struct *mm, · 733 unmodified lines | ||
| 829 | 830 | |
| 830 | 831 | for (i = 0; i < HPAGE_PMD_NR; i++) { |
| 831 | 832 | copy_user_highpage(pages[i], page + i, |
| 832 | − haddr + PAGE_SHIFT*i, vma); | |
| 833 | + haddr + PAGE_SIZE * i, vma); | |
| 833 | 834 | __SetPageUptodate(pages[i]); |
| 834 | 835 | cond_resched(); |
| 835 | 836 | } |
| @@ -1052,6 +1053,51 @@ int mincore_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd, · 216 unmodified lines | ||
| 1052 | 1053 | return ret; |
| 1053 | 1054 | } |
| 1054 | 1055 | |
| 1056 | +int move_huge_pmd(struct vm_area_struct *vma, struct vm_area_struct *new_vma, | |
| 1057 | + unsigned long old_addr, | |
| 1058 | + unsigned long new_addr, unsigned long old_end, | |
| 1059 | + pmd_t *old_pmd, pmd_t *new_pmd) | |
| 1060 | +{ | |
| 1061 | + int ret = 0; | |
| 1062 | + pmd_t pmd; | |
| 1063 | + | |
| 1064 | + struct mm_struct *mm = vma->vm_mm; | |
| 1065 | + | |
| 1066 | + if ((old_addr & ~HPAGE_PMD_MASK) || | |
| 1067 | + (new_addr & ~HPAGE_PMD_MASK) || | |
| 1068 | + old_end - old_addr < HPAGE_PMD_SIZE || | |
| 1069 | + (new_vma->vm_flags & VM_NOHUGEPAGE)) | |
| 1070 | + goto out; | |
| 1071 | + | |
| 1072 | + /* | |
| 1073 | + * The destination pmd shouldn't be established, free_pgtables() | |
| 1074 | + * should have release it. | |
| 1075 | + */ | |
| 1076 | + if (WARN_ON(!pmd_none(*new_pmd))) { | |
| 1077 | + VM_BUG_ON(pmd_trans_huge(*new_pmd)); | |
| 1078 | + goto out; | |
| 1079 | + } | |
| 1080 | + | |
| 1081 | + spin_lock(&mm->page_table_lock); | |
| 1082 | + if (likely(pmd_trans_huge(*old_pmd))) { | |
| 1083 | + if (pmd_trans_splitting(*old_pmd)) { | |
| 1084 | + spin_unlock(&mm->page_table_lock); | |
| 1085 | + wait_split_huge_page(vma->anon_vma, old_pmd); | |
| 1086 | + ret = -1; | |
| 1087 | + } else { | |
| 1088 | + pmd = pmdp_get_and_clear(mm, old_addr, old_pmd); | |
| 1089 | + VM_BUG_ON(!pmd_none(*new_pmd)); | |
| 1090 | + set_pmd_at(mm, new_addr, new_pmd, pmd); | |
| 1091 | + spin_unlock(&mm->page_table_lock); | |
| 1092 | + ret = 1; | |
| 1093 | + } | |
| 1094 | + } else { | |
| 1095 | + spin_unlock(&mm->page_table_lock); | |
| 1096 | + } | |
| 1097 | +out: | |
| 1098 | + return ret; | |
| 1099 | +} | |
| 1100 | + | |
| 1055 | 1101 | int change_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd, |
| 1056 | 1102 | unsigned long addr, pgprot_t newprot) |
| 1057 | 1103 | { |
| @@ -1906,7 +1952,7 @@ static void collapse_huge_page(struct mm_struct *mm, · 848 unmodified lines | ||
| 1906 | 1952 | BUG_ON(!pmd_none(*pmd)); |
| 1907 | 1953 | page_add_new_anon_rmap(new_page, vma, address); |
| 1908 | 1954 | set_pmd_at(mm, address, pmd, _pmd); |
| 1909 | − update_mmu_cache(vma, address, entry); | |
| 1955 | + update_mmu_cache(vma, address, _pmd); | |
| 1910 | 1956 | prepare_pmd_huge_pte(pgtable, mm); |
| 1911 | 1957 | mm->nr_ptes--; |
| 1912 | 1958 | spin_unlock(&mm->page_table_lock); |
| @@ -2024,6 +2070,8 @@ static void collect_mm_slot(struct mm_slot *mm_slot) · 111 unmodified lines | ||
| 2024 | 2070 | |
| 2025 | 2071 | static unsigned int khugepaged_scan_mm_slot(unsigned int pages, |
| 2026 | 2072 | struct page **hpage) |
| 2073 | + __releases(&khugepaged_mm_lock) | |
| 2074 | + __acquires(&khugepaged_mm_lock) | |
| 2027 | 2075 | { |
| 2028 | 2076 | struct mm_slot *mm_slot; |
| 2029 | 2077 | struct mm_struct *mm; |
| @@ -1905,7 +1905,8 @@ static ssize_t run_store(struct kobject *kobj, struct kobj_attribute *attr, · 1904 unmodified lines | ||
| 1905 | 1905 | |
| 1906 | 1906 | oom_score_adj = test_set_oom_score_adj(OOM_SCORE_ADJ_MAX); |
| 1907 | 1907 | err = unmerge_and_remove_all_rmap_items(); |
| 1908 | − test_set_oom_score_adj(oom_score_adj); | |
| 1908 | + compare_swap_oom_score_adj(OOM_SCORE_ADJ_MAX, | |
| 1909 | + oom_score_adj); | |
| 1909 | 1910 | if (err) { |
| 1910 | 1911 | ksm_run = KSM_RUN_STOP; |
| 1911 | 1912 | count = err; |
| @@ -58,7 +58,8 @@ static unsigned long __init_memblock memblock_addrs_overlap(phys_addr_t base1, p · 57 unmodified lines | ||
| 58 | 58 | return ((base1 < (base2 + size2)) && (base2 < (base1 + size1))); |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | −long __init_memblock memblock_overlaps_region(struct memblock_type *type, phys_addr_t base, phys_addr_t size) | |
| 61 | +static long __init_memblock memblock_overlaps_region(struct memblock_type *type, | |
| 62 | + phys_addr_t base, phys_addr_t size) | |
| 62 | 63 | { |
| 63 | 64 | unsigned long i; |
| 64 | 65 | |
| @@ -267,7 +268,7 @@ static int __init_memblock memblock_double_array(struct memblock_type *type) · 202 unmodified lines | ||
| 267 | 268 | return 0; |
| 268 | 269 | } |
| 269 | 270 | |
| 270 | −extern int __init_memblock __weak memblock_memory_can_coalesce(phys_addr_t addr1, phys_addr_t size1, | |
| 271 | +int __init_memblock __weak memblock_memory_can_coalesce(phys_addr_t addr1, phys_addr_t size1, | |
| 271 | 272 | phys_addr_t addr2, phys_addr_t size2) |
| 272 | 273 | { |
| 273 | 274 | return 1; |
| @@ -626,6 +627,12 @@ phys_addr_t __init memblock_phys_mem_size(void) · 352 unmodified lines | ||
| 626 | 627 | return memblock.memory_size; |
| 627 | 628 | } |
| 628 | 629 | |
| 630 | +/* lowest address */ | |
| 631 | +phys_addr_t __init_memblock memblock_start_of_DRAM(void) | |
| 632 | +{ | |
| 633 | + return memblock.memory.regions[0].base; | |
| 634 | +} | |
| 635 | + | |
| 629 | 636 | phys_addr_t __init_memblock memblock_end_of_DRAM(void) |
| 630 | 637 | { |
| 631 | 638 | int idx = memblock.memory.cnt - 1; |
| @@ -1185,7 +1185,8 @@ mem_cgroup_get_reclaim_stat_from_page(struct page *page) · 1184 unmodified lines | ||
| 1185 | 1185 | unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan, |
| 1186 | 1186 | struct list_head *dst, |
| 1187 | 1187 | unsigned long *scanned, int order, |
| 1188 | − int mode, struct zone *z, | |
| 1188 | + isolate_mode_t mode, | |
| 1189 | + struct zone *z, | |
| 1189 | 1190 | struct mem_cgroup *mem_cont, |
| 1190 | 1191 | int active, int file) |
| 1191 | 1192 | { |
| @@ -1310,7 +1310,7 @@ int unpoison_memory(unsigned long pfn) · 1309 unmodified lines | ||
| 1310 | 1310 | * to the end. |
| 1311 | 1311 | */ |
| 1312 | 1312 | if (PageHuge(page)) { |
| 1313 | − pr_debug("MCE: Memory failure is now running on free hugepage %#lx\n", pfn); | |
| 1313 | + pr_info("MCE: Memory failure is now running on free hugepage %#lx\n", pfn); | |
| 1314 | 1314 | return 0; |
| 1315 | 1315 | } |
| 1316 | 1316 | if (TestClearPageHWPoison(p)) |
| @@ -1419,7 +1419,7 @@ static int soft_offline_huge_page(struct page *page, int flags) · 102 unmodified lines | ||
| 1419 | 1419 | |
| 1420 | 1420 | if (PageHWPoison(hpage)) { |
| 1421 | 1421 | put_page(hpage); |
| 1422 | − pr_debug("soft offline: %#lx hugepage already poisoned\n", pfn); | |
| 1422 | + pr_info("soft offline: %#lx hugepage already poisoned\n", pfn); | |
| 1423 | 1423 | return -EBUSY; |
| 1424 | 1424 | } |
| 1425 | 1425 | |
| @@ -1433,8 +1433,8 @@ static int soft_offline_huge_page(struct page *page, int flags) · 7 unmodified lines | ||
| 1433 | 1433 | list_for_each_entry_safe(page1, page2, &pagelist, lru) |
| 1434 | 1434 | put_page(page1); |
| 1435 | 1435 | |
| 1436 | − pr_debug("soft offline: %#lx: migration failed %d, type %lx\n", | |
| 1437 | − pfn, ret, page->flags); | |
| 1436 | + pr_info("soft offline: %#lx: migration failed %d, type %lx\n", | |
| 1437 | + pfn, ret, page->flags); | |
| 1438 | 1438 | if (ret > 0) |
| 1439 | 1439 | ret = -EIO; |
| 1440 | 1440 | return ret; |
| @@ -1505,7 +1505,7 @@ int soft_offline_page(struct page *page, int flags) · 64 unmodified lines | ||
| 1505 | 1505 | } |
| 1506 | 1506 | if (!PageLRU(page)) { |
| 1507 | 1507 | pr_info("soft_offline: %#lx: unknown non LRU page type %lx\n", |
| 1508 | − pfn, page->flags); | |
| 1508 | + pfn, page->flags); | |
| 1509 | 1509 | return -EIO; |
| 1510 | 1510 | } |
| 1511 | 1511 | |
| @@ -1566,7 +1566,7 @@ int soft_offline_page(struct page *page, int flags) · 54 unmodified lines | ||
| 1566 | 1566 | } |
| 1567 | 1567 | } else { |
| 1568 | 1568 | pr_info("soft offline: %#lx: isolation failed: %d, page count %d, type %lx\n", |
| 1569 | − pfn, ret, page_count(page), page->flags); | |
| 1569 | + pfn, ret, page_count(page), page->flags); | |
| 1570 | 1570 | } |
| 1571 | 1571 | if (ret) |
| 1572 | 1572 | return ret; |
| @@ -111,7 +111,7 @@ enum zone_type policy_zone = 0; · 110 unmodified lines | ||
| 111 | 111 | /* |
| 112 | 112 | * run-time system-wide default policy => local allocation |
| 113 | 113 | */ |
| 114 | −struct mempolicy default_policy = { | |
| 114 | +static struct mempolicy default_policy = { | |
| 115 | 115 | .refcnt = ATOMIC_INIT(1), /* never free it */ |
| 116 | 116 | .mode = MPOL_PREFERRED, |
| 117 | 117 | .flags = MPOL_F_LOCAL, |
| @@ -621,38 +621,18 @@ static int move_to_new_page(struct page *newpage, struct page *page, · 620 unmodified lines | ||
| 621 | 621 | return rc; |
| 622 | 622 | } |
| 623 | 623 | |
| 624 | −/* | |
| 625 | − * Obtain the lock on page, remove all ptes and migrate the page | |
| 626 | − * to the newly allocated page in newpage. | |
| 627 | − */ | |
| 628 | −static int unmap_and_move(new_page_t get_new_page, unsigned long private, | |
| 629 | − struct page *page, int force, bool offlining, bool sync) | |
| 624 | +static int __unmap_and_move(struct page *page, struct page *newpage, | |
| 625 | + int force, bool offlining, bool sync) | |
| 630 | 626 | { |
| 631 | − int rc = 0; | |
| 632 | − int *result = NULL; | |
| 633 | − struct page *newpage = get_new_page(page, private, &result); | |
| 627 | + int rc = -EAGAIN; | |
| 634 | 628 | int remap_swapcache = 1; |
| 635 | 629 | int charge = 0; |
| 636 | 630 | struct mem_cgroup *mem; |
| 637 | 631 | struct anon_vma *anon_vma = NULL; |
| 638 | 632 | |
| 639 | − if (!newpage) | |
| 640 | − return -ENOMEM; | |
| 641 | − | |
| 642 | − if (page_count(page) == 1) { | |
| 643 | − /* page was freed from under us. So we are done. */ | |
| 644 | − goto move_newpage; | |
| 645 | − } | |
| 646 | − if (unlikely(PageTransHuge(page))) | |
| 647 | − if (unlikely(split_huge_page(page))) | |
| 648 | − goto move_newpage; | |
| 649 | − | |
| 650 | − /* prepare cgroup just returns 0 or -ENOMEM */ | |
| 651 | − rc = -EAGAIN; | |
| 652 | − | |
| 653 | 633 | if (!trylock_page(page)) { |
| 654 | 634 | if (!force || !sync) |
| 655 | − goto move_newpage; | |
| 635 | + goto out; | |
| 656 | 636 | |
| 657 | 637 | /* |
| 658 | 638 | * It's not safe for direct compaction to call lock_page. |
| @@ -668,7 +648,7 @@ static int unmap_and_move(new_page_t get_new_page, unsigned long private, · 9 unmodified lines | ||
| 668 | 648 | * altogether. |
| 669 | 649 | */ |
| 670 | 650 | if (current->flags & PF_MEMALLOC) |
| 671 | − goto move_newpage; | |
| 651 | + goto out; | |
| 672 | 652 | |
| 673 | 653 | lock_page(page); |
| 674 | 654 | } |
| @@ -785,27 +765,52 @@ uncharge: · 110 unmodified lines | ||
| 785 | 765 | mem_cgroup_end_migration(mem, page, newpage, rc == 0); |
| 786 | 766 | unlock: |
| 787 | 767 | unlock_page(page); |
| 768 | +out: | |
| 769 | + return rc; | |
| 770 | +} | |
| 788 | 771 | |
| 789 | −move_newpage: | |
| 772 | +/* | |
| 773 | + * Obtain the lock on page, remove all ptes and migrate the page | |
| 774 | + * to the newly allocated page in newpage. | |
| 775 | + */ | |
| 776 | +static int unmap_and_move(new_page_t get_new_page, unsigned long private, | |
| 777 | + struct page *page, int force, bool offlining, bool sync) | |
| 778 | +{ | |
| 779 | + int rc = 0; | |
| 780 | + int *result = NULL; | |
| 781 | + struct page *newpage = get_new_page(page, private, &result); | |
| 782 | + | |
| 783 | + if (!newpage) | |
| 784 | + return -ENOMEM; | |
| 785 | + | |
| 786 | + if (page_count(page) == 1) { | |
| 787 | + /* page was freed from under us. So we are done. */ | |
| 788 | + goto out; | |
| 789 | + } | |
| 790 | + | |
| 791 | + if (unlikely(PageTransHuge(page))) | |
| 792 | + if (unlikely(split_huge_page(page))) | |
| 793 | + goto out; | |
| 794 | + | |
| 795 | + rc = __unmap_and_move(page, newpage, force, offlining, sync); | |
| 796 | +out: | |
| 790 | 797 | if (rc != -EAGAIN) { |
| 791 | − /* | |
| 792 | − * A page that has been migrated has all references | |
| 793 | − * removed and will be freed. A page that has not been | |
| 794 | − * migrated will have kepts its references and be | |
| 795 | − * restored. | |
| 796 | − */ | |
| 797 | − list_del(&page->lru); | |
| 798 | + /* | |
| 799 | + * A page that has been migrated has all references | |
| 800 | + * removed and will be freed. A page that has not been | |
| 801 | + * migrated will have kepts its references and be | |
| 802 | + * restored. | |
| 803 | + */ | |
| 804 | + list_del(&page->lru); | |
| 798 | 805 | dec_zone_page_state(page, NR_ISOLATED_ANON + |
| 799 | 806 | page_is_file_cache(page)); |
| 800 | 807 | putback_lru_page(page); |
| 801 | 808 | } |
| 802 | − | |
| 803 | 809 | /* |
| 804 | 810 | * Move the new page to the LRU. If migration was not successful |
| 805 | 811 | * then this will free the page. |
| 806 | 812 | */ |
| 807 | 813 | putback_lru_page(newpage); |
| 808 | − | |
| 809 | 814 | if (result) { |
| 810 | 815 | if (rc) |
| 811 | 816 | *result = rc; |
| @@ -110,7 +110,15 @@ void munlock_vma_page(struct page *page) · 109 unmodified lines | ||
| 110 | 110 | if (TestClearPageMlocked(page)) { |
| 111 | 111 | dec_zone_page_state(page, NR_MLOCK); |
| 112 | 112 | if (!isolate_lru_page(page)) { |
| 113 | − int ret = try_to_munlock(page); | |
| 113 | + int ret = SWAP_AGAIN; | |
| 114 | + | |
| 115 | + /* | |
| 116 | + * Optimization: if the page was mapped just once, | |
| 117 | + * that's our mapping and we don't need to check all the | |
| 118 | + * other vmas. | |
| 119 | + */ | |
| 120 | + if (page_mapcount(page) > 1) | |
| 121 | + ret = try_to_munlock(page); | |
| 114 | 122 | /* |
| 115 | 123 | * did try_to_unlock() succeed or punt? |
| 116 | 124 | */ |
| @@ -549,7 +557,8 @@ SYSCALL_DEFINE1(mlockall, int, flags) · 432 unmodified lines | ||
| 549 | 557 | if (!can_do_mlock()) |
| 550 | 558 | goto out; |
| 551 | 559 | |
| 552 | − lru_add_drain_all(); /* flush pagevec */ | |
| 560 | + if (flags & MCL_CURRENT) | |
| 561 | + lru_add_drain_all(); /* flush pagevec */ | |
| 553 | 562 | |
| 554 | 563 | down_write(¤t->mm->mmap_sem); |
| 555 | 564 | |
| @@ -2558,7 +2558,6 @@ int mm_take_all_locks(struct mm_struct *mm) · 2557 unmodified lines | ||
| 2558 | 2558 | { |
| 2559 | 2559 | struct vm_area_struct *vma; |
| 2560 | 2560 | struct anon_vma_chain *avc; |
| 2561 | − int ret = -EINTR; | |
| 2562 | 2561 | |
| 2563 | 2562 | BUG_ON(down_read_trylock(&mm->mmap_sem)); |
| 2564 | 2563 | |
| @@ -2579,13 +2578,11 @@ int mm_take_all_locks(struct mm_struct *mm) · 14 unmodified lines | ||
| 2579 | 2578 | vm_lock_anon_vma(mm, avc->anon_vma); |
| 2580 | 2579 | } |
| 2581 | 2580 | |
| 2582 | − ret = 0; | |
| 2581 | + return 0; | |
| 2583 | 2582 | |
| 2584 | 2583 | out_unlock: |
| 2585 | − if (ret) | |
| 2586 | − mm_drop_all_locks(mm); | |
| 2587 | − | |
| 2588 | − return ret; | |
| 2584 | + mm_drop_all_locks(mm); | |
| 2585 | + return -EINTR; | |
| 2589 | 2586 | } |
| 2590 | 2587 | |
| 2591 | 2588 | static void vm_unlock_anon_vma(struct anon_vma *anon_vma) |
| @@ -41,8 +41,7 @@ static pmd_t *get_old_pmd(struct mm_struct *mm, unsigned long addr) · 40 unmodified lines | ||
| 41 | 41 | return NULL; |
| 42 | 42 | |
| 43 | 43 | pmd = pmd_offset(pud, addr); |
| 44 | − split_huge_page_pmd(mm, pmd); | |
| 45 | − if (pmd_none_or_clear_bad(pmd)) | |
| 44 | + if (pmd_none(*pmd)) | |
| 46 | 45 | return NULL; |
| 47 | 46 | |
| 48 | 47 | return pmd; |
| @@ -65,8 +64,6 @@ static pmd_t *alloc_new_pmd(struct mm_struct *mm, struct vm_area_struct *vma, · 16 unmodified lines | ||
| 65 | 64 | return NULL; |
| 66 | 65 | |
| 67 | 66 | VM_BUG_ON(pmd_trans_huge(*pmd)); |
| 68 | − if (pmd_none(*pmd) && __pte_alloc(mm, vma, pmd, addr)) | |
| 69 | − return NULL; | |
| 70 | 67 | |
| 71 | 68 | return pmd; |
| 72 | 69 | } |
| @@ -80,11 +77,7 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd, · 7 unmodified lines | ||
| 80 | 77 | struct mm_struct *mm = vma->vm_mm; |
| 81 | 78 | pte_t *old_pte, *new_pte, pte; |
| 82 | 79 | spinlock_t *old_ptl, *new_ptl; |
| 83 | − unsigned long old_start; | |
| 84 | 80 | |
| 85 | − old_start = old_addr; | |
| 86 | − mmu_notifier_invalidate_range_start(vma->vm_mm, | |
| 87 | − old_start, old_end); | |
| 88 | 81 | if (vma->vm_file) { |
| 89 | 82 | /* |
| 90 | 83 | * Subtle point from Rajesh Venkatasubramanian: before |
| @@ -111,7 +104,7 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd, · 20 unmodified lines | ||
| 111 | 104 | new_pte++, new_addr += PAGE_SIZE) { |
| 112 | 105 | if (pte_none(*old_pte)) |
| 113 | 106 | continue; |
| 114 | − pte = ptep_clear_flush(vma, old_addr, old_pte); | |
| 107 | + pte = ptep_get_and_clear(mm, old_addr, old_pte); | |
| 115 | 108 | pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr); |
| 116 | 109 | set_pte_at(mm, new_addr, new_pte, pte); |
| 117 | 110 | } |
| @@ -123,7 +116,6 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd, · 5 unmodified lines | ||
| 123 | 116 | pte_unmap_unlock(old_pte - 1, old_ptl); |
| 124 | 117 | if (mapping) |
| 125 | 118 | mutex_unlock(&mapping->i_mmap_mutex); |
| 126 | − mmu_notifier_invalidate_range_end(vma->vm_mm, old_start, old_end); | |
| 127 | 119 | } |
| 128 | 120 | |
| 129 | 121 | #define LATENCY_LIMIT (64 * PAGE_SIZE) |
| @@ -134,22 +126,43 @@ unsigned long move_page_tables(struct vm_area_struct *vma, · 4 unmodified lines | ||
| 134 | 126 | { |
| 135 | 127 | unsigned long extent, next, old_end; |
| 136 | 128 | pmd_t *old_pmd, *new_pmd; |
| 129 | + bool need_flush = false; | |
| 137 | 130 | |
| 138 | 131 | old_end = old_addr + len; |
| 139 | 132 | flush_cache_range(vma, old_addr, old_end); |
| 140 | 133 | |
| 134 | + mmu_notifier_invalidate_range_start(vma->vm_mm, old_addr, old_end); | |
| 135 | + | |
| 141 | 136 | for (; old_addr < old_end; old_addr += extent, new_addr += extent) { |
| 142 | 137 | cond_resched(); |
| 143 | 138 | next = (old_addr + PMD_SIZE) & PMD_MASK; |
| 144 | − if (next - 1 > old_end) | |
| 145 | − next = old_end; | |
| 139 | + /* even if next overflowed, extent below will be ok */ | |
| 146 | 140 | extent = next - old_addr; |
| 141 | + if (extent > old_end - old_addr) | |
| 142 | + extent = old_end - old_addr; | |
| 147 | 143 | old_pmd = get_old_pmd(vma->vm_mm, old_addr); |
| 148 | 144 | if (!old_pmd) |
| 149 | 145 | continue; |
| 150 | 146 | new_pmd = alloc_new_pmd(vma->vm_mm, vma, new_addr); |
| 151 | 147 | if (!new_pmd) |
| 152 | 148 | break; |
| 149 | + if (pmd_trans_huge(*old_pmd)) { | |
| 150 | + int err = 0; | |
| 151 | + if (extent == HPAGE_PMD_SIZE) | |
| 152 | + err = move_huge_pmd(vma, new_vma, old_addr, | |
| 153 | + new_addr, old_end, | |
| 154 | + old_pmd, new_pmd); | |
| 155 | + if (err > 0) { | |
| 156 | + need_flush = true; | |
| 157 | + continue; | |
| 158 | + } else if (!err) { | |
| 159 | + split_huge_page_pmd(vma->vm_mm, old_pmd); | |
| 160 | + } | |
| 161 | + VM_BUG_ON(pmd_trans_huge(*old_pmd)); | |
| 162 | + } | |
| 163 | + if (pmd_none(*new_pmd) && __pte_alloc(new_vma->vm_mm, new_vma, | |
| 164 | + new_pmd, new_addr)) | |
| 165 | + break; | |
| 153 | 166 | next = (new_addr + PMD_SIZE) & PMD_MASK; |
| 154 | 167 | if (extent > next - new_addr) |
| 155 | 168 | extent = next - new_addr; |
| @@ -157,7 +170,12 @@ unsigned long move_page_tables(struct vm_area_struct *vma, · 1 unmodified line | ||
| 157 | 170 | extent = LATENCY_LIMIT; |
| 158 | 171 | move_ptes(vma, old_pmd, old_addr, old_addr + extent, |
| 159 | 172 | new_vma, new_pmd, new_addr); |
| 173 | + need_flush = true; | |
| 160 | 174 | } |
| 175 | + if (likely(need_flush)) | |
| 176 | + flush_tlb_range(vma, old_end-len, old_addr); | |
| 177 | + | |
| 178 | + mmu_notifier_invalidate_range_end(vma->vm_mm, old_end-len, old_end); | |
| 161 | 179 | |
| 162 | 180 | return len + old_addr - old_end; /* how much done */ |
| 163 | 181 | } |
| @@ -32,12 +32,32 @@ · 31 unmodified lines | ||
| 32 | 32 | #include <linux/mempolicy.h> |
| 33 | 33 | #include <linux/security.h> |
| 34 | 34 | #include <linux/ptrace.h> |
| 35 | +#include <linux/freezer.h> | |
| 35 | 36 | |
| 36 | 37 | int sysctl_panic_on_oom; |
| 37 | 38 | int sysctl_oom_kill_allocating_task; |
| 38 | 39 | int sysctl_oom_dump_tasks = 1; |
| 39 | 40 | static DEFINE_SPINLOCK(zone_scan_lock); |
| 40 | 41 | |
| 42 | +/* | |
| 43 | + * compare_swap_oom_score_adj() - compare and swap current's oom_score_adj | |
| 44 | + * @old_val: old oom_score_adj for compare | |
| 45 | + * @new_val: new oom_score_adj for swap | |
| 46 | + * | |
| 47 | + * Sets the oom_score_adj value for current to @new_val iff its present value is | |
| 48 | + * @old_val. Usually used to reinstate a previous value to prevent racing with | |
| 49 | + * userspacing tuning the value in the interim. | |
| 50 | + */ | |
| 51 | +void compare_swap_oom_score_adj(int old_val, int new_val) | |
| 52 | +{ | |
| 53 | + struct sighand_struct *sighand = current->sighand; | |
| 54 | + | |
| 55 | + spin_lock_irq(&sighand->siglock); | |
| 56 | + if (current->signal->oom_score_adj == old_val) | |
| 57 | + current->signal->oom_score_adj = new_val; | |
| 58 | + spin_unlock_irq(&sighand->siglock); | |
| 59 | +} | |
| 60 | + | |
| 41 | 61 | /** |
| 42 | 62 | * test_set_oom_score_adj() - set current's oom_score_adj and return old value |
| 43 | 63 | * @new_val: new oom_score_adj value |
| @@ -53,13 +73,7 @@ int test_set_oom_score_adj(int new_val) · 9 unmodified lines | ||
| 53 | 73 | |
| 54 | 74 | spin_lock_irq(&sighand->siglock); |
| 55 | 75 | old_val = current->signal->oom_score_adj; |
| 56 | − if (new_val != old_val) { | |
| 57 | − if (new_val == OOM_SCORE_ADJ_MIN) | |
| 58 | − atomic_inc(¤t->mm->oom_disable_count); | |
| 59 | − else if (old_val == OOM_SCORE_ADJ_MIN) | |
| 60 | − atomic_dec(¤t->mm->oom_disable_count); | |
| 61 | − current->signal->oom_score_adj = new_val; | |
| 62 | − } | |
| 76 | + current->signal->oom_score_adj = new_val; | |
| 63 | 77 | spin_unlock_irq(&sighand->siglock); |
| 64 | 78 | |
| 65 | 79 | return old_val; |
| @@ -171,16 +185,6 @@ unsigned int oom_badness(struct task_struct *p, struct mem_cgroup *mem, · 105 unmodified lines | ||
| 171 | 185 | if (!p) |
| 172 | 186 | return 0; |
| 173 | 187 | |
| 174 | − /* | |
| 175 | − * Shortcut check for a thread sharing p->mm that is OOM_SCORE_ADJ_MIN | |
| 176 | − * so the entire heuristic doesn't need to be executed for something | |
| 177 | − * that cannot be killed. | |
| 178 | − */ | |
| 179 | − if (atomic_read(&p->mm->oom_disable_count)) { | |
| 180 | − task_unlock(p); | |
| 181 | − return 0; | |
| 182 | − } | |
| 183 | − | |
| 184 | 188 | /* |
| 185 | 189 | * The memory controller may have a limit of 0 bytes, so avoid a divide |
| 186 | 190 | * by zero, if necessary. |
| @@ -317,8 +321,11 @@ static struct task_struct *select_bad_process(unsigned int *ppoints, · 130 unmodified lines | ||
| 317 | 321 | * blocked waiting for another task which itself is waiting |
| 318 | 322 | * for memory. Is there a better alternative? |
| 319 | 323 | */ |
| 320 | − if (test_tsk_thread_flag(p, TIF_MEMDIE)) | |
| 324 | + if (test_tsk_thread_flag(p, TIF_MEMDIE)) { | |
| 325 | + if (unlikely(frozen(p))) | |
| 326 | + thaw_process(p); | |
| 321 | 327 | return ERR_PTR(-1UL); |
| 328 | + } | |
| 322 | 329 | if (!p->mm) |
| 323 | 330 | continue; |
| 324 | 331 | |
| @@ -435,7 +442,7 @@ static int oom_kill_task(struct task_struct *p, struct mem_cgroup *mem) · 110 unmodified lines | ||
| 435 | 442 | task_unlock(p); |
| 436 | 443 | |
| 437 | 444 | /* |
| 438 | − * Kill all processes sharing p->mm in other thread groups, if any. | |
| 445 | + * Kill all user processes sharing p->mm in other thread groups, if any. | |
| 439 | 446 | * They don't get access to memory reserves or a higher scheduler |
| 440 | 447 | * priority, though, to avoid depletion of all memory or task |
| 441 | 448 | * starvation. This prevents mm->mmap_sem livelock when an oom killed |
| @@ -445,7 +452,11 @@ static int oom_kill_task(struct task_struct *p, struct mem_cgroup *mem) · 3 unmodified lines | ||
| 445 | 452 | * signal. |
| 446 | 453 | */ |
| 447 | 454 | for_each_process(q) |
| 448 | − if (q->mm == mm && !same_thread_group(q, p)) { | |
| 455 | + if (q->mm == mm && !same_thread_group(q, p) && | |
| 456 | + !(q->flags & PF_KTHREAD)) { | |
| 457 | + if (q->signal->oom_score_adj == OOM_SCORE_ADJ_MIN) | |
| 458 | + continue; | |
| 459 | + | |
| 449 | 460 | task_lock(q); /* Protect ->comm from prctl() */ |
| 450 | 461 | pr_err("Kill process %d (%s) sharing same memory\n", |
| 451 | 462 | task_pid_nr(q), q->comm); |
| @@ -722,7 +733,7 @@ void out_of_memory(struct zonelist *zonelist, gfp_t gfp_mask, · 270 unmodified lines | ||
| 722 | 733 | read_lock(&tasklist_lock); |
| 723 | 734 | if (sysctl_oom_kill_allocating_task && |
| 724 | 735 | !oom_unkillable_task(current, NULL, nodemask) && |
| 725 | − current->mm && !atomic_read(¤t->mm->oom_disable_count)) { | |
| 736 | + current->mm) { | |
| 726 | 737 | /* |
| 727 | 738 | * oom_kill_process() needs tasklist_lock held. If it returns |
| 728 | 739 | * non-zero, current could not be killed so we must fallback to |
| @@ -305,7 +305,9 @@ static unsigned long task_min_dirty_limit(unsigned long bdi_dirty) · 304 unmodified lines | ||
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | /* |
| 308 | − * | |
| 308 | + * bdi_min_ratio keeps the sum of the minimum dirty shares of all | |
| 309 | + * registered backing devices, which, for obvious reasons, can not | |
| 310 | + * exceed 100%. | |
| 309 | 311 | */ |
| 310 | 312 | static unsigned int bdi_min_ratio; |
| 311 | 313 | |
| @@ -318,6 +318,7 @@ static void bad_page(struct page *page) · 317 unmodified lines | ||
| 318 | 318 | current->comm, page_to_pfn(page)); |
| 319 | 319 | dump_page(page); |
| 320 | 320 | |
| 321 | + print_modules(); | |
| 321 | 322 | dump_stack(); |
| 322 | 323 | out: |
| 323 | 324 | /* Leave bad fields for debug, except PageBuddy could make trouble */ |
| @@ -1753,7 +1754,6 @@ static DEFINE_RATELIMIT_STATE(nopage_rs, · 1429 unmodified lines | ||
| 1753 | 1754 | |
| 1754 | 1755 | void warn_alloc_failed(gfp_t gfp_mask, int order, const char *fmt, ...) |
| 1755 | 1756 | { |
| 1756 | − va_list args; | |
| 1757 | 1757 | unsigned int filter = SHOW_MEM_FILTER_NODES; |
| 1758 | 1758 | |
| 1759 | 1759 | if ((gfp_mask & __GFP_NOWARN) || !__ratelimit(&nopage_rs)) |
| @@ -1772,14 +1772,21 @@ void warn_alloc_failed(gfp_t gfp_mask, int order, const char *fmt, ...) · 12 unmodified lines | ||
| 1772 | 1772 | filter &= ~SHOW_MEM_FILTER_NODES; |
| 1773 | 1773 | |
| 1774 | 1774 | if (fmt) { |
| 1775 | − printk(KERN_WARNING); | |
| 1775 | + struct va_format vaf; | |
| 1776 | + va_list args; | |
| 1777 | + | |
| 1776 | 1778 | va_start(args, fmt); |
| 1777 | − vprintk(fmt, args); | |
| 1779 | + | |
| 1780 | + vaf.fmt = fmt; | |
| 1781 | + vaf.va = &args; | |
| 1782 | + | |
| 1783 | + pr_warn("%pV", &vaf); | |
| 1784 | + | |
| 1778 | 1785 | va_end(args); |
| 1779 | 1786 | } |
| 1780 | 1787 | |
| 1781 | − pr_warning("%s: page allocation failure: order:%d, mode:0x%x\n", | |
| 1782 | − current->comm, order, gfp_mask); | |
| 1788 | + pr_warn("%s: page allocation failure: order:%d, mode:0x%x\n", | |
| 1789 | + current->comm, order, gfp_mask); | |
| 1783 | 1790 | |
| 1784 | 1791 | dump_stack(); |
| 1785 | 1792 | if (!should_suppress_show_mem()) |
| @@ -0,0 +1,496 @@ | ||
| 1 | +/* | |
| 2 | + * linux/mm/process_vm_access.c | |
| 3 | + * | |
| 4 | + * Copyright (C) 2010-2011 Christopher Yeoh <cyeoh@au1.ibm.com>, IBM Corp. | |
| 5 | + * | |
| 6 | + * This program is free software; you can redistribute it and/or | |
| 7 | + * modify it under the terms of the GNU General Public License | |
| 8 | + * as published by the Free Software Foundation; either version | |
| 9 | + * 2 of the License, or (at your option) any later version. | |
| 10 | + */ | |
| 11 | + | |
| 12 | +#include <linux/mm.h> | |
| 13 | +#include <linux/uio.h> | |
| 14 | +#include <linux/sched.h> | |
| 15 | +#include <linux/highmem.h> | |
| 16 | +#include <linux/ptrace.h> | |
| 17 | +#include <linux/slab.h> | |
| 18 | +#include <linux/syscalls.h> | |
| 19 | + | |
| 20 | +#ifdef CONFIG_COMPAT | |
| 21 | +#include <linux/compat.h> | |
| 22 | +#endif | |
| 23 | + | |
| 24 | +/** | |
| 25 | + * process_vm_rw_pages - read/write pages from task specified | |
| 26 | + * @task: task to read/write from | |
| 27 | + * @mm: mm for task | |
| 28 | + * @process_pages: struct pages area that can store at least | |
| 29 | + * nr_pages_to_copy struct page pointers | |
| 30 | + * @pa: address of page in task to start copying from/to | |
| 31 | + * @start_offset: offset in page to start copying from/to | |
| 32 | + * @len: number of bytes to copy | |
| 33 | + * @lvec: iovec array specifying where to copy to/from | |
| 34 | + * @lvec_cnt: number of elements in iovec array | |
| 35 | + * @lvec_current: index in iovec array we are up to | |
| 36 | + * @lvec_offset: offset in bytes from current iovec iov_base we are up to | |
| 37 | + * @vm_write: 0 means copy from, 1 means copy to | |
| 38 | + * @nr_pages_to_copy: number of pages to copy | |
| 39 | + * @bytes_copied: returns number of bytes successfully copied | |
| 40 | + * Returns 0 on success, error code otherwise | |
| 41 | + */ | |
| 42 | +static int process_vm_rw_pages(struct task_struct *task, | |
| 43 | + struct mm_struct *mm, | |
| 44 | + struct page **process_pages, | |
| 45 | + unsigned long pa, | |
| 46 | + unsigned long start_offset, | |
| 47 | + unsigned long len, | |
| 48 | + const struct iovec *lvec, | |
| 49 | + unsigned long lvec_cnt, | |
| 50 | + unsigned long *lvec_current, | |
| 51 | + size_t *lvec_offset, | |
| 52 | + int vm_write, | |
| 53 | + unsigned int nr_pages_to_copy, | |
| 54 | + ssize_t *bytes_copied) | |
| 55 | +{ | |
| 56 | + int pages_pinned; | |
| 57 | + void *target_kaddr; | |
| 58 | + int pgs_copied = 0; | |
| 59 | + int j; | |
| 60 | + int ret; | |
| 61 | + ssize_t bytes_to_copy; | |
| 62 | + ssize_t rc = 0; | |
| 63 | + | |
| 64 | + *bytes_copied = 0; | |
| 65 | + | |
| 66 | + /* Get the pages we're interested in */ | |
| 67 | + down_read(&mm->mmap_sem); | |
| 68 | + pages_pinned = get_user_pages(task, mm, pa, | |
| 69 | + nr_pages_to_copy, | |
| 70 | + vm_write, 0, process_pages, NULL); | |
| 71 | + up_read(&mm->mmap_sem); | |
| 72 | + | |
| 73 | + if (pages_pinned != nr_pages_to_copy) { | |
| 74 | + rc = -EFAULT; | |
| 75 | + goto end; | |
| 76 | + } | |
| 77 | + | |
| 78 | + /* Do the copy for each page */ | |
| 79 | + for (pgs_copied = 0; | |
| 80 | + (pgs_copied < nr_pages_to_copy) && (*lvec_current < lvec_cnt); | |
| 81 | + pgs_copied++) { | |
| 82 | + /* Make sure we have a non zero length iovec */ | |
| 83 | + while (*lvec_current < lvec_cnt | |
| 84 | + && lvec[*lvec_current].iov_len == 0) | |
| 85 | + (*lvec_current)++; | |
| 86 | + if (*lvec_current == lvec_cnt) | |
| 87 | + break; | |
| 88 | + | |
| 89 | + /* | |
| 90 | + * Will copy smallest of: | |
| 91 | + * - bytes remaining in page | |
| 92 | + * - bytes remaining in destination iovec | |
| 93 | + */ | |
| 94 | + bytes_to_copy = min_t(ssize_t, PAGE_SIZE - start_offset, | |
| 95 | + len - *bytes_copied); | |
| 96 | + bytes_to_copy = min_t(ssize_t, bytes_to_copy, | |
| 97 | + lvec[*lvec_current].iov_len | |
| 98 | + - *lvec_offset); | |
| 99 | + | |
| 100 | + target_kaddr = kmap(process_pages[pgs_copied]) + start_offset; | |
| 101 | + | |
| 102 | + if (vm_write) | |
| 103 | + ret = copy_from_user(target_kaddr, | |
| 104 | + lvec[*lvec_current].iov_base | |
| 105 | + + *lvec_offset, | |
| 106 | + bytes_to_copy); | |
| 107 | + else | |
| 108 | + ret = copy_to_user(lvec[*lvec_current].iov_base | |
| 109 | + + *lvec_offset, | |
| 110 | + target_kaddr, bytes_to_copy); | |
| 111 | + kunmap(process_pages[pgs_copied]); | |
| 112 | + if (ret) { | |
| 113 | + *bytes_copied += bytes_to_copy - ret; | |
| 114 | + pgs_copied++; | |
| 115 | + rc = -EFAULT; | |
| 116 | + goto end; | |
| 117 | + } | |
| 118 | + *bytes_copied += bytes_to_copy; | |
| 119 | + *lvec_offset += bytes_to_copy; | |
| 120 | + if (*lvec_offset == lvec[*lvec_current].iov_len) { | |
| 121 | + /* | |
| 122 | + * Need to copy remaining part of page into the | |
| 123 | + * next iovec if there are any bytes left in page | |
| 124 | + */ | |
| 125 | + (*lvec_current)++; | |
| 126 | + *lvec_offset = 0; | |
| 127 | + start_offset = (start_offset + bytes_to_copy) | |
| 128 | + % PAGE_SIZE; | |
| 129 | + if (start_offset) | |
| 130 | + pgs_copied--; | |
| 131 | + } else { | |
| 132 | + start_offset = 0; | |
| 133 | + } | |
| 134 | + } | |
| 135 | + | |
| 136 | +end: | |
| 137 | + if (vm_write) { | |
| 138 | + for (j = 0; j < pages_pinned; j++) { | |
| 139 | + if (j < pgs_copied) | |
| 140 | + set_page_dirty_lock(process_pages[j]); | |
| 141 | + put_page(process_pages[j]); | |
| 142 | + } | |
| 143 | + } else { | |
| 144 | + for (j = 0; j < pages_pinned; j++) | |
| 145 | + put_page(process_pages[j]); | |
| 146 | + } | |
| 147 | + | |
| 148 | + return rc; | |
| 149 | +} | |
| 150 | + | |
| 151 | +/* Maximum number of pages kmalloc'd to hold struct page's during copy */ | |
| 152 | +#define PVM_MAX_KMALLOC_PAGES (PAGE_SIZE * 2) | |
| 153 | + | |
| 154 | +/** | |
| 155 | + * process_vm_rw_single_vec - read/write pages from task specified | |
| 156 | + * @addr: start memory address of target process | |
| 157 | + * @len: size of area to copy to/from | |
| 158 | + * @lvec: iovec array specifying where to copy to/from locally | |
| 159 | + * @lvec_cnt: number of elements in iovec array | |
| 160 | + * @lvec_current: index in iovec array we are up to | |
| 161 | + * @lvec_offset: offset in bytes from current iovec iov_base we are up to | |
| 162 | + * @process_pages: struct pages area that can store at least | |
| 163 | + * nr_pages_to_copy struct page pointers | |
| 164 | + * @mm: mm for task | |
| 165 | + * @task: task to read/write from | |
| 166 | + * @vm_write: 0 means copy from, 1 means copy to | |
| 167 | + * @bytes_copied: returns number of bytes successfully copied | |
| 168 | + * Returns 0 on success or on failure error code | |
| 169 | + */ | |
| 170 | +static int process_vm_rw_single_vec(unsigned long addr, | |
| 171 | + unsigned long len, | |
| 172 | + const struct iovec *lvec, | |
| 173 | + unsigned long lvec_cnt, | |
| 174 | + unsigned long *lvec_current, | |
| 175 | + size_t *lvec_offset, | |
| 176 | + struct page **process_pages, | |
| 177 | + struct mm_struct *mm, | |
| 178 | + struct task_struct *task, | |
| 179 | + int vm_write, | |
| 180 | + ssize_t *bytes_copied) | |
| 181 | +{ | |
| 182 | + unsigned long pa = addr & PAGE_MASK; | |
| 183 | + unsigned long start_offset = addr - pa; | |
| 184 | + unsigned long nr_pages; | |
| 185 | + ssize_t bytes_copied_loop; | |
| 186 | + ssize_t rc = 0; | |
| 187 | + unsigned long nr_pages_copied = 0; | |
| 188 | + unsigned long nr_pages_to_copy; | |
| 189 | + unsigned long max_pages_per_loop = PVM_MAX_KMALLOC_PAGES | |
| 190 | + / sizeof(struct pages *); | |
| 191 | + | |
| 192 | + *bytes_copied = 0; | |
| 193 | + | |
| 194 | + /* Work out address and page range required */ | |
| 195 | + if (len == 0) | |
| 196 | + return 0; | |
| 197 | + nr_pages = (addr + len - 1) / PAGE_SIZE - addr / PAGE_SIZE + 1; | |
| 198 | + | |
| 199 | + while ((nr_pages_copied < nr_pages) && (*lvec_current < lvec_cnt)) { | |
| 200 | + nr_pages_to_copy = min(nr_pages - nr_pages_copied, | |
| 201 | + max_pages_per_loop); | |
| 202 | + | |
| 203 | + rc = process_vm_rw_pages(task, mm, process_pages, pa, | |
| 204 | + start_offset, len, | |
| 205 | + lvec, lvec_cnt, | |
| 206 | + lvec_current, lvec_offset, | |
| 207 | + vm_write, nr_pages_to_copy, | |
| 208 | + &bytes_copied_loop); | |
| 209 | + start_offset = 0; | |
| 210 | + *bytes_copied += bytes_copied_loop; | |
| 211 | + | |
| 212 | + if (rc < 0) { | |
| 213 | + return rc; | |
| 214 | + } else { | |
| 215 | + len -= bytes_copied_loop; | |
| 216 | + nr_pages_copied += nr_pages_to_copy; | |
| 217 | + pa += nr_pages_to_copy * PAGE_SIZE; | |
| 218 | + } | |
| 219 | + } | |
| 220 | + | |
| 221 | + return rc; | |
| 222 | +} | |
| 223 | + | |
| 224 | +/* Maximum number of entries for process pages array | |
| 225 | + which lives on stack */ | |
| 226 | +#define PVM_MAX_PP_ARRAY_COUNT 16 | |
| 227 | + | |
| 228 | +/** | |
| 229 | + * process_vm_rw_core - core of reading/writing pages from task specified | |
| 230 | + * @pid: PID of process to read/write from/to | |
| 231 | + * @lvec: iovec array specifying where to copy to/from locally | |
| 232 | + * @liovcnt: size of lvec array | |
| 233 | + * @rvec: iovec array specifying where to copy to/from in the other process | |
| 234 | + * @riovcnt: size of rvec array | |
| 235 | + * @flags: currently unused | |
| 236 | + * @vm_write: 0 if reading from other process, 1 if writing to other process | |
| 237 | + * Returns the number of bytes read/written or error code. May | |
| 238 | + * return less bytes than expected if an error occurs during the copying | |
| 239 | + * process. | |
| 240 | + */ | |
| 241 | +static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec, | |
| 242 | + unsigned long liovcnt, | |
| 243 | + const struct iovec *rvec, | |
| 244 | + unsigned long riovcnt, | |
| 245 | + unsigned long flags, int vm_write) | |
| 246 | +{ | |
| 247 | + struct task_struct *task; | |
| 248 | + struct page *pp_stack[PVM_MAX_PP_ARRAY_COUNT]; | |
| 249 | + struct page **process_pages = pp_stack; | |
| 250 | + struct mm_struct *mm; | |
| 251 | + unsigned long i; | |
| 252 | + ssize_t rc = 0; | |
| 253 | + ssize_t bytes_copied_loop; | |
| 254 | + ssize_t bytes_copied = 0; | |
| 255 | + unsigned long nr_pages = 0; | |
| 256 | + unsigned long nr_pages_iov; | |
| 257 | + unsigned long iov_l_curr_idx = 0; | |
| 258 | + size_t iov_l_curr_offset = 0; | |
| 259 | + ssize_t iov_len; | |
| 260 | + | |
| 261 | + /* | |
| 262 | + * Work out how many pages of struct pages we're going to need | |
| 263 | + * when eventually calling get_user_pages | |
| 264 | + */ | |
| 265 | + for (i = 0; i < riovcnt; i++) { | |
| 266 | + iov_len = rvec[i].iov_len; | |
| 267 | + if (iov_len > 0) { | |
| 268 | + nr_pages_iov = ((unsigned long)rvec[i].iov_base | |
| 269 | + + iov_len) | |
| 270 | + / PAGE_SIZE - (unsigned long)rvec[i].iov_base | |
| 271 | + / PAGE_SIZE + 1; | |
| 272 | + nr_pages = max(nr_pages, nr_pages_iov); | |
| 273 | + } | |
| 274 | + } | |
| 275 | + | |
| 276 | + if (nr_pages == 0) | |
| 277 | + return 0; | |
| 278 | + | |
| 279 | + if (nr_pages > PVM_MAX_PP_ARRAY_COUNT) { | |
| 280 | + /* For reliability don't try to kmalloc more than | |
| 281 | + 2 pages worth */ | |
| 282 | + process_pages = kmalloc(min_t(size_t, PVM_MAX_KMALLOC_PAGES, | |
| 283 | + sizeof(struct pages *)*nr_pages), | |
| 284 | + GFP_KERNEL); | |
| 285 | + | |
| 286 | + if (!process_pages) | |
| 287 | + return -ENOMEM; | |
| 288 | + } | |
| 289 | + | |
| 290 | + /* Get process information */ | |
| 291 | + rcu_read_lock(); | |
| 292 | + task = find_task_by_vpid(pid); | |
| 293 | + if (task) | |
| 294 | + get_task_struct(task); | |
| 295 | + rcu_read_unlock(); | |
| 296 | + if (!task) { | |
| 297 | + rc = -ESRCH; | |
| 298 | + goto free_proc_pages; | |
| 299 | + } | |
| 300 | + | |
| 301 | + task_lock(task); | |
| 302 | + if (__ptrace_may_access(task, PTRACE_MODE_ATTACH)) { | |
| 303 | + task_unlock(task); | |
| 304 | + rc = -EPERM; | |
| 305 | + goto put_task_struct; | |
| 306 | + } | |
| 307 | + mm = task->mm; | |
| 308 | + | |
| 309 | + if (!mm || (task->flags & PF_KTHREAD)) { | |
| 310 | + task_unlock(task); | |
| 311 | + rc = -EINVAL; | |
| 312 | + goto put_task_struct; | |
| 313 | + } | |
| 314 | + | |
| 315 | + atomic_inc(&mm->mm_users); | |
| 316 | + task_unlock(task); | |
| 317 | + | |
| 318 | + for (i = 0; i < riovcnt && iov_l_curr_idx < liovcnt; i++) { | |
| 319 | + rc = process_vm_rw_single_vec( | |
| 320 | + (unsigned long)rvec[i].iov_base, rvec[i].iov_len, | |
| 321 | + lvec, liovcnt, &iov_l_curr_idx, &iov_l_curr_offset, | |
| 322 | + process_pages, mm, task, vm_write, &bytes_copied_loop); | |
| 323 | + bytes_copied += bytes_copied_loop; | |
| 324 | + if (rc != 0) { | |
| 325 | + /* If we have managed to copy any data at all then | |
| 326 | + we return the number of bytes copied. Otherwise | |
| 327 | + we return the error code */ | |
| 328 | + if (bytes_copied) | |
| 329 | + rc = bytes_copied; | |
| 330 | + goto put_mm; | |
| 331 | + } | |
| 332 | + } | |
| 333 | + | |
| 334 | + rc = bytes_copied; | |
| 335 | +put_mm: | |
| 336 | + mmput(mm); | |
| 337 | + | |
| 338 | +put_task_struct: | |
| 339 | + put_task_struct(task); | |
| 340 | + | |
| 341 | +free_proc_pages: | |
| 342 | + if (process_pages != pp_stack) | |
| 343 | + kfree(process_pages); | |
| 344 | + return rc; | |
| 345 | +} | |
| 346 | + | |
| 347 | +/** | |
| 348 | + * process_vm_rw - check iovecs before calling core routine | |
| 349 | + * @pid: PID of process to read/write from/to | |
| 350 | + * @lvec: iovec array specifying where to copy to/from locally | |
| 351 | + * @liovcnt: size of lvec array | |
| 352 | + * @rvec: iovec array specifying where to copy to/from in the other process | |
| 353 | + * @riovcnt: size of rvec array | |
| 354 | + * @flags: currently unused | |
| 355 | + * @vm_write: 0 if reading from other process, 1 if writing to other process | |
| 356 | + * Returns the number of bytes read/written or error code. May | |
| 357 | + * return less bytes than expected if an error occurs during the copying | |
| 358 | + * process. | |
| 359 | + */ | |
| 360 | +static ssize_t process_vm_rw(pid_t pid, | |
| 361 | + const struct iovec __user *lvec, | |
| 362 | + unsigned long liovcnt, | |
| 363 | + const struct iovec __user *rvec, | |
| 364 | + unsigned long riovcnt, | |
| 365 | + unsigned long flags, int vm_write) | |
| 366 | +{ | |
| 367 | + struct iovec iovstack_l[UIO_FASTIOV]; | |
| 368 | + struct iovec iovstack_r[UIO_FASTIOV]; | |
| 369 | + struct iovec *iov_l = iovstack_l; | |
| 370 | + struct iovec *iov_r = iovstack_r; | |
| 371 | + ssize_t rc; | |
| 372 | + | |
| 373 | + if (flags != 0) | |
| 374 | + return -EINVAL; | |
| 375 | + | |
| 376 | + /* Check iovecs */ | |
| 377 | + if (vm_write) | |
| 378 | + rc = rw_copy_check_uvector(WRITE, lvec, liovcnt, UIO_FASTIOV, | |
| 379 | + iovstack_l, &iov_l, 1); | |
| 380 | + else | |
| 381 | + rc = rw_copy_check_uvector(READ, lvec, liovcnt, UIO_FASTIOV, | |
| 382 | + iovstack_l, &iov_l, 1); | |
| 383 | + if (rc <= 0) | |
| 384 | + goto free_iovecs; | |
| 385 | + | |
| 386 | + rc = rw_copy_check_uvector(READ, rvec, riovcnt, UIO_FASTIOV, | |
| 387 | + iovstack_r, &iov_r, 0); | |
| 388 | + if (rc <= 0) | |
| 389 | + goto free_iovecs; | |
| 390 | + | |
| 391 | + rc = process_vm_rw_core(pid, iov_l, liovcnt, iov_r, riovcnt, flags, | |
| 392 | + vm_write); | |
| 393 | + | |
| 394 | +free_iovecs: | |
| 395 | + if (iov_r != iovstack_r) | |
| 396 | + kfree(iov_r); | |
| 397 | + if (iov_l != iovstack_l) | |
| 398 | + kfree(iov_l); | |
| 399 | + | |
| 400 | + return rc; | |
| 401 | +} | |
| 402 | + | |
| 403 | +SYSCALL_DEFINE6(process_vm_readv, pid_t, pid, const struct iovec __user *, lvec, | |
| 404 | + unsigned long, liovcnt, const struct iovec __user *, rvec, | |
| 405 | + unsigned long, riovcnt, unsigned long, flags) | |
| 406 | +{ | |
| 407 | + return process_vm_rw(pid, lvec, liovcnt, rvec, riovcnt, flags, 0); | |
| 408 | +} | |
| 409 | + | |
| 410 | +SYSCALL_DEFINE6(process_vm_writev, pid_t, pid, | |
| 411 | + const struct iovec __user *, lvec, | |
| 412 | + unsigned long, liovcnt, const struct iovec __user *, rvec, | |
| 413 | + unsigned long, riovcnt, unsigned long, flags) | |
| 414 | +{ | |
| 415 | + return process_vm_rw(pid, lvec, liovcnt, rvec, riovcnt, flags, 1); | |
| 416 | +} | |
| 417 | + | |
| 418 | +#ifdef CONFIG_COMPAT | |
| 419 | + | |
| 420 | +asmlinkage ssize_t | |
| 421 | +compat_process_vm_rw(compat_pid_t pid, | |
| 422 | + const struct compat_iovec __user *lvec, | |
| 423 | + unsigned long liovcnt, | |
| 424 | + const struct compat_iovec __user *rvec, | |
| 425 | + unsigned long riovcnt, | |
| 426 | + unsigned long flags, int vm_write) | |
| 427 | +{ | |
| 428 | + struct iovec iovstack_l[UIO_FASTIOV]; | |
| 429 | + struct iovec iovstack_r[UIO_FASTIOV]; | |
| 430 | + struct iovec *iov_l = iovstack_l; | |
| 431 | + struct iovec *iov_r = iovstack_r; | |
| 432 | + ssize_t rc = -EFAULT; | |
| 433 | + | |
| 434 | + if (flags != 0) | |
| 435 | + return -EINVAL; | |
| 436 | + | |
| 437 | + if (!access_ok(VERIFY_READ, lvec, liovcnt * sizeof(*lvec))) | |
| 438 | + goto out; | |
| 439 | + | |
| 440 | + if (!access_ok(VERIFY_READ, rvec, riovcnt * sizeof(*rvec))) | |
| 441 | + goto out; | |
| 442 | + | |
| 443 | + if (vm_write) | |
| 444 | + rc = compat_rw_copy_check_uvector(WRITE, lvec, liovcnt, | |
| 445 | + UIO_FASTIOV, iovstack_l, | |
| 446 | + &iov_l, 1); | |
| 447 | + else | |
| 448 | + rc = compat_rw_copy_check_uvector(READ, lvec, liovcnt, | |
| 449 | + UIO_FASTIOV, iovstack_l, | |
| 450 | + &iov_l, 1); | |
| 451 | + if (rc <= 0) | |
| 452 | + goto free_iovecs; | |
| 453 | + rc = compat_rw_copy_check_uvector(READ, rvec, riovcnt, | |
| 454 | + UIO_FASTIOV, iovstack_r, | |
| 455 | + &iov_r, 0); | |
| 456 | + if (rc <= 0) | |
| 457 | + goto free_iovecs; | |
| 458 | + | |
| 459 | + rc = process_vm_rw_core(pid, iov_l, liovcnt, iov_r, riovcnt, flags, | |
| 460 | + vm_write); | |
| 461 | + | |
| 462 | +free_iovecs: | |
| 463 | + if (iov_r != iovstack_r) | |
| 464 | + kfree(iov_r); | |
| 465 | + if (iov_l != iovstack_l) | |
| 466 | + kfree(iov_l); | |
| 467 | + | |
| 468 | +out: | |
| 469 | + return rc; | |
| 470 | +} | |
| 471 | + | |
| 472 | +asmlinkage ssize_t | |
| 473 | +compat_sys_process_vm_readv(compat_pid_t pid, | |
| 474 | + const struct compat_iovec __user *lvec, | |
| 475 | + unsigned long liovcnt, | |
| 476 | + const struct compat_iovec __user *rvec, | |
| 477 | + unsigned long riovcnt, | |
| 478 | + unsigned long flags) | |
| 479 | +{ | |
| 480 | + return compat_process_vm_rw(pid, lvec, liovcnt, rvec, | |
| 481 | + riovcnt, flags, 0); | |
| 482 | +} | |
| 483 | + | |
| 484 | +asmlinkage ssize_t | |
| 485 | +compat_sys_process_vm_writev(compat_pid_t pid, | |
| 486 | + const struct compat_iovec __user *lvec, | |
| 487 | + unsigned long liovcnt, | |
| 488 | + const struct compat_iovec __user *rvec, | |
| 489 | + unsigned long riovcnt, | |
| 490 | + unsigned long flags) | |
| 491 | +{ | |
| 492 | + return compat_process_vm_rw(pid, lvec, liovcnt, rvec, | |
| 493 | + riovcnt, flags, 1); | |
| 494 | +} | |
| 495 | + | |
| 496 | +#endif | |
| @@ -1164,7 +1164,7 @@ void page_remove_rmap(struct page *page) · 1163 unmodified lines | ||
| 1164 | 1164 | |
| 1165 | 1165 | /* |
| 1166 | 1166 | * Subfunctions of try_to_unmap: try_to_unmap_one called |
| 1167 | − * repeatedly from either try_to_unmap_anon or try_to_unmap_file. | |
| 1167 | + * repeatedly from try_to_unmap_ksm, try_to_unmap_anon or try_to_unmap_file. | |
| 1168 | 1168 | */ |
| 1169 | 1169 | int try_to_unmap_one(struct page *page, struct vm_area_struct *vma, |
| 1170 | 1170 | unsigned long address, enum ttu_flags flags) |
| @@ -1068,6 +1068,12 @@ int shmem_lock(struct file *file, int lock, struct user_struct *user) · 1067 unmodified lines | ||
| 1068 | 1068 | user_shm_unlock(inode->i_size, user); |
| 1069 | 1069 | info->flags &= ~VM_LOCKED; |
| 1070 | 1070 | mapping_clear_unevictable(file->f_mapping); |
| 1071 | + /* | |
| 1072 | + * Ensure that a racing putback_lru_page() can see | |
| 1073 | + * the pages of this mapping are evictable when we | |
| 1074 | + * skip them due to !PageLRU during the scan. | |
| 1075 | + */ | |
| 1076 | + smp_mb__after_clear_bit(); | |
| 1071 | 1077 | scan_mapping_unevictable_pages(file->f_mapping); |
| 1072 | 1078 | } |
| 1073 | 1079 | retval = 0; |
| @@ -655,49 +655,6 @@ static void init_object(struct kmem_cache *s, void *object, u8 val) · 654 unmodified lines | ||
| 655 | 655 | memset(p + s->objsize, val, s->inuse - s->objsize); |
| 656 | 656 | } |
| 657 | 657 | |
| 658 | −static u8 *check_bytes8(u8 *start, u8 value, unsigned int bytes) | |
| 659 | −{ | |
| 660 | − while (bytes) { | |
| 661 | − if (*start != value) | |
| 662 | − return start; | |
| 663 | − start++; | |
| 664 | − bytes--; | |
| 665 | − } | |
| 666 | − return NULL; | |
| 667 | −} | |
| 668 | − | |
| 669 | −static u8 *check_bytes(u8 *start, u8 value, unsigned int bytes) | |
| 670 | −{ | |
| 671 | − u64 value64; | |
| 672 | − unsigned int words, prefix; | |
| 673 | − | |
| 674 | − if (bytes <= 16) | |
| 675 | − return check_bytes8(start, value, bytes); | |
| 676 | − | |
| 677 | − value64 = value | value << 8 | value << 16 | value << 24; | |
| 678 | − value64 = (value64 & 0xffffffff) | value64 << 32; | |
| 679 | − prefix = 8 - ((unsigned long)start) % 8; | |
| 680 | − | |
| 681 | − if (prefix) { | |
| 682 | − u8 *r = check_bytes8(start, value, prefix); | |
| 683 | − if (r) | |
| 684 | − return r; | |
| 685 | − start += prefix; | |
| 686 | − bytes -= prefix; | |
| 687 | − } | |
| 688 | − | |
| 689 | − words = bytes / 8; | |
| 690 | − | |
| 691 | − while (words) { | |
| 692 | − if (*(u64 *)start != value64) | |
| 693 | − return check_bytes8(start, value, 8); | |
| 694 | − start += 8; | |
| 695 | − words--; | |
| 696 | − } | |
| 697 | − | |
| 698 | − return check_bytes8(start, value, bytes % 8); | |
| 699 | −} | |
| 700 | − | |
| 701 | 658 | static void restore_bytes(struct kmem_cache *s, char *message, u8 data, |
| 702 | 659 | void *from, void *to) |
| 703 | 660 | { |
| @@ -712,7 +669,7 @@ static int check_bytes_and_report(struct kmem_cache *s, struct page *page, · 8 unmodified lines | ||
| 712 | 669 | u8 *fault; |
| 713 | 670 | u8 *end; |
| 714 | 671 | |
| 715 | − fault = check_bytes(start, value, bytes); | |
| 672 | + fault = memchr_inv(start, value, bytes); | |
| 716 | 673 | if (!fault) |
| 717 | 674 | return 1; |
| 718 | 675 | |
| @@ -805,7 +762,7 @@ static int slab_pad_check(struct kmem_cache *s, struct page *page) · 86 unmodified lines | ||
| 805 | 762 | if (!remainder) |
| 806 | 763 | return 1; |
| 807 | 764 | |
| 808 | − fault = check_bytes(end - remainder, POISON_INUSE, remainder); | |
| 765 | + fault = memchr_inv(end - remainder, POISON_INUSE, remainder); | |
| 809 | 766 | if (!fault) |
| 810 | 767 | return 1; |
| 811 | 768 | while (end > fault && end[-1] == POISON_INUSE) |
| @@ -1617,7 +1617,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile) · 1616 unmodified lines | ||
| 1617 | 1617 | |
| 1618 | 1618 | oom_score_adj = test_set_oom_score_adj(OOM_SCORE_ADJ_MAX); |
| 1619 | 1619 | err = try_to_unuse(type); |
| 1620 | − test_set_oom_score_adj(oom_score_adj); | |
| 1620 | + compare_swap_oom_score_adj(OOM_SCORE_ADJ_MAX, oom_score_adj); | |
| 1621 | 1621 | |
| 1622 | 1622 | if (err) { |
| 1623 | 1623 | /* |
| @@ -29,7 +29,7 @@ · 28 unmodified lines | ||
| 29 | 29 | |
| 30 | 30 | static DEFINE_SPINLOCK(swap_token_lock); |
| 31 | 31 | struct mm_struct *swap_token_mm; |
| 32 | −struct mem_cgroup *swap_token_memcg; | |
| 32 | +static struct mem_cgroup *swap_token_memcg; | |
| 33 | 33 | |
| 34 | 34 | #ifdef CONFIG_CGROUP_MEM_RES_CTLR |
| 35 | 35 | static struct mem_cgroup *swap_token_memcg_from_mm(struct mm_struct *mm) |
| @@ -1253,18 +1253,22 @@ EXPORT_SYMBOL_GPL(map_vm_area); · 1252 unmodified lines | ||
| 1253 | 1253 | DEFINE_RWLOCK(vmlist_lock); |
| 1254 | 1254 | struct vm_struct *vmlist; |
| 1255 | 1255 | |
| 1256 | −static void insert_vmalloc_vm(struct vm_struct *vm, struct vmap_area *va, | |
| 1256 | +static void setup_vmalloc_vm(struct vm_struct *vm, struct vmap_area *va, | |
| 1257 | 1257 | unsigned long flags, void *caller) |
| 1258 | 1258 | { |
| 1259 | − struct vm_struct *tmp, **p; | |
| 1260 | − | |
| 1261 | 1259 | vm->flags = flags; |
| 1262 | 1260 | vm->addr = (void *)va->va_start; |
| 1263 | 1261 | vm->size = va->va_end - va->va_start; |
| 1264 | 1262 | vm->caller = caller; |
| 1265 | 1263 | va->private = vm; |
| 1266 | 1264 | va->flags |= VM_VM_AREA; |
| 1265 | +} | |
| 1267 | 1266 | |
| 1267 | +static void insert_vmalloc_vmlist(struct vm_struct *vm) | |
| 1268 | +{ | |
| 1269 | + struct vm_struct *tmp, **p; | |
| 1270 | + | |
| 1271 | + vm->flags &= ~VM_UNLIST; | |
| 1268 | 1272 | write_lock(&vmlist_lock); |
| 1269 | 1273 | for (p = &vmlist; (tmp = *p) != NULL; p = &tmp->next) { |
| 1270 | 1274 | if (tmp->addr >= vm->addr) |
| @@ -1275,6 +1279,13 @@ static void insert_vmalloc_vm(struct vm_struct *vm, struct vmap_area *va, · 4 unmodified lines | ||
| 1275 | 1279 | write_unlock(&vmlist_lock); |
| 1276 | 1280 | } |
| 1277 | 1281 | |
| 1282 | +static void insert_vmalloc_vm(struct vm_struct *vm, struct vmap_area *va, | |
| 1283 | + unsigned long flags, void *caller) | |
| 1284 | +{ | |
| 1285 | + setup_vmalloc_vm(vm, va, flags, caller); | |
| 1286 | + insert_vmalloc_vmlist(vm); | |
| 1287 | +} | |
| 1288 | + | |
| 1278 | 1289 | static struct vm_struct *__get_vm_area_node(unsigned long size, |
| 1279 | 1290 | unsigned long align, unsigned long flags, unsigned long start, |
| 1280 | 1291 | unsigned long end, int node, gfp_t gfp_mask, void *caller) |
| @@ -1313,7 +1324,18 @@ static struct vm_struct *__get_vm_area_node(unsigned long size, · 32 unmodified lines | ||
| 1313 | 1324 | return NULL; |
| 1314 | 1325 | } |
| 1315 | 1326 | |
| 1316 | − insert_vmalloc_vm(area, va, flags, caller); | |
| 1327 | + /* | |
| 1328 | + * When this function is called from __vmalloc_node_range, | |
| 1329 | + * we do not add vm_struct to vmlist here to avoid | |
| 1330 | + * accessing uninitialized members of vm_struct such as | |
| 1331 | + * pages and nr_pages fields. They will be set later. | |
| 1332 | + * To distinguish it from others, we use a VM_UNLIST flag. | |
| 1333 | + */ | |
| 1334 | + if (flags & VM_UNLIST) | |
| 1335 | + setup_vmalloc_vm(area, va, flags, caller); | |
| 1336 | + else | |
| 1337 | + insert_vmalloc_vm(area, va, flags, caller); | |
| 1338 | + | |
| 1317 | 1339 | return area; |
| 1318 | 1340 | } |
| 1319 | 1341 | |
| @@ -1381,17 +1403,20 @@ struct vm_struct *remove_vm_area(const void *addr) · 61 unmodified lines | ||
| 1381 | 1403 | va = find_vmap_area((unsigned long)addr); |
| 1382 | 1404 | if (va && va->flags & VM_VM_AREA) { |
| 1383 | 1405 | struct vm_struct *vm = va->private; |
| 1384 | − struct vm_struct *tmp, **p; | |
| 1385 | − /* | |
| 1386 | − * remove from list and disallow access to this vm_struct | |
| 1387 | − * before unmap. (address range confliction is maintained by | |
| 1388 | − * vmap.) | |
| 1389 | − */ | |
| 1390 | − write_lock(&vmlist_lock); | |
| 1391 | − for (p = &vmlist; (tmp = *p) != vm; p = &tmp->next) | |
| 1392 | − ; | |
| 1393 | − *p = tmp->next; | |
| 1394 | − write_unlock(&vmlist_lock); | |
| 1406 | + | |
| 1407 | + if (!(vm->flags & VM_UNLIST)) { | |
| 1408 | + struct vm_struct *tmp, **p; | |
| 1409 | + /* | |
| 1410 | + * remove from list and disallow access to | |
| 1411 | + * this vm_struct before unmap. (address range | |
| 1412 | + * confliction is maintained by vmap.) | |
| 1413 | + */ | |
| 1414 | + write_lock(&vmlist_lock); | |
| 1415 | + for (p = &vmlist; (tmp = *p) != vm; p = &tmp->next) | |
| 1416 | + ; | |
| 1417 | + *p = tmp->next; | |
| 1418 | + write_unlock(&vmlist_lock); | |
| 1419 | + } | |
| 1395 | 1420 | |
| 1396 | 1421 | vmap_debug_free_range(va->va_start, va->va_end); |
| 1397 | 1422 | free_unmap_vmap_area(va); |
| @@ -1568,8 +1593,8 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask, · 170 unmodified lines | ||
| 1568 | 1593 | return area->addr; |
| 1569 | 1594 | |
| 1570 | 1595 | fail: |
| 1571 | − warn_alloc_failed(gfp_mask, order, "vmalloc: allocation failure, " | |
| 1572 | − "allocated %ld of %ld bytes\n", | |
| 1596 | + warn_alloc_failed(gfp_mask, order, | |
| 1597 | + "vmalloc: allocation failure, allocated %ld of %ld bytes\n", | |
| 1573 | 1598 | (area->nr_pages*PAGE_SIZE), area->size); |
| 1574 | 1599 | vfree(area->addr); |
| 1575 | 1600 | return NULL; |
| @@ -1600,16 +1625,21 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align, · 24 unmodified lines | ||
| 1600 | 1625 | |
| 1601 | 1626 | size = PAGE_ALIGN(size); |
| 1602 | 1627 | if (!size || (size >> PAGE_SHIFT) > totalram_pages) |
| 1603 | − return NULL; | |
| 1604 | − | |
| 1605 | − area = __get_vm_area_node(size, align, VM_ALLOC, start, end, node, | |
| 1606 | − gfp_mask, caller); | |
| 1628 | + goto fail; | |
| 1607 | 1629 | |
| 1630 | + area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST, | |
| 1631 | + start, end, node, gfp_mask, caller); | |
| 1608 | 1632 | if (!area) |
| 1609 | − return NULL; | |
| 1633 | + goto fail; | |
| 1610 | 1634 | |
| 1611 | 1635 | addr = __vmalloc_area_node(area, gfp_mask, prot, node, caller); |
| 1612 | 1636 | |
| 1637 | + /* | |
| 1638 | + * In this function, newly allocated vm_struct is not added | |
| 1639 | + * to vmlist at __get_vm_area_node(). so, it is added here. | |
| 1640 | + */ | |
| 1641 | + insert_vmalloc_vmlist(area); | |
| 1642 | + | |
| 1613 | 1643 | /* |
| 1614 | 1644 | * A ref_count = 3 is needed because the vm_struct and vmap_area |
| 1615 | 1645 | * structures allocated in the __get_vm_area_node() function contain |
| @@ -1618,6 +1648,12 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align, · 2 unmodified lines | ||
| 1618 | 1648 | kmemleak_alloc(addr, real_size, 3, gfp_mask); |
| 1619 | 1649 | |
| 1620 | 1650 | return addr; |
| 1651 | + | |
| 1652 | +fail: | |
| 1653 | + warn_alloc_failed(gfp_mask, 0, | |
| 1654 | + "vmalloc: allocation failure: %lu bytes\n", | |
| 1655 | + real_size); | |
| 1656 | + return NULL; | |
| 1621 | 1657 | } |
| 1622 | 1658 | |
| 1623 | 1659 | /** |
| @@ -495,15 +495,6 @@ static pageout_t pageout(struct page *page, struct address_space *mapping, · 494 unmodified lines | ||
| 495 | 495 | return PAGE_ACTIVATE; |
| 496 | 496 | } |
| 497 | 497 | |
| 498 | − /* | |
| 499 | − * Wait on writeback if requested to. This happens when | |
| 500 | − * direct reclaiming a large contiguous area and the | |
| 501 | − * first attempt to free a range of pages fails. | |
| 502 | − */ | |
| 503 | − if (PageWriteback(page) && | |
| 504 | − (sc->reclaim_mode & RECLAIM_MODE_SYNC)) | |
| 505 | − wait_on_page_writeback(page); | |
| 506 | − | |
| 507 | 498 | if (!PageWriteback(page)) { |
| 508 | 499 | /* synchronous write or broken a_ops? */ |
| 509 | 500 | ClearPageReclaim(page); |
| @@ -642,13 +633,14 @@ redo: · 132 unmodified lines | ||
| 642 | 633 | lru = LRU_UNEVICTABLE; |
| 643 | 634 | add_page_to_unevictable_list(page); |
| 644 | 635 | /* |
| 645 | − * When racing with an mlock clearing (page is | |
| 646 | − * unlocked), make sure that if the other thread does | |
| 647 | − * not observe our setting of PG_lru and fails | |
| 648 | − * isolation, we see PG_mlocked cleared below and move | |
| 636 | + * When racing with an mlock or AS_UNEVICTABLE clearing | |
| 637 | + * (page is unlocked) make sure that if the other thread | |
| 638 | + * does not observe our setting of PG_lru and fails | |
| 639 | + * isolation/check_move_unevictable_page, | |
| 640 | + * we see PG_mlocked/AS_UNEVICTABLE cleared below and move | |
| 649 | 641 | * the page back to the evictable list. |
| 650 | 642 | * |
| 651 | − * The other side is TestClearPageMlocked(). | |
| 643 | + * The other side is TestClearPageMlocked() or shmem_lock(). | |
| 652 | 644 | */ |
| 653 | 645 | smp_mb(); |
| 654 | 646 | } |
| @@ -759,7 +751,10 @@ static noinline_for_stack void free_page_list(struct list_head *free_pages) · 104 unmodified lines | ||
| 759 | 751 | */ |
| 760 | 752 | static unsigned long shrink_page_list(struct list_head *page_list, |
| 761 | 753 | struct zone *zone, |
| 762 | − struct scan_control *sc) | |
| 754 | + struct scan_control *sc, | |
| 755 | + int priority, | |
| 756 | + unsigned long *ret_nr_dirty, | |
| 757 | + unsigned long *ret_nr_writeback) | |
| 763 | 758 | { |
| 764 | 759 | LIST_HEAD(ret_pages); |
| 765 | 760 | LIST_HEAD(free_pages); |
| @@ -767,6 +762,7 @@ static unsigned long shrink_page_list(struct list_head *page_list, · 1 unmodified line | ||
| 767 | 762 | unsigned long nr_dirty = 0; |
| 768 | 763 | unsigned long nr_congested = 0; |
| 769 | 764 | unsigned long nr_reclaimed = 0; |
| 765 | + unsigned long nr_writeback = 0; | |
| 770 | 766 | |
| 771 | 767 | cond_resched(); |
| 772 | 768 | |
| @@ -803,13 +799,12 @@ static unsigned long shrink_page_list(struct list_head *page_list, · 30 unmodified lines | ||
| 803 | 799 | (PageSwapCache(page) && (sc->gfp_mask & __GFP_IO)); |
| 804 | 800 | |
| 805 | 801 | if (PageWriteback(page)) { |
| 802 | + nr_writeback++; | |
| 806 | 803 | /* |
| 807 | − * Synchronous reclaim is performed in two passes, | |
| 808 | − * first an asynchronous pass over the list to | |
| 809 | − * start parallel writeback, and a second synchronous | |
| 810 | − * pass to wait for the IO to complete. Wait here | |
| 811 | − * for any page for which writeback has already | |
| 812 | − * started. | |
| 804 | + * Synchronous reclaim cannot queue pages for | |
| 805 | + * writeback due to the possibility of stack overflow | |
| 806 | + * but if it encounters a page under writeback, wait | |
| 807 | + * for the IO to complete. | |
| 813 | 808 | */ |
| 814 | 809 | if ((sc->reclaim_mode & RECLAIM_MODE_SYNC) && |
| 815 | 810 | may_enter_fs) |
| @@ -865,6 +860,25 @@ static unsigned long shrink_page_list(struct list_head *page_list, · 49 unmodified lines | ||
| 865 | 860 | if (PageDirty(page)) { |
| 866 | 861 | nr_dirty++; |
| 867 | 862 | |
| 863 | + /* | |
| 864 | + * Only kswapd can writeback filesystem pages to | |
| 865 | + * avoid risk of stack overflow but do not writeback | |
| 866 | + * unless under significant pressure. | |
| 867 | + */ | |
| 868 | + if (page_is_file_cache(page) && | |
| 869 | + (!current_is_kswapd() || priority >= DEF_PRIORITY - 2)) { | |
| 870 | + /* | |
| 871 | + * Immediately reclaim when written back. | |
| 872 | + * Similar in principal to deactivate_page() | |
| 873 | + * except we already have the page isolated | |
| 874 | + * and know it's dirty | |
| 875 | + */ | |
| 876 | + inc_zone_page_state(page, NR_VMSCAN_IMMEDIATE); | |
| 877 | + SetPageReclaim(page); | |
| 878 | + | |
| 879 | + goto keep_locked; | |
| 880 | + } | |
| 881 | + | |
| 868 | 882 | if (references == PAGEREF_RECLAIM_CLEAN) |
| 869 | 883 | goto keep_locked; |
| 870 | 884 | if (!may_enter_fs) |
| @@ -999,6 +1013,8 @@ keep_lumpy: · 128 unmodified lines | ||
| 999 | 1013 | |
| 1000 | 1014 | list_splice(&ret_pages, page_list); |
| 1001 | 1015 | count_vm_events(PGACTIVATE, pgactivate); |
| 1016 | + *ret_nr_dirty += nr_dirty; | |
| 1017 | + *ret_nr_writeback += nr_writeback; | |
| 1002 | 1018 | return nr_reclaimed; |
| 1003 | 1019 | } |
| 1004 | 1020 | |
| @@ -1012,23 +1028,27 @@ keep_lumpy: · 7 unmodified lines | ||
| 1012 | 1028 | * |
| 1013 | 1029 | * returns 0 on success, -ve errno on failure. |
| 1014 | 1030 | */ |
| 1015 | −int __isolate_lru_page(struct page *page, int mode, int file) | |
| 1031 | +int __isolate_lru_page(struct page *page, isolate_mode_t mode, int file) | |
| 1016 | 1032 | { |
| 1033 | + bool all_lru_mode; | |
| 1017 | 1034 | int ret = -EINVAL; |
| 1018 | 1035 | |
| 1019 | 1036 | /* Only take pages on the LRU. */ |
| 1020 | 1037 | if (!PageLRU(page)) |
| 1021 | 1038 | return ret; |
| 1022 | 1039 | |
| 1040 | + all_lru_mode = (mode & (ISOLATE_ACTIVE|ISOLATE_INACTIVE)) == | |
| 1041 | + (ISOLATE_ACTIVE|ISOLATE_INACTIVE); | |
| 1042 | + | |
| 1023 | 1043 | /* |
| 1024 | 1044 | * When checking the active state, we need to be sure we are |
| 1025 | 1045 | * dealing with comparible boolean values. Take the logical not |
| 1026 | 1046 | * of each. |
| 1027 | 1047 | */ |
| 1028 | − if (mode != ISOLATE_BOTH && (!PageActive(page) != !mode)) | |
| 1048 | + if (!all_lru_mode && !PageActive(page) != !(mode & ISOLATE_ACTIVE)) | |
| 1029 | 1049 | return ret; |
| 1030 | 1050 | |
| 1031 | − if (mode != ISOLATE_BOTH && page_is_file_cache(page) != file) | |
| 1051 | + if (!all_lru_mode && !!page_is_file_cache(page) != file) | |
| 1032 | 1052 | return ret; |
| 1033 | 1053 | |
| 1034 | 1054 | /* |
| @@ -1041,6 +1061,12 @@ int __isolate_lru_page(struct page *page, int mode, int file) · 6 unmodified lines | ||
| 1041 | 1061 | |
| 1042 | 1062 | ret = -EBUSY; |
| 1043 | 1063 | |
| 1064 | + if ((mode & ISOLATE_CLEAN) && (PageDirty(page) || PageWriteback(page))) | |
| 1065 | + return ret; | |
| 1066 | + | |
| 1067 | + if ((mode & ISOLATE_UNMAPPED) && page_mapped(page)) | |
| 1068 | + return ret; | |
| 1069 | + | |
| 1044 | 1070 | if (likely(get_page_unless_zero(page))) { |
| 1045 | 1071 | /* |
| 1046 | 1072 | * Be careful not to clear PageLRU until after we're |
| @@ -1076,7 +1102,8 @@ int __isolate_lru_page(struct page *page, int mode, int file) · 29 unmodified lines | ||
| 1076 | 1102 | */ |
| 1077 | 1103 | static unsigned long isolate_lru_pages(unsigned long nr_to_scan, |
| 1078 | 1104 | struct list_head *src, struct list_head *dst, |
| 1079 | − unsigned long *scanned, int order, int mode, int file) | |
| 1105 | + unsigned long *scanned, int order, isolate_mode_t mode, | |
| 1106 | + int file) | |
| 1080 | 1107 | { |
| 1081 | 1108 | unsigned long nr_taken = 0; |
| 1082 | 1109 | unsigned long nr_lumpy_taken = 0; |
| @@ -1201,8 +1228,8 @@ static unsigned long isolate_lru_pages(unsigned long nr_to_scan, · 118 unmodified lines | ||
| 1201 | 1228 | static unsigned long isolate_pages_global(unsigned long nr, |
| 1202 | 1229 | struct list_head *dst, |
| 1203 | 1230 | unsigned long *scanned, int order, |
| 1204 | − int mode, struct zone *z, | |
| 1205 | − int active, int file) | |
| 1231 | + isolate_mode_t mode, | |
| 1232 | + struct zone *z, int active, int file) | |
| 1206 | 1233 | { |
| 1207 | 1234 | int lru = LRU_BASE; |
| 1208 | 1235 | if (active) |
| @@ -1394,7 +1421,7 @@ static noinline_for_stack void update_isolated_counts(struct zone *zone, · 185 unmodified lines | ||
| 1394 | 1421 | } |
| 1395 | 1422 | |
| 1396 | 1423 | /* |
| 1397 | − * Returns true if the caller should wait to clean dirty/writeback pages. | |
| 1424 | + * Returns true if a direct reclaim should wait on pages under writeback. | |
| 1398 | 1425 | * |
| 1399 | 1426 | * If we are direct reclaiming for contiguous pages and we do not reclaim |
| 1400 | 1427 | * everything in the list, try again and wait for writeback IO to complete. |
| @@ -1448,6 +1475,9 @@ shrink_inactive_list(unsigned long nr_to_scan, struct zone *zone, · 47 unmodified lines | ||
| 1448 | 1475 | unsigned long nr_taken; |
| 1449 | 1476 | unsigned long nr_anon; |
| 1450 | 1477 | unsigned long nr_file; |
| 1478 | + unsigned long nr_dirty = 0; | |
| 1479 | + unsigned long nr_writeback = 0; | |
| 1480 | + isolate_mode_t reclaim_mode = ISOLATE_INACTIVE; | |
| 1451 | 1481 | |
| 1452 | 1482 | while (unlikely(too_many_isolated(zone, file, sc))) { |
| 1453 | 1483 | congestion_wait(BLK_RW_ASYNC, HZ/10); |
| @@ -1458,15 +1488,21 @@ shrink_inactive_list(unsigned long nr_to_scan, struct zone *zone, · 4 unmodified lines | ||
| 1458 | 1488 | } |
| 1459 | 1489 | |
| 1460 | 1490 | set_reclaim_mode(priority, sc, false); |
| 1491 | + if (sc->reclaim_mode & RECLAIM_MODE_LUMPYRECLAIM) | |
| 1492 | + reclaim_mode |= ISOLATE_ACTIVE; | |
| 1493 | + | |
| 1461 | 1494 | lru_add_drain(); |
| 1495 | + | |
| 1496 | + if (!sc->may_unmap) | |
| 1497 | + reclaim_mode |= ISOLATE_UNMAPPED; | |
| 1498 | + if (!sc->may_writepage) | |
| 1499 | + reclaim_mode |= ISOLATE_CLEAN; | |
| 1500 | + | |
| 1462 | 1501 | spin_lock_irq(&zone->lru_lock); |
| 1463 | 1502 | |
| 1464 | 1503 | if (scanning_global_lru(sc)) { |
| 1465 | − nr_taken = isolate_pages_global(nr_to_scan, | |
| 1466 | − &page_list, &nr_scanned, sc->order, | |
| 1467 | − sc->reclaim_mode & RECLAIM_MODE_LUMPYRECLAIM ? | |
| 1468 | − ISOLATE_BOTH : ISOLATE_INACTIVE, | |
| 1469 | − zone, 0, file); | |
| 1504 | + nr_taken = isolate_pages_global(nr_to_scan, &page_list, | |
| 1505 | + &nr_scanned, sc->order, reclaim_mode, zone, 0, file); | |
| 1470 | 1506 | zone->pages_scanned += nr_scanned; |
| 1471 | 1507 | if (current_is_kswapd()) |
| 1472 | 1508 | __count_zone_vm_events(PGSCAN_KSWAPD, zone, |
| @@ -1475,12 +1511,9 @@ shrink_inactive_list(unsigned long nr_to_scan, struct zone *zone, · 2 unmodified lines | ||
| 1475 | 1511 | __count_zone_vm_events(PGSCAN_DIRECT, zone, |
| 1476 | 1512 | nr_scanned); |
| 1477 | 1513 | } else { |
| 1478 | − nr_taken = mem_cgroup_isolate_pages(nr_to_scan, | |
| 1479 | − &page_list, &nr_scanned, sc->order, | |
| 1480 | − sc->reclaim_mode & RECLAIM_MODE_LUMPYRECLAIM ? | |
| 1481 | − ISOLATE_BOTH : ISOLATE_INACTIVE, | |
| 1482 | − zone, sc->mem_cgroup, | |
| 1483 | − 0, file); | |
| 1514 | + nr_taken = mem_cgroup_isolate_pages(nr_to_scan, &page_list, | |
| 1515 | + &nr_scanned, sc->order, reclaim_mode, zone, | |
| 1516 | + sc->mem_cgroup, 0, file); | |
| 1484 | 1517 | /* |
| 1485 | 1518 | * mem_cgroup_isolate_pages() keeps track of |
| 1486 | 1519 | * scanned pages on its own. |
| @@ -1496,12 +1529,14 @@ shrink_inactive_list(unsigned long nr_to_scan, struct zone *zone, · 9 unmodified lines | ||
| 1496 | 1529 | |
| 1497 | 1530 | spin_unlock_irq(&zone->lru_lock); |
| 1498 | 1531 | |
| 1499 | − nr_reclaimed = shrink_page_list(&page_list, zone, sc); | |
| 1532 | + nr_reclaimed = shrink_page_list(&page_list, zone, sc, priority, | |
| 1533 | + &nr_dirty, &nr_writeback); | |
| 1500 | 1534 | |
| 1501 | 1535 | /* Check if we should syncronously wait for writeback */ |
| 1502 | 1536 | if (should_reclaim_stall(nr_taken, nr_reclaimed, priority, sc)) { |
| 1503 | 1537 | set_reclaim_mode(priority, sc, true); |
| 1504 | − nr_reclaimed += shrink_page_list(&page_list, zone, sc); | |
| 1538 | + nr_reclaimed += shrink_page_list(&page_list, zone, sc, | |
| 1539 | + priority, &nr_dirty, &nr_writeback); | |
| 1505 | 1540 | } |
| 1506 | 1541 | |
| 1507 | 1542 | local_irq_disable(); |
| @@ -1511,6 +1546,32 @@ shrink_inactive_list(unsigned long nr_to_scan, struct zone *zone, · 3 unmodified lines | ||
| 1511 | 1546 | |
| 1512 | 1547 | putback_lru_pages(zone, sc, nr_anon, nr_file, &page_list); |
| 1513 | 1548 | |
| 1549 | + /* | |
| 1550 | + * If reclaim is isolating dirty pages under writeback, it implies | |
| 1551 | + * that the long-lived page allocation rate is exceeding the page | |
| 1552 | + * laundering rate. Either the global limits are not being effective | |
| 1553 | + * at throttling processes due to the page distribution throughout | |
| 1554 | + * zones or there is heavy usage of a slow backing device. The | |
| 1555 | + * only option is to throttle from reclaim context which is not ideal | |
| 1556 | + * as there is no guarantee the dirtying process is throttled in the | |
| 1557 | + * same way balance_dirty_pages() manages. | |
| 1558 | + * | |
| 1559 | + * This scales the number of dirty pages that must be under writeback | |
| 1560 | + * before throttling depending on priority. It is a simple backoff | |
| 1561 | + * function that has the most effect in the range DEF_PRIORITY to | |
| 1562 | + * DEF_PRIORITY-2 which is the priority reclaim is considered to be | |
| 1563 | + * in trouble and reclaim is considered to be in trouble. | |
| 1564 | + * | |
| 1565 | + * DEF_PRIORITY 100% isolated pages must be PageWriteback to throttle | |
| 1566 | + * DEF_PRIORITY-1 50% must be PageWriteback | |
| 1567 | + * DEF_PRIORITY-2 25% must be PageWriteback, kswapd in trouble | |
| 1568 | + * ... | |
| 1569 | + * DEF_PRIORITY-6 For SWAP_CLUSTER_MAX isolated pages, throttle if any | |
| 1570 | + * isolated page is PageWriteback | |
| 1571 | + */ | |
| 1572 | + if (nr_writeback && nr_writeback >= (nr_taken >> (DEF_PRIORITY-priority))) | |
| 1573 | + wait_iff_congested(zone, BLK_RW_ASYNC, HZ/10); | |
| 1574 | + | |
| 1514 | 1575 | trace_mm_vmscan_lru_shrink_inactive(zone->zone_pgdat->node_id, |
| 1515 | 1576 | zone_idx(zone), |
| 1516 | 1577 | nr_scanned, nr_reclaimed, |
| @@ -1582,19 +1643,26 @@ static void shrink_active_list(unsigned long nr_pages, struct zone *zone, · 65 unmodified lines | ||
| 1582 | 1643 | struct page *page; |
| 1583 | 1644 | struct zone_reclaim_stat *reclaim_stat = get_reclaim_stat(zone, sc); |
| 1584 | 1645 | unsigned long nr_rotated = 0; |
| 1646 | + isolate_mode_t reclaim_mode = ISOLATE_ACTIVE; | |
| 1585 | 1647 | |
| 1586 | 1648 | lru_add_drain(); |
| 1649 | + | |
| 1650 | + if (!sc->may_unmap) | |
| 1651 | + reclaim_mode |= ISOLATE_UNMAPPED; | |
| 1652 | + if (!sc->may_writepage) | |
| 1653 | + reclaim_mode |= ISOLATE_CLEAN; | |
| 1654 | + | |
| 1587 | 1655 | spin_lock_irq(&zone->lru_lock); |
| 1588 | 1656 | if (scanning_global_lru(sc)) { |
| 1589 | 1657 | nr_taken = isolate_pages_global(nr_pages, &l_hold, |
| 1590 | 1658 | &pgscanned, sc->order, |
| 1591 | − ISOLATE_ACTIVE, zone, | |
| 1659 | + reclaim_mode, zone, | |
| 1592 | 1660 | 1, file); |
| 1593 | 1661 | zone->pages_scanned += pgscanned; |
| 1594 | 1662 | } else { |
| 1595 | 1663 | nr_taken = mem_cgroup_isolate_pages(nr_pages, &l_hold, |
| 1596 | 1664 | &pgscanned, sc->order, |
| 1597 | − ISOLATE_ACTIVE, zone, | |
| 1665 | + reclaim_mode, zone, | |
| 1598 | 1666 | sc->mem_cgroup, 1, file); |
| 1599 | 1667 | /* |
| 1600 | 1668 | * mem_cgroup_isolate_pages() keeps track of |
| @@ -1795,12 +1863,19 @@ static void get_scan_count(struct zone *zone, struct scan_control *sc, · 194 unmodified lines | ||
| 1795 | 1863 | enum lru_list l; |
| 1796 | 1864 | int noswap = 0; |
| 1797 | 1865 | bool force_scan = false; |
| 1798 | − unsigned long nr_force_scan[2]; | |
| 1799 | 1866 | |
| 1800 | − /* kswapd does zone balancing and needs to scan this zone */ | |
| 1867 | + /* | |
| 1868 | + * If the zone or memcg is small, nr[l] can be 0. This | |
| 1869 | + * results in no scanning on this priority and a potential | |
| 1870 | + * priority drop. Global direct reclaim can go to the next | |
| 1871 | + * zone and tends to have no problems. Global kswapd is for | |
| 1872 | + * zone balancing and it needs to scan a minimum amount. When | |
| 1873 | + * reclaiming for a memcg, a priority drop can cause high | |
| 1874 | + * latencies, so it's better to scan a minimum amount there as | |
| 1875 | + * well. | |
| 1876 | + */ | |
| 1801 | 1877 | if (scanning_global_lru(sc) && current_is_kswapd()) |
| 1802 | 1878 | force_scan = true; |
| 1803 | − /* memcg may have small limit and need to avoid priority drop */ | |
| 1804 | 1879 | if (!scanning_global_lru(sc)) |
| 1805 | 1880 | force_scan = true; |
| 1806 | 1881 | |
| @@ -1810,8 +1885,6 @@ static void get_scan_count(struct zone *zone, struct scan_control *sc, · 3 unmodified lines | ||
| 1810 | 1885 | fraction[0] = 0; |
| 1811 | 1886 | fraction[1] = 1; |
| 1812 | 1887 | denominator = 1; |
| 1813 | − nr_force_scan[0] = 0; | |
| 1814 | − nr_force_scan[1] = SWAP_CLUSTER_MAX; | |
| 1815 | 1888 | goto out; |
| 1816 | 1889 | } |
| 1817 | 1890 | |
| @@ -1828,8 +1901,6 @@ static void get_scan_count(struct zone *zone, struct scan_control *sc, · 10 unmodified lines | ||
| 1828 | 1901 | fraction[0] = 1; |
| 1829 | 1902 | fraction[1] = 0; |
| 1830 | 1903 | denominator = 1; |
| 1831 | − nr_force_scan[0] = SWAP_CLUSTER_MAX; | |
| 1832 | − nr_force_scan[1] = 0; | |
| 1833 | 1904 | goto out; |
| 1834 | 1905 | } |
| 1835 | 1906 | } |
| @@ -1878,11 +1949,6 @@ static void get_scan_count(struct zone *zone, struct scan_control *sc, · 42 unmodified lines | ||
| 1878 | 1949 | fraction[0] = ap; |
| 1879 | 1950 | fraction[1] = fp; |
| 1880 | 1951 | denominator = ap + fp + 1; |
| 1881 | − if (force_scan) { | |
| 1882 | − unsigned long scan = SWAP_CLUSTER_MAX; | |
| 1883 | − nr_force_scan[0] = div64_u64(scan * ap, denominator); | |
| 1884 | − nr_force_scan[1] = div64_u64(scan * fp, denominator); | |
| 1885 | − } | |
| 1886 | 1952 | out: |
| 1887 | 1953 | for_each_evictable_lru(l) { |
| 1888 | 1954 | int file = is_file_lru(l); |
| @@ -1891,20 +1957,10 @@ out: · 2 unmodified lines | ||
| 1891 | 1957 | scan = zone_nr_lru_pages(zone, sc, l); |
| 1892 | 1958 | if (priority || noswap) { |
| 1893 | 1959 | scan >>= priority; |
| 1960 | + if (!scan && force_scan) | |
| 1961 | + scan = SWAP_CLUSTER_MAX; | |
| 1894 | 1962 | scan = div64_u64(scan * fraction[file], denominator); |
| 1895 | 1963 | } |
| 1896 | − | |
| 1897 | − /* | |
| 1898 | − * If zone is small or memcg is small, nr[l] can be 0. | |
| 1899 | − * This results no-scan on this priority and priority drop down. | |
| 1900 | − * For global direct reclaim, it can visit next zone and tend | |
| 1901 | − * not to have problems. For global kswapd, it's for zone | |
| 1902 | − * balancing and it need to scan a small amounts. When using | |
| 1903 | − * memcg, priority drop can cause big latency. So, it's better | |
| 1904 | − * to scan small amount. See may_noscan above. | |
| 1905 | − */ | |
| 1906 | − if (!scan && force_scan) | |
| 1907 | − scan = nr_force_scan[file]; | |
| 1908 | 1964 | nr[l] = scan; |
| 1909 | 1965 | } |
| 1910 | 1966 | } |
| @@ -1983,12 +2039,14 @@ static void shrink_zone(int priority, struct zone *zone, · 72 unmodified lines | ||
| 1983 | 2039 | enum lru_list l; |
| 1984 | 2040 | unsigned long nr_reclaimed, nr_scanned; |
| 1985 | 2041 | unsigned long nr_to_reclaim = sc->nr_to_reclaim; |
| 2042 | + struct blk_plug plug; | |
| 1986 | 2043 | |
| 1987 | 2044 | restart: |
| 1988 | 2045 | nr_reclaimed = 0; |
| 1989 | 2046 | nr_scanned = sc->nr_scanned; |
| 1990 | 2047 | get_scan_count(zone, sc, nr, priority); |
| 1991 | 2048 | |
| 2049 | + blk_start_plug(&plug); | |
| 1992 | 2050 | while (nr[LRU_INACTIVE_ANON] || nr[LRU_ACTIVE_FILE] || |
| 1993 | 2051 | nr[LRU_INACTIVE_FILE]) { |
| 1994 | 2052 | for_each_evictable_lru(l) { |
| @@ -2012,6 +2070,7 @@ restart: · 17 unmodified lines | ||
| 2012 | 2070 | if (nr_reclaimed >= nr_to_reclaim && priority < DEF_PRIORITY) |
| 2013 | 2071 | break; |
| 2014 | 2072 | } |
| 2073 | + blk_finish_plug(&plug); | |
| 2015 | 2074 | sc->nr_reclaimed += nr_reclaimed; |
| 2016 | 2075 | |
| 2017 | 2076 | /* |
| @@ -2044,14 +2103,19 @@ restart: · 26 unmodified lines | ||
| 2044 | 2103 | * |
| 2045 | 2104 | * If a zone is deemed to be full of pinned pages then just give it a light |
| 2046 | 2105 | * scan then give up on it. |
| 2106 | + * | |
| 2107 | + * This function returns true if a zone is being reclaimed for a costly | |
| 2108 | + * high-order allocation and compaction is either ready to begin or deferred. | |
| 2109 | + * This indicates to the caller that it should retry the allocation or fail. | |
| 2047 | 2110 | */ |
| 2048 | −static void shrink_zones(int priority, struct zonelist *zonelist, | |
| 2111 | +static bool shrink_zones(int priority, struct zonelist *zonelist, | |
| 2049 | 2112 | struct scan_control *sc) |
| 2050 | 2113 | { |
| 2051 | 2114 | struct zoneref *z; |
| 2052 | 2115 | struct zone *zone; |
| 2053 | 2116 | unsigned long nr_soft_reclaimed; |
| 2054 | 2117 | unsigned long nr_soft_scanned; |
| 2118 | + bool should_abort_reclaim = false; | |
| 2055 | 2119 | |
| 2056 | 2120 | for_each_zone_zonelist_nodemask(zone, z, zonelist, |
| 2057 | 2121 | gfp_zone(sc->gfp_mask), sc->nodemask) { |
| @@ -2066,6 +2130,23 @@ static void shrink_zones(int priority, struct zonelist *zonelist, · 8 unmodified lines | ||
| 2066 | 2130 | continue; |
| 2067 | 2131 | if (zone->all_unreclaimable && priority != DEF_PRIORITY) |
| 2068 | 2132 | continue; /* Let kswapd poll it */ |
| 2133 | + if (COMPACTION_BUILD) { | |
| 2134 | + /* | |
| 2135 | + * If we already have plenty of memory free for | |
| 2136 | + * compaction in this zone, don't free any more. | |
| 2137 | + * Even though compaction is invoked for any | |
| 2138 | + * non-zero order, only frequent costly order | |
| 2139 | + * reclamation is disruptive enough to become a | |
| 2140 | + * noticable problem, like transparent huge page | |
| 2141 | + * allocations. | |
| 2142 | + */ | |
| 2143 | + if (sc->order > PAGE_ALLOC_COSTLY_ORDER && | |
| 2144 | + (compaction_suitable(zone, sc->order) || | |
| 2145 | + compaction_deferred(zone))) { | |
| 2146 | + should_abort_reclaim = true; | |
| 2147 | + continue; | |
| 2148 | + } | |
| 2149 | + } | |
| 2069 | 2150 | /* |
| 2070 | 2151 | * This steals pages from memory cgroups over softlimit |
| 2071 | 2152 | * and returns the number of reclaimed pages and |
| @@ -2083,6 +2164,8 @@ static void shrink_zones(int priority, struct zonelist *zonelist, · 11 unmodified lines | ||
| 2083 | 2164 | |
| 2084 | 2165 | shrink_zone(priority, zone, sc); |
| 2085 | 2166 | } |
| 2167 | + | |
| 2168 | + return should_abort_reclaim; | |
| 2086 | 2169 | } |
| 2087 | 2170 | |
| 2088 | 2171 | static bool zone_reclaimable(struct zone *zone) |
| @@ -2147,7 +2230,9 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist, · 58 unmodified lines | ||
| 2147 | 2230 | sc->nr_scanned = 0; |
| 2148 | 2231 | if (!priority) |
| 2149 | 2232 | disable_swap_token(sc->mem_cgroup); |
| 2150 | − shrink_zones(priority, zonelist, sc); | |
| 2233 | + if (shrink_zones(priority, zonelist, sc)) | |
| 2234 | + break; | |
| 2235 | + | |
| 2151 | 2236 | /* |
| 2152 | 2237 | * Don't shrink slabs when reclaiming memory from |
| 2153 | 2238 | * over limit cgroups |
| @@ -2690,6 +2775,8 @@ out: · 536 unmodified lines | ||
| 2690 | 2775 | |
| 2691 | 2776 | /* If balanced, clear the congested flag */ |
| 2692 | 2777 | zone_clear_flag(zone, ZONE_CONGESTED); |
| 2778 | + if (i <= *classzone_idx) | |
| 2779 | + balanced += zone->present_pages; | |
| 2693 | 2780 | } |
| 2694 | 2781 | } |
| 2695 | 2782 | |
| @@ -2763,7 +2850,9 @@ static void kswapd_try_to_sleep(pg_data_t *pgdat, int order, int classzone_idx) · 67 unmodified lines | ||
| 2763 | 2850 | static int kswapd(void *p) |
| 2764 | 2851 | { |
| 2765 | 2852 | unsigned long order, new_order; |
| 2853 | + unsigned balanced_order; | |
| 2766 | 2854 | int classzone_idx, new_classzone_idx; |
| 2855 | + int balanced_classzone_idx; | |
| 2767 | 2856 | pg_data_t *pgdat = (pg_data_t*)p; |
| 2768 | 2857 | struct task_struct *tsk = current; |
| 2769 | 2858 | |
| @@ -2794,7 +2883,9 @@ static int kswapd(void *p) · 24 unmodified lines | ||
| 2794 | 2883 | set_freezable(); |
| 2795 | 2884 | |
| 2796 | 2885 | order = new_order = 0; |
| 2886 | + balanced_order = 0; | |
| 2797 | 2887 | classzone_idx = new_classzone_idx = pgdat->nr_zones - 1; |
| 2888 | + balanced_classzone_idx = classzone_idx; | |
| 2798 | 2889 | for ( ; ; ) { |
| 2799 | 2890 | int ret; |
| 2800 | 2891 | |
| @@ -2803,7 +2894,8 @@ static int kswapd(void *p) · 2 unmodified lines | ||
| 2803 | 2894 | * new request of a similar or harder type will succeed soon |
| 2804 | 2895 | * so consider going to sleep on the basis we reclaimed at |
| 2805 | 2896 | */ |
| 2806 | − if (classzone_idx >= new_classzone_idx && order == new_order) { | |
| 2897 | + if (balanced_classzone_idx >= new_classzone_idx && | |
| 2898 | + balanced_order == new_order) { | |
| 2807 | 2899 | new_order = pgdat->kswapd_max_order; |
| 2808 | 2900 | new_classzone_idx = pgdat->classzone_idx; |
| 2809 | 2901 | pgdat->kswapd_max_order = 0; |
| @@ -2818,9 +2910,12 @@ static int kswapd(void *p) · 8 unmodified lines | ||
| 2818 | 2910 | order = new_order; |
| 2819 | 2911 | classzone_idx = new_classzone_idx; |
| 2820 | 2912 | } else { |
| 2821 | − kswapd_try_to_sleep(pgdat, order, classzone_idx); | |
| 2913 | + kswapd_try_to_sleep(pgdat, balanced_order, | |
| 2914 | + balanced_classzone_idx); | |
| 2822 | 2915 | order = pgdat->kswapd_max_order; |
| 2823 | 2916 | classzone_idx = pgdat->classzone_idx; |
| 2917 | + new_order = order; | |
| 2918 | + new_classzone_idx = classzone_idx; | |
| 2824 | 2919 | pgdat->kswapd_max_order = 0; |
| 2825 | 2920 | pgdat->classzone_idx = pgdat->nr_zones - 1; |
| 2826 | 2921 | } |
| @@ -2835,7 +2930,9 @@ static int kswapd(void *p) · 8 unmodified lines | ||
| 2835 | 2930 | */ |
| 2836 | 2931 | if (!ret) { |
| 2837 | 2932 | trace_mm_vmscan_kswapd_wake(pgdat->node_id, order); |
| 2838 | − order = balance_pgdat(pgdat, order, &classzone_idx); | |
| 2933 | + balanced_classzone_idx = classzone_idx; | |
| 2934 | + balanced_order = balance_pgdat(pgdat, order, | |
| 2935 | + &balanced_classzone_idx); | |
| 2839 | 2936 | } |
| 2840 | 2937 | } |
| 2841 | 2938 | return 0; |
| @@ -3347,66 +3444,12 @@ void scan_mapping_unevictable_pages(struct address_space *mapping) · 505 unmodified lines | ||
| 3347 | 3444 | |
| 3348 | 3445 | } |
| 3349 | 3446 | |
| 3350 | −/** | |
| 3351 | − * scan_zone_unevictable_pages - check unevictable list for evictable pages | |
| 3352 | − * @zone - zone of which to scan the unevictable list | |
| 3353 | − * | |
| 3354 | − * Scan @zone's unevictable LRU lists to check for pages that have become | |
| 3355 | − * evictable. Move those that have to @zone's inactive list where they | |
| 3356 | − * become candidates for reclaim, unless shrink_inactive_zone() decides | |
| 3357 | − * to reactivate them. Pages that are still unevictable are rotated | |
| 3358 | − * back onto @zone's unevictable list. | |
| 3359 | − */ | |
| 3360 | −#define SCAN_UNEVICTABLE_BATCH_SIZE 16UL /* arbitrary lock hold batch size */ | |
| 3361 | −static void scan_zone_unevictable_pages(struct zone *zone) | |
| 3447 | +static void warn_scan_unevictable_pages(void) | |
| 3362 | 3448 | { |
| 3363 | − struct list_head *l_unevictable = &zone->lru[LRU_UNEVICTABLE].list; | |
| 3364 | − unsigned long scan; | |
| 3365 | − unsigned long nr_to_scan = zone_page_state(zone, NR_UNEVICTABLE); | |
| 3366 | − | |
| 3367 | − while (nr_to_scan > 0) { | |
| 3368 | − unsigned long batch_size = min(nr_to_scan, | |
| 3369 | − SCAN_UNEVICTABLE_BATCH_SIZE); | |
| 3370 | − | |
| 3371 | − spin_lock_irq(&zone->lru_lock); | |
| 3372 | − for (scan = 0; scan < batch_size; scan++) { | |
| 3373 | − struct page *page = lru_to_page(l_unevictable); | |
| 3374 | − | |
| 3375 | − if (!trylock_page(page)) | |
| 3376 | − continue; | |
| 3377 | − | |
| 3378 | − prefetchw_prev_lru_page(page, l_unevictable, flags); | |
| 3379 | − | |
| 3380 | − if (likely(PageLRU(page) && PageUnevictable(page))) | |
| 3381 | − check_move_unevictable_page(page, zone); | |
| 3382 | − | |
| 3383 | − unlock_page(page); | |
| 3384 | − } | |
| 3385 | − spin_unlock_irq(&zone->lru_lock); | |
| 3386 | − | |
| 3387 | − nr_to_scan -= batch_size; | |
| 3388 | − } | |
| 3389 | −} | |
| 3390 | − | |
| 3391 | − | |
| 3392 | −/** | |
| 3393 | − * scan_all_zones_unevictable_pages - scan all unevictable lists for evictable pages | |
| 3394 | − * | |
| 3395 | − * A really big hammer: scan all zones' unevictable LRU lists to check for | |
| 3396 | − * pages that have become evictable. Move those back to the zones' | |
| 3397 | − * inactive list where they become candidates for reclaim. | |
| 3398 | − * This occurs when, e.g., we have unswappable pages on the unevictable lists, | |
| 3399 | − * and we add swap to the system. As such, it runs in the context of a task | |
| 3400 | − * that has possibly/probably made some previously unevictable pages | |
| 3401 | − * evictable. | |
| 3402 | − */ | |
| 3403 | −static void scan_all_zones_unevictable_pages(void) | |
| 3404 | −{ | |
| 3405 | − struct zone *zone; | |
| 3406 | − | |
| 3407 | − for_each_zone(zone) { | |
| 3408 | − scan_zone_unevictable_pages(zone); | |
| 3409 | − } | |
| 3449 | + printk_once(KERN_WARNING | |
| 3450 | + "The scan_unevictable_pages sysctl/node-interface has been " | |
| 3451 | + "disabled for lack of a legitimate use case. If you have " | |
| 3452 | + "one, please send an email to linux-mm@kvack.org.\n"); | |
| 3410 | 3453 | } |
| 3411 | 3454 | |
| 3412 | 3455 | /* |
| @@ -3419,11 +3462,8 @@ int scan_unevictable_handler(struct ctl_table *table, int write, · 6 unmodified lines | ||
| 3419 | 3462 | void __user *buffer, |
| 3420 | 3463 | size_t *length, loff_t *ppos) |
| 3421 | 3464 | { |
| 3465 | + warn_scan_unevictable_pages(); | |
| 3422 | 3466 | proc_doulongvec_minmax(table, write, buffer, length, ppos); |
| 3423 | − | |
| 3424 | − if (write && *(unsigned long *)table->data) | |
| 3425 | − scan_all_zones_unevictable_pages(); | |
| 3426 | − | |
| 3427 | 3467 | scan_unevictable_pages = 0; |
| 3428 | 3468 | return 0; |
| 3429 | 3469 | } |
| @@ -3438,6 +3478,7 @@ static ssize_t read_scan_unevictable_node(struct sys_device *dev, · 8 unmodified lines | ||
| 3438 | 3478 | struct sysdev_attribute *attr, |
| 3439 | 3479 | char *buf) |
| 3440 | 3480 | { |
| 3481 | + warn_scan_unevictable_pages(); | |
| 3441 | 3482 | return sprintf(buf, "0\n"); /* always zero; should fit... */ |
| 3442 | 3483 | } |
| 3443 | 3484 | |
| @@ -3445,19 +3486,7 @@ static ssize_t write_scan_unevictable_node(struct sys_device *dev, · 1 unmodified line | ||
| 3445 | 3486 | struct sysdev_attribute *attr, |
| 3446 | 3487 | const char *buf, size_t count) |
| 3447 | 3488 | { |
| 3448 | − struct zone *node_zones = NODE_DATA(dev->id)->node_zones; | |
| 3449 | − struct zone *zone; | |
| 3450 | − unsigned long res; | |
| 3451 | − unsigned long req = strict_strtoul(buf, 10, &res); | |
| 3452 | − | |
| 3453 | − if (!req) | |
| 3454 | − return 1; /* zero is no-op */ | |
| 3455 | − | |
| 3456 | − for (zone = node_zones; zone - node_zones < MAX_NR_ZONES; ++zone) { | |
| 3457 | − if (!populated_zone(zone)) | |
| 3458 | − continue; | |
| 3459 | − scan_zone_unevictable_pages(zone); | |
| 3460 | − } | |
| 3489 | + warn_scan_unevictable_pages(); | |
| 3461 | 3490 | return 1; |
| 3462 | 3491 | } |
| 3463 | 3492 | |
| @@ -78,7 +78,7 @@ void vm_events_fold_cpu(int cpu) · 77 unmodified lines | ||
| 78 | 78 | * |
| 79 | 79 | * vm_stat contains the global counters |
| 80 | 80 | */ |
| 81 | −atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS]; | |
| 81 | +atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp; | |
| 82 | 82 | EXPORT_SYMBOL(vm_stat); |
| 83 | 83 | |
| 84 | 84 | #ifdef CONFIG_SMP |
| @@ -702,6 +702,7 @@ const char * const vmstat_text[] = { · 617 unmodified lines | ||
| 702 | 702 | "nr_unstable", |
| 703 | 703 | "nr_bounce", |
| 704 | 704 | "nr_vmscan_write", |
| 705 | + "nr_vmscan_immediate_reclaim", | |
| 705 | 706 | "nr_writeback_temp", |
| 706 | 707 | "nr_isolated_anon", |
| 707 | 708 | "nr_isolated_file", |
| @@ -27,7 +27,7 @@ · 26 unmodified lines | ||
| 27 | 27 | #include <net/nfc/nfc.h> |
| 28 | 28 | #include <net/sock.h> |
| 29 | 29 | |
| 30 | −__attribute__((format (printf, 2, 3))) | |
| 30 | +__printf(2, 3) | |
| 31 | 31 | int nfc_printk(const char *level, const char *fmt, ...); |
| 32 | 32 | |
| 33 | 33 | #define nfc_info(fmt, arg...) nfc_printk(KERN_INFO, fmt, ##arg) |
| @@ -36,8 +36,8 @@ · 35 unmodified lines | ||
| 36 | 36 | #define rdsdebug(fmt, args...) pr_debug("%s(): " fmt, __func__ , ##args) |
| 37 | 37 | #else |
| 38 | 38 | /* sigh, pr_debug() causes unused variable warnings */ |
| 39 | −static inline void __attribute__ ((format (printf, 1, 2))) | |
| 40 | −rdsdebug(char *fmt, ...) | |
| 39 | +static inline __printf(1, 2) | |
| 40 | +void rdsdebug(char *fmt, ...) | |
| 41 | 41 | { |
| 42 | 42 | } |
| 43 | 43 | #endif |
| @@ -625,8 +625,8 @@ void rds_for_each_conn_info(struct socket *sock, unsigned int len, · 581 unmodified lines | ||
| 625 | 625 | struct rds_info_lengths *lens, |
| 626 | 626 | int (*visitor)(struct rds_connection *, void *), |
| 627 | 627 | size_t item_len); |
| 628 | −void __rds_conn_error(struct rds_connection *conn, const char *, ...) | |
| 629 | − __attribute__ ((format (printf, 2, 3))); | |
| 628 | +__printf(2, 3) | |
| 629 | +void __rds_conn_error(struct rds_connection *conn, const char *, ...); | |
| 630 | 630 | #define rds_conn_error(conn, fmt...) \ |
| 631 | 631 | __rds_conn_error(conn, KERN_WARNING "RDS: " fmt) |
| 632 | 632 | |
| @@ -971,9 +971,8 @@ static void svc_unregister(const struct svc_serv *serv) · 970 unmodified lines | ||
| 971 | 971 | /* |
| 972 | 972 | * Printk the given error with the address of the client that caused it. |
| 973 | 973 | */ |
| 974 | −static int | |
| 975 | −__attribute__ ((format (printf, 2, 3))) | |
| 976 | −svc_printk(struct svc_rqst *rqstp, const char *fmt, ...) | |
| 974 | +static __printf(2, 3) | |
| 975 | +int svc_printk(struct svc_rqst *rqstp, const char *fmt, ...) | |
| 977 | 976 | { |
| 978 | 977 | va_list args; |
| 979 | 978 | int r; |
| @@ -240,9 +240,8 @@ our $NonptrType; · 239 unmodified lines | ||
| 240 | 240 | our $Type; |
| 241 | 241 | our $Declare; |
| 242 | 242 | |
| 243 | −our $UTF8 = qr { | |
| 244 | − [\x09\x0A\x0D\x20-\x7E] # ASCII | |
| 245 | − | [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte | |
| 243 | +our $NON_ASCII_UTF8 = qr{ | |
| 244 | + [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte | |
| 246 | 245 | | \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs |
| 247 | 246 | | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte |
| 248 | 247 | | \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates |
| @@ -251,6 +250,11 @@ our $UTF8 = qr { · 2 unmodified lines | ||
| 251 | 250 | | \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16 |
| 252 | 251 | }x; |
| 253 | 252 | |
| 253 | +our $UTF8 = qr{ | |
| 254 | + [\x09\x0A\x0D\x20-\x7E] # ASCII | |
| 255 | + | $NON_ASCII_UTF8 | |
| 256 | +}x; | |
| 257 | + | |
| 254 | 258 | our $typeTypedefs = qr{(?x: |
| 255 | 259 | (?:__)?(?:u|s|be|le)(?:8|16|32|64)| |
| 256 | 260 | atomic_t |
| @@ -1330,6 +1334,9 @@ sub process { · 1073 unmodified lines | ||
| 1330 | 1334 | my $signoff = 0; |
| 1331 | 1335 | my $is_patch = 0; |
| 1332 | 1336 | |
| 1337 | + my $in_header_lines = 1; | |
| 1338 | + my $in_commit_log = 0; #Scanning lines before patch | |
| 1339 | + | |
| 1333 | 1340 | our @report = (); |
| 1334 | 1341 | our $cnt_lines = 0; |
| 1335 | 1342 | our $cnt_error = 0; |
| @@ -1497,7 +1504,6 @@ sub process { · 161 unmodified lines | ||
| 1497 | 1504 | if ($line =~ /^diff --git.*?(\S+)$/) { |
| 1498 | 1505 | $realfile = $1; |
| 1499 | 1506 | $realfile =~ s@^([^/]*)/@@; |
| 1500 | − | |
| 1501 | 1507 | } elsif ($line =~ /^\+\+\+\s+(\S+)/) { |
| 1502 | 1508 | $realfile = $1; |
| 1503 | 1509 | $realfile =~ s@^([^/]*)/@@; |
| @@ -1536,6 +1542,7 @@ sub process { · 32 unmodified lines | ||
| 1536 | 1542 | # Check the patch for a signoff: |
| 1537 | 1543 | if ($line =~ /^\s*signed-off-by:/i) { |
| 1538 | 1544 | $signoff++; |
| 1545 | + $in_commit_log = 0; | |
| 1539 | 1546 | } |
| 1540 | 1547 | |
| 1541 | 1548 | # Check signature styles |
| @@ -1613,6 +1620,21 @@ sub process { · 71 unmodified lines | ||
| 1613 | 1620 | "Invalid UTF-8, patch and commit message should be encoded in UTF-8\n" . $hereptr); |
| 1614 | 1621 | } |
| 1615 | 1622 | |
| 1623 | +# Check if it's the start of a commit log | |
| 1624 | +# (not a header line and we haven't seen the patch filename) | |
| 1625 | + if ($in_header_lines && $realfile =~ /^$/ && | |
| 1626 | + $rawline !~ /^(commit\b|from\b|\w+:).+$/i) { | |
| 1627 | + $in_header_lines = 0; | |
| 1628 | + $in_commit_log = 1; | |
| 1629 | + } | |
| 1630 | + | |
| 1631 | +# Still not yet in a patch, check for any UTF-8 | |
| 1632 | + if ($in_commit_log && $realfile =~ /^$/ && | |
| 1633 | + $rawline =~ /$NON_ASCII_UTF8/) { | |
| 1634 | + CHK("UTF8_BEFORE_PATCH", | |
| 1635 | + "8-bit UTF-8 used in possible commit log\n" . $herecurr); | |
| 1636 | + } | |
| 1637 | + | |
| 1616 | 1638 | # ignore non-hunk lines and lines being removed |
| 1617 | 1639 | next if (!$hunk_line || $line =~ /^-/); |
| 1618 | 1640 | |
| @@ -3151,10 +3173,10 @@ sub process { · 1532 unmodified lines | ||
| 3151 | 3173 | "consider using a completion\n" . $herecurr); |
| 3152 | 3174 | |
| 3153 | 3175 | } |
| 3154 | −# recommend kstrto* over simple_strto* | |
| 3155 | − if ($line =~ /\bsimple_(strto.*?)\s*\(/) { | |
| 3176 | +# recommend kstrto* over simple_strto* and strict_strto* | |
| 3177 | + if ($line =~ /\b((simple|strict)_(strto(l|ll|ul|ull)))\s*\(/) { | |
| 3156 | 3178 | WARN("CONSIDER_KSTRTO", |
| 3157 | − "consider using kstrto* in preference to simple_$1\n" . $herecurr); | |
| 3179 | + "$1 is obsolete, use k$3 instead\n" . $herecurr); | |
| 3158 | 3180 | } |
| 3159 | 3181 | # check for __initcall(), use device_initcall() explicitly please |
| 3160 | 3182 | if ($line =~ /^.\s*__initcall\s*\(/) { |
| @@ -38,7 +38,7 @@ long compat_keyctl_instantiate_key_iov( · 37 unmodified lines | ||
| 38 | 38 | |
| 39 | 39 | ret = compat_rw_copy_check_uvector(WRITE, _payload_iov, ioc, |
| 40 | 40 | ARRAY_SIZE(iovstack), |
| 41 | − iovstack, &iov); | |
| 41 | + iovstack, &iov, 1); | |
| 42 | 42 | if (ret < 0) |
| 43 | 43 | return ret; |
| 44 | 44 | if (ret == 0) |
| @@ -293,7 +293,7 @@ static char *datablob_format(struct encrypted_key_payload *epayload, · 292 unmodified lines | ||
| 293 | 293 | /* convert the hex encoded iv, encrypted-data and HMAC to ascii */ |
| 294 | 294 | bufp = &ascii_buf[len]; |
| 295 | 295 | for (i = 0; i < (asciiblob_len - len) / 2; i++) |
| 296 | − bufp = pack_hex_byte(bufp, iv[i]); | |
| 296 | + bufp = hex_byte_pack(bufp, iv[i]); | |
| 297 | 297 | out: |
| 298 | 298 | return ascii_buf; |
| 299 | 299 | } |
| @@ -1065,7 +1065,7 @@ long keyctl_instantiate_key_iov(key_serial_t id, · 1064 unmodified lines | ||
| 1065 | 1065 | goto no_payload; |
| 1066 | 1066 | |
| 1067 | 1067 | ret = rw_copy_check_uvector(WRITE, _payload_iov, ioc, |
| 1068 | − ARRAY_SIZE(iovstack), iovstack, &iov); | |
| 1068 | + ARRAY_SIZE(iovstack), iovstack, &iov, 1); | |
| 1069 | 1069 | if (ret < 0) |
| 1070 | 1070 | return ret; |
| 1071 | 1071 | if (ret == 0) |
| @@ -1098,7 +1098,7 @@ static long trusted_read(const struct key *key, char __user *buffer, · 1097 unmodified lines | ||
| 1098 | 1098 | |
| 1099 | 1099 | bufp = ascii_buf; |
| 1100 | 1100 | for (i = 0; i < p->blob_len; i++) |
| 1101 | − bufp = pack_hex_byte(bufp, p->blob[i]); | |
| 1101 | + bufp = hex_byte_pack(bufp, p->blob[i]); | |
| 1102 | 1102 | if ((copy_to_user(buffer, ascii_buf, 2 * p->blob_len)) != 0) { |
| 1103 | 1103 | kfree(ascii_buf); |
| 1104 | 1104 | return -EFAULT; |
| @@ -32,7 +32,7 @@ enum bus_reset_handling { · 31 unmodified lines | ||
| 32 | 32 | SUCCEED_ON_BUS_RESET, |
| 33 | 33 | }; |
| 34 | 34 | |
| 35 | −static __attribute__((format(printf, 2, 3))) | |
| 35 | +static __printf(2, 3) | |
| 36 | 36 | void cmp_error(struct cmp_connection *c, const char *fmt, ...) |
| 37 | 37 | { |
| 38 | 38 | va_list va; |