aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/base/memory.c15
-rw-r--r--drivers/char/hpet.c4
-rw-r--r--drivers/s390/char/sclp_cmd.c7
-rw-r--r--fs/jffs2/readinode.c2
-rw-r--r--fs/ntfs/super.c25
-rw-r--r--include/linux/memory.h2
-rw-r--r--mm/page_cgroup.c20
7 files changed, 50 insertions, 25 deletions
diff --git a/drivers/base/memory.c b/drivers/base/memory.c
index 2f8691511190..db0848e54cc6 100644
--- a/drivers/base/memory.c
+++ b/drivers/base/memory.c
@@ -429,12 +429,16 @@ static inline int memory_fail_init(void)
429 * differentiation between which *physical* devices each 429 * differentiation between which *physical* devices each
430 * section belongs to... 430 * section belongs to...
431 */ 431 */
432int __weak arch_get_memory_phys_device(unsigned long start_pfn)
433{
434 return 0;
435}
432 436
433static int add_memory_block(int nid, struct mem_section *section, 437static int add_memory_block(int nid, struct mem_section *section,
434 unsigned long state, int phys_device, 438 unsigned long state, enum mem_add_context context)
435 enum mem_add_context context)
436{ 439{
437 struct memory_block *mem = kzalloc(sizeof(*mem), GFP_KERNEL); 440 struct memory_block *mem = kzalloc(sizeof(*mem), GFP_KERNEL);
441 unsigned long start_pfn;
438 int ret = 0; 442 int ret = 0;
439 443
440 if (!mem) 444 if (!mem)
@@ -443,7 +447,8 @@ static int add_memory_block(int nid, struct mem_section *section,
443 mem->phys_index = __section_nr(section); 447 mem->phys_index = __section_nr(section);
444 mem->state = state; 448 mem->state = state;
445 mutex_init(&mem->state_mutex); 449 mutex_init(&mem->state_mutex);
446 mem->phys_device = phys_device; 450 start_pfn = section_nr_to_pfn(mem->phys_index);
451 mem->phys_device = arch_get_memory_phys_device(start_pfn);
447 452
448 ret = register_memory(mem, section); 453 ret = register_memory(mem, section);
449 if (!ret) 454 if (!ret)
@@ -515,7 +520,7 @@ int remove_memory_block(unsigned long node_id, struct mem_section *section,
515 */ 520 */
516int register_new_memory(int nid, struct mem_section *section) 521int register_new_memory(int nid, struct mem_section *section)
517{ 522{
518 return add_memory_block(nid, section, MEM_OFFLINE, 0, HOTPLUG); 523 return add_memory_block(nid, section, MEM_OFFLINE, HOTPLUG);
519} 524}
520 525
521int unregister_memory_section(struct mem_section *section) 526int unregister_memory_section(struct mem_section *section)
@@ -548,7 +553,7 @@ int __init memory_dev_init(void)
548 if (!present_section_nr(i)) 553 if (!present_section_nr(i))
549 continue; 554 continue;
550 err = add_memory_block(0, __nr_to_section(i), MEM_ONLINE, 555 err = add_memory_block(0, __nr_to_section(i), MEM_ONLINE,
551 0, BOOT); 556 BOOT);
552 if (!ret) 557 if (!ret)
553 ret = err; 558 ret = err;
554 } 559 }
diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
index e481c5938bad..9c5eea3ea4de 100644
--- a/drivers/char/hpet.c
+++ b/drivers/char/hpet.c
@@ -215,9 +215,7 @@ static void hpet_timer_set_irq(struct hpet_dev *devp)
215 else 215 else
216 v &= ~0xffff; 216 v &= ~0xffff;
217 217
218 for (irq = find_first_bit(&v, HPET_MAX_IRQ); irq < HPET_MAX_IRQ; 218 for_each_set_bit(irq, &v, HPET_MAX_IRQ) {
219 irq = find_next_bit(&v, HPET_MAX_IRQ, 1 + irq)) {
220
221 if (irq >= nr_irqs) { 219 if (irq >= nr_irqs) {
222 irq = HPET_MAX_IRQ; 220 irq = HPET_MAX_IRQ;
223 break; 221 break;
diff --git a/drivers/s390/char/sclp_cmd.c b/drivers/s390/char/sclp_cmd.c
index b3beab610da4..fc7ae05ce48a 100644
--- a/drivers/s390/char/sclp_cmd.c
+++ b/drivers/s390/char/sclp_cmd.c
@@ -704,6 +704,13 @@ int sclp_chp_deconfigure(struct chp_id chpid)
704 return do_chp_configure(SCLP_CMDW_DECONFIGURE_CHPATH | chpid.id << 8); 704 return do_chp_configure(SCLP_CMDW_DECONFIGURE_CHPATH | chpid.id << 8);
705} 705}
706 706
707int arch_get_memory_phys_device(unsigned long start_pfn)
708{
709 if (!rzm)
710 return 0;
711 return PFN_PHYS(start_pfn) / rzm;
712}
713
707struct chp_info_sccb { 714struct chp_info_sccb {
708 struct sccb_header header; 715 struct sccb_header header;
709 u8 recognized[SCLP_CHP_INFO_MASK_SIZE]; 716 u8 recognized[SCLP_CHP_INFO_MASK_SIZE];
diff --git a/fs/jffs2/readinode.c b/fs/jffs2/readinode.c
index e22de8397b74..d32ee9412cb9 100644
--- a/fs/jffs2/readinode.c
+++ b/fs/jffs2/readinode.c
@@ -567,7 +567,7 @@ static void jffs2_free_tmp_dnode_info_list(struct rb_root *list)
567 else BUG(); 567 else BUG();
568 } 568 }
569 } 569 }
570 list->rb_node = NULL; 570 *list = RB_ROOT;
571} 571}
572 572
573static void jffs2_free_full_dirent_list(struct jffs2_full_dirent *fd) 573static void jffs2_free_full_dirent_list(struct jffs2_full_dirent *fd)
diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
index 1cf39dfaee7a..0de1db6cddbf 100644
--- a/fs/ntfs/super.c
+++ b/fs/ntfs/super.c
@@ -31,6 +31,7 @@
31#include <linux/vfs.h> 31#include <linux/vfs.h>
32#include <linux/moduleparam.h> 32#include <linux/moduleparam.h>
33#include <linux/smp_lock.h> 33#include <linux/smp_lock.h>
34#include <linux/bitmap.h>
34 35
35#include "sysctl.h" 36#include "sysctl.h"
36#include "logfile.h" 37#include "logfile.h"
@@ -2458,7 +2459,6 @@ static void ntfs_put_super(struct super_block *sb)
2458static s64 get_nr_free_clusters(ntfs_volume *vol) 2459static s64 get_nr_free_clusters(ntfs_volume *vol)
2459{ 2460{
2460 s64 nr_free = vol->nr_clusters; 2461 s64 nr_free = vol->nr_clusters;
2461 u32 *kaddr;
2462 struct address_space *mapping = vol->lcnbmp_ino->i_mapping; 2462 struct address_space *mapping = vol->lcnbmp_ino->i_mapping;
2463 struct page *page; 2463 struct page *page;
2464 pgoff_t index, max_index; 2464 pgoff_t index, max_index;
@@ -2477,7 +2477,8 @@ static s64 get_nr_free_clusters(ntfs_volume *vol)
2477 ntfs_debug("Reading $Bitmap, max_index = 0x%lx, max_size = 0x%lx.", 2477 ntfs_debug("Reading $Bitmap, max_index = 0x%lx, max_size = 0x%lx.",
2478 max_index, PAGE_CACHE_SIZE / 4); 2478 max_index, PAGE_CACHE_SIZE / 4);
2479 for (index = 0; index < max_index; index++) { 2479 for (index = 0; index < max_index; index++) {
2480 unsigned int i; 2480 unsigned long *kaddr;
2481
2481 /* 2482 /*
2482 * Read the page from page cache, getting it from backing store 2483 * Read the page from page cache, getting it from backing store
2483 * if necessary, and increment the use count. 2484 * if necessary, and increment the use count.
@@ -2490,16 +2491,16 @@ static s64 get_nr_free_clusters(ntfs_volume *vol)
2490 nr_free -= PAGE_CACHE_SIZE * 8; 2491 nr_free -= PAGE_CACHE_SIZE * 8;
2491 continue; 2492 continue;
2492 } 2493 }
2493 kaddr = (u32*)kmap_atomic(page, KM_USER0); 2494 kaddr = kmap_atomic(page, KM_USER0);
2494 /* 2495 /*
2495 * For each 4 bytes, subtract the number of set bits. If this 2496 * Subtract the number of set bits. If this
2496 * is the last page and it is partial we don't really care as 2497 * is the last page and it is partial we don't really care as
2497 * it just means we do a little extra work but it won't affect 2498 * it just means we do a little extra work but it won't affect
2498 * the result as all out of range bytes are set to zero by 2499 * the result as all out of range bytes are set to zero by
2499 * ntfs_readpage(). 2500 * ntfs_readpage().
2500 */ 2501 */
2501 for (i = 0; i < PAGE_CACHE_SIZE / 4; i++) 2502 nr_free -= bitmap_weight(kaddr,
2502 nr_free -= (s64)hweight32(kaddr[i]); 2503 PAGE_CACHE_SIZE * BITS_PER_BYTE);
2503 kunmap_atomic(kaddr, KM_USER0); 2504 kunmap_atomic(kaddr, KM_USER0);
2504 page_cache_release(page); 2505 page_cache_release(page);
2505 } 2506 }
@@ -2538,7 +2539,6 @@ static s64 get_nr_free_clusters(ntfs_volume *vol)
2538static unsigned long __get_nr_free_mft_records(ntfs_volume *vol, 2539static unsigned long __get_nr_free_mft_records(ntfs_volume *vol,
2539 s64 nr_free, const pgoff_t max_index) 2540 s64 nr_free, const pgoff_t max_index)
2540{ 2541{
2541 u32 *kaddr;
2542 struct address_space *mapping = vol->mftbmp_ino->i_mapping; 2542 struct address_space *mapping = vol->mftbmp_ino->i_mapping;
2543 struct page *page; 2543 struct page *page;
2544 pgoff_t index; 2544 pgoff_t index;
@@ -2548,7 +2548,8 @@ static unsigned long __get_nr_free_mft_records(ntfs_volume *vol,
2548 ntfs_debug("Reading $MFT/$BITMAP, max_index = 0x%lx, max_size = " 2548 ntfs_debug("Reading $MFT/$BITMAP, max_index = 0x%lx, max_size = "
2549 "0x%lx.", max_index, PAGE_CACHE_SIZE / 4); 2549 "0x%lx.", max_index, PAGE_CACHE_SIZE / 4);
2550 for (index = 0; index < max_index; index++) { 2550 for (index = 0; index < max_index; index++) {
2551 unsigned int i; 2551 unsigned long *kaddr;
2552
2552 /* 2553 /*
2553 * Read the page from page cache, getting it from backing store 2554 * Read the page from page cache, getting it from backing store
2554 * if necessary, and increment the use count. 2555 * if necessary, and increment the use count.
@@ -2561,16 +2562,16 @@ static unsigned long __get_nr_free_mft_records(ntfs_volume *vol,
2561 nr_free -= PAGE_CACHE_SIZE * 8; 2562 nr_free -= PAGE_CACHE_SIZE * 8;
2562 continue; 2563 continue;
2563 } 2564 }
2564 kaddr = (u32*)kmap_atomic(page, KM_USER0); 2565 kaddr = kmap_atomic(page, KM_USER0);
2565 /* 2566 /*
2566 * For each 4 bytes, subtract the number of set bits. If this 2567 * Subtract the number of set bits. If this
2567 * is the last page and it is partial we don't really care as 2568 * is the last page and it is partial we don't really care as
2568 * it just means we do a little extra work but it won't affect 2569 * it just means we do a little extra work but it won't affect
2569 * the result as all out of range bytes are set to zero by 2570 * the result as all out of range bytes are set to zero by
2570 * ntfs_readpage(). 2571 * ntfs_readpage().
2571 */ 2572 */
2572 for (i = 0; i < PAGE_CACHE_SIZE / 4; i++) 2573 nr_free -= bitmap_weight(kaddr,
2573 nr_free -= (s64)hweight32(kaddr[i]); 2574 PAGE_CACHE_SIZE * BITS_PER_BYTE);
2574 kunmap_atomic(kaddr, KM_USER0); 2575 kunmap_atomic(kaddr, KM_USER0);
2575 page_cache_release(page); 2576 page_cache_release(page);
2576 } 2577 }
diff --git a/include/linux/memory.h b/include/linux/memory.h
index 1adfe779eb99..85582e1bcee9 100644
--- a/include/linux/memory.h
+++ b/include/linux/memory.h
@@ -36,6 +36,8 @@ struct memory_block {
36 struct sys_device sysdev; 36 struct sys_device sysdev;
37}; 37};
38 38
39int arch_get_memory_phys_device(unsigned long start_pfn);
40
39/* These states are exposed to userspace as text strings in sysfs */ 41/* These states are exposed to userspace as text strings in sysfs */
40#define MEM_ONLINE (1<<0) /* exposed to userspace */ 42#define MEM_ONLINE (1<<0) /* exposed to userspace */
41#define MEM_GOING_OFFLINE (1<<1) /* exposed to userspace */ 43#define MEM_GOING_OFFLINE (1<<1) /* exposed to userspace */
diff --git a/mm/page_cgroup.c b/mm/page_cgroup.c
index 3dd88539a0e6..6c0081441a32 100644
--- a/mm/page_cgroup.c
+++ b/mm/page_cgroup.c
@@ -284,6 +284,7 @@ static DEFINE_MUTEX(swap_cgroup_mutex);
284struct swap_cgroup_ctrl { 284struct swap_cgroup_ctrl {
285 struct page **map; 285 struct page **map;
286 unsigned long length; 286 unsigned long length;
287 spinlock_t lock;
287}; 288};
288 289
289struct swap_cgroup_ctrl swap_cgroup_ctrl[MAX_SWAPFILES]; 290struct swap_cgroup_ctrl swap_cgroup_ctrl[MAX_SWAPFILES];
@@ -353,16 +354,22 @@ unsigned short swap_cgroup_cmpxchg(swp_entry_t ent,
353 struct swap_cgroup_ctrl *ctrl; 354 struct swap_cgroup_ctrl *ctrl;
354 struct page *mappage; 355 struct page *mappage;
355 struct swap_cgroup *sc; 356 struct swap_cgroup *sc;
357 unsigned long flags;
358 unsigned short retval;
356 359
357 ctrl = &swap_cgroup_ctrl[type]; 360 ctrl = &swap_cgroup_ctrl[type];
358 361
359 mappage = ctrl->map[idx]; 362 mappage = ctrl->map[idx];
360 sc = page_address(mappage); 363 sc = page_address(mappage);
361 sc += pos; 364 sc += pos;
362 if (cmpxchg(&sc->id, old, new) == old) 365 spin_lock_irqsave(&ctrl->lock, flags);
363 return old; 366 retval = sc->id;
367 if (retval == old)
368 sc->id = new;
364 else 369 else
365 return 0; 370 retval = 0;
371 spin_unlock_irqrestore(&ctrl->lock, flags);
372 return retval;
366} 373}
367 374
368/** 375/**
@@ -383,13 +390,17 @@ unsigned short swap_cgroup_record(swp_entry_t ent, unsigned short id)
383 struct page *mappage; 390 struct page *mappage;
384 struct swap_cgroup *sc; 391 struct swap_cgroup *sc;
385 unsigned short old; 392 unsigned short old;
393 unsigned long flags;
386 394
387 ctrl = &swap_cgroup_ctrl[type]; 395 ctrl = &swap_cgroup_ctrl[type];
388 396
389 mappage = ctrl->map[idx]; 397 mappage = ctrl->map[idx];
390 sc = page_address(mappage); 398 sc = page_address(mappage);
391 sc += pos; 399 sc += pos;
392 old = xchg(&sc->id, id); 400 spin_lock_irqsave(&ctrl->lock, flags);
401 old = sc->id;
402 sc->id = id;
403 spin_unlock_irqrestore(&ctrl->lock, flags);
393 404
394 return old; 405 return old;
395} 406}
@@ -441,6 +452,7 @@ int swap_cgroup_swapon(int type, unsigned long max_pages)
441 mutex_lock(&swap_cgroup_mutex); 452 mutex_lock(&swap_cgroup_mutex);
442 ctrl->length = length; 453 ctrl->length = length;
443 ctrl->map = array; 454 ctrl->map = array;
455 spin_lock_init(&ctrl->lock);
444 if (swap_cgroup_prepare(type)) { 456 if (swap_cgroup_prepare(type)) {
445 /* memory shortage */ 457 /* memory shortage */
446 ctrl->map = NULL; 458 ctrl->map = NULL;