aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2008-07-28 15:14:43 -0400
committerIngo Molnar <mingo@elte.hu>2008-07-28 15:14:43 -0400
commit414f746d232d41ed6ae8632c4495ae795373c44b (patch)
tree167f9bc8f139c6e82e6732b38c7a938b8a9d31cd /lib
parent5a7a201c51c324876d00a54e7208af6af12d1ca4 (diff)
parentc9272c4f9fbe2087beb3392f526dc5b19efaa56b (diff)
Merge branch 'linus' into cpus4096
Diffstat (limited to 'lib')
-rw-r--r--lib/Makefile4
-rw-r--r--lib/debugobjects.c15
-rw-r--r--lib/idr.c2
-rw-r--r--lib/iomap.c3
-rw-r--r--lib/kobject_uevent.c6
-rw-r--r--lib/plist.c13
-rw-r--r--lib/radix-tree.c180
-rw-r--r--lib/show_mem.c63
-rw-r--r--lib/swiotlb.c4
-rw-r--r--lib/syscall.c75
10 files changed, 315 insertions, 50 deletions
diff --git a/lib/Makefile b/lib/Makefile
index 9085ad6fa53d..3b1f94bbe9de 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -11,7 +11,7 @@ lib-y := ctype.o string.o vsprintf.o cmdline.o \
11 rbtree.o radix-tree.o dump_stack.o \ 11 rbtree.o radix-tree.o dump_stack.o \
12 idr.o int_sqrt.o extable.o prio_tree.o \ 12 idr.o int_sqrt.o extable.o prio_tree.o \
13 sha1.o irq_regs.o reciprocal_div.o argv_split.o \ 13 sha1.o irq_regs.o reciprocal_div.o argv_split.o \
14 proportions.o prio_heap.o ratelimit.o 14 proportions.o prio_heap.o ratelimit.o show_mem.o
15 15
16lib-$(CONFIG_MMU) += ioremap.o 16lib-$(CONFIG_MMU) += ioremap.o
17lib-$(CONFIG_SMP) += cpumask.o 17lib-$(CONFIG_SMP) += cpumask.o
@@ -78,6 +78,8 @@ lib-$(CONFIG_GENERIC_BUG) += bug.o
78 78
79obj-$(CONFIG_HAVE_LMB) += lmb.o 79obj-$(CONFIG_HAVE_LMB) += lmb.o
80 80
81obj-$(CONFIG_HAVE_ARCH_TRACEHOOK) += syscall.o
82
81hostprogs-y := gen_crc32table 83hostprogs-y := gen_crc32table
82clean-files := crc32table.h 84clean-files := crc32table.h
83 85
diff --git a/lib/debugobjects.c b/lib/debugobjects.c
index f86196390cfd..45a6bde762d1 100644
--- a/lib/debugobjects.c
+++ b/lib/debugobjects.c
@@ -205,9 +205,8 @@ static void debug_print_object(struct debug_obj *obj, char *msg)
205 205
206 if (limit < 5 && obj->descr != descr_test) { 206 if (limit < 5 && obj->descr != descr_test) {
207 limit++; 207 limit++;
208 printk(KERN_ERR "ODEBUG: %s %s object type: %s\n", msg, 208 WARN(1, KERN_ERR "ODEBUG: %s %s object type: %s\n", msg,
209 obj_states[obj->state], obj->descr->name); 209 obj_states[obj->state], obj->descr->name);
210 WARN_ON(1);
211 } 210 }
212 debug_objects_warnings++; 211 debug_objects_warnings++;
213} 212}
@@ -733,26 +732,22 @@ check_results(void *addr, enum debug_obj_state state, int fixups, int warnings)
733 732
734 obj = lookup_object(addr, db); 733 obj = lookup_object(addr, db);
735 if (!obj && state != ODEBUG_STATE_NONE) { 734 if (!obj && state != ODEBUG_STATE_NONE) {
736 printk(KERN_ERR "ODEBUG: selftest object not found\n"); 735 WARN(1, KERN_ERR "ODEBUG: selftest object not found\n");
737 WARN_ON(1);
738 goto out; 736 goto out;
739 } 737 }
740 if (obj && obj->state != state) { 738 if (obj && obj->state != state) {
741 printk(KERN_ERR "ODEBUG: selftest wrong state: %d != %d\n", 739 WARN(1, KERN_ERR "ODEBUG: selftest wrong state: %d != %d\n",
742 obj->state, state); 740 obj->state, state);
743 WARN_ON(1);
744 goto out; 741 goto out;
745 } 742 }
746 if (fixups != debug_objects_fixups) { 743 if (fixups != debug_objects_fixups) {
747 printk(KERN_ERR "ODEBUG: selftest fixups failed %d != %d\n", 744 WARN(1, KERN_ERR "ODEBUG: selftest fixups failed %d != %d\n",
748 fixups, debug_objects_fixups); 745 fixups, debug_objects_fixups);
749 WARN_ON(1);
750 goto out; 746 goto out;
751 } 747 }
752 if (warnings != debug_objects_warnings) { 748 if (warnings != debug_objects_warnings) {
753 printk(KERN_ERR "ODEBUG: selftest warnings failed %d != %d\n", 749 WARN(1, KERN_ERR "ODEBUG: selftest warnings failed %d != %d\n",
754 warnings, debug_objects_warnings); 750 warnings, debug_objects_warnings);
755 WARN_ON(1);
756 goto out; 751 goto out;
757 } 752 }
758 res = 0; 753 res = 0;
diff --git a/lib/idr.c b/lib/idr.c
index 3476f8203e97..e728c7fccc4d 100644
--- a/lib/idr.c
+++ b/lib/idr.c
@@ -607,7 +607,7 @@ void *idr_replace(struct idr *idp, void *ptr, int id)
607} 607}
608EXPORT_SYMBOL(idr_replace); 608EXPORT_SYMBOL(idr_replace);
609 609
610static void idr_cache_ctor(struct kmem_cache *idr_layer_cache, void *idr_layer) 610static void idr_cache_ctor(void *idr_layer)
611{ 611{
612 memset(idr_layer, 0, sizeof(struct idr_layer)); 612 memset(idr_layer, 0, sizeof(struct idr_layer));
613} 613}
diff --git a/lib/iomap.c b/lib/iomap.c
index 37a3ea4cac9f..d32229385151 100644
--- a/lib/iomap.c
+++ b/lib/iomap.c
@@ -40,8 +40,7 @@ static void bad_io_access(unsigned long port, const char *access)
40 static int count = 10; 40 static int count = 10;
41 if (count) { 41 if (count) {
42 count--; 42 count--;
43 printk(KERN_ERR "Bad IO access at port %#lx (%s)\n", port, access); 43 WARN(1, KERN_ERR "Bad IO access at port %#lx (%s)\n", port, access);
44 WARN_ON(1);
45 } 44 }
46} 45}
47 46
diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
index 9f8d599459d1..3f914725bda8 100644
--- a/lib/kobject_uevent.c
+++ b/lib/kobject_uevent.c
@@ -285,8 +285,7 @@ int add_uevent_var(struct kobj_uevent_env *env, const char *format, ...)
285 int len; 285 int len;
286 286
287 if (env->envp_idx >= ARRAY_SIZE(env->envp)) { 287 if (env->envp_idx >= ARRAY_SIZE(env->envp)) {
288 printk(KERN_ERR "add_uevent_var: too many keys\n"); 288 WARN(1, KERN_ERR "add_uevent_var: too many keys\n");
289 WARN_ON(1);
290 return -ENOMEM; 289 return -ENOMEM;
291 } 290 }
292 291
@@ -297,8 +296,7 @@ int add_uevent_var(struct kobj_uevent_env *env, const char *format, ...)
297 va_end(args); 296 va_end(args);
298 297
299 if (len >= (sizeof(env->buf) - env->buflen)) { 298 if (len >= (sizeof(env->buf) - env->buflen)) {
300 printk(KERN_ERR "add_uevent_var: buffer size too small\n"); 299 WARN(1, KERN_ERR "add_uevent_var: buffer size too small\n");
301 WARN_ON(1);
302 return -ENOMEM; 300 return -ENOMEM;
303 } 301 }
304 302
diff --git a/lib/plist.c b/lib/plist.c
index 3074a02272f3..d6c64a824e1d 100644
--- a/lib/plist.c
+++ b/lib/plist.c
@@ -31,12 +31,13 @@
31static void plist_check_prev_next(struct list_head *t, struct list_head *p, 31static void plist_check_prev_next(struct list_head *t, struct list_head *p,
32 struct list_head *n) 32 struct list_head *n)
33{ 33{
34 if (n->prev != p || p->next != n) { 34 WARN(n->prev != p || p->next != n,
35 printk("top: %p, n: %p, p: %p\n", t, t->next, t->prev); 35 "top: %p, n: %p, p: %p\n"
36 printk("prev: %p, n: %p, p: %p\n", p, p->next, p->prev); 36 "prev: %p, n: %p, p: %p\n"
37 printk("next: %p, n: %p, p: %p\n", n, n->next, n->prev); 37 "next: %p, n: %p, p: %p\n",
38 WARN_ON(1); 38 t, t->next, t->prev,
39 } 39 p, p->next, p->prev,
40 n, n->next, n->prev);
40} 41}
41 42
42static void plist_check_list(struct list_head *top) 43static void plist_check_list(struct list_head *top)
diff --git a/lib/radix-tree.c b/lib/radix-tree.c
index 56ec21a7f73d..be86b32bc874 100644
--- a/lib/radix-tree.c
+++ b/lib/radix-tree.c
@@ -359,18 +359,17 @@ EXPORT_SYMBOL(radix_tree_insert);
359 * Returns: the slot corresponding to the position @index in the 359 * Returns: the slot corresponding to the position @index in the
360 * radix tree @root. This is useful for update-if-exists operations. 360 * radix tree @root. This is useful for update-if-exists operations.
361 * 361 *
362 * This function cannot be called under rcu_read_lock, it must be 362 * This function can be called under rcu_read_lock iff the slot is not
363 * excluded from writers, as must the returned slot for subsequent 363 * modified by radix_tree_replace_slot, otherwise it must be called
364 * use by radix_tree_deref_slot() and radix_tree_replace slot. 364 * exclusive from other writers. Any dereference of the slot must be done
365 * Caller must hold tree write locked across slot lookup and 365 * using radix_tree_deref_slot.
366 * replace.
367 */ 366 */
368void **radix_tree_lookup_slot(struct radix_tree_root *root, unsigned long index) 367void **radix_tree_lookup_slot(struct radix_tree_root *root, unsigned long index)
369{ 368{
370 unsigned int height, shift; 369 unsigned int height, shift;
371 struct radix_tree_node *node, **slot; 370 struct radix_tree_node *node, **slot;
372 371
373 node = root->rnode; 372 node = rcu_dereference(root->rnode);
374 if (node == NULL) 373 if (node == NULL)
375 return NULL; 374 return NULL;
376 375
@@ -390,7 +389,7 @@ void **radix_tree_lookup_slot(struct radix_tree_root *root, unsigned long index)
390 do { 389 do {
391 slot = (struct radix_tree_node **) 390 slot = (struct radix_tree_node **)
392 (node->slots + ((index>>shift) & RADIX_TREE_MAP_MASK)); 391 (node->slots + ((index>>shift) & RADIX_TREE_MAP_MASK));
393 node = *slot; 392 node = rcu_dereference(*slot);
394 if (node == NULL) 393 if (node == NULL)
395 return NULL; 394 return NULL;
396 395
@@ -667,7 +666,7 @@ unsigned long radix_tree_next_hole(struct radix_tree_root *root,
667EXPORT_SYMBOL(radix_tree_next_hole); 666EXPORT_SYMBOL(radix_tree_next_hole);
668 667
669static unsigned int 668static unsigned int
670__lookup(struct radix_tree_node *slot, void **results, unsigned long index, 669__lookup(struct radix_tree_node *slot, void ***results, unsigned long index,
671 unsigned int max_items, unsigned long *next_index) 670 unsigned int max_items, unsigned long *next_index)
672{ 671{
673 unsigned int nr_found = 0; 672 unsigned int nr_found = 0;
@@ -701,11 +700,9 @@ __lookup(struct radix_tree_node *slot, void **results, unsigned long index,
701 700
702 /* Bottom level: grab some items */ 701 /* Bottom level: grab some items */
703 for (i = index & RADIX_TREE_MAP_MASK; i < RADIX_TREE_MAP_SIZE; i++) { 702 for (i = index & RADIX_TREE_MAP_MASK; i < RADIX_TREE_MAP_SIZE; i++) {
704 struct radix_tree_node *node;
705 index++; 703 index++;
706 node = slot->slots[i]; 704 if (slot->slots[i]) {
707 if (node) { 705 results[nr_found++] = &(slot->slots[i]);
708 results[nr_found++] = rcu_dereference(node);
709 if (nr_found == max_items) 706 if (nr_found == max_items)
710 goto out; 707 goto out;
711 } 708 }
@@ -759,13 +756,22 @@ radix_tree_gang_lookup(struct radix_tree_root *root, void **results,
759 756
760 ret = 0; 757 ret = 0;
761 while (ret < max_items) { 758 while (ret < max_items) {
762 unsigned int nr_found; 759 unsigned int nr_found, slots_found, i;
763 unsigned long next_index; /* Index of next search */ 760 unsigned long next_index; /* Index of next search */
764 761
765 if (cur_index > max_index) 762 if (cur_index > max_index)
766 break; 763 break;
767 nr_found = __lookup(node, results + ret, cur_index, 764 slots_found = __lookup(node, (void ***)results + ret, cur_index,
768 max_items - ret, &next_index); 765 max_items - ret, &next_index);
766 nr_found = 0;
767 for (i = 0; i < slots_found; i++) {
768 struct radix_tree_node *slot;
769 slot = *(((void ***)results)[ret + i]);
770 if (!slot)
771 continue;
772 results[ret + nr_found] = rcu_dereference(slot);
773 nr_found++;
774 }
769 ret += nr_found; 775 ret += nr_found;
770 if (next_index == 0) 776 if (next_index == 0)
771 break; 777 break;
@@ -776,12 +782,71 @@ radix_tree_gang_lookup(struct radix_tree_root *root, void **results,
776} 782}
777EXPORT_SYMBOL(radix_tree_gang_lookup); 783EXPORT_SYMBOL(radix_tree_gang_lookup);
778 784
785/**
786 * radix_tree_gang_lookup_slot - perform multiple slot lookup on radix tree
787 * @root: radix tree root
788 * @results: where the results of the lookup are placed
789 * @first_index: start the lookup from this key
790 * @max_items: place up to this many items at *results
791 *
792 * Performs an index-ascending scan of the tree for present items. Places
793 * their slots at *@results and returns the number of items which were
794 * placed at *@results.
795 *
796 * The implementation is naive.
797 *
798 * Like radix_tree_gang_lookup as far as RCU and locking goes. Slots must
799 * be dereferenced with radix_tree_deref_slot, and if using only RCU
800 * protection, radix_tree_deref_slot may fail requiring a retry.
801 */
802unsigned int
803radix_tree_gang_lookup_slot(struct radix_tree_root *root, void ***results,
804 unsigned long first_index, unsigned int max_items)
805{
806 unsigned long max_index;
807 struct radix_tree_node *node;
808 unsigned long cur_index = first_index;
809 unsigned int ret;
810
811 node = rcu_dereference(root->rnode);
812 if (!node)
813 return 0;
814
815 if (!radix_tree_is_indirect_ptr(node)) {
816 if (first_index > 0)
817 return 0;
818 results[0] = (void **)&root->rnode;
819 return 1;
820 }
821 node = radix_tree_indirect_to_ptr(node);
822
823 max_index = radix_tree_maxindex(node->height);
824
825 ret = 0;
826 while (ret < max_items) {
827 unsigned int slots_found;
828 unsigned long next_index; /* Index of next search */
829
830 if (cur_index > max_index)
831 break;
832 slots_found = __lookup(node, results + ret, cur_index,
833 max_items - ret, &next_index);
834 ret += slots_found;
835 if (next_index == 0)
836 break;
837 cur_index = next_index;
838 }
839
840 return ret;
841}
842EXPORT_SYMBOL(radix_tree_gang_lookup_slot);
843
779/* 844/*
780 * FIXME: the two tag_get()s here should use find_next_bit() instead of 845 * FIXME: the two tag_get()s here should use find_next_bit() instead of
781 * open-coding the search. 846 * open-coding the search.
782 */ 847 */
783static unsigned int 848static unsigned int
784__lookup_tag(struct radix_tree_node *slot, void **results, unsigned long index, 849__lookup_tag(struct radix_tree_node *slot, void ***results, unsigned long index,
785 unsigned int max_items, unsigned long *next_index, unsigned int tag) 850 unsigned int max_items, unsigned long *next_index, unsigned int tag)
786{ 851{
787 unsigned int nr_found = 0; 852 unsigned int nr_found = 0;
@@ -811,11 +876,9 @@ __lookup_tag(struct radix_tree_node *slot, void **results, unsigned long index,
811 unsigned long j = index & RADIX_TREE_MAP_MASK; 876 unsigned long j = index & RADIX_TREE_MAP_MASK;
812 877
813 for ( ; j < RADIX_TREE_MAP_SIZE; j++) { 878 for ( ; j < RADIX_TREE_MAP_SIZE; j++) {
814 struct radix_tree_node *node;
815 index++; 879 index++;
816 if (!tag_get(slot, tag, j)) 880 if (!tag_get(slot, tag, j))
817 continue; 881 continue;
818 node = slot->slots[j];
819 /* 882 /*
820 * Even though the tag was found set, we need to 883 * Even though the tag was found set, we need to
821 * recheck that we have a non-NULL node, because 884 * recheck that we have a non-NULL node, because
@@ -826,9 +889,8 @@ __lookup_tag(struct radix_tree_node *slot, void **results, unsigned long index,
826 * lookup ->slots[x] without a lock (ie. can't 889 * lookup ->slots[x] without a lock (ie. can't
827 * rely on its value remaining the same). 890 * rely on its value remaining the same).
828 */ 891 */
829 if (node) { 892 if (slot->slots[j]) {
830 node = rcu_dereference(node); 893 results[nr_found++] = &(slot->slots[j]);
831 results[nr_found++] = node;
832 if (nr_found == max_items) 894 if (nr_found == max_items)
833 goto out; 895 goto out;
834 } 896 }
@@ -887,13 +949,22 @@ radix_tree_gang_lookup_tag(struct radix_tree_root *root, void **results,
887 949
888 ret = 0; 950 ret = 0;
889 while (ret < max_items) { 951 while (ret < max_items) {
890 unsigned int nr_found; 952 unsigned int nr_found, slots_found, i;
891 unsigned long next_index; /* Index of next search */ 953 unsigned long next_index; /* Index of next search */
892 954
893 if (cur_index > max_index) 955 if (cur_index > max_index)
894 break; 956 break;
895 nr_found = __lookup_tag(node, results + ret, cur_index, 957 slots_found = __lookup_tag(node, (void ***)results + ret,
896 max_items - ret, &next_index, tag); 958 cur_index, max_items - ret, &next_index, tag);
959 nr_found = 0;
960 for (i = 0; i < slots_found; i++) {
961 struct radix_tree_node *slot;
962 slot = *(((void ***)results)[ret + i]);
963 if (!slot)
964 continue;
965 results[ret + nr_found] = rcu_dereference(slot);
966 nr_found++;
967 }
897 ret += nr_found; 968 ret += nr_found;
898 if (next_index == 0) 969 if (next_index == 0)
899 break; 970 break;
@@ -905,6 +976,67 @@ radix_tree_gang_lookup_tag(struct radix_tree_root *root, void **results,
905EXPORT_SYMBOL(radix_tree_gang_lookup_tag); 976EXPORT_SYMBOL(radix_tree_gang_lookup_tag);
906 977
907/** 978/**
979 * radix_tree_gang_lookup_tag_slot - perform multiple slot lookup on a
980 * radix tree based on a tag
981 * @root: radix tree root
982 * @results: where the results of the lookup are placed
983 * @first_index: start the lookup from this key
984 * @max_items: place up to this many items at *results
985 * @tag: the tag index (< RADIX_TREE_MAX_TAGS)
986 *
987 * Performs an index-ascending scan of the tree for present items which
988 * have the tag indexed by @tag set. Places the slots at *@results and
989 * returns the number of slots which were placed at *@results.
990 */
991unsigned int
992radix_tree_gang_lookup_tag_slot(struct radix_tree_root *root, void ***results,
993 unsigned long first_index, unsigned int max_items,
994 unsigned int tag)
995{
996 struct radix_tree_node *node;
997 unsigned long max_index;
998 unsigned long cur_index = first_index;
999 unsigned int ret;
1000
1001 /* check the root's tag bit */
1002 if (!root_tag_get(root, tag))
1003 return 0;
1004
1005 node = rcu_dereference(root->rnode);
1006 if (!node)
1007 return 0;
1008
1009 if (!radix_tree_is_indirect_ptr(node)) {
1010 if (first_index > 0)
1011 return 0;
1012 results[0] = (void **)&root->rnode;
1013 return 1;
1014 }
1015 node = radix_tree_indirect_to_ptr(node);
1016
1017 max_index = radix_tree_maxindex(node->height);
1018
1019 ret = 0;
1020 while (ret < max_items) {
1021 unsigned int slots_found;
1022 unsigned long next_index; /* Index of next search */
1023
1024 if (cur_index > max_index)
1025 break;
1026 slots_found = __lookup_tag(node, results + ret,
1027 cur_index, max_items - ret, &next_index, tag);
1028 ret += slots_found;
1029 if (next_index == 0)
1030 break;
1031 cur_index = next_index;
1032 }
1033
1034 return ret;
1035}
1036EXPORT_SYMBOL(radix_tree_gang_lookup_tag_slot);
1037
1038
1039/**
908 * radix_tree_shrink - shrink height of a radix tree to minimal 1040 * radix_tree_shrink - shrink height of a radix tree to minimal
909 * @root radix tree root 1041 * @root radix tree root
910 */ 1042 */
@@ -1051,7 +1183,7 @@ int radix_tree_tagged(struct radix_tree_root *root, unsigned int tag)
1051EXPORT_SYMBOL(radix_tree_tagged); 1183EXPORT_SYMBOL(radix_tree_tagged);
1052 1184
1053static void 1185static void
1054radix_tree_node_ctor(struct kmem_cache *cachep, void *node) 1186radix_tree_node_ctor(void *node)
1055{ 1187{
1056 memset(node, 0, sizeof(struct radix_tree_node)); 1188 memset(node, 0, sizeof(struct radix_tree_node));
1057} 1189}
diff --git a/lib/show_mem.c b/lib/show_mem.c
new file mode 100644
index 000000000000..238e72a18ce1
--- /dev/null
+++ b/lib/show_mem.c
@@ -0,0 +1,63 @@
1/*
2 * Generic show_mem() implementation
3 *
4 * Copyright (C) 2008 Johannes Weiner <hannes@saeurebad.de>
5 * All code subject to the GPL version 2.
6 */
7
8#include <linux/mm.h>
9#include <linux/nmi.h>
10#include <linux/quicklist.h>
11
12void show_mem(void)
13{
14 pg_data_t *pgdat;
15 unsigned long total = 0, reserved = 0, shared = 0,
16 nonshared = 0, highmem = 0;
17
18 printk(KERN_INFO "Mem-Info:\n");
19 show_free_areas();
20
21 for_each_online_pgdat(pgdat) {
22 unsigned long i, flags;
23
24 pgdat_resize_lock(pgdat, &flags);
25 for (i = 0; i < pgdat->node_spanned_pages; i++) {
26 struct page *page;
27 unsigned long pfn = pgdat->node_start_pfn + i;
28
29 if (unlikely(!(i % MAX_ORDER_NR_PAGES)))
30 touch_nmi_watchdog();
31
32 if (!pfn_valid(pfn))
33 continue;
34
35 page = pfn_to_page(pfn);
36
37 if (PageHighMem(page))
38 highmem++;
39
40 if (PageReserved(page))
41 reserved++;
42 else if (page_count(page) == 1)
43 nonshared++;
44 else if (page_count(page) > 1)
45 shared += page_count(page) - 1;
46
47 total++;
48 }
49 pgdat_resize_unlock(pgdat, &flags);
50 }
51
52 printk(KERN_INFO "%lu pages RAM\n", total);
53#ifdef CONFIG_HIGHMEM
54 printk(KERN_INFO "%lu pages HighMem\n", highmem);
55#endif
56 printk(KERN_INFO "%lu pages reserved\n", reserved);
57 printk(KERN_INFO "%lu pages shared\n", shared);
58 printk(KERN_INFO "%lu pages non-shared\n", nonshared);
59#ifdef CONFIG_QUICKLIST
60 printk(KERN_INFO "%lu pages in pagetable cache\n",
61 quicklist_total_size());
62#endif
63}
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index d568894df8cc..977edbdbc1de 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -492,7 +492,7 @@ swiotlb_alloc_coherent(struct device *hwdev, size_t size,
492 */ 492 */
493 dma_addr_t handle; 493 dma_addr_t handle;
494 handle = swiotlb_map_single(NULL, NULL, size, DMA_FROM_DEVICE); 494 handle = swiotlb_map_single(NULL, NULL, size, DMA_FROM_DEVICE);
495 if (swiotlb_dma_mapping_error(handle)) 495 if (swiotlb_dma_mapping_error(hwdev, handle))
496 return NULL; 496 return NULL;
497 497
498 ret = bus_to_virt(handle); 498 ret = bus_to_virt(handle);
@@ -824,7 +824,7 @@ swiotlb_sync_sg_for_device(struct device *hwdev, struct scatterlist *sg,
824} 824}
825 825
826int 826int
827swiotlb_dma_mapping_error(dma_addr_t dma_addr) 827swiotlb_dma_mapping_error(struct device *hwdev, dma_addr_t dma_addr)
828{ 828{
829 return (dma_addr == virt_to_bus(io_tlb_overflow_buffer)); 829 return (dma_addr == virt_to_bus(io_tlb_overflow_buffer));
830} 830}
diff --git a/lib/syscall.c b/lib/syscall.c
new file mode 100644
index 000000000000..a4f7067f72fa
--- /dev/null
+++ b/lib/syscall.c
@@ -0,0 +1,75 @@
1#include <linux/ptrace.h>
2#include <linux/sched.h>
3#include <linux/module.h>
4#include <asm/syscall.h>
5
6static int collect_syscall(struct task_struct *target, long *callno,
7 unsigned long args[6], unsigned int maxargs,
8 unsigned long *sp, unsigned long *pc)
9{
10 struct pt_regs *regs = task_pt_regs(target);
11 if (unlikely(!regs))
12 return -EAGAIN;
13
14 *sp = user_stack_pointer(regs);
15 *pc = instruction_pointer(regs);
16
17 *callno = syscall_get_nr(target, regs);
18 if (*callno != -1L && maxargs > 0)
19 syscall_get_arguments(target, regs, 0, maxargs, args);
20
21 return 0;
22}
23
24/**
25 * task_current_syscall - Discover what a blocked task is doing.
26 * @target: thread to examine
27 * @callno: filled with system call number or -1
28 * @args: filled with @maxargs system call arguments
29 * @maxargs: number of elements in @args to fill
30 * @sp: filled with user stack pointer
31 * @pc: filled with user PC
32 *
33 * If @target is blocked in a system call, returns zero with *@callno
34 * set to the the call's number and @args filled in with its arguments.
35 * Registers not used for system call arguments may not be available and
36 * it is not kosher to use &struct user_regset calls while the system
37 * call is still in progress. Note we may get this result if @target
38 * has finished its system call but not yet returned to user mode, such
39 * as when it's stopped for signal handling or syscall exit tracing.
40 *
41 * If @target is blocked in the kernel during a fault or exception,
42 * returns zero with *@callno set to -1 and does not fill in @args.
43 * If so, it's now safe to examine @target using &struct user_regset
44 * get() calls as long as we're sure @target won't return to user mode.
45 *
46 * Returns -%EAGAIN if @target does not remain blocked.
47 *
48 * Returns -%EINVAL if @maxargs is too large (maximum is six).
49 */
50int task_current_syscall(struct task_struct *target, long *callno,
51 unsigned long args[6], unsigned int maxargs,
52 unsigned long *sp, unsigned long *pc)
53{
54 long state;
55 unsigned long ncsw;
56
57 if (unlikely(maxargs > 6))
58 return -EINVAL;
59
60 if (target == current)
61 return collect_syscall(target, callno, args, maxargs, sp, pc);
62
63 state = target->state;
64 if (unlikely(!state))
65 return -EAGAIN;
66
67 ncsw = wait_task_inactive(target, state);
68 if (unlikely(!ncsw) ||
69 unlikely(collect_syscall(target, callno, args, maxargs, sp, pc)) ||
70 unlikely(wait_task_inactive(target, state) != ncsw))
71 return -EAGAIN;
72
73 return 0;
74}
75EXPORT_SYMBOL_GPL(task_current_syscall);