aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2012-01-10checkpatch: complex macro should allow the empty do while loopAndy Whitcroft1-1/+1
It is common to stub out a function as below, this is triggering a complex macro format incorrectly. Sort this out: #define cma_early_regions_reserve(reserve) do { } while (0) Signed-off-by: Andy Whitcroft <[email protected]> Cc: Joe Perches <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2012-01-10checkpatch: fix EXPORT_SYMBOL handling following a functionAndy Whitcroft1-1/+1
The following fragment defeats the DEVICE_ATTR style handing, check for and ignore the close brace '}' in this context: int foo() { } DEVICE_ATTR(link_power_management_policy, S_IRUGO | S_IWUSR, ata_scsi_lpm_show, ata_scsi_lpm_put); EXPORT_SYMBOL_GPL(dev_attr_link_power_management_policy); Signed-off-by: Andy Whitcroft <[email protected]> Cc: Joe Perches <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2012-01-10checkpatch: only apply kconfig help checks for options which promptAndy Whitcroft1-5/+12
The intent of this check is to catch the options which the user will see and ensure they are properly described. It is also common for internal only options to have a brief description. Allow this form. Reported-by: Steven Rostedt <[email protected]> Tested-by: Steven Rostedt <[email protected]> Signed-off-by: Andy Whitcroft <[email protected]> Cc: Joe Perches <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2012-01-10checkpatch: optimise statement scanner when mid-statementAndy Whitcroft1-2/+20
In the middle of a long definition or similar, there is no possibility of finding a smaller sub-statement. Optimise this case by skipping statement aquirey where there are no starts of statement (open brace '{' or semi-colon ';'). We are likely to scan slightly more than needed still but this is safest. Signed-off-by: Andy Whitcroft <[email protected]> Cc: Joe Perches <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2012-01-10checkpatch: ## is not a valid modifierAndy Whitcroft1-1/+3
Inserting a # into the modifiers list will incorrectly add the null string to the modifiers list, leading to an infinite loop. As neither of these is a valid modifier form simply ignore them. Signed-off-by: Andy Whitcroft <[email protected]> Reported-by: Joe Perches <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2012-01-10checkpatch: improve memset and min/max with cast checkingJoe Perches1-36/+33
Improve the checking of arguments to memset and min/max tests. Move the checking of min/max to statement blocks instead of single line. Change $Constant to allow any case type 0x initiator and trailing ul specifier. Add $FuncArg type as any function argument with or without a cast. Print the whole statement when showing memset or min/max messages. Improve the memset with 0 as 3rd argument error message. There are still weaknesses in the $FuncArg and $Constant code as arbitrary parentheses and negative signs are not generically supported. [[email protected]: fix per Andy] Signed-off-by: Joe Perches <[email protected]> Acked-by: Andy Whitcroft <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2012-01-10checkpatch: check for common memset parameter issues against statmentsAndy Whitcroft1-6/+22
Move the memset checks over to work against the statement. Also add checks for 0 and 1 used as lengths. Generally these indicate badly ordered parameters. Signed-off-by: Andy Whitcroft <[email protected]> Cc: Joe Perches <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2012-01-10checkpatch: correctly track the end of preprocessor commands in contextAndy Whitcroft1-51/+39
When looking for a statement we currently run on through preprocessor commands. This means that a header file with just definitions is parsed over and over again combining all of the lines from the current line to the end of file leading to severe performance issues. Fix up context accumulation to track preprocessor commands and stop when reaching the end of them. At the same time vastly simplify the #define handling. Signed-off-by: Andy Whitcroft <[email protected]> Cc: Joe Perches <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2012-01-10checkpatch: prefer __printf over __attribute__((format(printf,...)))Joe Perches1-0/+6
Add a warn for not using __printf. Signed-off-by: Joe Perches <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2012-01-10checkpatch: update signature "might be better as" warningJoe Perches1-2/+5
email header lines can look like signature tags. It's valid to have multiple email recipients on a single line but not valid to have multiple signatures on a single line. Validate signatures only when not in the email headers. Clear the $in_commit_log flag when the patch filename appears. Add '-' to the valid chars in a message header for headers like "Message-Id:" and "In-Reply-To:". Signed-off-by: Joe Perches <[email protected]> Reported-by: Julia Lawall <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2012-01-10btree: export btree_get_prev() so modules can use btree_for_eachSteve Hodgson1-0/+1
The btree_for_each API is implemented with macros that internally call btree_get_prev(), so if btree_get_prev() isn't exported then modules fail to link if they try to use one of the btree_for_each macros. Since the rest of the btree API is exported, we should keep things orthogonal and make this work too. Signed-off-by: Roland Dreier <[email protected]> Signed-off-by: Steve Hodgson <[email protected]> Acked-by: Joern Engel <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2012-01-10leds: convert wm8350 driver to devm_kzalloc()Mark Brown1-5/+2
Saves a small amount of code and systematically eliminates leaks. Signed-off-by: Mark Brown <[email protected]> Cc: Richard Purdie <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2012-01-10leds: convert wm831x status driver to devm_kzalloc()Mark Brown1-3/+2
Saves a small amount of code and systematically eliminates leaks. Signed-off-by: Mark Brown <[email protected]> Cc: Richard Purdie <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2012-01-10drivers/leds/leds-mc13783.c: fix off-by-one for checking num_ledsAxel Lin1-1/+1
The LED id begins from 0. Thus the maximum number of leds should be MC13783_LED_MAX + 1. Signed-off-by: Axel Lin <[email protected]> Acked-by: Philippe Retornaz <[email protected]> Cc: Richard Purdie <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2012-01-10leds: add driver for TCA6507 LED controllerNeilBrown4-0/+822
TI's TCA6507 is the LED driver in the GTA04 Openmoko motherboard. The driver provides full support for brightness levels and hardware blinking. This driver can drive each of 7 outputs as an LED or a GPIO output, and provides hardware-assist blinking. [[email protected]: fix __mod_i2c_device_table alias] [[email protected]: coding-style fixes] Signed-off-by: NeilBrown <[email protected]> Cc: Richard Purdie <[email protected]> Cc: Randy Dunlap <[email protected]> Cc: Dan Carpenter <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2012-01-10drivers/leds/leds-netxbig.c: use gpio_request_one()Axel Lin1-18/+6
Use gpio_request_one() instead of multiple gpiolib calls. This also simplifies error handling a bit. Signed-off-by: Axel Lin <[email protected]> Cc: Simon Guinot <[email protected]> Cc: Richard Purdie <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2012-01-10drivers/leds/leds-bd2802.c: use gpio_request_one()Axel Lin1-2/+1
Use gpio_request_one() instead of multiple gpiolib calls. Signed-off-by: Axel Lin <[email protected]> Cc: Kim Kyuwon <[email protected]> Cc: Richard Purdie <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2012-01-10drivers/leds/leds-lp5523.c: remove unneeded forward declarationAxel Lin1-2/+0
Signed-off-by: Axel Lin <[email protected]> Cc: Samu Onkalo <[email protected]> Cc: Richard Purdie <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2012-01-10leds: convert leds-dac124s085 to module_spi_driverAxel Lin1-12/+1
Factor out some boilerplate code for spi driver registration into module_spi_driver. Signed-off-by: Axel Lin <[email protected]> Cc: Haojian Zhuang <[email protected]> Cc: Mark Brown <[email protected]> Cc: Richard Purdie <[email protected]> Cc: Michael Hennerich <[email protected]> Cc: Mike Rapoport <[email protected]> Acked-by: Guennadi Liakhovetski <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2012-01-10leds: convert led i2c drivers to module_i2c_driverAxel Lin7-98/+7
Factor out some boilerplate code for i2c driver registration into module_i2c_driver. Signed-off-by: Axel Lin <[email protected]> Cc: Haojian Zhuang <[email protected]> Cc: Mark Brown <[email protected]> Cc: Richard Purdie <[email protected]> Cc: Michael Hennerich <[email protected]> Cc: Mike Rapoport <[email protected]> Cc: Guennadi Liakhovetski <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2012-01-10leds: convert led platform drivers to module_platform_driverAxel Lin21-265/+31
Factor out some boilerplate code for platform driver registration into module_platform_driver. Signed-off-by: Axel Lin <[email protected]> Acked-by: Haojian Zhuang <[email protected]> [led-88pm860x.c] Acked-by: Mark Brown <[email protected]> Cc: Richard Purdie <[email protected]> Cc: Michael Hennerich <[email protected]> Cc: Mike Rapoport <[email protected]> Cc: Guennadi Liakhovetski <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2012-01-10backlight: convert pwm_bl to dev_pm_opsMark Brown1-10/+11
Should be no functional changes, mainly a reorganisation to support future work. [[email protected]: fix CONFIG_PM=n build] Signed-off-by: Mark Brown <[email protected]> Cc: Richard Purdie <[email protected]> Cc: Florian Tobias Schandinat <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2012-01-10backlight: convert platform_lcd to devm_kzalloc()Mark Brown1-5/+4
Saves some error handling code and eliminates a class of leaks. Signed-off-by: Mark Brown <[email protected]> Cc: Richard Purdie <[email protected]> Cc: Florian Tobias Schandinat <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2012-01-10backlight: use kstrtoul()Jingoo Han2-19/+13
The usage of simple_strtoul() or strict_strtoul() is not preferred. Thus, kstrtoul should be used. This patch also fixes checkpatch error as follows: ERROR: space required after that ',' (ctx:VxV) Signed-off-by: Jingoo Han <[email protected]> Cc: Richard Purdie <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2012-01-10drivers/video/backlight/ep93xx_bl.c: remove duplicated header includeJingoo Han1-1/+0
module.h is included twice. Signed-off-by: Jingoo Han <[email protected]> Acked-by: H Hartley Sweeten <[email protected]> Cc: Ryan Mallon <[email protected]> Cc: Richard Purdie <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2012-01-10backlight/ld9040.c: regulator control in the driverDonghwa Lee1-12/+59
This patch supports regulator power control in the driver. Current ld9040 driver was controlled power on/off sequence by callback function in the board file. But, by doing this, there's no need to register lcd power on/off callback function in the board file. Signed-off-by: Donghwa Lee <[email protected]> Signed-off-by: Kyungmin Park <[email protected]> Signed-off-by: Inki Dae <[email protected]> Cc: Richard Purdie <[email protected]> Cc: Florian Tobias Schandinat <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2012-01-10backlight: convert drivers/video/backlight/* to use module_platform_driver()Axel Lin13-148/+13
Convert the drivers in drivers/video/backlight/* to use the module_platform_driver() macro which makes the code smaller and a bit simpler. Signed-off-by: Axel Lin <[email protected]> Acked-by: Haojian Zhuang <[email protected]> Acked-by: H Hartley Sweeten <[email protected]> [ep93xx_bl.c] Cc: Mike Rapoport <[email protected]> Cc: Richard Purdie <[email protected]> Acked-by: Michael Hennerich <[email protected]> Acked-by: Mark Brown <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2012-01-10backlight: remove ADX backlight device supportPaul Bolle3-191/+0
Support for the Avionic Design Xanthos backlight device got added in commit 3b96ea9ef8 ("backlight: Add support for the Avionic Design Xanthos backlight device."). That support depends on ARCH_PXA_ADX. The code that should have provided that Kconfig symbol never got submitted. It has never been possible to even build this driver. Remove it. Signed-off-by: Paul Bolle <[email protected]> Acked-by: Thierry Reding <[email protected]> Cc: Richard Purdie <[email protected]> Cc: Wim Van Sebroeck <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2012-01-10devfreq: add devfreq maintainer entryKyungmin Park1-0/+7
As devfreq is merged at mainline. Also update the maintainer entry. Signed-off-by: Kyungmin Park <[email protected]> Cc: Kevin Hilman <[email protected]> Cc: MyungJoo Ham <[email protected]> Acked-by: Rafael J. Wysocki <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2012-01-10MAINTAINERS: spi: update F: patternsJoe Perches1-3/+3
commit ca632f55669 ("spi: reorganize drivers") renamed the files, update the F: patterns. Signed-off-by: Joe Perches <[email protected]> Acked-by: Grant Likely <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2012-01-10MAINTAINERS: serial:blackfin: update F: patternJoe Perches1-1/+1
commit 0c6967b5a0 ("serial:blackfin: rename Blackfin serial driver to bfin_uart.c") renamed the file, update the pattern. Signed-off-by: Joe Perches <[email protected]> Acked-by: Sonic Zhang <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2012-01-10MAINTAINERS: staging: media: update F: patternsJoe Perches1-2/+2
commit 4860c73804c ("staging: Move media drivers to staging/media") moved the files, update the F: patterns. Signed-off-by: Joe Perches <[email protected]> Acked-by: Mauro Carvalho Chehab<[email protected]> Cc: Greg KH <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2012-01-10MAINTAINERS: update encrypted-keys F: patternsJoe Perches1-2/+1
commit 61cf45d0199 ("encrypted-keys: create encrypted-keys directory") moved the files, update the patterns. Signed-off-by: Joe Perches <[email protected]> Cc: Mimi Zohar <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2012-01-10MAINTAINERS: update greth F: patternsJoe Perches1-1/+1
commit 1fe003fd424 ("greth: Move the Aeroflex Gaisler driver") moved the files, update the patterns. Signed-off-by: Joe Perches <[email protected]> Cc: Kristoffer Glembo <[email protected]> Cc: Jeff Kirsher <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2012-01-10MAINTAINERS: update tulip F: patternsJoe Perches1-2/+2
commit a88394cfb58 ("ewrk3/tulip: Move the DEC - Tulip drivers") moved the files, update the patterns. Signed-off-by: Joe Perches <[email protected]> Acked-by: Grant Grundler <[email protected]> Cc: Jeff Kirsher <[email protected]> Cc: Tobias Ringstrom <[email protected]> Cc: Grant Grundler <[email protected]> Cc: David Davies <[email protected]> Cc: David Miller <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2012-01-10MAINTAINERS: update sdhci F: patternsJoe Perches1-1/+2
commit 38576af1f8c ("mmc: sdhci: make sdhci-of device drivers self registered") moved the files around. Update the patterns. Signed-off-by: Joe Perches <[email protected]> Cc: Shawn Guo <[email protected]> Cc: Chris Ball <[email protected]> Acked-by: Anton Vorontsov <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2012-01-10MAINTAINERS: update mfd F: patternsJoe Perches1-1/+0
commit 8959e74399c ("mfd: Delete ab3550 driver") removed the driver, update the patterns. Signed-off-by: Joe Perches <[email protected]> Acked-by: Linus Walleij <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2012-01-10MAINTAINERS: update marvell ccic F: patternsJoe Perches1-1/+1
Commit f8fc729870ee ("[media] marvell-cam: Move cafe-ccic into its own directory") moved the files, update the pattern. Signed-off-by: Joe Perches <[email protected]> Cc: Jonathan Corbet <[email protected]> Acked-by: Mauro Carvalho Chehab<[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2012-01-10MAINTAINERS: update bt8xx gpio F: patternsJoe Perches1-1/+1
Commit c103de240439d ("gpio: reorganize drivers") renamed the file, update the pattern. Signed-off-by: Joe Perches <[email protected]> Cc: Grant Likely <[email protected]> Cc: Michael Buesch <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2012-01-10MAINTAINERS: update adp gpio F: patternsJoe Perches1-2/+2
Commit c103de240439df ("gpio: reorganize drivers") renamed the files, update the patterns. Signed-off-by: Joe Perches <[email protected]> Acked-by: Grant Likely <[email protected]> Acked-by: Michael Hennerich <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2012-01-10MAINTAINERS: update various arm F: patternsJoe Perches1-7/+2
Track renames and missing or deleted files. Signed-off-by: Joe Perches <[email protected]> Cc: Russell King <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2012-01-10get_maintainers.pl: follow renames when looking up commit signersIan Campbell1-1/+1
I happen to have had a commit to various network drivers since the big renaming/reorg which happened to drivers/net recently. This means that I now appear to be in the top few commit signers (by %age) for many of them so am getting sent all sorts of stuff and people who are involved with the driver are not. e.g. (to pick one at random): $ ./scripts/get_maintainer.pl -f drivers/net/ethernet/nvidia/forcedeth.c "David S. Miller" <[email protected]> (commit_signer:5/7=71%) Ian Campbell <[email protected]> (commit_signer:2/7=29%) Eric Dumazet <[email protected]> (commit_signer:1/7=14%) Jeff Kirsher <[email protected]> (commit_signer:1/7=14%) Jiri Pirko <[email protected]> (commit_signer:1/7=14%) [email protected] (open list:NETWORKING DRIVERS) [email protected] (open list) With the following patch the renames are followed and the result appears much more sensible: $ ./scripts/get_maintainer.pl -f drivers/net/ethernet/nvidia/forcedeth.c "David S. Miller" <[email protected]> (commit_signer:31/34=91%) Joe Perches <[email protected]> (commit_signer:11/34=32%) Szymon Janc <[email protected]> (commit_signer:5/34=15%) Jiri Pirko <[email protected]> (commit_signer:3/34=9%) Paul <[email protected]> (commit_signer:2/34=6%) [email protected] (open list:NETWORKING DRIVERS) [email protected] (open list) Signed-off-by: Ian Campbell <[email protected]> Acked-by: Joe Perches <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2012-01-10mm/vmalloc.c: change void* into explict vm_struct*Minchan Kim1-4/+4
vmap_area->private is void* but we don't use the field for various purpose but use only for vm_struct. So change it to a vm_struct* with naming to improve for readability and type checking. Signed-off-by: Minchan Kim <[email protected]> Acked-by: David Rientjes <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2012-01-10mm: vmscan: fix typo in isolating lru pagesHillf Danton1-1/+1
It is not the tag page but the cursor page that we should process, and it looks a typo. Signed-off-by: Hillf Danton <[email protected]> Cc: Michal Hocko <[email protected]> Cc: KAMEZAWA Hiroyuki <[email protected]> Cc: Andrea Arcangeli <[email protected]> Cc: David Rientjes <[email protected]> Cc: Hugh Dickins <[email protected]> Acked-by: KOSAKI Motohiro <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2012-01-10mm: test PageSwapBacked in lumpy reclaimHugh Dickins1-1/+1
Lumpy reclaim does well to stop at a PageAnon when there's no swap, but better is to stop at any PageSwapBacked, which includes shmem/tmpfs too. Signed-off-by: Hugh Dickins <[email protected]> Reviewed-by: KOSAKI Motohiro <[email protected]> Reviewed-by: Minchan Kim <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2012-01-10mm/migrate.c: remove the unused macro lru_to_pageWang Sheng-Hui1-2/+0
lru_to_page is not used in mm/migrate.c. Signed-off-by: Wang Sheng-Hui <[email protected]> Acked-by: Mel Gorman <[email protected]> Acked-by: Kyungmin Park <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2012-01-10mm/hugetlb.c: avoid bogus counter of surplus huge pageHillf Danton1-1/+1
If we have to hand back the newly allocated huge page to page allocator, for any reason, the changed counter should be recovered. This affects only s390 at present. Signed-off-by: Hillf Danton <[email protected]> Reviewed-by: Michal Hocko <[email protected]> Acked-by: KAMEZAWA Hiroyuki <[email protected]> Cc: Martin Schwidefsky <[email protected]> Cc: Heiko Carstens <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2012-01-10mempool: fix first round failure behaviorTejun Heo1-2/+11
mempool modifies gfp_mask so that the backing allocator doesn't try too hard or trigger warning message when there's pool to fall back on. In addition, for the first try, it removes __GFP_WAIT and IO, so that it doesn't trigger reclaim or wait when allocation can be fulfilled from pool; however, when that allocation fails and pool is empty too, it waits for the pool to be replenished before retrying. Allocation which could have succeeded after a bit of reclaim has to wait on the reserved items and it's not like mempool doesn't retry with __GFP_WAIT and IO. It just does that *after* someone returns an element, pointlessly delaying things. Fix it by retrying immediately if the first round of allocation attempts w/o __GFP_WAIT and IO fails. [[email protected]: shorten the lock hold time] Signed-off-by: Tejun Heo <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2012-01-10mempool: drop unnecessary and incorrect BUG_ON() from mempool_destroy()Tejun Heo1-19/+11
mempool_destroy() is a thin wrapper around free_pool(). The only thing it adds is BUG_ON(pool->curr_nr != pool->min_nr). The intention seems to be to enforce that all allocated elements are freed; however, the BUG_ON() can't achieve that (it doesn't know anything about objects above min_nr) and incorrect as mempool_resize() is allowed to leave the pool extended but not filled. Furthermore, panicking is way worse than any memory leak and there are better debug tools to track memory leaks. Drop the BUG_ON() from mempool_destory() and as that leaves the function identical to free_pool(), replace it. Signed-off-by: Tejun Heo <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2012-01-10mempool: fix and document synchronization and memory barrier usageTejun Heo1-13/+48
mempool_alloc/free() use undocumented smp_mb()'s. The code is slightly broken and misleading. The lockless part is in mempool_free(). It wants to determine whether the item being freed needs to be returned to the pool or backing allocator without grabbing pool->lock. Two things need to be guaranteed for correct operation. 1. pool->curr_nr + #allocated should never dip below pool->min_nr. 2. Waiters shouldn't be left dangling. For #1, The only necessary condition is that curr_nr visible at free is from after the allocation of the element being freed (details in the comment). For most cases, this is true without any barrier but there can be fringe cases where the allocated pointer is passed to the freeing task without going through memory barriers. To cover this case, wmb is necessary before returning from allocation and rmb is necessary before reading curr_nr. IOW, ALLOCATING TASK FREEING TASK update pool state after alloc; wmb(); pass pointer to freeing task; read pointer; rmb(); read pool state to free; The current code doesn't have wmb after pool update during allocation and may theoretically, on machines where unlock doesn't behave as full wmb, lead to pool depletion and deadlock. smp_wmb() needs to be added after successful allocation from reserved elements and smp_mb() in mempool_free() can be replaced with smp_rmb(). For #2, the waiter needs to add itself to waitqueue and then check the wait condition and the waker needs to update the wait condition and then wake up. Because waitqueue operations always go through full spinlock synchronization, there is no need for extra memory barriers. Furthermore, mempool_alloc() is already holding pool->lock when it decides that it needs to wait. There is no reason to do unlock - add waitqueue - test condition again. It can simply add itself to waitqueue while holding pool->lock and then unlock and sleep. This patch adds smp_wmb() after successful allocation from reserved pool, replaces smp_mb() in mempool_free() with smp_rmb() and extend pool->lock over waitqueue addition. More importantly, it explains what memory barriers do and how the lockless testing is correct. -v2: Oleg pointed out that unlock doesn't imply wmb. Added explicit smp_wmb() after successful allocation from reserved pool and updated comments accordingly. Signed-off-by: Tejun Heo <[email protected]> Cc: Oleg Nesterov <[email protected]> Cc: "Paul E. McKenney" <[email protected]> Cc: David Howells <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>