diff options
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/cgroup.c | 130 | ||||
| -rw-r--r-- | kernel/cgroup_freezer.c | 72 | ||||
| -rw-r--r-- | kernel/cred.c | 4 | ||||
| -rw-r--r-- | kernel/exit.c | 5 | ||||
| -rw-r--r-- | kernel/fork.c | 17 | ||||
| -rw-r--r-- | kernel/futex.c | 2 | ||||
| -rw-r--r-- | kernel/irq/irqdesc.c | 15 | ||||
| -rw-r--r-- | kernel/kexec.c | 2 | ||||
| -rw-r--r-- | kernel/kprobes.c | 7 | ||||
| -rw-r--r-- | kernel/module.c | 2 | ||||
| -rw-r--r-- | kernel/ns_cgroup.c | 8 | ||||
| -rw-r--r-- | kernel/perf_event.c | 94 | ||||
| -rw-r--r-- | kernel/power/snapshot.c | 18 | ||||
| -rw-r--r-- | kernel/power/swap.c | 6 | ||||
| -rw-r--r-- | kernel/printk.c | 5 | ||||
| -rw-r--r-- | kernel/ptrace.c | 36 | ||||
| -rw-r--r-- | kernel/resource.c | 153 | ||||
| -rw-r--r-- | kernel/signal.c | 5 | ||||
| -rw-r--r-- | kernel/smp.c | 8 | ||||
| -rw-r--r-- | kernel/softirq.c | 16 | ||||
| -rw-r--r-- | kernel/stop_machine.c | 6 | ||||
| -rw-r--r-- | kernel/sysctl.c | 14 | ||||
| -rw-r--r-- | kernel/taskstats.c | 172 | ||||
| -rw-r--r-- | kernel/trace/ring_buffer.c | 335 | ||||
| -rw-r--r-- | kernel/trace/trace.c | 8 | ||||
| -rw-r--r-- | kernel/trace/trace_kprobe.c | 1 | ||||
| -rw-r--r-- | kernel/tsacct.c | 10 | ||||
| -rw-r--r-- | kernel/user.c | 1 | ||||
| -rw-r--r-- | kernel/wait.c | 6 | ||||
| -rw-r--r-- | kernel/workqueue.c | 2 |
30 files changed, 702 insertions, 458 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 7b69b8d0313d..5cf366965d0c 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
| @@ -243,6 +243,11 @@ static int notify_on_release(const struct cgroup *cgrp) | |||
| 243 | return test_bit(CGRP_NOTIFY_ON_RELEASE, &cgrp->flags); | 243 | return test_bit(CGRP_NOTIFY_ON_RELEASE, &cgrp->flags); |
| 244 | } | 244 | } |
| 245 | 245 | ||
| 246 | static int clone_children(const struct cgroup *cgrp) | ||
| 247 | { | ||
| 248 | return test_bit(CGRP_CLONE_CHILDREN, &cgrp->flags); | ||
| 249 | } | ||
| 250 | |||
| 246 | /* | 251 | /* |
| 247 | * for_each_subsys() allows you to iterate on each subsystem attached to | 252 | * for_each_subsys() allows you to iterate on each subsystem attached to |
| 248 | * an active hierarchy | 253 | * an active hierarchy |
| @@ -777,6 +782,7 @@ static struct inode *cgroup_new_inode(mode_t mode, struct super_block *sb) | |||
| 777 | struct inode *inode = new_inode(sb); | 782 | struct inode *inode = new_inode(sb); |
| 778 | 783 | ||
| 779 | if (inode) { | 784 | if (inode) { |
| 785 | inode->i_ino = get_next_ino(); | ||
| 780 | inode->i_mode = mode; | 786 | inode->i_mode = mode; |
| 781 | inode->i_uid = current_fsuid(); | 787 | inode->i_uid = current_fsuid(); |
| 782 | inode->i_gid = current_fsgid(); | 788 | inode->i_gid = current_fsgid(); |
| @@ -1039,6 +1045,8 @@ static int cgroup_show_options(struct seq_file *seq, struct vfsmount *vfs) | |||
| 1039 | seq_puts(seq, ",noprefix"); | 1045 | seq_puts(seq, ",noprefix"); |
| 1040 | if (strlen(root->release_agent_path)) | 1046 | if (strlen(root->release_agent_path)) |
| 1041 | seq_printf(seq, ",release_agent=%s", root->release_agent_path); | 1047 | seq_printf(seq, ",release_agent=%s", root->release_agent_path); |
| 1048 | if (clone_children(&root->top_cgroup)) | ||
| 1049 | seq_puts(seq, ",clone_children"); | ||
| 1042 | if (strlen(root->name)) | 1050 | if (strlen(root->name)) |
| 1043 | seq_printf(seq, ",name=%s", root->name); | 1051 | seq_printf(seq, ",name=%s", root->name); |
| 1044 | mutex_unlock(&cgroup_mutex); | 1052 | mutex_unlock(&cgroup_mutex); |
| @@ -1049,6 +1057,7 @@ struct cgroup_sb_opts { | |||
| 1049 | unsigned long subsys_bits; | 1057 | unsigned long subsys_bits; |
| 1050 | unsigned long flags; | 1058 | unsigned long flags; |
| 1051 | char *release_agent; | 1059 | char *release_agent; |
| 1060 | bool clone_children; | ||
| 1052 | char *name; | 1061 | char *name; |
| 1053 | /* User explicitly requested empty subsystem */ | 1062 | /* User explicitly requested empty subsystem */ |
| 1054 | bool none; | 1063 | bool none; |
| @@ -1065,7 +1074,8 @@ struct cgroup_sb_opts { | |||
| 1065 | */ | 1074 | */ |
| 1066 | static int parse_cgroupfs_options(char *data, struct cgroup_sb_opts *opts) | 1075 | static int parse_cgroupfs_options(char *data, struct cgroup_sb_opts *opts) |
| 1067 | { | 1076 | { |
| 1068 | char *token, *o = data ?: "all"; | 1077 | char *token, *o = data; |
| 1078 | bool all_ss = false, one_ss = false; | ||
| 1069 | unsigned long mask = (unsigned long)-1; | 1079 | unsigned long mask = (unsigned long)-1; |
| 1070 | int i; | 1080 | int i; |
| 1071 | bool module_pin_failed = false; | 1081 | bool module_pin_failed = false; |
| @@ -1081,22 +1091,27 @@ static int parse_cgroupfs_options(char *data, struct cgroup_sb_opts *opts) | |||
| 1081 | while ((token = strsep(&o, ",")) != NULL) { | 1091 | while ((token = strsep(&o, ",")) != NULL) { |
| 1082 | if (!*token) | 1092 | if (!*token) |
| 1083 | return -EINVAL; | 1093 | return -EINVAL; |
| 1084 | if (!strcmp(token, "all")) { | 1094 | if (!strcmp(token, "none")) { |
| 1085 | /* Add all non-disabled subsystems */ | ||
| 1086 | opts->subsys_bits = 0; | ||
| 1087 | for (i = 0; i < CGROUP_SUBSYS_COUNT; i++) { | ||
| 1088 | struct cgroup_subsys *ss = subsys[i]; | ||
| 1089 | if (ss == NULL) | ||
| 1090 | continue; | ||
| 1091 | if (!ss->disabled) | ||
| 1092 | opts->subsys_bits |= 1ul << i; | ||
| 1093 | } | ||
| 1094 | } else if (!strcmp(token, "none")) { | ||
| 1095 | /* Explicitly have no subsystems */ | 1095 | /* Explicitly have no subsystems */ |
| 1096 | opts->none = true; | 1096 | opts->none = true; |
| 1097 | } else if (!strcmp(token, "noprefix")) { | 1097 | continue; |
| 1098 | } | ||
| 1099 | if (!strcmp(token, "all")) { | ||
| 1100 | /* Mutually exclusive option 'all' + subsystem name */ | ||
| 1101 | if (one_ss) | ||
| 1102 | return -EINVAL; | ||
| 1103 | all_ss = true; | ||
| 1104 | continue; | ||
| 1105 | } | ||
| 1106 | if (!strcmp(token, "noprefix")) { | ||
| 1098 | set_bit(ROOT_NOPREFIX, &opts->flags); | 1107 | set_bit(ROOT_NOPREFIX, &opts->flags); |
| 1099 | } else if (!strncmp(token, "release_agent=", 14)) { | 1108 | continue; |
| 1109 | } | ||
| 1110 | if (!strcmp(token, "clone_children")) { | ||
| 1111 | opts->clone_children = true; | ||
| 1112 | continue; | ||
| 1113 | } | ||
| 1114 | if (!strncmp(token, "release_agent=", 14)) { | ||
| 1100 | /* Specifying two release agents is forbidden */ | 1115 | /* Specifying two release agents is forbidden */ |
| 1101 | if (opts->release_agent) | 1116 | if (opts->release_agent) |
| 1102 | return -EINVAL; | 1117 | return -EINVAL; |
| @@ -1104,7 +1119,9 @@ static int parse_cgroupfs_options(char *data, struct cgroup_sb_opts *opts) | |||
| 1104 | kstrndup(token + 14, PATH_MAX - 1, GFP_KERNEL); | 1119 | kstrndup(token + 14, PATH_MAX - 1, GFP_KERNEL); |
| 1105 | if (!opts->release_agent) | 1120 | if (!opts->release_agent) |
| 1106 | return -ENOMEM; | 1121 | return -ENOMEM; |
| 1107 | } else if (!strncmp(token, "name=", 5)) { | 1122 | continue; |
| 1123 | } | ||
| 1124 | if (!strncmp(token, "name=", 5)) { | ||
| 1108 | const char *name = token + 5; | 1125 | const char *name = token + 5; |
| 1109 | /* Can't specify an empty name */ | 1126 | /* Can't specify an empty name */ |
| 1110 | if (!strlen(name)) | 1127 | if (!strlen(name)) |
| @@ -1126,20 +1143,44 @@ static int parse_cgroupfs_options(char *data, struct cgroup_sb_opts *opts) | |||
| 1126 | GFP_KERNEL); | 1143 | GFP_KERNEL); |
| 1127 | if (!opts->name) | 1144 | if (!opts->name) |
| 1128 | return -ENOMEM; | 1145 | return -ENOMEM; |
| 1129 | } else { | 1146 | |
| 1130 | struct cgroup_subsys *ss; | 1147 | continue; |
| 1131 | for (i = 0; i < CGROUP_SUBSYS_COUNT; i++) { | 1148 | } |
| 1132 | ss = subsys[i]; | 1149 | |
| 1133 | if (ss == NULL) | 1150 | for (i = 0; i < CGROUP_SUBSYS_COUNT; i++) { |
| 1134 | continue; | 1151 | struct cgroup_subsys *ss = subsys[i]; |
| 1135 | if (!strcmp(token, ss->name)) { | 1152 | if (ss == NULL) |
| 1136 | if (!ss->disabled) | 1153 | continue; |
| 1137 | set_bit(i, &opts->subsys_bits); | 1154 | if (strcmp(token, ss->name)) |
| 1138 | break; | 1155 | continue; |
| 1139 | } | 1156 | if (ss->disabled) |
| 1140 | } | 1157 | continue; |
| 1141 | if (i == CGROUP_SUBSYS_COUNT) | 1158 | |
| 1142 | return -ENOENT; | 1159 | /* Mutually exclusive option 'all' + subsystem name */ |
| 1160 | if (all_ss) | ||
| 1161 | return -EINVAL; | ||
| 1162 | set_bit(i, &opts->subsys_bits); | ||
| 1163 | one_ss = true; | ||
| 1164 | |||
| 1165 | break; | ||
| 1166 | } | ||
| 1167 | if (i == CGROUP_SUBSYS_COUNT) | ||
| 1168 | return -ENOENT; | ||
| 1169 | } | ||
| 1170 | |||
| 1171 | /* | ||
| 1172 | * If the 'all' option was specified select all the subsystems, | ||
| 1173 | * otherwise 'all, 'none' and a subsystem name options were not | ||
| 1174 | * specified, let's default to 'all' | ||
| 1175 | */ | ||
| 1176 | if (all_ss || (!all_ss && !one_ss && !opts->none)) { | ||
| 1177 | for (i = 0; i < CGROUP_SUBSYS_COUNT; i++) { | ||
| 1178 | struct cgroup_subsys *ss = subsys[i]; | ||
| 1179 | if (ss == NULL) | ||
| 1180 | continue; | ||
| 1181 | if (ss->disabled) | ||
| 1182 | continue; | ||
| 1183 | set_bit(i, &opts->subsys_bits); | ||
| 1143 | } | 1184 | } |
| 1144 | } | 1185 | } |
| 1145 | 1186 | ||
| @@ -1354,6 +1395,8 @@ static struct cgroupfs_root *cgroup_root_from_opts(struct cgroup_sb_opts *opts) | |||
| 1354 | strcpy(root->release_agent_path, opts->release_agent); | 1395 | strcpy(root->release_agent_path, opts->release_agent); |
| 1355 | if (opts->name) | 1396 | if (opts->name) |
| 1356 | strcpy(root->name, opts->name); | 1397 | strcpy(root->name, opts->name); |
| 1398 | if (opts->clone_children) | ||
| 1399 | set_bit(CGRP_CLONE_CHILDREN, &root->top_cgroup.flags); | ||
| 1357 | return root; | 1400 | return root; |
| 1358 | } | 1401 | } |
| 1359 | 1402 | ||
| @@ -1879,6 +1922,8 @@ static int cgroup_release_agent_write(struct cgroup *cgrp, struct cftype *cft, | |||
| 1879 | const char *buffer) | 1922 | const char *buffer) |
| 1880 | { | 1923 | { |
| 1881 | BUILD_BUG_ON(sizeof(cgrp->root->release_agent_path) < PATH_MAX); | 1924 | BUILD_BUG_ON(sizeof(cgrp->root->release_agent_path) < PATH_MAX); |
| 1925 | if (strlen(buffer) >= PATH_MAX) | ||
| 1926 | return -EINVAL; | ||
| 1882 | if (!cgroup_lock_live_group(cgrp)) | 1927 | if (!cgroup_lock_live_group(cgrp)) |
| 1883 | return -ENODEV; | 1928 | return -ENODEV; |
| 1884 | strcpy(cgrp->root->release_agent_path, buffer); | 1929 | strcpy(cgrp->root->release_agent_path, buffer); |
| @@ -3172,6 +3217,23 @@ fail: | |||
| 3172 | return ret; | 3217 | return ret; |
| 3173 | } | 3218 | } |
| 3174 | 3219 | ||
| 3220 | static u64 cgroup_clone_children_read(struct cgroup *cgrp, | ||
| 3221 | struct cftype *cft) | ||
| 3222 | { | ||
| 3223 | return clone_children(cgrp); | ||
| 3224 | } | ||
| 3225 | |||
| 3226 | static int cgroup_clone_children_write(struct cgroup *cgrp, | ||
| 3227 | struct cftype *cft, | ||
| 3228 | u64 val) | ||
| 3229 | { | ||
| 3230 | if (val) | ||
| 3231 | set_bit(CGRP_CLONE_CHILDREN, &cgrp->flags); | ||
| 3232 | else | ||
| 3233 | clear_bit(CGRP_CLONE_CHILDREN, &cgrp->flags); | ||
| 3234 | return 0; | ||
| 3235 | } | ||
| 3236 | |||
| 3175 | /* | 3237 | /* |
| 3176 | * for the common functions, 'private' gives the type of file | 3238 | * for the common functions, 'private' gives the type of file |
| 3177 | */ | 3239 | */ |
| @@ -3202,6 +3264,11 @@ static struct cftype files[] = { | |||
| 3202 | .write_string = cgroup_write_event_control, | 3264 | .write_string = cgroup_write_event_control, |
| 3203 | .mode = S_IWUGO, | 3265 | .mode = S_IWUGO, |
| 3204 | }, | 3266 | }, |
| 3267 | { | ||
| 3268 | .name = "cgroup.clone_children", | ||
| 3269 | .read_u64 = cgroup_clone_children_read, | ||
| 3270 | .write_u64 = cgroup_clone_children_write, | ||
| 3271 | }, | ||
| 3205 | }; | 3272 | }; |
| 3206 | 3273 | ||
| 3207 | static struct cftype cft_release_agent = { | 3274 | static struct cftype cft_release_agent = { |
| @@ -3331,6 +3398,9 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry, | |||
| 3331 | if (notify_on_release(parent)) | 3398 | if (notify_on_release(parent)) |
| 3332 | set_bit(CGRP_NOTIFY_ON_RELEASE, &cgrp->flags); | 3399 | set_bit(CGRP_NOTIFY_ON_RELEASE, &cgrp->flags); |
| 3333 | 3400 | ||
| 3401 | if (clone_children(parent)) | ||
| 3402 | set_bit(CGRP_CLONE_CHILDREN, &cgrp->flags); | ||
| 3403 | |||
| 3334 | for_each_subsys(root, ss) { | 3404 | for_each_subsys(root, ss) { |
| 3335 | struct cgroup_subsys_state *css = ss->create(ss, cgrp); | 3405 | struct cgroup_subsys_state *css = ss->create(ss, cgrp); |
| 3336 | 3406 | ||
| @@ -3345,6 +3415,8 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry, | |||
| 3345 | goto err_destroy; | 3415 | goto err_destroy; |
| 3346 | } | 3416 | } |
| 3347 | /* At error, ->destroy() callback has to free assigned ID. */ | 3417 | /* At error, ->destroy() callback has to free assigned ID. */ |
| 3418 | if (clone_children(parent) && ss->post_clone) | ||
| 3419 | ss->post_clone(ss, cgrp); | ||
| 3348 | } | 3420 | } |
| 3349 | 3421 | ||
| 3350 | cgroup_lock_hierarchy(root); | 3422 | cgroup_lock_hierarchy(root); |
diff --git a/kernel/cgroup_freezer.c b/kernel/cgroup_freezer.c index ce71ed53e88f..e7bebb7c6c38 100644 --- a/kernel/cgroup_freezer.c +++ b/kernel/cgroup_freezer.c | |||
| @@ -48,20 +48,19 @@ static inline struct freezer *task_freezer(struct task_struct *task) | |||
| 48 | struct freezer, css); | 48 | struct freezer, css); |
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | int cgroup_freezing_or_frozen(struct task_struct *task) | 51 | static inline int __cgroup_freezing_or_frozen(struct task_struct *task) |
| 52 | { | 52 | { |
| 53 | struct freezer *freezer; | 53 | enum freezer_state state = task_freezer(task)->state; |
| 54 | enum freezer_state state; | 54 | return (state == CGROUP_FREEZING) || (state == CGROUP_FROZEN); |
| 55 | } | ||
| 55 | 56 | ||
| 57 | int cgroup_freezing_or_frozen(struct task_struct *task) | ||
| 58 | { | ||
| 59 | int result; | ||
| 56 | task_lock(task); | 60 | task_lock(task); |
| 57 | freezer = task_freezer(task); | 61 | result = __cgroup_freezing_or_frozen(task); |
| 58 | if (!freezer->css.cgroup->parent) | ||
| 59 | state = CGROUP_THAWED; /* root cgroup can't be frozen */ | ||
| 60 | else | ||
| 61 | state = freezer->state; | ||
| 62 | task_unlock(task); | 62 | task_unlock(task); |
| 63 | 63 | return result; | |
| 64 | return (state == CGROUP_FREEZING) || (state == CGROUP_FROZEN); | ||
| 65 | } | 64 | } |
| 66 | 65 | ||
| 67 | /* | 66 | /* |
| @@ -154,13 +153,6 @@ static void freezer_destroy(struct cgroup_subsys *ss, | |||
| 154 | kfree(cgroup_freezer(cgroup)); | 153 | kfree(cgroup_freezer(cgroup)); |
| 155 | } | 154 | } |
| 156 | 155 | ||
| 157 | /* Task is frozen or will freeze immediately when next it gets woken */ | ||
| 158 | static bool is_task_frozen_enough(struct task_struct *task) | ||
| 159 | { | ||
| 160 | return frozen(task) || | ||
| 161 | (task_is_stopped_or_traced(task) && freezing(task)); | ||
| 162 | } | ||
| 163 | |||
| 164 | /* | 156 | /* |
| 165 | * The call to cgroup_lock() in the freezer.state write method prevents | 157 | * The call to cgroup_lock() in the freezer.state write method prevents |
| 166 | * a write to that file racing against an attach, and hence the | 158 | * a write to that file racing against an attach, and hence the |
| @@ -174,24 +166,25 @@ static int freezer_can_attach(struct cgroup_subsys *ss, | |||
| 174 | 166 | ||
| 175 | /* | 167 | /* |
| 176 | * Anything frozen can't move or be moved to/from. | 168 | * Anything frozen can't move or be moved to/from. |
| 177 | * | ||
| 178 | * Since orig_freezer->state == FROZEN means that @task has been | ||
| 179 | * frozen, so it's sufficient to check the latter condition. | ||
| 180 | */ | 169 | */ |
| 181 | 170 | ||
| 182 | if (is_task_frozen_enough(task)) | 171 | freezer = cgroup_freezer(new_cgroup); |
| 172 | if (freezer->state != CGROUP_THAWED) | ||
| 183 | return -EBUSY; | 173 | return -EBUSY; |
| 184 | 174 | ||
| 185 | freezer = cgroup_freezer(new_cgroup); | 175 | rcu_read_lock(); |
| 186 | if (freezer->state == CGROUP_FROZEN) | 176 | if (__cgroup_freezing_or_frozen(task)) { |
| 177 | rcu_read_unlock(); | ||
| 187 | return -EBUSY; | 178 | return -EBUSY; |
| 179 | } | ||
| 180 | rcu_read_unlock(); | ||
| 188 | 181 | ||
| 189 | if (threadgroup) { | 182 | if (threadgroup) { |
| 190 | struct task_struct *c; | 183 | struct task_struct *c; |
| 191 | 184 | ||
| 192 | rcu_read_lock(); | 185 | rcu_read_lock(); |
| 193 | list_for_each_entry_rcu(c, &task->thread_group, thread_group) { | 186 | list_for_each_entry_rcu(c, &task->thread_group, thread_group) { |
| 194 | if (is_task_frozen_enough(c)) { | 187 | if (__cgroup_freezing_or_frozen(c)) { |
| 195 | rcu_read_unlock(); | 188 | rcu_read_unlock(); |
| 196 | return -EBUSY; | 189 | return -EBUSY; |
| 197 | } | 190 | } |
| @@ -236,31 +229,30 @@ static void freezer_fork(struct cgroup_subsys *ss, struct task_struct *task) | |||
| 236 | /* | 229 | /* |
| 237 | * caller must hold freezer->lock | 230 | * caller must hold freezer->lock |
| 238 | */ | 231 | */ |
| 239 | static void update_freezer_state(struct cgroup *cgroup, | 232 | static void update_if_frozen(struct cgroup *cgroup, |
| 240 | struct freezer *freezer) | 233 | struct freezer *freezer) |
| 241 | { | 234 | { |
| 242 | struct cgroup_iter it; | 235 | struct cgroup_iter it; |
| 243 | struct task_struct *task; | 236 | struct task_struct *task; |
| 244 | unsigned int nfrozen = 0, ntotal = 0; | 237 | unsigned int nfrozen = 0, ntotal = 0; |
| 238 | enum freezer_state old_state = freezer->state; | ||
| 245 | 239 | ||
| 246 | cgroup_iter_start(cgroup, &it); | 240 | cgroup_iter_start(cgroup, &it); |
| 247 | while ((task = cgroup_iter_next(cgroup, &it))) { | 241 | while ((task = cgroup_iter_next(cgroup, &it))) { |
| 248 | ntotal++; | 242 | ntotal++; |
| 249 | if (is_task_frozen_enough(task)) | 243 | if (frozen(task)) |
| 250 | nfrozen++; | 244 | nfrozen++; |
| 251 | } | 245 | } |
| 252 | 246 | ||
| 253 | /* | 247 | if (old_state == CGROUP_THAWED) { |
| 254 | * Transition to FROZEN when no new tasks can be added ensures | 248 | BUG_ON(nfrozen > 0); |
| 255 | * that we never exist in the FROZEN state while there are unfrozen | 249 | } else if (old_state == CGROUP_FREEZING) { |
| 256 | * tasks. | 250 | if (nfrozen == ntotal) |
| 257 | */ | 251 | freezer->state = CGROUP_FROZEN; |
| 258 | if (nfrozen == ntotal) | 252 | } else { /* old_state == CGROUP_FROZEN */ |
| 259 | freezer->state = CGROUP_FROZEN; | 253 | BUG_ON(nfrozen != ntotal); |
| 260 | else if (nfrozen > 0) | 254 | } |
| 261 | freezer->state = CGROUP_FREEZING; | 255 | |
| 262 | else | ||
| 263 | freezer->state = CGROUP_THAWED; | ||
| 264 | cgroup_iter_end(cgroup, &it); | 256 | cgroup_iter_end(cgroup, &it); |
| 265 | } | 257 | } |
| 266 | 258 | ||
| @@ -279,7 +271,7 @@ static int freezer_read(struct cgroup *cgroup, struct cftype *cft, | |||
| 279 | if (state == CGROUP_FREEZING) { | 271 | if (state == CGROUP_FREEZING) { |
| 280 | /* We change from FREEZING to FROZEN lazily if the cgroup was | 272 | /* We change from FREEZING to FROZEN lazily if the cgroup was |
| 281 | * only partially frozen when we exitted write. */ | 273 | * only partially frozen when we exitted write. */ |
| 282 | update_freezer_state(cgroup, freezer); | 274 | update_if_frozen(cgroup, freezer); |
| 283 | state = freezer->state; | 275 | state = freezer->state; |
| 284 | } | 276 | } |
| 285 | spin_unlock_irq(&freezer->lock); | 277 | spin_unlock_irq(&freezer->lock); |
| @@ -301,7 +293,7 @@ static int try_to_freeze_cgroup(struct cgroup *cgroup, struct freezer *freezer) | |||
| 301 | while ((task = cgroup_iter_next(cgroup, &it))) { | 293 | while ((task = cgroup_iter_next(cgroup, &it))) { |
| 302 | if (!freeze_task(task, true)) | 294 | if (!freeze_task(task, true)) |
| 303 | continue; | 295 | continue; |
| 304 | if (is_task_frozen_enough(task)) | 296 | if (frozen(task)) |
| 305 | continue; | 297 | continue; |
| 306 | if (!freezing(task) && !freezer_should_skip(task)) | 298 | if (!freezing(task) && !freezer_should_skip(task)) |
| 307 | num_cant_freeze_now++; | 299 | num_cant_freeze_now++; |
| @@ -335,7 +327,7 @@ static int freezer_change_state(struct cgroup *cgroup, | |||
| 335 | 327 | ||
| 336 | spin_lock_irq(&freezer->lock); | 328 | spin_lock_irq(&freezer->lock); |
| 337 | 329 | ||
| 338 | update_freezer_state(cgroup, freezer); | 330 | update_if_frozen(cgroup, freezer); |
| 339 | if (goal_state == freezer->state) | 331 | if (goal_state == freezer->state) |
| 340 | goto out; | 332 | goto out; |
| 341 | 333 | ||
diff --git a/kernel/cred.c b/kernel/cred.c index 9a3e22641fe7..6a1aa004e376 100644 --- a/kernel/cred.c +++ b/kernel/cred.c | |||
| @@ -325,7 +325,7 @@ EXPORT_SYMBOL(prepare_creds); | |||
| 325 | 325 | ||
| 326 | /* | 326 | /* |
| 327 | * Prepare credentials for current to perform an execve() | 327 | * Prepare credentials for current to perform an execve() |
| 328 | * - The caller must hold current->cred_guard_mutex | 328 | * - The caller must hold ->cred_guard_mutex |
| 329 | */ | 329 | */ |
| 330 | struct cred *prepare_exec_creds(void) | 330 | struct cred *prepare_exec_creds(void) |
| 331 | { | 331 | { |
| @@ -384,8 +384,6 @@ int copy_creds(struct task_struct *p, unsigned long clone_flags) | |||
| 384 | struct cred *new; | 384 | struct cred *new; |
| 385 | int ret; | 385 | int ret; |
| 386 | 386 | ||
| 387 | mutex_init(&p->cred_guard_mutex); | ||
| 388 | |||
| 389 | if ( | 387 | if ( |
| 390 | #ifdef CONFIG_KEYS | 388 | #ifdef CONFIG_KEYS |
| 391 | !p->cred->thread_keyring && | 389 | !p->cred->thread_keyring && |
diff --git a/kernel/exit.c b/kernel/exit.c index e2bdf37f9fde..b194febf5799 100644 --- a/kernel/exit.c +++ b/kernel/exit.c | |||
| @@ -50,6 +50,7 @@ | |||
| 50 | #include <linux/perf_event.h> | 50 | #include <linux/perf_event.h> |
| 51 | #include <trace/events/sched.h> | 51 | #include <trace/events/sched.h> |
| 52 | #include <linux/hw_breakpoint.h> | 52 | #include <linux/hw_breakpoint.h> |
| 53 | #include <linux/oom.h> | ||
| 53 | 54 | ||
| 54 | #include <asm/uaccess.h> | 55 | #include <asm/uaccess.h> |
| 55 | #include <asm/unistd.h> | 56 | #include <asm/unistd.h> |
| @@ -687,6 +688,8 @@ static void exit_mm(struct task_struct * tsk) | |||
| 687 | enter_lazy_tlb(mm, current); | 688 | enter_lazy_tlb(mm, current); |
| 688 | /* We don't want this task to be frozen prematurely */ | 689 | /* We don't want this task to be frozen prematurely */ |
| 689 | clear_freeze_flag(tsk); | 690 | clear_freeze_flag(tsk); |
| 691 | if (tsk->signal->oom_score_adj == OOM_SCORE_ADJ_MIN) | ||
| 692 | atomic_dec(&mm->oom_disable_count); | ||
| 690 | task_unlock(tsk); | 693 | task_unlock(tsk); |
| 691 | mm_update_next_owner(mm); | 694 | mm_update_next_owner(mm); |
| 692 | mmput(mm); | 695 | mmput(mm); |
| @@ -700,6 +703,8 @@ static void exit_mm(struct task_struct * tsk) | |||
| 700 | * space. | 703 | * space. |
| 701 | */ | 704 | */ |
| 702 | static struct task_struct *find_new_reaper(struct task_struct *father) | 705 | static struct task_struct *find_new_reaper(struct task_struct *father) |
| 706 | __releases(&tasklist_lock) | ||
| 707 | __acquires(&tasklist_lock) | ||
| 703 | { | 708 | { |
| 704 | struct pid_namespace *pid_ns = task_active_pid_ns(father); | 709 | struct pid_namespace *pid_ns = task_active_pid_ns(father); |
| 705 | struct task_struct *thread; | 710 | struct task_struct *thread; |
diff --git a/kernel/fork.c b/kernel/fork.c index c445f8cc408d..3b159c5991b7 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
| @@ -65,6 +65,7 @@ | |||
| 65 | #include <linux/perf_event.h> | 65 | #include <linux/perf_event.h> |
| 66 | #include <linux/posix-timers.h> | 66 | #include <linux/posix-timers.h> |
| 67 | #include <linux/user-return-notifier.h> | 67 | #include <linux/user-return-notifier.h> |
| 68 | #include <linux/oom.h> | ||
| 68 | 69 | ||
| 69 | #include <asm/pgtable.h> | 70 | #include <asm/pgtable.h> |
| 70 | #include <asm/pgalloc.h> | 71 | #include <asm/pgalloc.h> |
| @@ -488,6 +489,7 @@ static struct mm_struct * mm_init(struct mm_struct * mm, struct task_struct *p) | |||
| 488 | mm->cached_hole_size = ~0UL; | 489 | mm->cached_hole_size = ~0UL; |
| 489 | mm_init_aio(mm); | 490 | mm_init_aio(mm); |
| 490 | mm_init_owner(mm, p); | 491 | mm_init_owner(mm, p); |
| 492 | atomic_set(&mm->oom_disable_count, 0); | ||
| 491 | 493 | ||
| 492 | if (likely(!mm_alloc_pgd(mm))) { | 494 | if (likely(!mm_alloc_pgd(mm))) { |
| 493 | mm->def_flags = 0; | 495 | mm->def_flags = 0; |
| @@ -741,6 +743,8 @@ good_mm: | |||
| 741 | /* Initializing for Swap token stuff */ | 743 | /* Initializing for Swap token stuff */ |
| 742 | mm->token_priority = 0; | 744 | mm->token_priority = 0; |
| 743 | mm->last_interval = 0; | 745 | mm->last_interval = 0; |
| 746 | if (tsk->signal->oom_score_adj == OOM_SCORE_ADJ_MIN) | ||
| 747 | atomic_inc(&mm->oom_disable_count); | ||
| 744 | 748 | ||
| 745 | tsk->mm = mm; | 749 | tsk->mm = mm; |
| 746 | tsk->active_mm = mm; | 750 | tsk->active_mm = mm; |
| @@ -904,6 +908,8 @@ static int copy_signal(unsigned long clone_flags, struct task_struct *tsk) | |||
| 904 | sig->oom_adj = current->signal->oom_adj; | 908 | sig->oom_adj = current->signal->oom_adj; |
| 905 | sig->oom_score_adj = current->signal->oom_score_adj; | 909 | sig->oom_score_adj = current->signal->oom_score_adj; |
| 906 | 910 | ||
| 911 | mutex_init(&sig->cred_guard_mutex); | ||
| 912 | |||
| 907 | return 0; | 913 | return 0; |
| 908 | } | 914 | } |
| 909 | 915 | ||
| @@ -1299,8 +1305,13 @@ bad_fork_cleanup_io: | |||
| 1299 | bad_fork_cleanup_namespaces: | 1305 | bad_fork_cleanup_namespaces: |
| 1300 | exit_task_namespaces(p); | 1306 | exit_task_namespaces(p); |
| 1301 | bad_fork_cleanup_mm: | 1307 | bad_fork_cleanup_mm: |
| 1302 | if (p->mm) | 1308 | if (p->mm) { |
| 1309 | task_lock(p); | ||
| 1310 | if (p->signal->oom_score_adj == OOM_SCORE_ADJ_MIN) | ||
| 1311 | atomic_dec(&p->mm->oom_disable_count); | ||
| 1312 | task_unlock(p); | ||
| 1303 | mmput(p->mm); | 1313 | mmput(p->mm); |
| 1314 | } | ||
| 1304 | bad_fork_cleanup_signal: | 1315 | bad_fork_cleanup_signal: |
| 1305 | if (!(clone_flags & CLONE_THREAD)) | 1316 | if (!(clone_flags & CLONE_THREAD)) |
| 1306 | free_signal_struct(p->signal); | 1317 | free_signal_struct(p->signal); |
| @@ -1693,6 +1704,10 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags) | |||
| 1693 | active_mm = current->active_mm; | 1704 | active_mm = current->active_mm; |
| 1694 | current->mm = new_mm; | 1705 | current->mm = new_mm; |
| 1695 | current->active_mm = new_mm; | 1706 | current->active_mm = new_mm; |
| 1707 | if (current->signal->oom_score_adj == OOM_SCORE_ADJ_MIN) { | ||
| 1708 | atomic_dec(&mm->oom_disable_count); | ||
| 1709 | atomic_inc(&new_mm->oom_disable_count); | ||
| 1710 | } | ||
| 1696 | activate_mm(active_mm, new_mm); | 1711 | activate_mm(active_mm, new_mm); |
| 1697 | new_mm = mm; | 1712 | new_mm = mm; |
| 1698 | } | 1713 | } |
diff --git a/kernel/futex.c b/kernel/futex.c index a118bf160e0b..6c683b37f2ce 100644 --- a/kernel/futex.c +++ b/kernel/futex.c | |||
| @@ -169,7 +169,7 @@ static void get_futex_key_refs(union futex_key *key) | |||
| 169 | 169 | ||
| 170 | switch (key->both.offset & (FUT_OFF_INODE|FUT_OFF_MMSHARED)) { | 170 | switch (key->both.offset & (FUT_OFF_INODE|FUT_OFF_MMSHARED)) { |
| 171 | case FUT_OFF_INODE: | 171 | case FUT_OFF_INODE: |
| 172 | atomic_inc(&key->shared.inode->i_count); | 172 | ihold(key->shared.inode); |
| 173 | break; | 173 | break; |
| 174 | case FUT_OFF_MMSHARED: | 174 | case FUT_OFF_MMSHARED: |
| 175 | atomic_inc(&key->private.mm->mm_count); | 175 | atomic_inc(&key->private.mm->mm_count); |
diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c index 9d917ff72675..9988d03797f5 100644 --- a/kernel/irq/irqdesc.c +++ b/kernel/irq/irqdesc.c | |||
| @@ -393,3 +393,18 @@ unsigned int kstat_irqs_cpu(unsigned int irq, int cpu) | |||
| 393 | struct irq_desc *desc = irq_to_desc(irq); | 393 | struct irq_desc *desc = irq_to_desc(irq); |
| 394 | return desc ? desc->kstat_irqs[cpu] : 0; | 394 | return desc ? desc->kstat_irqs[cpu] : 0; |
| 395 | } | 395 | } |
| 396 | |||
| 397 | #ifdef CONFIG_GENERIC_HARDIRQS | ||
| 398 | unsigned int kstat_irqs(unsigned int irq) | ||
| 399 | { | ||
| 400 | struct irq_desc *desc = irq_to_desc(irq); | ||
| 401 | int cpu; | ||
| 402 | int sum = 0; | ||
| 403 | |||
| 404 | if (!desc) | ||
| 405 | return 0; | ||
| 406 | for_each_possible_cpu(cpu) | ||
| 407 | sum += desc->kstat_irqs[cpu]; | ||
| 408 | return sum; | ||
| 409 | } | ||
| 410 | #endif /* CONFIG_GENERIC_HARDIRQS */ | ||
diff --git a/kernel/kexec.c b/kernel/kexec.c index c0613f7d6730..b55045bc7563 100644 --- a/kernel/kexec.c +++ b/kernel/kexec.c | |||
| @@ -816,7 +816,7 @@ static int kimage_load_normal_segment(struct kimage *image, | |||
| 816 | 816 | ||
| 817 | ptr = kmap(page); | 817 | ptr = kmap(page); |
| 818 | /* Start with a clear page */ | 818 | /* Start with a clear page */ |
| 819 | memset(ptr, 0, PAGE_SIZE); | 819 | clear_page(ptr); |
| 820 | ptr += maddr & ~PAGE_MASK; | 820 | ptr += maddr & ~PAGE_MASK; |
| 821 | mchunk = PAGE_SIZE - (maddr & ~PAGE_MASK); | 821 | mchunk = PAGE_SIZE - (maddr & ~PAGE_MASK); |
| 822 | if (mchunk > mbytes) | 822 | if (mchunk > mbytes) |
diff --git a/kernel/kprobes.c b/kernel/kprobes.c index 56a891914273..99865c33a60d 100644 --- a/kernel/kprobes.c +++ b/kernel/kprobes.c | |||
| @@ -74,7 +74,8 @@ static struct hlist_head kretprobe_inst_table[KPROBE_TABLE_SIZE]; | |||
| 74 | /* NOTE: change this value only with kprobe_mutex held */ | 74 | /* NOTE: change this value only with kprobe_mutex held */ |
| 75 | static bool kprobes_all_disarmed; | 75 | static bool kprobes_all_disarmed; |
| 76 | 76 | ||
| 77 | static DEFINE_MUTEX(kprobe_mutex); /* Protects kprobe_table */ | 77 | /* This protects kprobe_table and optimizing_list */ |
| 78 | static DEFINE_MUTEX(kprobe_mutex); | ||
| 78 | static DEFINE_PER_CPU(struct kprobe *, kprobe_instance) = NULL; | 79 | static DEFINE_PER_CPU(struct kprobe *, kprobe_instance) = NULL; |
| 79 | static struct { | 80 | static struct { |
| 80 | spinlock_t lock ____cacheline_aligned_in_smp; | 81 | spinlock_t lock ____cacheline_aligned_in_smp; |
| @@ -595,6 +596,7 @@ static __kprobes void try_to_optimize_kprobe(struct kprobe *p) | |||
| 595 | } | 596 | } |
| 596 | 597 | ||
| 597 | #ifdef CONFIG_SYSCTL | 598 | #ifdef CONFIG_SYSCTL |
| 599 | /* This should be called with kprobe_mutex locked */ | ||
| 598 | static void __kprobes optimize_all_kprobes(void) | 600 | static void __kprobes optimize_all_kprobes(void) |
| 599 | { | 601 | { |
| 600 | struct hlist_head *head; | 602 | struct hlist_head *head; |
| @@ -607,17 +609,16 @@ static void __kprobes optimize_all_kprobes(void) | |||
| 607 | return; | 609 | return; |
| 608 | 610 | ||
| 609 | kprobes_allow_optimization = true; | 611 | kprobes_allow_optimization = true; |
| 610 | mutex_lock(&text_mutex); | ||
| 611 | for (i = 0; i < KPROBE_TABLE_SIZE; i++) { | 612 | for (i = 0; i < KPROBE_TABLE_SIZE; i++) { |
| 612 | head = &kprobe_table[i]; | 613 | head = &kprobe_table[i]; |
| 613 | hlist_for_each_entry_rcu(p, node, head, hlist) | 614 | hlist_for_each_entry_rcu(p, node, head, hlist) |
| 614 | if (!kprobe_disabled(p)) | 615 | if (!kprobe_disabled(p)) |
| 615 | optimize_kprobe(p); | 616 | optimize_kprobe(p); |
| 616 | } | 617 | } |
| 617 | mutex_unlock(&text_mutex); | ||
| 618 | printk(KERN_INFO "Kprobes globally optimized\n"); | 618 | printk(KERN_INFO "Kprobes globally optimized\n"); |
| 619 | } | 619 | } |
| 620 | 620 | ||
| 621 | /* This should be called with kprobe_mutex locked */ | ||
| 621 | static void __kprobes unoptimize_all_kprobes(void) | 622 | static void __kprobes unoptimize_all_kprobes(void) |
| 622 | { | 623 | { |
| 623 | struct hlist_head *head; | 624 | struct hlist_head *head; |
diff --git a/kernel/module.c b/kernel/module.c index 2df46301a7a4..437a74a7524a 100644 --- a/kernel/module.c +++ b/kernel/module.c | |||
| @@ -2037,7 +2037,7 @@ static inline void layout_symtab(struct module *mod, struct load_info *info) | |||
| 2037 | { | 2037 | { |
| 2038 | } | 2038 | } |
| 2039 | 2039 | ||
| 2040 | static void add_kallsyms(struct module *mod, struct load_info *info) | 2040 | static void add_kallsyms(struct module *mod, const struct load_info *info) |
| 2041 | { | 2041 | { |
| 2042 | } | 2042 | } |
| 2043 | #endif /* CONFIG_KALLSYMS */ | 2043 | #endif /* CONFIG_KALLSYMS */ |
diff --git a/kernel/ns_cgroup.c b/kernel/ns_cgroup.c index 2a5dfec8efe0..2c98ad94ba0e 100644 --- a/kernel/ns_cgroup.c +++ b/kernel/ns_cgroup.c | |||
| @@ -85,6 +85,14 @@ static struct cgroup_subsys_state *ns_create(struct cgroup_subsys *ss, | |||
| 85 | return ERR_PTR(-EPERM); | 85 | return ERR_PTR(-EPERM); |
| 86 | if (!cgroup_is_descendant(cgroup, current)) | 86 | if (!cgroup_is_descendant(cgroup, current)) |
| 87 | return ERR_PTR(-EPERM); | 87 | return ERR_PTR(-EPERM); |
| 88 | if (test_bit(CGRP_CLONE_CHILDREN, &cgroup->flags)) { | ||
| 89 | printk("ns_cgroup can't be created with parent " | ||
| 90 | "'clone_children' set.\n"); | ||
| 91 | return ERR_PTR(-EINVAL); | ||
| 92 | } | ||
| 93 | |||
| 94 | printk_once("ns_cgroup deprecated: consider using the " | ||
| 95 | "'clone_children' flag without the ns_cgroup.\n"); | ||
| 88 | 96 | ||
| 89 | ns_cgroup = kzalloc(sizeof(*ns_cgroup), GFP_KERNEL); | 97 | ns_cgroup = kzalloc(sizeof(*ns_cgroup), GFP_KERNEL); |
| 90 | if (!ns_cgroup) | 98 | if (!ns_cgroup) |
diff --git a/kernel/perf_event.c b/kernel/perf_event.c index f309e8014c78..517d827f4982 100644 --- a/kernel/perf_event.c +++ b/kernel/perf_event.c | |||
| @@ -417,8 +417,8 @@ event_filter_match(struct perf_event *event) | |||
| 417 | return event->cpu == -1 || event->cpu == smp_processor_id(); | 417 | return event->cpu == -1 || event->cpu == smp_processor_id(); |
| 418 | } | 418 | } |
| 419 | 419 | ||
| 420 | static int | 420 | static void |
| 421 | __event_sched_out(struct perf_event *event, | 421 | event_sched_out(struct perf_event *event, |
| 422 | struct perf_cpu_context *cpuctx, | 422 | struct perf_cpu_context *cpuctx, |
| 423 | struct perf_event_context *ctx) | 423 | struct perf_event_context *ctx) |
| 424 | { | 424 | { |
| @@ -437,13 +437,14 @@ __event_sched_out(struct perf_event *event, | |||
| 437 | } | 437 | } |
| 438 | 438 | ||
| 439 | if (event->state != PERF_EVENT_STATE_ACTIVE) | 439 | if (event->state != PERF_EVENT_STATE_ACTIVE) |
| 440 | return 0; | 440 | return; |
| 441 | 441 | ||
| 442 | event->state = PERF_EVENT_STATE_INACTIVE; | 442 | event->state = PERF_EVENT_STATE_INACTIVE; |
| 443 | if (event->pending_disable) { | 443 | if (event->pending_disable) { |
| 444 | event->pending_disable = 0; | 444 | event->pending_disable = 0; |
| 445 | event->state = PERF_EVENT_STATE_OFF; | 445 | event->state = PERF_EVENT_STATE_OFF; |
| 446 | } | 446 | } |
| 447 | event->tstamp_stopped = ctx->time; | ||
| 447 | event->pmu->del(event, 0); | 448 | event->pmu->del(event, 0); |
| 448 | event->oncpu = -1; | 449 | event->oncpu = -1; |
| 449 | 450 | ||
| @@ -452,19 +453,6 @@ __event_sched_out(struct perf_event *event, | |||
| 452 | ctx->nr_active--; | 453 | ctx->nr_active--; |
| 453 | if (event->attr.exclusive || !cpuctx->active_oncpu) | 454 | if (event->attr.exclusive || !cpuctx->active_oncpu) |
| 454 | cpuctx->exclusive = 0; | 455 | cpuctx->exclusive = 0; |
| 455 | return 1; | ||
| 456 | } | ||
| 457 | |||
| 458 | static void | ||
| 459 | event_sched_out(struct perf_event *event, | ||
| 460 | struct perf_cpu_context *cpuctx, | ||
| 461 | struct perf_event_context *ctx) | ||
| 462 | { | ||
| 463 | int ret; | ||
| 464 | |||
| 465 | ret = __event_sched_out(event, cpuctx, ctx); | ||
| 466 | if (ret) | ||
| 467 | event->tstamp_stopped = ctx->time; | ||
| 468 | } | 456 | } |
| 469 | 457 | ||
| 470 | static void | 458 | static void |
| @@ -664,7 +652,7 @@ retry: | |||
| 664 | } | 652 | } |
| 665 | 653 | ||
| 666 | static int | 654 | static int |
| 667 | __event_sched_in(struct perf_event *event, | 655 | event_sched_in(struct perf_event *event, |
| 668 | struct perf_cpu_context *cpuctx, | 656 | struct perf_cpu_context *cpuctx, |
| 669 | struct perf_event_context *ctx) | 657 | struct perf_event_context *ctx) |
| 670 | { | 658 | { |
| @@ -684,6 +672,8 @@ __event_sched_in(struct perf_event *event, | |||
| 684 | return -EAGAIN; | 672 | return -EAGAIN; |
| 685 | } | 673 | } |
| 686 | 674 | ||
| 675 | event->tstamp_running += ctx->time - event->tstamp_stopped; | ||
| 676 | |||
| 687 | if (!is_software_event(event)) | 677 | if (!is_software_event(event)) |
| 688 | cpuctx->active_oncpu++; | 678 | cpuctx->active_oncpu++; |
| 689 | ctx->nr_active++; | 679 | ctx->nr_active++; |
| @@ -694,35 +684,6 @@ __event_sched_in(struct perf_event *event, | |||
| 694 | return 0; | 684 | return 0; |
| 695 | } | 685 | } |
| 696 | 686 | ||
| 697 | static inline int | ||
| 698 | event_sched_in(struct perf_event *event, | ||
| 699 | struct perf_cpu_context *cpuctx, | ||
| 700 | struct perf_event_context *ctx) | ||
| 701 | { | ||
| 702 | int ret = __event_sched_in(event, cpuctx, ctx); | ||
| 703 | if (ret) | ||
| 704 | return ret; | ||
| 705 | event->tstamp_running += ctx->time - event->tstamp_stopped; | ||
| 706 | return 0; | ||
| 707 | } | ||
| 708 | |||
| 709 | static void | ||
| 710 | group_commit_event_sched_in(struct perf_event *group_event, | ||
| 711 | struct perf_cpu_context *cpuctx, | ||
| 712 | struct perf_event_context *ctx) | ||
| 713 | { | ||
| 714 | struct perf_event *event; | ||
| 715 | u64 now = ctx->time; | ||
| 716 | |||
| 717 | group_event->tstamp_running += now - group_event->tstamp_stopped; | ||
| 718 | /* | ||
| 719 | * Schedule in siblings as one group (if any): | ||
| 720 | */ | ||
| 721 | list_for_each_entry(event, &group_event->sibling_list, group_entry) { | ||
| 722 | event->tstamp_running += now - event->tstamp_stopped; | ||
| 723 | } | ||
| 724 | } | ||
| 725 | |||
| 726 | static int | 687 | static int |
| 727 | group_sched_in(struct perf_event *group_event, | 688 | group_sched_in(struct perf_event *group_event, |
| 728 | struct perf_cpu_context *cpuctx, | 689 | struct perf_cpu_context *cpuctx, |
| @@ -730,19 +691,15 @@ group_sched_in(struct perf_event *group_event, | |||
| 730 | { | 691 | { |
| 731 | struct perf_event *event, *partial_group = NULL; | 692 | struct perf_event *event, *partial_group = NULL; |
| 732 | struct pmu *pmu = group_event->pmu; | 693 | struct pmu *pmu = group_event->pmu; |
| 694 | u64 now = ctx->time; | ||
| 695 | bool simulate = false; | ||
| 733 | 696 | ||
| 734 | if (group_event->state == PERF_EVENT_STATE_OFF) | 697 | if (group_event->state == PERF_EVENT_STATE_OFF) |
| 735 | return 0; | 698 | return 0; |
| 736 | 699 | ||
| 737 | pmu->start_txn(pmu); | 700 | pmu->start_txn(pmu); |
| 738 | 701 | ||
| 739 | /* | 702 | if (event_sched_in(group_event, cpuctx, ctx)) { |
| 740 | * use __event_sched_in() to delay updating tstamp_running | ||
| 741 | * until the transaction is committed. In case of failure | ||
| 742 | * we will keep an unmodified tstamp_running which is a | ||
| 743 | * requirement to get correct timing information | ||
| 744 | */ | ||
| 745 | if (__event_sched_in(group_event, cpuctx, ctx)) { | ||
| 746 | pmu->cancel_txn(pmu); | 703 | pmu->cancel_txn(pmu); |
| 747 | return -EAGAIN; | 704 | return -EAGAIN; |
| 748 | } | 705 | } |
| @@ -751,31 +708,42 @@ group_sched_in(struct perf_event *group_event, | |||
| 751 | * Schedule in siblings as one group (if any): | 708 | * Schedule in siblings as one group (if any): |
| 752 | */ | 709 | */ |
| 753 | list_for_each_entry(event, &group_event->sibling_list, group_entry) { | 710 | list_for_each_entry(event, &group_event->sibling_list, group_entry) { |
| 754 | if (__event_sched_in(event, cpuctx, ctx)) { | 711 | if (event_sched_in(event, cpuctx, ctx)) { |
| 755 | partial_group = event; | 712 | partial_group = event; |
| 756 | goto group_error; | 713 | goto group_error; |
| 757 | } | 714 | } |
| 758 | } | 715 | } |
| 759 | 716 | ||
| 760 | if (!pmu->commit_txn(pmu)) { | 717 | if (!pmu->commit_txn(pmu)) |
| 761 | /* commit tstamp_running */ | ||
| 762 | group_commit_event_sched_in(group_event, cpuctx, ctx); | ||
| 763 | return 0; | 718 | return 0; |
| 764 | } | 719 | |
| 765 | group_error: | 720 | group_error: |
| 766 | /* | 721 | /* |
| 767 | * Groups can be scheduled in as one unit only, so undo any | 722 | * Groups can be scheduled in as one unit only, so undo any |
| 768 | * partial group before returning: | 723 | * partial group before returning: |
| 724 | * The events up to the failed event are scheduled out normally, | ||
| 725 | * tstamp_stopped will be updated. | ||
| 769 | * | 726 | * |
| 770 | * use __event_sched_out() to avoid updating tstamp_stopped | 727 | * The failed events and the remaining siblings need to have |
| 771 | * because the event never actually ran | 728 | * their timings updated as if they had gone thru event_sched_in() |
| 729 | * and event_sched_out(). This is required to get consistent timings | ||
| 730 | * across the group. This also takes care of the case where the group | ||
| 731 | * could never be scheduled by ensuring tstamp_stopped is set to mark | ||
| 732 | * the time the event was actually stopped, such that time delta | ||
| 733 | * calculation in update_event_times() is correct. | ||
| 772 | */ | 734 | */ |
| 773 | list_for_each_entry(event, &group_event->sibling_list, group_entry) { | 735 | list_for_each_entry(event, &group_event->sibling_list, group_entry) { |
| 774 | if (event == partial_group) | 736 | if (event == partial_group) |
| 775 | break; | 737 | simulate = true; |
| 776 | __event_sched_out(event, cpuctx, ctx); | 738 | |
| 739 | if (simulate) { | ||
| 740 | event->tstamp_running += now - event->tstamp_stopped; | ||
| 741 | event->tstamp_stopped = now; | ||
| 742 | } else { | ||
| 743 | event_sched_out(event, cpuctx, ctx); | ||
| 744 | } | ||
| 777 | } | 745 | } |
| 778 | __event_sched_out(group_event, cpuctx, ctx); | 746 | event_sched_out(group_event, cpuctx, ctx); |
| 779 | 747 | ||
| 780 | pmu->cancel_txn(pmu); | 748 | pmu->cancel_txn(pmu); |
| 781 | 749 | ||
diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c index ac7eb109f196..0dac75ea4456 100644 --- a/kernel/power/snapshot.c +++ b/kernel/power/snapshot.c | |||
| @@ -984,8 +984,8 @@ static void copy_data_page(unsigned long dst_pfn, unsigned long src_pfn) | |||
| 984 | src = kmap_atomic(s_page, KM_USER0); | 984 | src = kmap_atomic(s_page, KM_USER0); |
| 985 | dst = kmap_atomic(d_page, KM_USER1); | 985 | dst = kmap_atomic(d_page, KM_USER1); |
| 986 | do_copy_page(dst, src); | 986 | do_copy_page(dst, src); |
| 987 | kunmap_atomic(src, KM_USER0); | ||
| 988 | kunmap_atomic(dst, KM_USER1); | 987 | kunmap_atomic(dst, KM_USER1); |
| 988 | kunmap_atomic(src, KM_USER0); | ||
| 989 | } else { | 989 | } else { |
| 990 | if (PageHighMem(d_page)) { | 990 | if (PageHighMem(d_page)) { |
| 991 | /* Page pointed to by src may contain some kernel | 991 | /* Page pointed to by src may contain some kernel |
| @@ -993,7 +993,7 @@ static void copy_data_page(unsigned long dst_pfn, unsigned long src_pfn) | |||
| 993 | */ | 993 | */ |
| 994 | safe_copy_page(buffer, s_page); | 994 | safe_copy_page(buffer, s_page); |
| 995 | dst = kmap_atomic(d_page, KM_USER0); | 995 | dst = kmap_atomic(d_page, KM_USER0); |
| 996 | memcpy(dst, buffer, PAGE_SIZE); | 996 | copy_page(dst, buffer); |
| 997 | kunmap_atomic(dst, KM_USER0); | 997 | kunmap_atomic(dst, KM_USER0); |
| 998 | } else { | 998 | } else { |
| 999 | safe_copy_page(page_address(d_page), s_page); | 999 | safe_copy_page(page_address(d_page), s_page); |
| @@ -1687,7 +1687,7 @@ int snapshot_read_next(struct snapshot_handle *handle) | |||
| 1687 | memory_bm_position_reset(&orig_bm); | 1687 | memory_bm_position_reset(&orig_bm); |
| 1688 | memory_bm_position_reset(©_bm); | 1688 | memory_bm_position_reset(©_bm); |
| 1689 | } else if (handle->cur <= nr_meta_pages) { | 1689 | } else if (handle->cur <= nr_meta_pages) { |
| 1690 | memset(buffer, 0, PAGE_SIZE); | 1690 | clear_page(buffer); |
| 1691 | pack_pfns(buffer, &orig_bm); | 1691 | pack_pfns(buffer, &orig_bm); |
| 1692 | } else { | 1692 | } else { |
| 1693 | struct page *page; | 1693 | struct page *page; |
| @@ -1701,7 +1701,7 @@ int snapshot_read_next(struct snapshot_handle *handle) | |||
| 1701 | void *kaddr; | 1701 | void *kaddr; |
| 1702 | 1702 | ||
| 1703 | kaddr = kmap_atomic(page, KM_USER0); | 1703 | kaddr = kmap_atomic(page, KM_USER0); |
| 1704 | memcpy(buffer, kaddr, PAGE_SIZE); | 1704 | copy_page(buffer, kaddr); |
| 1705 | kunmap_atomic(kaddr, KM_USER0); | 1705 | kunmap_atomic(kaddr, KM_USER0); |
| 1706 | handle->buffer = buffer; | 1706 | handle->buffer = buffer; |
| 1707 | } else { | 1707 | } else { |
| @@ -1984,7 +1984,7 @@ static void copy_last_highmem_page(void) | |||
| 1984 | void *dst; | 1984 | void *dst; |
| 1985 | 1985 | ||
| 1986 | dst = kmap_atomic(last_highmem_page, KM_USER0); | 1986 | dst = kmap_atomic(last_highmem_page, KM_USER0); |
| 1987 | memcpy(dst, buffer, PAGE_SIZE); | 1987 | copy_page(dst, buffer); |
| 1988 | kunmap_atomic(dst, KM_USER0); | 1988 | kunmap_atomic(dst, KM_USER0); |
| 1989 | last_highmem_page = NULL; | 1989 | last_highmem_page = NULL; |
| 1990 | } | 1990 | } |
| @@ -2270,11 +2270,11 @@ swap_two_pages_data(struct page *p1, struct page *p2, void *buf) | |||
| 2270 | 2270 | ||
| 2271 | kaddr1 = kmap_atomic(p1, KM_USER0); | 2271 | kaddr1 = kmap_atomic(p1, KM_USER0); |
| 2272 | kaddr2 = kmap_atomic(p2, KM_USER1); | 2272 | kaddr2 = kmap_atomic(p2, KM_USER1); |
| 2273 | memcpy(buf, kaddr1, PAGE_SIZE); | 2273 | copy_page(buf, kaddr1); |
| 2274 | memcpy(kaddr1, kaddr2, PAGE_SIZE); | 2274 | copy_page(kaddr1, kaddr2); |
| 2275 | memcpy(kaddr2, buf, PAGE_SIZE); | 2275 | copy_page(kaddr2, buf); |
| 2276 | kunmap_atomic(kaddr1, KM_USER0); | ||
| 2277 | kunmap_atomic(kaddr2, KM_USER1); | 2276 | kunmap_atomic(kaddr2, KM_USER1); |
| 2277 | kunmap_atomic(kaddr1, KM_USER0); | ||
| 2278 | } | 2278 | } |
| 2279 | 2279 | ||
| 2280 | /** | 2280 | /** |
diff --git a/kernel/power/swap.c b/kernel/power/swap.c index 916eaa790399..a0e4a86ccf94 100644 --- a/kernel/power/swap.c +++ b/kernel/power/swap.c | |||
| @@ -251,7 +251,7 @@ static int write_page(void *buf, sector_t offset, struct bio **bio_chain) | |||
| 251 | if (bio_chain) { | 251 | if (bio_chain) { |
| 252 | src = (void *)__get_free_page(__GFP_WAIT | __GFP_HIGH); | 252 | src = (void *)__get_free_page(__GFP_WAIT | __GFP_HIGH); |
| 253 | if (src) { | 253 | if (src) { |
| 254 | memcpy(src, buf, PAGE_SIZE); | 254 | copy_page(src, buf); |
| 255 | } else { | 255 | } else { |
| 256 | WARN_ON_ONCE(1); | 256 | WARN_ON_ONCE(1); |
| 257 | bio_chain = NULL; /* Go synchronous */ | 257 | bio_chain = NULL; /* Go synchronous */ |
| @@ -325,7 +325,7 @@ static int swap_write_page(struct swap_map_handle *handle, void *buf, | |||
| 325 | error = write_page(handle->cur, handle->cur_swap, NULL); | 325 | error = write_page(handle->cur, handle->cur_swap, NULL); |
| 326 | if (error) | 326 | if (error) |
| 327 | goto out; | 327 | goto out; |
| 328 | memset(handle->cur, 0, PAGE_SIZE); | 328 | clear_page(handle->cur); |
| 329 | handle->cur_swap = offset; | 329 | handle->cur_swap = offset; |
| 330 | handle->k = 0; | 330 | handle->k = 0; |
| 331 | } | 331 | } |
| @@ -910,7 +910,7 @@ int swsusp_check(void) | |||
| 910 | hib_resume_bdev = open_by_devnum(swsusp_resume_device, FMODE_READ); | 910 | hib_resume_bdev = open_by_devnum(swsusp_resume_device, FMODE_READ); |
| 911 | if (!IS_ERR(hib_resume_bdev)) { | 911 | if (!IS_ERR(hib_resume_bdev)) { |
| 912 | set_blocksize(hib_resume_bdev, PAGE_SIZE); | 912 | set_blocksize(hib_resume_bdev, PAGE_SIZE); |
| 913 | memset(swsusp_header, 0, PAGE_SIZE); | 913 | clear_page(swsusp_header); |
| 914 | error = hib_bio_read_page(swsusp_resume_block, | 914 | error = hib_bio_read_page(swsusp_resume_block, |
| 915 | swsusp_header, NULL); | 915 | swsusp_header, NULL); |
| 916 | if (error) | 916 | if (error) |
diff --git a/kernel/printk.c b/kernel/printk.c index 2531017795f6..b2ebaee8c377 100644 --- a/kernel/printk.c +++ b/kernel/printk.c | |||
| @@ -210,7 +210,7 @@ __setup("log_buf_len=", log_buf_len_setup); | |||
| 210 | 210 | ||
| 211 | #ifdef CONFIG_BOOT_PRINTK_DELAY | 211 | #ifdef CONFIG_BOOT_PRINTK_DELAY |
| 212 | 212 | ||
| 213 | static unsigned int boot_delay; /* msecs delay after each printk during bootup */ | 213 | static int boot_delay; /* msecs delay after each printk during bootup */ |
| 214 | static unsigned long long loops_per_msec; /* based on boot_delay */ | 214 | static unsigned long long loops_per_msec; /* based on boot_delay */ |
| 215 | 215 | ||
| 216 | static int __init boot_delay_setup(char *str) | 216 | static int __init boot_delay_setup(char *str) |
| @@ -647,6 +647,7 @@ static inline int can_use_console(unsigned int cpu) | |||
| 647 | * released but interrupts still disabled. | 647 | * released but interrupts still disabled. |
| 648 | */ | 648 | */ |
| 649 | static int acquire_console_semaphore_for_printk(unsigned int cpu) | 649 | static int acquire_console_semaphore_for_printk(unsigned int cpu) |
| 650 | __releases(&logbuf_lock) | ||
| 650 | { | 651 | { |
| 651 | int retval = 0; | 652 | int retval = 0; |
| 652 | 653 | ||
| @@ -1511,7 +1512,7 @@ int kmsg_dump_unregister(struct kmsg_dumper *dumper) | |||
| 1511 | } | 1512 | } |
| 1512 | EXPORT_SYMBOL_GPL(kmsg_dump_unregister); | 1513 | EXPORT_SYMBOL_GPL(kmsg_dump_unregister); |
| 1513 | 1514 | ||
| 1514 | static const char const *kmsg_reasons[] = { | 1515 | static const char * const kmsg_reasons[] = { |
| 1515 | [KMSG_DUMP_OOPS] = "oops", | 1516 | [KMSG_DUMP_OOPS] = "oops", |
| 1516 | [KMSG_DUMP_PANIC] = "panic", | 1517 | [KMSG_DUMP_PANIC] = "panic", |
| 1517 | [KMSG_DUMP_KEXEC] = "kexec", | 1518 | [KMSG_DUMP_KEXEC] = "kexec", |
diff --git a/kernel/ptrace.c b/kernel/ptrace.c index f34d798ef4a2..99bbaa3e5b0d 100644 --- a/kernel/ptrace.c +++ b/kernel/ptrace.c | |||
| @@ -181,7 +181,7 @@ int ptrace_attach(struct task_struct *task) | |||
| 181 | * under ptrace. | 181 | * under ptrace. |
| 182 | */ | 182 | */ |
| 183 | retval = -ERESTARTNOINTR; | 183 | retval = -ERESTARTNOINTR; |
| 184 | if (mutex_lock_interruptible(&task->cred_guard_mutex)) | 184 | if (mutex_lock_interruptible(&task->signal->cred_guard_mutex)) |
| 185 | goto out; | 185 | goto out; |
| 186 | 186 | ||
| 187 | task_lock(task); | 187 | task_lock(task); |
| @@ -208,7 +208,7 @@ int ptrace_attach(struct task_struct *task) | |||
| 208 | unlock_tasklist: | 208 | unlock_tasklist: |
| 209 | write_unlock_irq(&tasklist_lock); | 209 | write_unlock_irq(&tasklist_lock); |
| 210 | unlock_creds: | 210 | unlock_creds: |
| 211 | mutex_unlock(&task->cred_guard_mutex); | 211 | mutex_unlock(&task->signal->cred_guard_mutex); |
| 212 | out: | 212 | out: |
| 213 | return retval; | 213 | return retval; |
| 214 | } | 214 | } |
| @@ -329,6 +329,8 @@ int ptrace_detach(struct task_struct *child, unsigned int data) | |||
| 329 | * and reacquire the lock. | 329 | * and reacquire the lock. |
| 330 | */ | 330 | */ |
| 331 | void exit_ptrace(struct task_struct *tracer) | 331 | void exit_ptrace(struct task_struct *tracer) |
| 332 | __releases(&tasklist_lock) | ||
| 333 | __acquires(&tasklist_lock) | ||
| 332 | { | 334 | { |
| 333 | struct task_struct *p, *n; | 335 | struct task_struct *p, *n; |
| 334 | LIST_HEAD(ptrace_dead); | 336 | LIST_HEAD(ptrace_dead); |
| @@ -402,7 +404,7 @@ int ptrace_writedata(struct task_struct *tsk, char __user *src, unsigned long ds | |||
| 402 | return copied; | 404 | return copied; |
| 403 | } | 405 | } |
| 404 | 406 | ||
| 405 | static int ptrace_setoptions(struct task_struct *child, long data) | 407 | static int ptrace_setoptions(struct task_struct *child, unsigned long data) |
| 406 | { | 408 | { |
| 407 | child->ptrace &= ~PT_TRACE_MASK; | 409 | child->ptrace &= ~PT_TRACE_MASK; |
| 408 | 410 | ||
| @@ -481,7 +483,8 @@ static int ptrace_setsiginfo(struct task_struct *child, const siginfo_t *info) | |||
| 481 | #define is_sysemu_singlestep(request) 0 | 483 | #define is_sysemu_singlestep(request) 0 |
| 482 | #endif | 484 | #endif |
| 483 | 485 | ||
| 484 | static int ptrace_resume(struct task_struct *child, long request, long data) | 486 | static int ptrace_resume(struct task_struct *child, long request, |
| 487 | unsigned long data) | ||
| 485 | { | 488 | { |
| 486 | if (!valid_signal(data)) | 489 | if (!valid_signal(data)) |
| 487 | return -EIO; | 490 | return -EIO; |
| @@ -558,10 +561,12 @@ static int ptrace_regset(struct task_struct *task, int req, unsigned int type, | |||
| 558 | #endif | 561 | #endif |
| 559 | 562 | ||
| 560 | int ptrace_request(struct task_struct *child, long request, | 563 | int ptrace_request(struct task_struct *child, long request, |
| 561 | long addr, long data) | 564 | unsigned long addr, unsigned long data) |
| 562 | { | 565 | { |
| 563 | int ret = -EIO; | 566 | int ret = -EIO; |
| 564 | siginfo_t siginfo; | 567 | siginfo_t siginfo; |
| 568 | void __user *datavp = (void __user *) data; | ||
| 569 | unsigned long __user *datalp = datavp; | ||
| 565 | 570 | ||
| 566 | switch (request) { | 571 | switch (request) { |
| 567 | case PTRACE_PEEKTEXT: | 572 | case PTRACE_PEEKTEXT: |
| @@ -578,19 +583,17 @@ int ptrace_request(struct task_struct *child, long request, | |||
| 578 | ret = ptrace_setoptions(child, data); | 583 | ret = ptrace_setoptions(child, data); |
| 579 | break; | 584 | break; |
| 580 | case PTRACE_GETEVENTMSG: | 585 | case PTRACE_GETEVENTMSG: |
| 581 | ret = put_user(child->ptrace_message, (unsigned long __user *) data); | 586 | ret = put_user(child->ptrace_message, datalp); |
| 582 | break; | 587 | break; |
| 583 | 588 | ||
| 584 | case PTRACE_GETSIGINFO: | 589 | case PTRACE_GETSIGINFO: |
| 585 | ret = ptrace_getsiginfo(child, &siginfo); | 590 | ret = ptrace_getsiginfo(child, &siginfo); |
| 586 | if (!ret) | 591 | if (!ret) |
| 587 | ret = copy_siginfo_to_user((siginfo_t __user *) data, | 592 | ret = copy_siginfo_to_user(datavp, &siginfo); |
| 588 | &siginfo); | ||
| 589 | break; | 593 | break; |
| 590 | 594 | ||
| 591 | case PTRACE_SETSIGINFO: | 595 | case PTRACE_SETSIGINFO: |
| 592 | if (copy_from_user(&siginfo, (siginfo_t __user *) data, | 596 | if (copy_from_user(&siginfo, datavp, sizeof siginfo)) |
| 593 | sizeof siginfo)) | ||
| 594 | ret = -EFAULT; | 597 | ret = -EFAULT; |
| 595 | else | 598 | else |
| 596 | ret = ptrace_setsiginfo(child, &siginfo); | 599 | ret = ptrace_setsiginfo(child, &siginfo); |
| @@ -621,7 +624,7 @@ int ptrace_request(struct task_struct *child, long request, | |||
| 621 | } | 624 | } |
| 622 | mmput(mm); | 625 | mmput(mm); |
| 623 | 626 | ||
| 624 | ret = put_user(tmp, (unsigned long __user *) data); | 627 | ret = put_user(tmp, datalp); |
| 625 | break; | 628 | break; |
| 626 | } | 629 | } |
| 627 | #endif | 630 | #endif |
| @@ -650,7 +653,7 @@ int ptrace_request(struct task_struct *child, long request, | |||
| 650 | case PTRACE_SETREGSET: | 653 | case PTRACE_SETREGSET: |
| 651 | { | 654 | { |
| 652 | struct iovec kiov; | 655 | struct iovec kiov; |
| 653 | struct iovec __user *uiov = (struct iovec __user *) data; | 656 | struct iovec __user *uiov = datavp; |
| 654 | 657 | ||
| 655 | if (!access_ok(VERIFY_WRITE, uiov, sizeof(*uiov))) | 658 | if (!access_ok(VERIFY_WRITE, uiov, sizeof(*uiov))) |
| 656 | return -EFAULT; | 659 | return -EFAULT; |
| @@ -691,7 +694,8 @@ static struct task_struct *ptrace_get_task_struct(pid_t pid) | |||
| 691 | #define arch_ptrace_attach(child) do { } while (0) | 694 | #define arch_ptrace_attach(child) do { } while (0) |
| 692 | #endif | 695 | #endif |
| 693 | 696 | ||
| 694 | SYSCALL_DEFINE4(ptrace, long, request, long, pid, long, addr, long, data) | 697 | SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr, |
| 698 | unsigned long, data) | ||
| 695 | { | 699 | { |
| 696 | struct task_struct *child; | 700 | struct task_struct *child; |
| 697 | long ret; | 701 | long ret; |
| @@ -732,7 +736,8 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, long, addr, long, data) | |||
| 732 | return ret; | 736 | return ret; |
| 733 | } | 737 | } |
| 734 | 738 | ||
| 735 | int generic_ptrace_peekdata(struct task_struct *tsk, long addr, long data) | 739 | int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr, |
| 740 | unsigned long data) | ||
| 736 | { | 741 | { |
| 737 | unsigned long tmp; | 742 | unsigned long tmp; |
| 738 | int copied; | 743 | int copied; |
| @@ -743,7 +748,8 @@ int generic_ptrace_peekdata(struct task_struct *tsk, long addr, long data) | |||
| 743 | return put_user(tmp, (unsigned long __user *)data); | 748 | return put_user(tmp, (unsigned long __user *)data); |
| 744 | } | 749 | } |
| 745 | 750 | ||
| 746 | int generic_ptrace_pokedata(struct task_struct *tsk, long addr, long data) | 751 | int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr, |
| 752 | unsigned long data) | ||
| 747 | { | 753 | { |
| 748 | int copied; | 754 | int copied; |
| 749 | 755 | ||
diff --git a/kernel/resource.c b/kernel/resource.c index 7b36976e5dea..9fad33efd0db 100644 --- a/kernel/resource.c +++ b/kernel/resource.c | |||
| @@ -40,6 +40,23 @@ EXPORT_SYMBOL(iomem_resource); | |||
| 40 | 40 | ||
| 41 | static DEFINE_RWLOCK(resource_lock); | 41 | static DEFINE_RWLOCK(resource_lock); |
| 42 | 42 | ||
| 43 | /* | ||
| 44 | * By default, we allocate free space bottom-up. The architecture can request | ||
| 45 | * top-down by clearing this flag. The user can override the architecture's | ||
| 46 | * choice with the "resource_alloc_from_bottom" kernel boot option, but that | ||
| 47 | * should only be a debugging tool. | ||
| 48 | */ | ||
| 49 | int resource_alloc_from_bottom = 1; | ||
| 50 | |||
| 51 | static __init int setup_alloc_from_bottom(char *s) | ||
| 52 | { | ||
| 53 | printk(KERN_INFO | ||
| 54 | "resource: allocating from bottom-up; please report a bug\n"); | ||
| 55 | resource_alloc_from_bottom = 1; | ||
| 56 | return 0; | ||
| 57 | } | ||
| 58 | early_param("resource_alloc_from_bottom", setup_alloc_from_bottom); | ||
| 59 | |||
| 43 | static void *r_next(struct seq_file *m, void *v, loff_t *pos) | 60 | static void *r_next(struct seq_file *m, void *v, loff_t *pos) |
| 44 | { | 61 | { |
| 45 | struct resource *p = v; | 62 | struct resource *p = v; |
| @@ -357,8 +374,97 @@ int __weak page_is_ram(unsigned long pfn) | |||
| 357 | return walk_system_ram_range(pfn, 1, NULL, __is_ram) == 1; | 374 | return walk_system_ram_range(pfn, 1, NULL, __is_ram) == 1; |
| 358 | } | 375 | } |
| 359 | 376 | ||
| 377 | static resource_size_t simple_align_resource(void *data, | ||
| 378 | const struct resource *avail, | ||
| 379 | resource_size_t size, | ||
| 380 | resource_size_t align) | ||
| 381 | { | ||
| 382 | return avail->start; | ||
| 383 | } | ||
| 384 | |||
| 385 | static void resource_clip(struct resource *res, resource_size_t min, | ||
| 386 | resource_size_t max) | ||
| 387 | { | ||
| 388 | if (res->start < min) | ||
| 389 | res->start = min; | ||
| 390 | if (res->end > max) | ||
| 391 | res->end = max; | ||
| 392 | } | ||
| 393 | |||
| 394 | static bool resource_contains(struct resource *res1, struct resource *res2) | ||
| 395 | { | ||
| 396 | return res1->start <= res2->start && res1->end >= res2->end; | ||
| 397 | } | ||
| 398 | |||
| 399 | /* | ||
| 400 | * Find the resource before "child" in the sibling list of "root" children. | ||
| 401 | */ | ||
| 402 | static struct resource *find_sibling_prev(struct resource *root, struct resource *child) | ||
| 403 | { | ||
| 404 | struct resource *this; | ||
| 405 | |||
| 406 | for (this = root->child; this; this = this->sibling) | ||
| 407 | if (this->sibling == child) | ||
| 408 | return this; | ||
| 409 | |||
| 410 | return NULL; | ||
| 411 | } | ||
| 412 | |||
| 413 | /* | ||
| 414 | * Find empty slot in the resource tree given range and alignment. | ||
| 415 | * This version allocates from the end of the root resource first. | ||
| 416 | */ | ||
| 417 | static int find_resource_from_top(struct resource *root, struct resource *new, | ||
| 418 | resource_size_t size, resource_size_t min, | ||
| 419 | resource_size_t max, resource_size_t align, | ||
| 420 | resource_size_t (*alignf)(void *, | ||
| 421 | const struct resource *, | ||
| 422 | resource_size_t, | ||
| 423 | resource_size_t), | ||
| 424 | void *alignf_data) | ||
| 425 | { | ||
| 426 | struct resource *this; | ||
| 427 | struct resource tmp, avail, alloc; | ||
| 428 | |||
| 429 | tmp.start = root->end; | ||
| 430 | tmp.end = root->end; | ||
| 431 | |||
| 432 | this = find_sibling_prev(root, NULL); | ||
| 433 | for (;;) { | ||
| 434 | if (this) { | ||
| 435 | if (this->end < root->end) | ||
| 436 | tmp.start = this->end + 1; | ||
| 437 | } else | ||
| 438 | tmp.start = root->start; | ||
| 439 | |||
| 440 | resource_clip(&tmp, min, max); | ||
| 441 | |||
| 442 | /* Check for overflow after ALIGN() */ | ||
| 443 | avail = *new; | ||
| 444 | avail.start = ALIGN(tmp.start, align); | ||
| 445 | avail.end = tmp.end; | ||
| 446 | if (avail.start >= tmp.start) { | ||
| 447 | alloc.start = alignf(alignf_data, &avail, size, align); | ||
| 448 | alloc.end = alloc.start + size - 1; | ||
| 449 | if (resource_contains(&avail, &alloc)) { | ||
| 450 | new->start = alloc.start; | ||
| 451 | new->end = alloc.end; | ||
| 452 | return 0; | ||
| 453 | } | ||
| 454 | } | ||
| 455 | |||
| 456 | if (!this || this->start == root->start) | ||
| 457 | break; | ||
| 458 | |||
| 459 | tmp.end = this->start - 1; | ||
| 460 | this = find_sibling_prev(root, this); | ||
| 461 | } | ||
| 462 | return -EBUSY; | ||
| 463 | } | ||
| 464 | |||
| 360 | /* | 465 | /* |
| 361 | * Find empty slot in the resource tree given range and alignment. | 466 | * Find empty slot in the resource tree given range and alignment. |
| 467 | * This version allocates from the beginning of the root resource first. | ||
| 362 | */ | 468 | */ |
| 363 | static int find_resource(struct resource *root, struct resource *new, | 469 | static int find_resource(struct resource *root, struct resource *new, |
| 364 | resource_size_t size, resource_size_t min, | 470 | resource_size_t size, resource_size_t min, |
| @@ -370,36 +476,43 @@ static int find_resource(struct resource *root, struct resource *new, | |||
| 370 | void *alignf_data) | 476 | void *alignf_data) |
| 371 | { | 477 | { |
| 372 | struct resource *this = root->child; | 478 | struct resource *this = root->child; |
| 373 | struct resource tmp = *new; | 479 | struct resource tmp = *new, avail, alloc; |
| 374 | 480 | ||
| 375 | tmp.start = root->start; | 481 | tmp.start = root->start; |
| 376 | /* | 482 | /* |
| 377 | * Skip past an allocated resource that starts at 0, since the assignment | 483 | * Skip past an allocated resource that starts at 0, since the |
| 378 | * of this->start - 1 to tmp->end below would cause an underflow. | 484 | * assignment of this->start - 1 to tmp->end below would cause an |
| 485 | * underflow. | ||
| 379 | */ | 486 | */ |
| 380 | if (this && this->start == 0) { | 487 | if (this && this->start == 0) { |
| 381 | tmp.start = this->end + 1; | 488 | tmp.start = this->end + 1; |
| 382 | this = this->sibling; | 489 | this = this->sibling; |
| 383 | } | 490 | } |
| 384 | for(;;) { | 491 | for (;;) { |
| 385 | if (this) | 492 | if (this) |
| 386 | tmp.end = this->start - 1; | 493 | tmp.end = this->start - 1; |
| 387 | else | 494 | else |
| 388 | tmp.end = root->end; | 495 | tmp.end = root->end; |
| 389 | if (tmp.start < min) | 496 | |
| 390 | tmp.start = min; | 497 | resource_clip(&tmp, min, max); |
| 391 | if (tmp.end > max) | 498 | |
| 392 | tmp.end = max; | 499 | /* Check for overflow after ALIGN() */ |
| 393 | tmp.start = ALIGN(tmp.start, align); | 500 | avail = *new; |
| 394 | if (alignf) | 501 | avail.start = ALIGN(tmp.start, align); |
| 395 | tmp.start = alignf(alignf_data, &tmp, size, align); | 502 | avail.end = tmp.end; |
| 396 | if (tmp.start < tmp.end && tmp.end - tmp.start >= size - 1) { | 503 | if (avail.start >= tmp.start) { |
| 397 | new->start = tmp.start; | 504 | alloc.start = alignf(alignf_data, &avail, size, align); |
| 398 | new->end = tmp.start + size - 1; | 505 | alloc.end = alloc.start + size - 1; |
| 399 | return 0; | 506 | if (resource_contains(&avail, &alloc)) { |
| 507 | new->start = alloc.start; | ||
| 508 | new->end = alloc.end; | ||
| 509 | return 0; | ||
| 510 | } | ||
| 400 | } | 511 | } |
| 512 | |||
| 401 | if (!this) | 513 | if (!this) |
| 402 | break; | 514 | break; |
| 515 | |||
| 403 | tmp.start = this->end + 1; | 516 | tmp.start = this->end + 1; |
| 404 | this = this->sibling; | 517 | this = this->sibling; |
| 405 | } | 518 | } |
| @@ -428,8 +541,14 @@ int allocate_resource(struct resource *root, struct resource *new, | |||
| 428 | { | 541 | { |
| 429 | int err; | 542 | int err; |
| 430 | 543 | ||
| 544 | if (!alignf) | ||
| 545 | alignf = simple_align_resource; | ||
| 546 | |||
| 431 | write_lock(&resource_lock); | 547 | write_lock(&resource_lock); |
| 432 | err = find_resource(root, new, size, min, max, align, alignf, alignf_data); | 548 | if (resource_alloc_from_bottom) |
| 549 | err = find_resource(root, new, size, min, max, align, alignf, alignf_data); | ||
| 550 | else | ||
| 551 | err = find_resource_from_top(root, new, size, min, max, align, alignf, alignf_data); | ||
| 433 | if (err >= 0 && __request_resource(root, new)) | 552 | if (err >= 0 && __request_resource(root, new)) |
| 434 | err = -EBUSY; | 553 | err = -EBUSY; |
| 435 | write_unlock(&resource_lock); | 554 | write_unlock(&resource_lock); |
| @@ -453,6 +572,8 @@ static struct resource * __insert_resource(struct resource *parent, struct resou | |||
| 453 | 572 | ||
| 454 | if (first == parent) | 573 | if (first == parent) |
| 455 | return first; | 574 | return first; |
| 575 | if (WARN_ON(first == new)) /* duplicated insertion */ | ||
| 576 | return first; | ||
| 456 | 577 | ||
| 457 | if ((first->start > new->start) || (first->end < new->end)) | 578 | if ((first->start > new->start) || (first->end < new->end)) |
| 458 | break; | 579 | break; |
diff --git a/kernel/signal.c b/kernel/signal.c index 919562c3d6b7..4e3cff10fdce 100644 --- a/kernel/signal.c +++ b/kernel/signal.c | |||
| @@ -1105,7 +1105,8 @@ int zap_other_threads(struct task_struct *p) | |||
| 1105 | return count; | 1105 | return count; |
| 1106 | } | 1106 | } |
| 1107 | 1107 | ||
| 1108 | struct sighand_struct *lock_task_sighand(struct task_struct *tsk, unsigned long *flags) | 1108 | struct sighand_struct *__lock_task_sighand(struct task_struct *tsk, |
| 1109 | unsigned long *flags) | ||
| 1109 | { | 1110 | { |
| 1110 | struct sighand_struct *sighand; | 1111 | struct sighand_struct *sighand; |
| 1111 | 1112 | ||
| @@ -1617,6 +1618,8 @@ static int sigkill_pending(struct task_struct *tsk) | |||
| 1617 | * is gone, we keep current->exit_code unless clear_code. | 1618 | * is gone, we keep current->exit_code unless clear_code. |
| 1618 | */ | 1619 | */ |
| 1619 | static void ptrace_stop(int exit_code, int clear_code, siginfo_t *info) | 1620 | static void ptrace_stop(int exit_code, int clear_code, siginfo_t *info) |
| 1621 | __releases(¤t->sighand->siglock) | ||
| 1622 | __acquires(¤t->sighand->siglock) | ||
| 1620 | { | 1623 | { |
| 1621 | if (arch_ptrace_stop_needed(exit_code, info)) { | 1624 | if (arch_ptrace_stop_needed(exit_code, info)) { |
| 1622 | /* | 1625 | /* |
diff --git a/kernel/smp.c b/kernel/smp.c index ed6aacfcb7ef..12ed8b013e2d 100644 --- a/kernel/smp.c +++ b/kernel/smp.c | |||
| @@ -267,7 +267,7 @@ static DEFINE_PER_CPU_SHARED_ALIGNED(struct call_single_data, csd_data); | |||
| 267 | * | 267 | * |
| 268 | * Returns 0 on success, else a negative status code. | 268 | * Returns 0 on success, else a negative status code. |
| 269 | */ | 269 | */ |
| 270 | int smp_call_function_single(int cpu, void (*func) (void *info), void *info, | 270 | int smp_call_function_single(int cpu, smp_call_func_t func, void *info, |
| 271 | int wait) | 271 | int wait) |
| 272 | { | 272 | { |
| 273 | struct call_single_data d = { | 273 | struct call_single_data d = { |
| @@ -336,7 +336,7 @@ EXPORT_SYMBOL(smp_call_function_single); | |||
| 336 | * 3) any other online cpu in @mask | 336 | * 3) any other online cpu in @mask |
| 337 | */ | 337 | */ |
| 338 | int smp_call_function_any(const struct cpumask *mask, | 338 | int smp_call_function_any(const struct cpumask *mask, |
| 339 | void (*func)(void *info), void *info, int wait) | 339 | smp_call_func_t func, void *info, int wait) |
| 340 | { | 340 | { |
| 341 | unsigned int cpu; | 341 | unsigned int cpu; |
| 342 | const struct cpumask *nodemask; | 342 | const struct cpumask *nodemask; |
| @@ -416,7 +416,7 @@ void __smp_call_function_single(int cpu, struct call_single_data *data, | |||
| 416 | * must be disabled when calling this function. | 416 | * must be disabled when calling this function. |
| 417 | */ | 417 | */ |
| 418 | void smp_call_function_many(const struct cpumask *mask, | 418 | void smp_call_function_many(const struct cpumask *mask, |
| 419 | void (*func)(void *), void *info, bool wait) | 419 | smp_call_func_t func, void *info, bool wait) |
| 420 | { | 420 | { |
| 421 | struct call_function_data *data; | 421 | struct call_function_data *data; |
| 422 | unsigned long flags; | 422 | unsigned long flags; |
| @@ -500,7 +500,7 @@ EXPORT_SYMBOL(smp_call_function_many); | |||
| 500 | * You must not call this function with disabled interrupts or from a | 500 | * You must not call this function with disabled interrupts or from a |
| 501 | * hardware interrupt handler or from a bottom half handler. | 501 | * hardware interrupt handler or from a bottom half handler. |
| 502 | */ | 502 | */ |
| 503 | int smp_call_function(void (*func)(void *), void *info, int wait) | 503 | int smp_call_function(smp_call_func_t func, void *info, int wait) |
| 504 | { | 504 | { |
| 505 | preempt_disable(); | 505 | preempt_disable(); |
| 506 | smp_call_function_many(cpu_online_mask, func, info, wait); | 506 | smp_call_function_many(cpu_online_mask, func, info, wait); |
diff --git a/kernel/softirq.c b/kernel/softirq.c index f02a9dfa19bc..18f4be0d5fe0 100644 --- a/kernel/softirq.c +++ b/kernel/softirq.c | |||
| @@ -229,18 +229,20 @@ restart: | |||
| 229 | 229 | ||
| 230 | do { | 230 | do { |
| 231 | if (pending & 1) { | 231 | if (pending & 1) { |
| 232 | unsigned int vec_nr = h - softirq_vec; | ||
| 232 | int prev_count = preempt_count(); | 233 | int prev_count = preempt_count(); |
| 233 | kstat_incr_softirqs_this_cpu(h - softirq_vec); | ||
| 234 | 234 | ||
| 235 | trace_softirq_entry(h, softirq_vec); | 235 | kstat_incr_softirqs_this_cpu(vec_nr); |
| 236 | |||
| 237 | trace_softirq_entry(vec_nr); | ||
| 236 | h->action(h); | 238 | h->action(h); |
| 237 | trace_softirq_exit(h, softirq_vec); | 239 | trace_softirq_exit(vec_nr); |
| 238 | if (unlikely(prev_count != preempt_count())) { | 240 | if (unlikely(prev_count != preempt_count())) { |
| 239 | printk(KERN_ERR "huh, entered softirq %td %s %p" | 241 | printk(KERN_ERR "huh, entered softirq %u %s %p" |
| 240 | "with preempt_count %08x," | 242 | "with preempt_count %08x," |
| 241 | " exited with %08x?\n", h - softirq_vec, | 243 | " exited with %08x?\n", vec_nr, |
| 242 | softirq_to_name[h - softirq_vec], | 244 | softirq_to_name[vec_nr], h->action, |
| 243 | h->action, prev_count, preempt_count()); | 245 | prev_count, preempt_count()); |
| 244 | preempt_count() = prev_count; | 246 | preempt_count() = prev_count; |
| 245 | } | 247 | } |
| 246 | 248 | ||
diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c index 090c28812ce1..2df820b03beb 100644 --- a/kernel/stop_machine.c +++ b/kernel/stop_machine.c | |||
| @@ -262,7 +262,7 @@ repeat: | |||
| 262 | cpu_stop_fn_t fn = work->fn; | 262 | cpu_stop_fn_t fn = work->fn; |
| 263 | void *arg = work->arg; | 263 | void *arg = work->arg; |
| 264 | struct cpu_stop_done *done = work->done; | 264 | struct cpu_stop_done *done = work->done; |
| 265 | char ksym_buf[KSYM_NAME_LEN]; | 265 | char ksym_buf[KSYM_NAME_LEN] __maybe_unused; |
| 266 | 266 | ||
| 267 | __set_current_state(TASK_RUNNING); | 267 | __set_current_state(TASK_RUNNING); |
| 268 | 268 | ||
| @@ -304,7 +304,7 @@ static int __cpuinit cpu_stop_cpu_callback(struct notifier_block *nfb, | |||
| 304 | p = kthread_create(cpu_stopper_thread, stopper, "migration/%d", | 304 | p = kthread_create(cpu_stopper_thread, stopper, "migration/%d", |
| 305 | cpu); | 305 | cpu); |
| 306 | if (IS_ERR(p)) | 306 | if (IS_ERR(p)) |
| 307 | return NOTIFY_BAD; | 307 | return notifier_from_errno(PTR_ERR(p)); |
| 308 | get_task_struct(p); | 308 | get_task_struct(p); |
| 309 | kthread_bind(p, cpu); | 309 | kthread_bind(p, cpu); |
| 310 | sched_set_stop_task(cpu, p); | 310 | sched_set_stop_task(cpu, p); |
| @@ -372,7 +372,7 @@ static int __init cpu_stop_init(void) | |||
| 372 | /* start one for the boot cpu */ | 372 | /* start one for the boot cpu */ |
| 373 | err = cpu_stop_cpu_callback(&cpu_stop_cpu_notifier, CPU_UP_PREPARE, | 373 | err = cpu_stop_cpu_callback(&cpu_stop_cpu_notifier, CPU_UP_PREPARE, |
| 374 | bcpu); | 374 | bcpu); |
| 375 | BUG_ON(err == NOTIFY_BAD); | 375 | BUG_ON(err != NOTIFY_OK); |
| 376 | cpu_stop_cpu_callback(&cpu_stop_cpu_notifier, CPU_ONLINE, bcpu); | 376 | cpu_stop_cpu_callback(&cpu_stop_cpu_notifier, CPU_ONLINE, bcpu); |
| 377 | register_cpu_notifier(&cpu_stop_cpu_notifier); | 377 | register_cpu_notifier(&cpu_stop_cpu_notifier); |
| 378 | 378 | ||
diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 3a45c224770f..c33a1edb799f 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c | |||
| @@ -161,8 +161,6 @@ extern int no_unaligned_warning; | |||
| 161 | extern int unaligned_dump_stack; | 161 | extern int unaligned_dump_stack; |
| 162 | #endif | 162 | #endif |
| 163 | 163 | ||
| 164 | extern struct ratelimit_state printk_ratelimit_state; | ||
| 165 | |||
| 166 | #ifdef CONFIG_PROC_SYSCTL | 164 | #ifdef CONFIG_PROC_SYSCTL |
| 167 | static int proc_do_cad_pid(struct ctl_table *table, int write, | 165 | static int proc_do_cad_pid(struct ctl_table *table, int write, |
| 168 | void __user *buffer, size_t *lenp, loff_t *ppos); | 166 | void __user *buffer, size_t *lenp, loff_t *ppos); |
| @@ -1340,28 +1338,28 @@ static struct ctl_table fs_table[] = { | |||
| 1340 | .data = &inodes_stat, | 1338 | .data = &inodes_stat, |
| 1341 | .maxlen = 2*sizeof(int), | 1339 | .maxlen = 2*sizeof(int), |
| 1342 | .mode = 0444, | 1340 | .mode = 0444, |
| 1343 | .proc_handler = proc_dointvec, | 1341 | .proc_handler = proc_nr_inodes, |
| 1344 | }, | 1342 | }, |
| 1345 | { | 1343 | { |
| 1346 | .procname = "inode-state", | 1344 | .procname = "inode-state", |
| 1347 | .data = &inodes_stat, | 1345 | .data = &inodes_stat, |
| 1348 | .maxlen = 7*sizeof(int), | 1346 | .maxlen = 7*sizeof(int), |
| 1349 | .mode = 0444, | 1347 | .mode = 0444, |
| 1350 | .proc_handler = proc_dointvec, | 1348 | .proc_handler = proc_nr_inodes, |
| 1351 | }, | 1349 | }, |
| 1352 | { | 1350 | { |
| 1353 | .procname = "file-nr", | 1351 | .procname = "file-nr", |
| 1354 | .data = &files_stat, | 1352 | .data = &files_stat, |
| 1355 | .maxlen = 3*sizeof(int), | 1353 | .maxlen = sizeof(files_stat), |
| 1356 | .mode = 0444, | 1354 | .mode = 0444, |
| 1357 | .proc_handler = proc_nr_files, | 1355 | .proc_handler = proc_nr_files, |
| 1358 | }, | 1356 | }, |
| 1359 | { | 1357 | { |
| 1360 | .procname = "file-max", | 1358 | .procname = "file-max", |
| 1361 | .data = &files_stat.max_files, | 1359 | .data = &files_stat.max_files, |
| 1362 | .maxlen = sizeof(int), | 1360 | .maxlen = sizeof(files_stat.max_files), |
| 1363 | .mode = 0644, | 1361 | .mode = 0644, |
| 1364 | .proc_handler = proc_dointvec, | 1362 | .proc_handler = proc_doulongvec_minmax, |
| 1365 | }, | 1363 | }, |
| 1366 | { | 1364 | { |
| 1367 | .procname = "nr_open", | 1365 | .procname = "nr_open", |
| @@ -1377,7 +1375,7 @@ static struct ctl_table fs_table[] = { | |||
| 1377 | .data = &dentry_stat, | 1375 | .data = &dentry_stat, |
| 1378 | .maxlen = 6*sizeof(int), | 1376 | .maxlen = 6*sizeof(int), |
| 1379 | .mode = 0444, | 1377 | .mode = 0444, |
| 1380 | .proc_handler = proc_dointvec, | 1378 | .proc_handler = proc_nr_dentry, |
| 1381 | }, | 1379 | }, |
| 1382 | { | 1380 | { |
| 1383 | .procname = "overflowuid", | 1381 | .procname = "overflowuid", |
diff --git a/kernel/taskstats.c b/kernel/taskstats.c index 11281d5792bd..c8231fb15708 100644 --- a/kernel/taskstats.c +++ b/kernel/taskstats.c | |||
| @@ -175,22 +175,8 @@ static void send_cpu_listeners(struct sk_buff *skb, | |||
| 175 | up_write(&listeners->sem); | 175 | up_write(&listeners->sem); |
| 176 | } | 176 | } |
| 177 | 177 | ||
| 178 | static int fill_pid(pid_t pid, struct task_struct *tsk, | 178 | static void fill_stats(struct task_struct *tsk, struct taskstats *stats) |
| 179 | struct taskstats *stats) | ||
| 180 | { | 179 | { |
| 181 | int rc = 0; | ||
| 182 | |||
| 183 | if (!tsk) { | ||
| 184 | rcu_read_lock(); | ||
| 185 | tsk = find_task_by_vpid(pid); | ||
| 186 | if (tsk) | ||
| 187 | get_task_struct(tsk); | ||
| 188 | rcu_read_unlock(); | ||
| 189 | if (!tsk) | ||
| 190 | return -ESRCH; | ||
| 191 | } else | ||
| 192 | get_task_struct(tsk); | ||
| 193 | |||
| 194 | memset(stats, 0, sizeof(*stats)); | 180 | memset(stats, 0, sizeof(*stats)); |
| 195 | /* | 181 | /* |
| 196 | * Each accounting subsystem adds calls to its functions to | 182 | * Each accounting subsystem adds calls to its functions to |
| @@ -209,17 +195,27 @@ static int fill_pid(pid_t pid, struct task_struct *tsk, | |||
| 209 | 195 | ||
| 210 | /* fill in extended acct fields */ | 196 | /* fill in extended acct fields */ |
| 211 | xacct_add_tsk(stats, tsk); | 197 | xacct_add_tsk(stats, tsk); |
| 198 | } | ||
| 212 | 199 | ||
| 213 | /* Define err: label here if needed */ | 200 | static int fill_stats_for_pid(pid_t pid, struct taskstats *stats) |
| 214 | put_task_struct(tsk); | 201 | { |
| 215 | return rc; | 202 | struct task_struct *tsk; |
| 216 | 203 | ||
| 204 | rcu_read_lock(); | ||
| 205 | tsk = find_task_by_vpid(pid); | ||
| 206 | if (tsk) | ||
| 207 | get_task_struct(tsk); | ||
| 208 | rcu_read_unlock(); | ||
| 209 | if (!tsk) | ||
| 210 | return -ESRCH; | ||
| 211 | fill_stats(tsk, stats); | ||
| 212 | put_task_struct(tsk); | ||
| 213 | return 0; | ||
| 217 | } | 214 | } |
| 218 | 215 | ||
| 219 | static int fill_tgid(pid_t tgid, struct task_struct *first, | 216 | static int fill_stats_for_tgid(pid_t tgid, struct taskstats *stats) |
| 220 | struct taskstats *stats) | ||
| 221 | { | 217 | { |
| 222 | struct task_struct *tsk; | 218 | struct task_struct *tsk, *first; |
| 223 | unsigned long flags; | 219 | unsigned long flags; |
| 224 | int rc = -ESRCH; | 220 | int rc = -ESRCH; |
| 225 | 221 | ||
| @@ -228,8 +224,7 @@ static int fill_tgid(pid_t tgid, struct task_struct *first, | |||
| 228 | * leaders who are already counted with the dead tasks | 224 | * leaders who are already counted with the dead tasks |
| 229 | */ | 225 | */ |
| 230 | rcu_read_lock(); | 226 | rcu_read_lock(); |
| 231 | if (!first) | 227 | first = find_task_by_vpid(tgid); |
| 232 | first = find_task_by_vpid(tgid); | ||
| 233 | 228 | ||
| 234 | if (!first || !lock_task_sighand(first, &flags)) | 229 | if (!first || !lock_task_sighand(first, &flags)) |
| 235 | goto out; | 230 | goto out; |
| @@ -268,7 +263,6 @@ out: | |||
| 268 | return rc; | 263 | return rc; |
| 269 | } | 264 | } |
| 270 | 265 | ||
| 271 | |||
| 272 | static void fill_tgid_exit(struct task_struct *tsk) | 266 | static void fill_tgid_exit(struct task_struct *tsk) |
| 273 | { | 267 | { |
| 274 | unsigned long flags; | 268 | unsigned long flags; |
| @@ -360,6 +354,12 @@ static struct taskstats *mk_reply(struct sk_buff *skb, int type, u32 pid) | |||
| 360 | struct nlattr *na, *ret; | 354 | struct nlattr *na, *ret; |
| 361 | int aggr; | 355 | int aggr; |
| 362 | 356 | ||
| 357 | /* If we don't pad, we end up with alignment on a 4 byte boundary. | ||
| 358 | * This causes lots of runtime warnings on systems requiring 8 byte | ||
| 359 | * alignment */ | ||
| 360 | u32 pids[2] = { pid, 0 }; | ||
| 361 | int pid_size = ALIGN(sizeof(pid), sizeof(long)); | ||
| 362 | |||
| 363 | aggr = (type == TASKSTATS_TYPE_PID) | 363 | aggr = (type == TASKSTATS_TYPE_PID) |
| 364 | ? TASKSTATS_TYPE_AGGR_PID | 364 | ? TASKSTATS_TYPE_AGGR_PID |
| 365 | : TASKSTATS_TYPE_AGGR_TGID; | 365 | : TASKSTATS_TYPE_AGGR_TGID; |
| @@ -367,7 +367,7 @@ static struct taskstats *mk_reply(struct sk_buff *skb, int type, u32 pid) | |||
| 367 | na = nla_nest_start(skb, aggr); | 367 | na = nla_nest_start(skb, aggr); |
| 368 | if (!na) | 368 | if (!na) |
| 369 | goto err; | 369 | goto err; |
| 370 | if (nla_put(skb, type, sizeof(pid), &pid) < 0) | 370 | if (nla_put(skb, type, pid_size, pids) < 0) |
| 371 | goto err; | 371 | goto err; |
| 372 | ret = nla_reserve(skb, TASKSTATS_TYPE_STATS, sizeof(struct taskstats)); | 372 | ret = nla_reserve(skb, TASKSTATS_TYPE_STATS, sizeof(struct taskstats)); |
| 373 | if (!ret) | 373 | if (!ret) |
| @@ -424,39 +424,46 @@ err: | |||
| 424 | return rc; | 424 | return rc; |
| 425 | } | 425 | } |
| 426 | 426 | ||
| 427 | static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info) | 427 | static int cmd_attr_register_cpumask(struct genl_info *info) |
| 428 | { | 428 | { |
| 429 | int rc; | ||
| 430 | struct sk_buff *rep_skb; | ||
| 431 | struct taskstats *stats; | ||
| 432 | size_t size; | ||
| 433 | cpumask_var_t mask; | 429 | cpumask_var_t mask; |
| 430 | int rc; | ||
| 434 | 431 | ||
| 435 | if (!alloc_cpumask_var(&mask, GFP_KERNEL)) | 432 | if (!alloc_cpumask_var(&mask, GFP_KERNEL)) |
| 436 | return -ENOMEM; | 433 | return -ENOMEM; |
| 437 | |||
| 438 | rc = parse(info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK], mask); | 434 | rc = parse(info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK], mask); |
| 439 | if (rc < 0) | 435 | if (rc < 0) |
| 440 | goto free_return_rc; | 436 | goto out; |
| 441 | if (rc == 0) { | 437 | rc = add_del_listener(info->snd_pid, mask, REGISTER); |
| 442 | rc = add_del_listener(info->snd_pid, mask, REGISTER); | 438 | out: |
| 443 | goto free_return_rc; | 439 | free_cpumask_var(mask); |
| 444 | } | 440 | return rc; |
| 441 | } | ||
| 442 | |||
| 443 | static int cmd_attr_deregister_cpumask(struct genl_info *info) | ||
| 444 | { | ||
| 445 | cpumask_var_t mask; | ||
| 446 | int rc; | ||
| 445 | 447 | ||
| 448 | if (!alloc_cpumask_var(&mask, GFP_KERNEL)) | ||
| 449 | return -ENOMEM; | ||
| 446 | rc = parse(info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK], mask); | 450 | rc = parse(info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK], mask); |
| 447 | if (rc < 0) | 451 | if (rc < 0) |
| 448 | goto free_return_rc; | 452 | goto out; |
| 449 | if (rc == 0) { | 453 | rc = add_del_listener(info->snd_pid, mask, DEREGISTER); |
| 450 | rc = add_del_listener(info->snd_pid, mask, DEREGISTER); | 454 | out: |
| 451 | free_return_rc: | ||
| 452 | free_cpumask_var(mask); | ||
| 453 | return rc; | ||
| 454 | } | ||
| 455 | free_cpumask_var(mask); | 455 | free_cpumask_var(mask); |
| 456 | return rc; | ||
| 457 | } | ||
| 458 | |||
| 459 | static int cmd_attr_pid(struct genl_info *info) | ||
| 460 | { | ||
| 461 | struct taskstats *stats; | ||
| 462 | struct sk_buff *rep_skb; | ||
| 463 | size_t size; | ||
| 464 | u32 pid; | ||
| 465 | int rc; | ||
| 456 | 466 | ||
| 457 | /* | ||
| 458 | * Size includes space for nested attributes | ||
| 459 | */ | ||
| 460 | size = nla_total_size(sizeof(u32)) + | 467 | size = nla_total_size(sizeof(u32)) + |
| 461 | nla_total_size(sizeof(struct taskstats)) + nla_total_size(0); | 468 | nla_total_size(sizeof(struct taskstats)) + nla_total_size(0); |
| 462 | 469 | ||
| @@ -465,33 +472,64 @@ free_return_rc: | |||
| 465 | return rc; | 472 | return rc; |
| 466 | 473 | ||
| 467 | rc = -EINVAL; | 474 | rc = -EINVAL; |
| 468 | if (info->attrs[TASKSTATS_CMD_ATTR_PID]) { | 475 | pid = nla_get_u32(info->attrs[TASKSTATS_CMD_ATTR_PID]); |
| 469 | u32 pid = nla_get_u32(info->attrs[TASKSTATS_CMD_ATTR_PID]); | 476 | stats = mk_reply(rep_skb, TASKSTATS_TYPE_PID, pid); |
| 470 | stats = mk_reply(rep_skb, TASKSTATS_TYPE_PID, pid); | 477 | if (!stats) |
| 471 | if (!stats) | 478 | goto err; |
| 472 | goto err; | 479 | |
| 473 | 480 | rc = fill_stats_for_pid(pid, stats); | |
| 474 | rc = fill_pid(pid, NULL, stats); | 481 | if (rc < 0) |
| 475 | if (rc < 0) | 482 | goto err; |
| 476 | goto err; | 483 | return send_reply(rep_skb, info); |
| 477 | } else if (info->attrs[TASKSTATS_CMD_ATTR_TGID]) { | 484 | err: |
| 478 | u32 tgid = nla_get_u32(info->attrs[TASKSTATS_CMD_ATTR_TGID]); | 485 | nlmsg_free(rep_skb); |
| 479 | stats = mk_reply(rep_skb, TASKSTATS_TYPE_TGID, tgid); | 486 | return rc; |
| 480 | if (!stats) | 487 | } |
| 481 | goto err; | 488 | |
| 482 | 489 | static int cmd_attr_tgid(struct genl_info *info) | |
| 483 | rc = fill_tgid(tgid, NULL, stats); | 490 | { |
| 484 | if (rc < 0) | 491 | struct taskstats *stats; |
| 485 | goto err; | 492 | struct sk_buff *rep_skb; |
| 486 | } else | 493 | size_t size; |
| 494 | u32 tgid; | ||
| 495 | int rc; | ||
| 496 | |||
| 497 | size = nla_total_size(sizeof(u32)) + | ||
| 498 | nla_total_size(sizeof(struct taskstats)) + nla_total_size(0); | ||
| 499 | |||
| 500 | rc = prepare_reply(info, TASKSTATS_CMD_NEW, &rep_skb, size); | ||
| 501 | if (rc < 0) | ||
| 502 | return rc; | ||
| 503 | |||
| 504 | rc = -EINVAL; | ||
| 505 | tgid = nla_get_u32(info->attrs[TASKSTATS_CMD_ATTR_TGID]); | ||
| 506 | stats = mk_reply(rep_skb, TASKSTATS_TYPE_TGID, tgid); | ||
| 507 | if (!stats) | ||
| 487 | goto err; | 508 | goto err; |
| 488 | 509 | ||
| 510 | rc = fill_stats_for_tgid(tgid, stats); | ||
| 511 | if (rc < 0) | ||
| 512 | goto err; | ||
| 489 | return send_reply(rep_skb, info); | 513 | return send_reply(rep_skb, info); |
| 490 | err: | 514 | err: |
| 491 | nlmsg_free(rep_skb); | 515 | nlmsg_free(rep_skb); |
| 492 | return rc; | 516 | return rc; |
| 493 | } | 517 | } |
| 494 | 518 | ||
| 519 | static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info) | ||
| 520 | { | ||
| 521 | if (info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK]) | ||
| 522 | return cmd_attr_register_cpumask(info); | ||
| 523 | else if (info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK]) | ||
| 524 | return cmd_attr_deregister_cpumask(info); | ||
| 525 | else if (info->attrs[TASKSTATS_CMD_ATTR_PID]) | ||
| 526 | return cmd_attr_pid(info); | ||
| 527 | else if (info->attrs[TASKSTATS_CMD_ATTR_TGID]) | ||
| 528 | return cmd_attr_tgid(info); | ||
| 529 | else | ||
| 530 | return -EINVAL; | ||
| 531 | } | ||
| 532 | |||
| 495 | static struct taskstats *taskstats_tgid_alloc(struct task_struct *tsk) | 533 | static struct taskstats *taskstats_tgid_alloc(struct task_struct *tsk) |
| 496 | { | 534 | { |
| 497 | struct signal_struct *sig = tsk->signal; | 535 | struct signal_struct *sig = tsk->signal; |
| @@ -555,9 +593,7 @@ void taskstats_exit(struct task_struct *tsk, int group_dead) | |||
| 555 | if (!stats) | 593 | if (!stats) |
| 556 | goto err; | 594 | goto err; |
| 557 | 595 | ||
| 558 | rc = fill_pid(-1, tsk, stats); | 596 | fill_stats(tsk, stats); |
| 559 | if (rc < 0) | ||
| 560 | goto err; | ||
| 561 | 597 | ||
| 562 | /* | 598 | /* |
| 563 | * Doesn't matter if tsk is the leader or the last group member leaving | 599 | * Doesn't matter if tsk is the leader or the last group member leaving |
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c index c3dab054d18e..9ed509a015d8 100644 --- a/kernel/trace/ring_buffer.c +++ b/kernel/trace/ring_buffer.c | |||
| @@ -224,6 +224,9 @@ enum { | |||
| 224 | RB_LEN_TIME_STAMP = 16, | 224 | RB_LEN_TIME_STAMP = 16, |
| 225 | }; | 225 | }; |
| 226 | 226 | ||
| 227 | #define skip_time_extend(event) \ | ||
| 228 | ((struct ring_buffer_event *)((char *)event + RB_LEN_TIME_EXTEND)) | ||
| 229 | |||
| 227 | static inline int rb_null_event(struct ring_buffer_event *event) | 230 | static inline int rb_null_event(struct ring_buffer_event *event) |
| 228 | { | 231 | { |
| 229 | return event->type_len == RINGBUF_TYPE_PADDING && !event->time_delta; | 232 | return event->type_len == RINGBUF_TYPE_PADDING && !event->time_delta; |
| @@ -248,8 +251,12 @@ rb_event_data_length(struct ring_buffer_event *event) | |||
| 248 | return length + RB_EVNT_HDR_SIZE; | 251 | return length + RB_EVNT_HDR_SIZE; |
| 249 | } | 252 | } |
| 250 | 253 | ||
| 251 | /* inline for ring buffer fast paths */ | 254 | /* |
| 252 | static unsigned | 255 | * Return the length of the given event. Will return |
| 256 | * the length of the time extend if the event is a | ||
| 257 | * time extend. | ||
| 258 | */ | ||
| 259 | static inline unsigned | ||
| 253 | rb_event_length(struct ring_buffer_event *event) | 260 | rb_event_length(struct ring_buffer_event *event) |
| 254 | { | 261 | { |
| 255 | switch (event->type_len) { | 262 | switch (event->type_len) { |
| @@ -274,13 +281,41 @@ rb_event_length(struct ring_buffer_event *event) | |||
| 274 | return 0; | 281 | return 0; |
| 275 | } | 282 | } |
| 276 | 283 | ||
| 284 | /* | ||
| 285 | * Return total length of time extend and data, | ||
| 286 | * or just the event length for all other events. | ||
| 287 | */ | ||
| 288 | static inline unsigned | ||
| 289 | rb_event_ts_length(struct ring_buffer_event *event) | ||
| 290 | { | ||
| 291 | unsigned len = 0; | ||
| 292 | |||
| 293 | if (event->type_len == RINGBUF_TYPE_TIME_EXTEND) { | ||
| 294 | /* time extends include the data event after it */ | ||
| 295 | len = RB_LEN_TIME_EXTEND; | ||
| 296 | event = skip_time_extend(event); | ||
| 297 | } | ||
| 298 | return len + rb_event_length(event); | ||
| 299 | } | ||
| 300 | |||
| 277 | /** | 301 | /** |
| 278 | * ring_buffer_event_length - return the length of the event | 302 | * ring_buffer_event_length - return the length of the event |
| 279 | * @event: the event to get the length of | 303 | * @event: the event to get the length of |
| 304 | * | ||
| 305 | * Returns the size of the data load of a data event. | ||
| 306 | * If the event is something other than a data event, it | ||
| 307 | * returns the size of the event itself. With the exception | ||
| 308 | * of a TIME EXTEND, where it still returns the size of the | ||
| 309 | * data load of the data event after it. | ||
| 280 | */ | 310 | */ |
| 281 | unsigned ring_buffer_event_length(struct ring_buffer_event *event) | 311 | unsigned ring_buffer_event_length(struct ring_buffer_event *event) |
| 282 | { | 312 | { |
| 283 | unsigned length = rb_event_length(event); | 313 | unsigned length; |
| 314 | |||
| 315 | if (event->type_len == RINGBUF_TYPE_TIME_EXTEND) | ||
| 316 | event = skip_time_extend(event); | ||
| 317 | |||
| 318 | length = rb_event_length(event); | ||
| 284 | if (event->type_len > RINGBUF_TYPE_DATA_TYPE_LEN_MAX) | 319 | if (event->type_len > RINGBUF_TYPE_DATA_TYPE_LEN_MAX) |
| 285 | return length; | 320 | return length; |
| 286 | length -= RB_EVNT_HDR_SIZE; | 321 | length -= RB_EVNT_HDR_SIZE; |
| @@ -294,6 +329,8 @@ EXPORT_SYMBOL_GPL(ring_buffer_event_length); | |||
| 294 | static void * | 329 | static void * |
| 295 | rb_event_data(struct ring_buffer_event *event) | 330 | rb_event_data(struct ring_buffer_event *event) |
| 296 | { | 331 | { |
| 332 | if (event->type_len == RINGBUF_TYPE_TIME_EXTEND) | ||
| 333 | event = skip_time_extend(event); | ||
| 297 | BUG_ON(event->type_len > RINGBUF_TYPE_DATA_TYPE_LEN_MAX); | 334 | BUG_ON(event->type_len > RINGBUF_TYPE_DATA_TYPE_LEN_MAX); |
| 298 | /* If length is in len field, then array[0] has the data */ | 335 | /* If length is in len field, then array[0] has the data */ |
| 299 | if (event->type_len) | 336 | if (event->type_len) |
| @@ -404,9 +441,6 @@ static inline int test_time_stamp(u64 delta) | |||
| 404 | /* Max payload is BUF_PAGE_SIZE - header (8bytes) */ | 441 | /* Max payload is BUF_PAGE_SIZE - header (8bytes) */ |
| 405 | #define BUF_MAX_DATA_SIZE (BUF_PAGE_SIZE - (sizeof(u32) * 2)) | 442 | #define BUF_MAX_DATA_SIZE (BUF_PAGE_SIZE - (sizeof(u32) * 2)) |
| 406 | 443 | ||
| 407 | /* Max number of timestamps that can fit on a page */ | ||
| 408 | #define RB_TIMESTAMPS_PER_PAGE (BUF_PAGE_SIZE / RB_LEN_TIME_EXTEND) | ||
| 409 | |||
| 410 | int ring_buffer_print_page_header(struct trace_seq *s) | 444 | int ring_buffer_print_page_header(struct trace_seq *s) |
| 411 | { | 445 | { |
| 412 | struct buffer_data_page field; | 446 | struct buffer_data_page field; |
| @@ -1546,6 +1580,25 @@ static void rb_inc_iter(struct ring_buffer_iter *iter) | |||
| 1546 | iter->head = 0; | 1580 | iter->head = 0; |
| 1547 | } | 1581 | } |
| 1548 | 1582 | ||
| 1583 | /* Slow path, do not inline */ | ||
| 1584 | static noinline struct ring_buffer_event * | ||
| 1585 | rb_add_time_stamp(struct ring_buffer_event *event, u64 delta) | ||
| 1586 | { | ||
| 1587 | event->type_len = RINGBUF_TYPE_TIME_EXTEND; | ||
| 1588 | |||
| 1589 | /* Not the first event on the page? */ | ||
| 1590 | if (rb_event_index(event)) { | ||
| 1591 | event->time_delta = delta & TS_MASK; | ||
| 1592 | event->array[0] = delta >> TS_SHIFT; | ||
| 1593 | } else { | ||
| 1594 | /* nope, just zero it */ | ||
| 1595 | event->time_delta = 0; | ||
| 1596 | event->array[0] = 0; | ||
| 1597 | } | ||
| 1598 | |||
| 1599 | return skip_time_extend(event); | ||
| 1600 | } | ||
| 1601 | |||
| 1549 | /** | 1602 | /** |
| 1550 | * ring_buffer_update_event - update event type and data | 1603 | * ring_buffer_update_event - update event type and data |
| 1551 | * @event: the even to update | 1604 | * @event: the even to update |
| @@ -1558,28 +1611,31 @@ static void rb_inc_iter(struct ring_buffer_iter *iter) | |||
| 1558 | * data field. | 1611 | * data field. |
| 1559 | */ | 1612 | */ |
| 1560 | static void | 1613 | static void |
| 1561 | rb_update_event(struct ring_buffer_event *event, | 1614 | rb_update_event(struct ring_buffer_per_cpu *cpu_buffer, |
| 1562 | unsigned type, unsigned length) | 1615 | struct ring_buffer_event *event, unsigned length, |
| 1616 | int add_timestamp, u64 delta) | ||
| 1563 | { | 1617 | { |
| 1564 | event->type_len = type; | 1618 | /* Only a commit updates the timestamp */ |
| 1565 | 1619 | if (unlikely(!rb_event_is_commit(cpu_buffer, event))) | |
| 1566 | switch (type) { | 1620 | delta = 0; |
| 1567 | |||
| 1568 | case RINGBUF_TYPE_PADDING: | ||
| 1569 | case RINGBUF_TYPE_TIME_EXTEND: | ||
| 1570 | case RINGBUF_TYPE_TIME_STAMP: | ||
| 1571 | break; | ||
| 1572 | 1621 | ||
| 1573 | case 0: | 1622 | /* |
| 1574 | length -= RB_EVNT_HDR_SIZE; | 1623 | * If we need to add a timestamp, then we |
| 1575 | if (length > RB_MAX_SMALL_DATA || RB_FORCE_8BYTE_ALIGNMENT) | 1624 | * add it to the start of the resevered space. |
| 1576 | event->array[0] = length; | 1625 | */ |
| 1577 | else | 1626 | if (unlikely(add_timestamp)) { |
| 1578 | event->type_len = DIV_ROUND_UP(length, RB_ALIGNMENT); | 1627 | event = rb_add_time_stamp(event, delta); |
| 1579 | break; | 1628 | length -= RB_LEN_TIME_EXTEND; |
| 1580 | default: | 1629 | delta = 0; |
| 1581 | BUG(); | ||
| 1582 | } | 1630 | } |
| 1631 | |||
| 1632 | event->time_delta = delta; | ||
| 1633 | length -= RB_EVNT_HDR_SIZE; | ||
| 1634 | if (length > RB_MAX_SMALL_DATA || RB_FORCE_8BYTE_ALIGNMENT) { | ||
| 1635 | event->type_len = 0; | ||
| 1636 | event->array[0] = length; | ||
| 1637 | } else | ||
| 1638 | event->type_len = DIV_ROUND_UP(length, RB_ALIGNMENT); | ||
| 1583 | } | 1639 | } |
| 1584 | 1640 | ||
| 1585 | /* | 1641 | /* |
| @@ -1823,10 +1879,13 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer, | |||
| 1823 | local_sub(length, &tail_page->write); | 1879 | local_sub(length, &tail_page->write); |
| 1824 | } | 1880 | } |
| 1825 | 1881 | ||
| 1826 | static struct ring_buffer_event * | 1882 | /* |
| 1883 | * This is the slow path, force gcc not to inline it. | ||
| 1884 | */ | ||
| 1885 | static noinline struct ring_buffer_event * | ||
| 1827 | rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer, | 1886 | rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer, |
| 1828 | unsigned long length, unsigned long tail, | 1887 | unsigned long length, unsigned long tail, |
| 1829 | struct buffer_page *tail_page, u64 *ts) | 1888 | struct buffer_page *tail_page, u64 ts) |
| 1830 | { | 1889 | { |
| 1831 | struct buffer_page *commit_page = cpu_buffer->commit_page; | 1890 | struct buffer_page *commit_page = cpu_buffer->commit_page; |
| 1832 | struct ring_buffer *buffer = cpu_buffer->buffer; | 1891 | struct ring_buffer *buffer = cpu_buffer->buffer; |
| @@ -1909,8 +1968,8 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer, | |||
| 1909 | * Nested commits always have zero deltas, so | 1968 | * Nested commits always have zero deltas, so |
| 1910 | * just reread the time stamp | 1969 | * just reread the time stamp |
| 1911 | */ | 1970 | */ |
| 1912 | *ts = rb_time_stamp(buffer); | 1971 | ts = rb_time_stamp(buffer); |
| 1913 | next_page->page->time_stamp = *ts; | 1972 | next_page->page->time_stamp = ts; |
| 1914 | } | 1973 | } |
| 1915 | 1974 | ||
| 1916 | out_again: | 1975 | out_again: |
| @@ -1929,12 +1988,21 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer, | |||
| 1929 | 1988 | ||
| 1930 | static struct ring_buffer_event * | 1989 | static struct ring_buffer_event * |
| 1931 | __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer, | 1990 | __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer, |
| 1932 | unsigned type, unsigned long length, u64 *ts) | 1991 | unsigned long length, u64 ts, |
| 1992 | u64 delta, int add_timestamp) | ||
| 1933 | { | 1993 | { |
| 1934 | struct buffer_page *tail_page; | 1994 | struct buffer_page *tail_page; |
| 1935 | struct ring_buffer_event *event; | 1995 | struct ring_buffer_event *event; |
| 1936 | unsigned long tail, write; | 1996 | unsigned long tail, write; |
| 1937 | 1997 | ||
| 1998 | /* | ||
| 1999 | * If the time delta since the last event is too big to | ||
| 2000 | * hold in the time field of the event, then we append a | ||
| 2001 | * TIME EXTEND event ahead of the data event. | ||
| 2002 | */ | ||
| 2003 | if (unlikely(add_timestamp)) | ||
| 2004 | length += RB_LEN_TIME_EXTEND; | ||
| 2005 | |||
| 1938 | tail_page = cpu_buffer->tail_page; | 2006 | tail_page = cpu_buffer->tail_page; |
| 1939 | write = local_add_return(length, &tail_page->write); | 2007 | write = local_add_return(length, &tail_page->write); |
| 1940 | 2008 | ||
| @@ -1943,7 +2011,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer, | |||
| 1943 | tail = write - length; | 2011 | tail = write - length; |
| 1944 | 2012 | ||
| 1945 | /* See if we shot pass the end of this buffer page */ | 2013 | /* See if we shot pass the end of this buffer page */ |
| 1946 | if (write > BUF_PAGE_SIZE) | 2014 | if (unlikely(write > BUF_PAGE_SIZE)) |
| 1947 | return rb_move_tail(cpu_buffer, length, tail, | 2015 | return rb_move_tail(cpu_buffer, length, tail, |
| 1948 | tail_page, ts); | 2016 | tail_page, ts); |
| 1949 | 2017 | ||
| @@ -1951,18 +2019,16 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer, | |||
| 1951 | 2019 | ||
| 1952 | event = __rb_page_index(tail_page, tail); | 2020 | event = __rb_page_index(tail_page, tail); |
| 1953 | kmemcheck_annotate_bitfield(event, bitfield); | 2021 | kmemcheck_annotate_bitfield(event, bitfield); |
| 1954 | rb_update_event(event, type, length); | 2022 | rb_update_event(cpu_buffer, event, length, add_timestamp, delta); |
| 1955 | 2023 | ||
| 1956 | /* The passed in type is zero for DATA */ | 2024 | local_inc(&tail_page->entries); |
| 1957 | if (likely(!type)) | ||
| 1958 | local_inc(&tail_page->entries); | ||
| 1959 | 2025 | ||
| 1960 | /* | 2026 | /* |
| 1961 | * If this is the first commit on the page, then update | 2027 | * If this is the first commit on the page, then update |
| 1962 | * its timestamp. | 2028 | * its timestamp. |
| 1963 | */ | 2029 | */ |
| 1964 | if (!tail) | 2030 | if (!tail) |
| 1965 | tail_page->page->time_stamp = *ts; | 2031 | tail_page->page->time_stamp = ts; |
| 1966 | 2032 | ||
| 1967 | return event; | 2033 | return event; |
| 1968 | } | 2034 | } |
| @@ -1977,7 +2043,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer, | |||
| 1977 | unsigned long addr; | 2043 | unsigned long addr; |
| 1978 | 2044 | ||
| 1979 | new_index = rb_event_index(event); | 2045 | new_index = rb_event_index(event); |
| 1980 | old_index = new_index + rb_event_length(event); | 2046 | old_index = new_index + rb_event_ts_length(event); |
| 1981 | addr = (unsigned long)event; | 2047 | addr = (unsigned long)event; |
| 1982 | addr &= PAGE_MASK; | 2048 | addr &= PAGE_MASK; |
| 1983 | 2049 | ||
| @@ -2003,76 +2069,13 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer, | |||
| 2003 | return 0; | 2069 | return 0; |
| 2004 | } | 2070 | } |
| 2005 | 2071 | ||
| 2006 | static int | ||
| 2007 | rb_add_time_stamp(struct ring_buffer_per_cpu *cpu_buffer, | ||
| 2008 | u64 *ts, u64 *delta) | ||
| 2009 | { | ||
| 2010 | struct ring_buffer_event *event; | ||
| 2011 | int ret; | ||
| 2012 | |||
| 2013 | WARN_ONCE(*delta > (1ULL << 59), | ||
| 2014 | KERN_WARNING "Delta way too big! %llu ts=%llu write stamp = %llu\n", | ||
| 2015 | (unsigned long long)*delta, | ||
| 2016 | (unsigned long long)*ts, | ||
| 2017 | (unsigned long long)cpu_buffer->write_stamp); | ||
| 2018 | |||
| 2019 | /* | ||
| 2020 | * The delta is too big, we to add a | ||
| 2021 | * new timestamp. | ||
| 2022 | */ | ||
| 2023 | event = __rb_reserve_next(cpu_buffer, | ||
| 2024 | RINGBUF_TYPE_TIME_EXTEND, | ||
| 2025 | RB_LEN_TIME_EXTEND, | ||
| 2026 | ts); | ||
| 2027 | if (!event) | ||
| 2028 | return -EBUSY; | ||
| 2029 | |||
| 2030 | if (PTR_ERR(event) == -EAGAIN) | ||
| 2031 | return -EAGAIN; | ||
| 2032 | |||
| 2033 | /* Only a commited time event can update the write stamp */ | ||
| 2034 | if (rb_event_is_commit(cpu_buffer, event)) { | ||
| 2035 | /* | ||
| 2036 | * If this is the first on the page, then it was | ||
| 2037 | * updated with the page itself. Try to discard it | ||
| 2038 | * and if we can't just make it zero. | ||
| 2039 | */ | ||
| 2040 | if (rb_event_index(event)) { | ||
| 2041 | event->time_delta = *delta & TS_MASK; | ||
| 2042 | event->array[0] = *delta >> TS_SHIFT; | ||
| 2043 | } else { | ||
| 2044 | /* try to discard, since we do not need this */ | ||
| 2045 | if (!rb_try_to_discard(cpu_buffer, event)) { | ||
| 2046 | /* nope, just zero it */ | ||
| 2047 | event->time_delta = 0; | ||
| 2048 | event->array[0] = 0; | ||
| 2049 | } | ||
| 2050 | } | ||
| 2051 | cpu_buffer->write_stamp = *ts; | ||
| 2052 | /* let the caller know this was the commit */ | ||
| 2053 | ret = 1; | ||
| 2054 | } else { | ||
| 2055 | /* Try to discard the event */ | ||
| 2056 | if (!rb_try_to_discard(cpu_buffer, event)) { | ||
| 2057 | /* Darn, this is just wasted space */ | ||
| 2058 | event->time_delta = 0; | ||
| 2059 | event->array[0] = 0; | ||
| 2060 | } | ||
| 2061 | ret = 0; | ||
| 2062 | } | ||
| 2063 | |||
| 2064 | *delta = 0; | ||
| 2065 | |||
| 2066 | return ret; | ||
| 2067 | } | ||
| 2068 | |||
| 2069 | static void rb_start_commit(struct ring_buffer_per_cpu *cpu_buffer) | 2072 | static void rb_start_commit(struct ring_buffer_per_cpu *cpu_buffer) |
| 2070 | { | 2073 | { |
| 2071 | local_inc(&cpu_buffer->committing); | 2074 | local_inc(&cpu_buffer->committing); |
| 2072 | local_inc(&cpu_buffer->commits); | 2075 | local_inc(&cpu_buffer->commits); |
| 2073 | } | 2076 | } |
| 2074 | 2077 | ||
| 2075 | static void rb_end_commit(struct ring_buffer_per_cpu *cpu_buffer) | 2078 | static inline void rb_end_commit(struct ring_buffer_per_cpu *cpu_buffer) |
| 2076 | { | 2079 | { |
| 2077 | unsigned long commits; | 2080 | unsigned long commits; |
| 2078 | 2081 | ||
| @@ -2110,9 +2113,10 @@ rb_reserve_next_event(struct ring_buffer *buffer, | |||
| 2110 | unsigned long length) | 2113 | unsigned long length) |
| 2111 | { | 2114 | { |
| 2112 | struct ring_buffer_event *event; | 2115 | struct ring_buffer_event *event; |
| 2113 | u64 ts, delta = 0; | 2116 | u64 ts, delta; |
| 2114 | int commit = 0; | ||
| 2115 | int nr_loops = 0; | 2117 | int nr_loops = 0; |
| 2118 | int add_timestamp; | ||
| 2119 | u64 diff; | ||
| 2116 | 2120 | ||
| 2117 | rb_start_commit(cpu_buffer); | 2121 | rb_start_commit(cpu_buffer); |
| 2118 | 2122 | ||
| @@ -2133,6 +2137,9 @@ rb_reserve_next_event(struct ring_buffer *buffer, | |||
| 2133 | 2137 | ||
| 2134 | length = rb_calculate_event_length(length); | 2138 | length = rb_calculate_event_length(length); |
| 2135 | again: | 2139 | again: |
| 2140 | add_timestamp = 0; | ||
| 2141 | delta = 0; | ||
| 2142 | |||
| 2136 | /* | 2143 | /* |
| 2137 | * We allow for interrupts to reenter here and do a trace. | 2144 | * We allow for interrupts to reenter here and do a trace. |
| 2138 | * If one does, it will cause this original code to loop | 2145 | * If one does, it will cause this original code to loop |
| @@ -2146,56 +2153,32 @@ rb_reserve_next_event(struct ring_buffer *buffer, | |||
| 2146 | goto out_fail; | 2153 | goto out_fail; |
| 2147 | 2154 | ||
| 2148 | ts = rb_time_stamp(cpu_buffer->buffer); | 2155 | ts = rb_time_stamp(cpu_buffer->buffer); |
| 2156 | diff = ts - cpu_buffer->write_stamp; | ||
| 2149 | 2157 | ||
| 2150 | /* | 2158 | /* make sure this diff is calculated here */ |
| 2151 | * Only the first commit can update the timestamp. | 2159 | barrier(); |
| 2152 | * Yes there is a race here. If an interrupt comes in | ||
| 2153 | * just after the conditional and it traces too, then it | ||
| 2154 | * will also check the deltas. More than one timestamp may | ||
| 2155 | * also be made. But only the entry that did the actual | ||
| 2156 | * commit will be something other than zero. | ||
| 2157 | */ | ||
| 2158 | if (likely(cpu_buffer->tail_page == cpu_buffer->commit_page && | ||
| 2159 | rb_page_write(cpu_buffer->tail_page) == | ||
| 2160 | rb_commit_index(cpu_buffer))) { | ||
| 2161 | u64 diff; | ||
| 2162 | |||
| 2163 | diff = ts - cpu_buffer->write_stamp; | ||
| 2164 | |||
| 2165 | /* make sure this diff is calculated here */ | ||
| 2166 | barrier(); | ||
| 2167 | |||
| 2168 | /* Did the write stamp get updated already? */ | ||
| 2169 | if (unlikely(ts < cpu_buffer->write_stamp)) | ||
| 2170 | goto get_event; | ||
| 2171 | 2160 | ||
| 2161 | /* Did the write stamp get updated already? */ | ||
| 2162 | if (likely(ts >= cpu_buffer->write_stamp)) { | ||
| 2172 | delta = diff; | 2163 | delta = diff; |
| 2173 | if (unlikely(test_time_stamp(delta))) { | 2164 | if (unlikely(test_time_stamp(delta))) { |
| 2174 | 2165 | WARN_ONCE(delta > (1ULL << 59), | |
| 2175 | commit = rb_add_time_stamp(cpu_buffer, &ts, &delta); | 2166 | KERN_WARNING "Delta way too big! %llu ts=%llu write stamp = %llu\n", |
| 2176 | if (commit == -EBUSY) | 2167 | (unsigned long long)delta, |
| 2177 | goto out_fail; | 2168 | (unsigned long long)ts, |
| 2178 | 2169 | (unsigned long long)cpu_buffer->write_stamp); | |
| 2179 | if (commit == -EAGAIN) | 2170 | add_timestamp = 1; |
| 2180 | goto again; | ||
| 2181 | |||
| 2182 | RB_WARN_ON(cpu_buffer, commit < 0); | ||
| 2183 | } | 2171 | } |
| 2184 | } | 2172 | } |
| 2185 | 2173 | ||
| 2186 | get_event: | 2174 | event = __rb_reserve_next(cpu_buffer, length, ts, |
| 2187 | event = __rb_reserve_next(cpu_buffer, 0, length, &ts); | 2175 | delta, add_timestamp); |
| 2188 | if (unlikely(PTR_ERR(event) == -EAGAIN)) | 2176 | if (unlikely(PTR_ERR(event) == -EAGAIN)) |
| 2189 | goto again; | 2177 | goto again; |
| 2190 | 2178 | ||
| 2191 | if (!event) | 2179 | if (!event) |
| 2192 | goto out_fail; | 2180 | goto out_fail; |
| 2193 | 2181 | ||
| 2194 | if (!rb_event_is_commit(cpu_buffer, event)) | ||
| 2195 | delta = 0; | ||
| 2196 | |||
| 2197 | event->time_delta = delta; | ||
| 2198 | |||
| 2199 | return event; | 2182 | return event; |
| 2200 | 2183 | ||
| 2201 | out_fail: | 2184 | out_fail: |
| @@ -2207,13 +2190,9 @@ rb_reserve_next_event(struct ring_buffer *buffer, | |||
| 2207 | 2190 | ||
| 2208 | #define TRACE_RECURSIVE_DEPTH 16 | 2191 | #define TRACE_RECURSIVE_DEPTH 16 |
| 2209 | 2192 | ||
| 2210 | static int trace_recursive_lock(void) | 2193 | /* Keep this code out of the fast path cache */ |
| 2194 | static noinline void trace_recursive_fail(void) | ||
| 2211 | { | 2195 | { |
| 2212 | current->trace_recursion++; | ||
| 2213 | |||
| 2214 | if (likely(current->trace_recursion < TRACE_RECURSIVE_DEPTH)) | ||
| 2215 | return 0; | ||
| 2216 | |||
| 2217 | /* Disable all tracing before we do anything else */ | 2196 | /* Disable all tracing before we do anything else */ |
| 2218 | tracing_off_permanent(); | 2197 | tracing_off_permanent(); |
| 2219 | 2198 | ||
| @@ -2225,10 +2204,21 @@ static int trace_recursive_lock(void) | |||
| 2225 | in_nmi()); | 2204 | in_nmi()); |
| 2226 | 2205 | ||
| 2227 | WARN_ON_ONCE(1); | 2206 | WARN_ON_ONCE(1); |
| 2207 | } | ||
| 2208 | |||
| 2209 | static inline int trace_recursive_lock(void) | ||
| 2210 | { | ||
| 2211 | current->trace_recursion++; | ||
| 2212 | |||
| 2213 | if (likely(current->trace_recursion < TRACE_RECURSIVE_DEPTH)) | ||
| 2214 | return 0; | ||
| 2215 | |||
| 2216 | trace_recursive_fail(); | ||
| 2217 | |||
| 2228 | return -1; | 2218 | return -1; |
| 2229 | } | 2219 | } |
| 2230 | 2220 | ||
| 2231 | static void trace_recursive_unlock(void) | 2221 | static inline void trace_recursive_unlock(void) |
| 2232 | { | 2222 | { |
| 2233 | WARN_ON_ONCE(!current->trace_recursion); | 2223 | WARN_ON_ONCE(!current->trace_recursion); |
| 2234 | 2224 | ||
| @@ -2308,12 +2298,28 @@ static void | |||
| 2308 | rb_update_write_stamp(struct ring_buffer_per_cpu *cpu_buffer, | 2298 | rb_update_write_stamp(struct ring_buffer_per_cpu *cpu_buffer, |
| 2309 | struct ring_buffer_event *event) | 2299 | struct ring_buffer_event *event) |
| 2310 | { | 2300 | { |
| 2301 | u64 delta; | ||
| 2302 | |||
| 2311 | /* | 2303 | /* |
| 2312 | * The event first in the commit queue updates the | 2304 | * The event first in the commit queue updates the |
| 2313 | * time stamp. | 2305 | * time stamp. |
| 2314 | */ | 2306 | */ |
| 2315 | if (rb_event_is_commit(cpu_buffer, event)) | 2307 | if (rb_event_is_commit(cpu_buffer, event)) { |
| 2316 | cpu_buffer->write_stamp += event->time_delta; | 2308 | /* |
| 2309 | * A commit event that is first on a page | ||
| 2310 | * updates the write timestamp with the page stamp | ||
| 2311 | */ | ||
| 2312 | if (!rb_event_index(event)) | ||
| 2313 | cpu_buffer->write_stamp = | ||
| 2314 | cpu_buffer->commit_page->page->time_stamp; | ||
| 2315 | else if (event->type_len == RINGBUF_TYPE_TIME_EXTEND) { | ||
| 2316 | delta = event->array[0]; | ||
| 2317 | delta <<= TS_SHIFT; | ||
| 2318 | delta += event->time_delta; | ||
| 2319 | cpu_buffer->write_stamp += delta; | ||
| 2320 | } else | ||
| 2321 | cpu_buffer->write_stamp += event->time_delta; | ||
| 2322 | } | ||
| 2317 | } | 2323 | } |
| 2318 | 2324 | ||
| 2319 | static void rb_commit(struct ring_buffer_per_cpu *cpu_buffer, | 2325 | static void rb_commit(struct ring_buffer_per_cpu *cpu_buffer, |
| @@ -2353,6 +2359,9 @@ EXPORT_SYMBOL_GPL(ring_buffer_unlock_commit); | |||
| 2353 | 2359 | ||
| 2354 | static inline void rb_event_discard(struct ring_buffer_event *event) | 2360 | static inline void rb_event_discard(struct ring_buffer_event *event) |
| 2355 | { | 2361 | { |
| 2362 | if (event->type_len == RINGBUF_TYPE_TIME_EXTEND) | ||
| 2363 | event = skip_time_extend(event); | ||
| 2364 | |||
| 2356 | /* array[0] holds the actual length for the discarded event */ | 2365 | /* array[0] holds the actual length for the discarded event */ |
| 2357 | event->array[0] = rb_event_data_length(event) - RB_EVNT_HDR_SIZE; | 2366 | event->array[0] = rb_event_data_length(event) - RB_EVNT_HDR_SIZE; |
| 2358 | event->type_len = RINGBUF_TYPE_PADDING; | 2367 | event->type_len = RINGBUF_TYPE_PADDING; |
| @@ -3049,12 +3058,12 @@ rb_buffer_peek(struct ring_buffer_per_cpu *cpu_buffer, u64 *ts, | |||
| 3049 | 3058 | ||
| 3050 | again: | 3059 | again: |
| 3051 | /* | 3060 | /* |
| 3052 | * We repeat when a timestamp is encountered. It is possible | 3061 | * We repeat when a time extend is encountered. |
| 3053 | * to get multiple timestamps from an interrupt entering just | 3062 | * Since the time extend is always attached to a data event, |
| 3054 | * as one timestamp is about to be written, or from discarded | 3063 | * we should never loop more than once. |
| 3055 | * commits. The most that we can have is the number on a single page. | 3064 | * (We never hit the following condition more than twice). |
| 3056 | */ | 3065 | */ |
| 3057 | if (RB_WARN_ON(cpu_buffer, ++nr_loops > RB_TIMESTAMPS_PER_PAGE)) | 3066 | if (RB_WARN_ON(cpu_buffer, ++nr_loops > 2)) |
| 3058 | return NULL; | 3067 | return NULL; |
| 3059 | 3068 | ||
| 3060 | reader = rb_get_reader_page(cpu_buffer); | 3069 | reader = rb_get_reader_page(cpu_buffer); |
| @@ -3130,14 +3139,12 @@ rb_iter_peek(struct ring_buffer_iter *iter, u64 *ts) | |||
| 3130 | return NULL; | 3139 | return NULL; |
| 3131 | 3140 | ||
| 3132 | /* | 3141 | /* |
| 3133 | * We repeat when a timestamp is encountered. | 3142 | * We repeat when a time extend is encountered. |
| 3134 | * We can get multiple timestamps by nested interrupts or also | 3143 | * Since the time extend is always attached to a data event, |
| 3135 | * if filtering is on (discarding commits). Since discarding | 3144 | * we should never loop more than once. |
| 3136 | * commits can be frequent we can get a lot of timestamps. | 3145 | * (We never hit the following condition more than twice). |
| 3137 | * But we limit them by not adding timestamps if they begin | ||
| 3138 | * at the start of a page. | ||
| 3139 | */ | 3146 | */ |
| 3140 | if (RB_WARN_ON(cpu_buffer, ++nr_loops > RB_TIMESTAMPS_PER_PAGE)) | 3147 | if (RB_WARN_ON(cpu_buffer, ++nr_loops > 2)) |
| 3141 | return NULL; | 3148 | return NULL; |
| 3142 | 3149 | ||
| 3143 | if (rb_per_cpu_empty(cpu_buffer)) | 3150 | if (rb_per_cpu_empty(cpu_buffer)) |
| @@ -3835,7 +3842,8 @@ int ring_buffer_read_page(struct ring_buffer *buffer, | |||
| 3835 | if (len > (commit - read)) | 3842 | if (len > (commit - read)) |
| 3836 | len = (commit - read); | 3843 | len = (commit - read); |
| 3837 | 3844 | ||
| 3838 | size = rb_event_length(event); | 3845 | /* Always keep the time extend and data together */ |
| 3846 | size = rb_event_ts_length(event); | ||
| 3839 | 3847 | ||
| 3840 | if (len < size) | 3848 | if (len < size) |
| 3841 | goto out_unlock; | 3849 | goto out_unlock; |
| @@ -3857,7 +3865,8 @@ int ring_buffer_read_page(struct ring_buffer *buffer, | |||
| 3857 | break; | 3865 | break; |
| 3858 | 3866 | ||
| 3859 | event = rb_reader_event(cpu_buffer); | 3867 | event = rb_reader_event(cpu_buffer); |
| 3860 | size = rb_event_length(event); | 3868 | /* Always keep the time extend and data together */ |
| 3869 | size = rb_event_ts_length(event); | ||
| 3861 | } while (len > size); | 3870 | } while (len > size); |
| 3862 | 3871 | ||
| 3863 | /* update bpage */ | 3872 | /* update bpage */ |
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 001bcd2ccf4a..82d9b8106cd0 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
| @@ -3996,13 +3996,9 @@ static void tracing_init_debugfs_percpu(long cpu) | |||
| 3996 | { | 3996 | { |
| 3997 | struct dentry *d_percpu = tracing_dentry_percpu(); | 3997 | struct dentry *d_percpu = tracing_dentry_percpu(); |
| 3998 | struct dentry *d_cpu; | 3998 | struct dentry *d_cpu; |
| 3999 | /* strlen(cpu) + MAX(log10(cpu)) + '\0' */ | 3999 | char cpu_dir[30]; /* 30 characters should be more than enough */ |
| 4000 | char cpu_dir[7]; | ||
| 4001 | 4000 | ||
| 4002 | if (cpu > 999 || cpu < 0) | 4001 | snprintf(cpu_dir, 30, "cpu%ld", cpu); |
| 4003 | return; | ||
| 4004 | |||
| 4005 | sprintf(cpu_dir, "cpu%ld", cpu); | ||
| 4006 | d_cpu = debugfs_create_dir(cpu_dir, d_percpu); | 4002 | d_cpu = debugfs_create_dir(cpu_dir, d_percpu); |
| 4007 | if (!d_cpu) { | 4003 | if (!d_cpu) { |
| 4008 | pr_warning("Could not create debugfs '%s' entry\n", cpu_dir); | 4004 | pr_warning("Could not create debugfs '%s' entry\n", cpu_dir); |
diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c index b8d2852baa4a..2dec9bcde8b4 100644 --- a/kernel/trace/trace_kprobe.c +++ b/kernel/trace/trace_kprobe.c | |||
| @@ -31,7 +31,6 @@ | |||
| 31 | #include <linux/perf_event.h> | 31 | #include <linux/perf_event.h> |
| 32 | #include <linux/stringify.h> | 32 | #include <linux/stringify.h> |
| 33 | #include <linux/limits.h> | 33 | #include <linux/limits.h> |
| 34 | #include <linux/uaccess.h> | ||
| 35 | #include <asm/bitsperlong.h> | 34 | #include <asm/bitsperlong.h> |
| 36 | 35 | ||
| 37 | #include "trace.h" | 36 | #include "trace.h" |
diff --git a/kernel/tsacct.c b/kernel/tsacct.c index 0a67e041edf8..24dc60d9fa1f 100644 --- a/kernel/tsacct.c +++ b/kernel/tsacct.c | |||
| @@ -63,12 +63,10 @@ void bacct_add_tsk(struct taskstats *stats, struct task_struct *tsk) | |||
| 63 | stats->ac_ppid = pid_alive(tsk) ? | 63 | stats->ac_ppid = pid_alive(tsk) ? |
| 64 | rcu_dereference(tsk->real_parent)->tgid : 0; | 64 | rcu_dereference(tsk->real_parent)->tgid : 0; |
| 65 | rcu_read_unlock(); | 65 | rcu_read_unlock(); |
| 66 | stats->ac_utime = cputime_to_msecs(tsk->utime) * USEC_PER_MSEC; | 66 | stats->ac_utime = cputime_to_usecs(tsk->utime); |
| 67 | stats->ac_stime = cputime_to_msecs(tsk->stime) * USEC_PER_MSEC; | 67 | stats->ac_stime = cputime_to_usecs(tsk->stime); |
| 68 | stats->ac_utimescaled = | 68 | stats->ac_utimescaled = cputime_to_usecs(tsk->utimescaled); |
| 69 | cputime_to_msecs(tsk->utimescaled) * USEC_PER_MSEC; | 69 | stats->ac_stimescaled = cputime_to_usecs(tsk->stimescaled); |
| 70 | stats->ac_stimescaled = | ||
| 71 | cputime_to_msecs(tsk->stimescaled) * USEC_PER_MSEC; | ||
| 72 | stats->ac_minflt = tsk->min_flt; | 70 | stats->ac_minflt = tsk->min_flt; |
| 73 | stats->ac_majflt = tsk->maj_flt; | 71 | stats->ac_majflt = tsk->maj_flt; |
| 74 | 72 | ||
diff --git a/kernel/user.c b/kernel/user.c index 7e72614b736d..2c7d8d5914b1 100644 --- a/kernel/user.c +++ b/kernel/user.c | |||
| @@ -91,6 +91,7 @@ static struct user_struct *uid_hash_find(uid_t uid, struct hlist_head *hashent) | |||
| 91 | * upon function exit. | 91 | * upon function exit. |
| 92 | */ | 92 | */ |
| 93 | static void free_user(struct user_struct *up, unsigned long flags) | 93 | static void free_user(struct user_struct *up, unsigned long flags) |
| 94 | __releases(&uidhash_lock) | ||
| 94 | { | 95 | { |
| 95 | uid_hash_remove(up); | 96 | uid_hash_remove(up); |
| 96 | spin_unlock_irqrestore(&uidhash_lock, flags); | 97 | spin_unlock_irqrestore(&uidhash_lock, flags); |
diff --git a/kernel/wait.c b/kernel/wait.c index c4bd3d825f35..b0310eb6cc1e 100644 --- a/kernel/wait.c +++ b/kernel/wait.c | |||
| @@ -92,7 +92,7 @@ prepare_to_wait_exclusive(wait_queue_head_t *q, wait_queue_t *wait, int state) | |||
| 92 | } | 92 | } |
| 93 | EXPORT_SYMBOL(prepare_to_wait_exclusive); | 93 | EXPORT_SYMBOL(prepare_to_wait_exclusive); |
| 94 | 94 | ||
| 95 | /* | 95 | /** |
| 96 | * finish_wait - clean up after waiting in a queue | 96 | * finish_wait - clean up after waiting in a queue |
| 97 | * @q: waitqueue waited on | 97 | * @q: waitqueue waited on |
| 98 | * @wait: wait descriptor | 98 | * @wait: wait descriptor |
| @@ -127,11 +127,11 @@ void finish_wait(wait_queue_head_t *q, wait_queue_t *wait) | |||
| 127 | } | 127 | } |
| 128 | EXPORT_SYMBOL(finish_wait); | 128 | EXPORT_SYMBOL(finish_wait); |
| 129 | 129 | ||
| 130 | /* | 130 | /** |
| 131 | * abort_exclusive_wait - abort exclusive waiting in a queue | 131 | * abort_exclusive_wait - abort exclusive waiting in a queue |
| 132 | * @q: waitqueue waited on | 132 | * @q: waitqueue waited on |
| 133 | * @wait: wait descriptor | 133 | * @wait: wait descriptor |
| 134 | * @state: runstate of the waiter to be woken | 134 | * @mode: runstate of the waiter to be woken |
| 135 | * @key: key to identify a wait bit queue or %NULL | 135 | * @key: key to identify a wait bit queue or %NULL |
| 136 | * | 136 | * |
| 137 | * Sets current thread back to running state and removes | 137 | * Sets current thread back to running state and removes |
diff --git a/kernel/workqueue.c b/kernel/workqueue.c index e5ff2cbaadc2..90db1bd1a978 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c | |||
| @@ -2064,7 +2064,7 @@ static void insert_wq_barrier(struct cpu_workqueue_struct *cwq, | |||
| 2064 | * checks and call back into the fixup functions where we | 2064 | * checks and call back into the fixup functions where we |
| 2065 | * might deadlock. | 2065 | * might deadlock. |
| 2066 | */ | 2066 | */ |
| 2067 | INIT_WORK_ON_STACK(&barr->work, wq_barrier_func); | 2067 | INIT_WORK_ONSTACK(&barr->work, wq_barrier_func); |
| 2068 | __set_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(&barr->work)); | 2068 | __set_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(&barr->work)); |
| 2069 | init_completion(&barr->done); | 2069 | init_completion(&barr->done); |
| 2070 | 2070 | ||
