aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'kernel')
-rw-r--r--kernel/cgroup.c48
-rw-r--r--kernel/compat.c24
-rw-r--r--kernel/cpuset.c9
-rw-r--r--kernel/events/core.c14
-rw-r--r--kernel/fork.c5
-rw-r--r--kernel/futex.c1
-rw-r--r--kernel/irq/chip.c1
-rw-r--r--kernel/kcmp.c7
-rw-r--r--kernel/power/power.h1
-rw-r--r--kernel/power/snapshot.c50
-rw-r--r--kernel/power/suspend.c2
-rw-r--r--kernel/power/suspend_test.c31
-rw-r--r--kernel/printk/printk.c6
-rw-r--r--kernel/rcu/tree.h2
-rw-r--r--kernel/rcu/tree_plugin.h22
-rw-r--r--kernel/time/alarmtimer.c34
-rw-r--r--kernel/time/tick-sched.c14
-rw-r--r--kernel/time/time.c56
-rw-r--r--kernel/time/timekeeping.c5
-rw-r--r--kernel/trace/ring_buffer.c2
20 files changed, 204 insertions, 130 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 7dc8788cfd52..3a73f995a81e 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -1035,6 +1035,11 @@ static void cgroup_get(struct cgroup *cgrp)
1035 css_get(&cgrp->self); 1035 css_get(&cgrp->self);
1036} 1036}
1037 1037
1038static bool cgroup_tryget(struct cgroup *cgrp)
1039{
1040 return css_tryget(&cgrp->self);
1041}
1042
1038static void cgroup_put(struct cgroup *cgrp) 1043static void cgroup_put(struct cgroup *cgrp)
1039{ 1044{
1040 css_put(&cgrp->self); 1045 css_put(&cgrp->self);
@@ -1147,7 +1152,8 @@ static struct cgroup *cgroup_kn_lock_live(struct kernfs_node *kn)
1147 * protection against removal. Ensure @cgrp stays accessible and 1152 * protection against removal. Ensure @cgrp stays accessible and
1148 * break the active_ref protection. 1153 * break the active_ref protection.
1149 */ 1154 */
1150 cgroup_get(cgrp); 1155 if (!cgroup_tryget(cgrp))
1156 return NULL;
1151 kernfs_break_active_protection(kn); 1157 kernfs_break_active_protection(kn);
1152 1158
1153 mutex_lock(&cgroup_mutex); 1159 mutex_lock(&cgroup_mutex);
@@ -3271,8 +3277,17 @@ int cgroup_add_legacy_cftypes(struct cgroup_subsys *ss, struct cftype *cfts)
3271{ 3277{
3272 struct cftype *cft; 3278 struct cftype *cft;
3273 3279
3274 for (cft = cfts; cft && cft->name[0] != '\0'; cft++) 3280 /*
3275 cft->flags |= __CFTYPE_NOT_ON_DFL; 3281 * If legacy_flies_on_dfl, we want to show the legacy files on the
3282 * dfl hierarchy but iff the target subsystem hasn't been updated
3283 * for the dfl hierarchy yet.
3284 */
3285 if (!cgroup_legacy_files_on_dfl ||
3286 ss->dfl_cftypes != ss->legacy_cftypes) {
3287 for (cft = cfts; cft && cft->name[0] != '\0'; cft++)
3288 cft->flags |= __CFTYPE_NOT_ON_DFL;
3289 }
3290
3276 return cgroup_add_cftypes(ss, cfts); 3291 return cgroup_add_cftypes(ss, cfts);
3277} 3292}
3278 3293
@@ -3970,7 +3985,6 @@ static int pidlist_array_load(struct cgroup *cgrp, enum cgroup_filetype type,
3970 3985
3971 l = cgroup_pidlist_find_create(cgrp, type); 3986 l = cgroup_pidlist_find_create(cgrp, type);
3972 if (!l) { 3987 if (!l) {
3973 mutex_unlock(&cgrp->pidlist_mutex);
3974 pidlist_free(array); 3988 pidlist_free(array);
3975 return -ENOMEM; 3989 return -ENOMEM;
3976 } 3990 }
@@ -4387,6 +4401,15 @@ static void css_release_work_fn(struct work_struct *work)
4387 /* cgroup release path */ 4401 /* cgroup release path */
4388 cgroup_idr_remove(&cgrp->root->cgroup_idr, cgrp->id); 4402 cgroup_idr_remove(&cgrp->root->cgroup_idr, cgrp->id);
4389 cgrp->id = -1; 4403 cgrp->id = -1;
4404
4405 /*
4406 * There are two control paths which try to determine
4407 * cgroup from dentry without going through kernfs -
4408 * cgroupstats_build() and css_tryget_online_from_dir().
4409 * Those are supported by RCU protecting clearing of
4410 * cgrp->kn->priv backpointer.
4411 */
4412 RCU_INIT_POINTER(*(void __rcu __force **)&cgrp->kn->priv, NULL);
4390 } 4413 }
4391 4414
4392 mutex_unlock(&cgroup_mutex); 4415 mutex_unlock(&cgroup_mutex);
@@ -4543,6 +4566,11 @@ static int cgroup_mkdir(struct kernfs_node *parent_kn, const char *name,
4543 struct cftype *base_files; 4566 struct cftype *base_files;
4544 int ssid, ret; 4567 int ssid, ret;
4545 4568
4569 /* Do not accept '\n' to prevent making /proc/<pid>/cgroup unparsable.
4570 */
4571 if (strchr(name, '\n'))
4572 return -EINVAL;
4573
4546 parent = cgroup_kn_lock_live(parent_kn); 4574 parent = cgroup_kn_lock_live(parent_kn);
4547 if (!parent) 4575 if (!parent)
4548 return -ENODEV; 4576 return -ENODEV;
@@ -4820,16 +4848,6 @@ static int cgroup_rmdir(struct kernfs_node *kn)
4820 4848
4821 cgroup_kn_unlock(kn); 4849 cgroup_kn_unlock(kn);
4822 4850
4823 /*
4824 * There are two control paths which try to determine cgroup from
4825 * dentry without going through kernfs - cgroupstats_build() and
4826 * css_tryget_online_from_dir(). Those are supported by RCU
4827 * protecting clearing of cgrp->kn->priv backpointer, which should
4828 * happen after all files under it have been removed.
4829 */
4830 if (!ret)
4831 RCU_INIT_POINTER(*(void __rcu __force **)&kn->priv, NULL);
4832
4833 cgroup_put(cgrp); 4851 cgroup_put(cgrp);
4834 return ret; 4852 return ret;
4835} 4853}
@@ -5416,7 +5434,7 @@ struct cgroup_subsys_state *css_tryget_online_from_dir(struct dentry *dentry,
5416 /* 5434 /*
5417 * This path doesn't originate from kernfs and @kn could already 5435 * This path doesn't originate from kernfs and @kn could already
5418 * have been or be removed at any point. @kn->priv is RCU 5436 * have been or be removed at any point. @kn->priv is RCU
5419 * protected for this access. See cgroup_rmdir() for details. 5437 * protected for this access. See css_release_work_fn() for details.
5420 */ 5438 */
5421 cgrp = rcu_dereference(kn->priv); 5439 cgrp = rcu_dereference(kn->priv);
5422 if (cgrp) 5440 if (cgrp)
diff --git a/kernel/compat.c b/kernel/compat.c
index 633394f442f8..ebb3c369d03d 100644
--- a/kernel/compat.c
+++ b/kernel/compat.c
@@ -226,7 +226,7 @@ static long compat_nanosleep_restart(struct restart_block *restart)
226 ret = hrtimer_nanosleep_restart(restart); 226 ret = hrtimer_nanosleep_restart(restart);
227 set_fs(oldfs); 227 set_fs(oldfs);
228 228
229 if (ret) { 229 if (ret == -ERESTART_RESTARTBLOCK) {
230 rmtp = restart->nanosleep.compat_rmtp; 230 rmtp = restart->nanosleep.compat_rmtp;
231 231
232 if (rmtp && compat_put_timespec(&rmt, rmtp)) 232 if (rmtp && compat_put_timespec(&rmt, rmtp))
@@ -256,7 +256,26 @@ COMPAT_SYSCALL_DEFINE2(nanosleep, struct compat_timespec __user *, rqtp,
256 HRTIMER_MODE_REL, CLOCK_MONOTONIC); 256 HRTIMER_MODE_REL, CLOCK_MONOTONIC);
257 set_fs(oldfs); 257 set_fs(oldfs);
258 258
259 if (ret) { 259 /*
260 * hrtimer_nanosleep() can only return 0 or
261 * -ERESTART_RESTARTBLOCK here because:
262 *
263 * - we call it with HRTIMER_MODE_REL and therefor exclude the
264 * -ERESTARTNOHAND return path.
265 *
266 * - we supply the rmtp argument from the task stack (due to
267 * the necessary compat conversion. So the update cannot
268 * fail, which excludes the -EFAULT return path as well. If
269 * it fails nevertheless we have a bigger problem and wont
270 * reach this place anymore.
271 *
272 * - if the return value is 0, we do not have to update rmtp
273 * because there is no remaining time.
274 *
275 * We check for -ERESTART_RESTARTBLOCK nevertheless if the
276 * core implementation decides to return random nonsense.
277 */
278 if (ret == -ERESTART_RESTARTBLOCK) {
260 struct restart_block *restart 279 struct restart_block *restart
261 = &current_thread_info()->restart_block; 280 = &current_thread_info()->restart_block;
262 281
@@ -266,7 +285,6 @@ COMPAT_SYSCALL_DEFINE2(nanosleep, struct compat_timespec __user *, rqtp,
266 if (rmtp && compat_put_timespec(&rmt, rmtp)) 285 if (rmtp && compat_put_timespec(&rmt, rmtp))
267 return -EFAULT; 286 return -EFAULT;
268 } 287 }
269
270 return ret; 288 return ret;
271} 289}
272 290
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index 22874d7cf2c0..52cb04c993b7 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -365,13 +365,14 @@ static void cpuset_update_task_spread_flag(struct cpuset *cs,
365 struct task_struct *tsk) 365 struct task_struct *tsk)
366{ 366{
367 if (is_spread_page(cs)) 367 if (is_spread_page(cs))
368 tsk->flags |= PF_SPREAD_PAGE; 368 task_set_spread_page(tsk);
369 else 369 else
370 tsk->flags &= ~PF_SPREAD_PAGE; 370 task_clear_spread_page(tsk);
371
371 if (is_spread_slab(cs)) 372 if (is_spread_slab(cs))
372 tsk->flags |= PF_SPREAD_SLAB; 373 task_set_spread_slab(tsk);
373 else 374 else
374 tsk->flags &= ~PF_SPREAD_SLAB; 375 task_clear_spread_slab(tsk);
375} 376}
376 377
377/* 378/*
diff --git a/kernel/events/core.c b/kernel/events/core.c
index f9c1ed002dbc..963bf139e2b2 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -1524,6 +1524,11 @@ retry:
1524 */ 1524 */
1525 if (ctx->is_active) { 1525 if (ctx->is_active) {
1526 raw_spin_unlock_irq(&ctx->lock); 1526 raw_spin_unlock_irq(&ctx->lock);
1527 /*
1528 * Reload the task pointer, it might have been changed by
1529 * a concurrent perf_event_context_sched_out().
1530 */
1531 task = ctx->task;
1527 goto retry; 1532 goto retry;
1528 } 1533 }
1529 1534
@@ -1967,6 +1972,11 @@ retry:
1967 */ 1972 */
1968 if (ctx->is_active) { 1973 if (ctx->is_active) {
1969 raw_spin_unlock_irq(&ctx->lock); 1974 raw_spin_unlock_irq(&ctx->lock);
1975 /*
1976 * Reload the task pointer, it might have been changed by
1977 * a concurrent perf_event_context_sched_out().
1978 */
1979 task = ctx->task;
1970 goto retry; 1980 goto retry;
1971 } 1981 }
1972 1982
@@ -7938,8 +7948,10 @@ int perf_event_init_task(struct task_struct *child)
7938 7948
7939 for_each_task_context_nr(ctxn) { 7949 for_each_task_context_nr(ctxn) {
7940 ret = perf_event_init_context(child, ctxn); 7950 ret = perf_event_init_context(child, ctxn);
7941 if (ret) 7951 if (ret) {
7952 perf_event_free_task(child);
7942 return ret; 7953 return ret;
7954 }
7943 } 7955 }
7944 7956
7945 return 0; 7957 return 0;
diff --git a/kernel/fork.c b/kernel/fork.c
index 0cf9cdb6e491..a91e47d86de2 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1360,7 +1360,7 @@ static struct task_struct *copy_process(unsigned long clone_flags,
1360 goto bad_fork_cleanup_policy; 1360 goto bad_fork_cleanup_policy;
1361 retval = audit_alloc(p); 1361 retval = audit_alloc(p);
1362 if (retval) 1362 if (retval)
1363 goto bad_fork_cleanup_policy; 1363 goto bad_fork_cleanup_perf;
1364 /* copy all the process information */ 1364 /* copy all the process information */
1365 shm_init_task(p); 1365 shm_init_task(p);
1366 retval = copy_semundo(clone_flags, p); 1366 retval = copy_semundo(clone_flags, p);
@@ -1566,8 +1566,9 @@ bad_fork_cleanup_semundo:
1566 exit_sem(p); 1566 exit_sem(p);
1567bad_fork_cleanup_audit: 1567bad_fork_cleanup_audit:
1568 audit_free(p); 1568 audit_free(p);
1569bad_fork_cleanup_policy: 1569bad_fork_cleanup_perf:
1570 perf_event_free_task(p); 1570 perf_event_free_task(p);
1571bad_fork_cleanup_policy:
1571#ifdef CONFIG_NUMA 1572#ifdef CONFIG_NUMA
1572 mpol_put(p->mempolicy); 1573 mpol_put(p->mempolicy);
1573bad_fork_cleanup_threadgroup_lock: 1574bad_fork_cleanup_threadgroup_lock:
diff --git a/kernel/futex.c b/kernel/futex.c
index d3a9d946d0b7..815d7af2ffe8 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -2592,6 +2592,7 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, unsigned int flags,
2592 * shared futexes. We need to compare the keys: 2592 * shared futexes. We need to compare the keys:
2593 */ 2593 */
2594 if (match_futex(&q.key, &key2)) { 2594 if (match_futex(&q.key, &key2)) {
2595 queue_unlock(hb);
2595 ret = -EINVAL; 2596 ret = -EINVAL;
2596 goto out_put_keys; 2597 goto out_put_keys;
2597 } 2598 }
diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c
index a2b28a2fd7b1..6223fab9a9d2 100644
--- a/kernel/irq/chip.c
+++ b/kernel/irq/chip.c
@@ -517,6 +517,7 @@ out:
517 chip->irq_eoi(&desc->irq_data); 517 chip->irq_eoi(&desc->irq_data);
518 raw_spin_unlock(&desc->lock); 518 raw_spin_unlock(&desc->lock);
519} 519}
520EXPORT_SYMBOL_GPL(handle_fasteoi_irq);
520 521
521/** 522/**
522 * handle_edge_irq - edge type IRQ handler 523 * handle_edge_irq - edge type IRQ handler
diff --git a/kernel/kcmp.c b/kernel/kcmp.c
index e30ac0fe61c3..0aa69ea1d8fd 100644
--- a/kernel/kcmp.c
+++ b/kernel/kcmp.c
@@ -44,11 +44,12 @@ static long kptr_obfuscate(long v, int type)
44 */ 44 */
45static int kcmp_ptr(void *v1, void *v2, enum kcmp_type type) 45static int kcmp_ptr(void *v1, void *v2, enum kcmp_type type)
46{ 46{
47 long ret; 47 long t1, t2;
48 48
49 ret = kptr_obfuscate((long)v1, type) - kptr_obfuscate((long)v2, type); 49 t1 = kptr_obfuscate((long)v1, type);
50 t2 = kptr_obfuscate((long)v2, type);
50 51
51 return (ret < 0) | ((ret > 0) << 1); 52 return (t1 < t2) | ((t1 > t2) << 1);
52} 53}
53 54
54/* The caller must have pinned the task */ 55/* The caller must have pinned the task */
diff --git a/kernel/power/power.h b/kernel/power/power.h
index 5d49dcac2537..2df883a9d3cb 100644
--- a/kernel/power/power.h
+++ b/kernel/power/power.h
@@ -179,6 +179,7 @@ extern void swsusp_show_speed(struct timeval *, struct timeval *,
179 179
180#ifdef CONFIG_SUSPEND 180#ifdef CONFIG_SUSPEND
181/* kernel/power/suspend.c */ 181/* kernel/power/suspend.c */
182extern const char *pm_labels[];
182extern const char *pm_states[]; 183extern const char *pm_states[];
183 184
184extern int suspend_devices_and_enter(suspend_state_t state); 185extern int suspend_devices_and_enter(suspend_state_t state);
diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c
index c4b8093c80b3..f1604d8cf489 100644
--- a/kernel/power/snapshot.c
+++ b/kernel/power/snapshot.c
@@ -725,14 +725,6 @@ static void memory_bm_clear_bit(struct memory_bitmap *bm, unsigned long pfn)
725 clear_bit(bit, addr); 725 clear_bit(bit, addr);
726} 726}
727 727
728static void memory_bm_clear_current(struct memory_bitmap *bm)
729{
730 int bit;
731
732 bit = max(bm->cur.node_bit - 1, 0);
733 clear_bit(bit, bm->cur.node->data);
734}
735
736static int memory_bm_test_bit(struct memory_bitmap *bm, unsigned long pfn) 728static int memory_bm_test_bit(struct memory_bitmap *bm, unsigned long pfn)
737{ 729{
738 void *addr; 730 void *addr;
@@ -1341,35 +1333,23 @@ static struct memory_bitmap copy_bm;
1341 1333
1342void swsusp_free(void) 1334void swsusp_free(void)
1343{ 1335{
1344 unsigned long fb_pfn, fr_pfn; 1336 struct zone *zone;
1345 1337 unsigned long pfn, max_zone_pfn;
1346 memory_bm_position_reset(forbidden_pages_map);
1347 memory_bm_position_reset(free_pages_map);
1348
1349loop:
1350 fr_pfn = memory_bm_next_pfn(free_pages_map);
1351 fb_pfn = memory_bm_next_pfn(forbidden_pages_map);
1352
1353 /*
1354 * Find the next bit set in both bitmaps. This is guaranteed to
1355 * terminate when fb_pfn == fr_pfn == BM_END_OF_MAP.
1356 */
1357 do {
1358 if (fb_pfn < fr_pfn)
1359 fb_pfn = memory_bm_next_pfn(forbidden_pages_map);
1360 if (fr_pfn < fb_pfn)
1361 fr_pfn = memory_bm_next_pfn(free_pages_map);
1362 } while (fb_pfn != fr_pfn);
1363
1364 if (fr_pfn != BM_END_OF_MAP && pfn_valid(fr_pfn)) {
1365 struct page *page = pfn_to_page(fr_pfn);
1366 1338
1367 memory_bm_clear_current(forbidden_pages_map); 1339 for_each_populated_zone(zone) {
1368 memory_bm_clear_current(free_pages_map); 1340 max_zone_pfn = zone_end_pfn(zone);
1369 __free_page(page); 1341 for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++)
1370 goto loop; 1342 if (pfn_valid(pfn)) {
1343 struct page *page = pfn_to_page(pfn);
1344
1345 if (swsusp_page_is_forbidden(page) &&
1346 swsusp_page_is_free(page)) {
1347 swsusp_unset_page_forbidden(page);
1348 swsusp_unset_page_free(page);
1349 __free_page(page);
1350 }
1351 }
1371 } 1352 }
1372
1373 nr_copy_pages = 0; 1353 nr_copy_pages = 0;
1374 nr_meta_pages = 0; 1354 nr_meta_pages = 0;
1375 restore_pblist = NULL; 1355 restore_pblist = NULL;
diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
index 6dadb25cb0d8..18c62195660f 100644
--- a/kernel/power/suspend.c
+++ b/kernel/power/suspend.c
@@ -31,7 +31,7 @@
31 31
32#include "power.h" 32#include "power.h"
33 33
34static const char *pm_labels[] = { "mem", "standby", "freeze", }; 34const char *pm_labels[] = { "mem", "standby", "freeze", NULL };
35const char *pm_states[PM_SUSPEND_MAX]; 35const char *pm_states[PM_SUSPEND_MAX];
36 36
37static const struct platform_suspend_ops *suspend_ops; 37static const struct platform_suspend_ops *suspend_ops;
diff --git a/kernel/power/suspend_test.c b/kernel/power/suspend_test.c
index 2f524928b6aa..bd91bc177c93 100644
--- a/kernel/power/suspend_test.c
+++ b/kernel/power/suspend_test.c
@@ -129,20 +129,20 @@ static int __init has_wakealarm(struct device *dev, const void *data)
129 * at startup time. They're normally disabled, for faster boot and because 129 * at startup time. They're normally disabled, for faster boot and because
130 * we can't know which states really work on this particular system. 130 * we can't know which states really work on this particular system.
131 */ 131 */
132static suspend_state_t test_state __initdata = PM_SUSPEND_ON; 132static const char *test_state_label __initdata;
133 133
134static char warn_bad_state[] __initdata = 134static char warn_bad_state[] __initdata =
135 KERN_WARNING "PM: can't test '%s' suspend state\n"; 135 KERN_WARNING "PM: can't test '%s' suspend state\n";
136 136
137static int __init setup_test_suspend(char *value) 137static int __init setup_test_suspend(char *value)
138{ 138{
139 suspend_state_t i; 139 int i;
140 140
141 /* "=mem" ==> "mem" */ 141 /* "=mem" ==> "mem" */
142 value++; 142 value++;
143 for (i = PM_SUSPEND_MIN; i < PM_SUSPEND_MAX; i++) 143 for (i = 0; pm_labels[i]; i++)
144 if (!strcmp(pm_states[i], value)) { 144 if (!strcmp(pm_labels[i], value)) {
145 test_state = i; 145 test_state_label = pm_labels[i];
146 return 0; 146 return 0;
147 } 147 }
148 148
@@ -158,13 +158,21 @@ static int __init test_suspend(void)
158 158
159 struct rtc_device *rtc = NULL; 159 struct rtc_device *rtc = NULL;
160 struct device *dev; 160 struct device *dev;
161 suspend_state_t test_state;
161 162
162 /* PM is initialized by now; is that state testable? */ 163 /* PM is initialized by now; is that state testable? */
163 if (test_state == PM_SUSPEND_ON) 164 if (!test_state_label)
164 goto done; 165 return 0;
165 if (!pm_states[test_state]) { 166
166 printk(warn_bad_state, pm_states[test_state]); 167 for (test_state = PM_SUSPEND_MIN; test_state < PM_SUSPEND_MAX; test_state++) {
167 goto done; 168 const char *state_label = pm_states[test_state];
169
170 if (state_label && !strcmp(test_state_label, state_label))
171 break;
172 }
173 if (test_state == PM_SUSPEND_MAX) {
174 printk(warn_bad_state, test_state_label);
175 return 0;
168 } 176 }
169 177
170 /* RTCs have initialized by now too ... can we use one? */ 178 /* RTCs have initialized by now too ... can we use one? */
@@ -173,13 +181,12 @@ static int __init test_suspend(void)
173 rtc = rtc_class_open(dev_name(dev)); 181 rtc = rtc_class_open(dev_name(dev));
174 if (!rtc) { 182 if (!rtc) {
175 printk(warn_no_rtc); 183 printk(warn_no_rtc);
176 goto done; 184 return 0;
177 } 185 }
178 186
179 /* go for it */ 187 /* go for it */
180 test_wakealarm(rtc, test_state); 188 test_wakealarm(rtc, test_state);
181 rtc_class_close(rtc); 189 rtc_class_close(rtc);
182done:
183 return 0; 190 return 0;
184} 191}
185late_initcall(test_suspend); 192late_initcall(test_suspend);
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index e04c455a0e38..1ce770687ea8 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -1665,15 +1665,15 @@ asmlinkage int vprintk_emit(int facility, int level,
1665 raw_spin_lock(&logbuf_lock); 1665 raw_spin_lock(&logbuf_lock);
1666 logbuf_cpu = this_cpu; 1666 logbuf_cpu = this_cpu;
1667 1667
1668 if (recursion_bug) { 1668 if (unlikely(recursion_bug)) {
1669 static const char recursion_msg[] = 1669 static const char recursion_msg[] =
1670 "BUG: recent printk recursion!"; 1670 "BUG: recent printk recursion!";
1671 1671
1672 recursion_bug = 0; 1672 recursion_bug = 0;
1673 text_len = strlen(recursion_msg);
1674 /* emit KERN_CRIT message */ 1673 /* emit KERN_CRIT message */
1675 printed_len += log_store(0, 2, LOG_PREFIX|LOG_NEWLINE, 0, 1674 printed_len += log_store(0, 2, LOG_PREFIX|LOG_NEWLINE, 0,
1676 NULL, 0, recursion_msg, text_len); 1675 NULL, 0, recursion_msg,
1676 strlen(recursion_msg));
1677 } 1677 }
1678 1678
1679 /* 1679 /*
diff --git a/kernel/rcu/tree.h b/kernel/rcu/tree.h
index 71e64c718f75..6a86eb7bac45 100644
--- a/kernel/rcu/tree.h
+++ b/kernel/rcu/tree.h
@@ -358,7 +358,7 @@ struct rcu_data {
358 struct rcu_head **nocb_gp_tail; 358 struct rcu_head **nocb_gp_tail;
359 long nocb_gp_count; 359 long nocb_gp_count;
360 long nocb_gp_count_lazy; 360 long nocb_gp_count_lazy;
361 bool nocb_leader_wake; /* Is the nocb leader thread awake? */ 361 bool nocb_leader_sleep; /* Is the nocb leader thread asleep? */
362 struct rcu_data *nocb_next_follower; 362 struct rcu_data *nocb_next_follower;
363 /* Next follower in wakeup chain. */ 363 /* Next follower in wakeup chain. */
364 364
diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
index 00dc411e9676..a7997e272564 100644
--- a/kernel/rcu/tree_plugin.h
+++ b/kernel/rcu/tree_plugin.h
@@ -2074,9 +2074,9 @@ static void wake_nocb_leader(struct rcu_data *rdp, bool force)
2074 2074
2075 if (!ACCESS_ONCE(rdp_leader->nocb_kthread)) 2075 if (!ACCESS_ONCE(rdp_leader->nocb_kthread))
2076 return; 2076 return;
2077 if (!ACCESS_ONCE(rdp_leader->nocb_leader_wake) || force) { 2077 if (ACCESS_ONCE(rdp_leader->nocb_leader_sleep) || force) {
2078 /* Prior xchg orders against prior callback enqueue. */ 2078 /* Prior xchg orders against prior callback enqueue. */
2079 ACCESS_ONCE(rdp_leader->nocb_leader_wake) = true; 2079 ACCESS_ONCE(rdp_leader->nocb_leader_sleep) = false;
2080 wake_up(&rdp_leader->nocb_wq); 2080 wake_up(&rdp_leader->nocb_wq);
2081 } 2081 }
2082} 2082}
@@ -2253,7 +2253,7 @@ wait_again:
2253 if (!rcu_nocb_poll) { 2253 if (!rcu_nocb_poll) {
2254 trace_rcu_nocb_wake(my_rdp->rsp->name, my_rdp->cpu, "Sleep"); 2254 trace_rcu_nocb_wake(my_rdp->rsp->name, my_rdp->cpu, "Sleep");
2255 wait_event_interruptible(my_rdp->nocb_wq, 2255 wait_event_interruptible(my_rdp->nocb_wq,
2256 ACCESS_ONCE(my_rdp->nocb_leader_wake)); 2256 !ACCESS_ONCE(my_rdp->nocb_leader_sleep));
2257 /* Memory barrier handled by smp_mb() calls below and repoll. */ 2257 /* Memory barrier handled by smp_mb() calls below and repoll. */
2258 } else if (firsttime) { 2258 } else if (firsttime) {
2259 firsttime = false; /* Don't drown trace log with "Poll"! */ 2259 firsttime = false; /* Don't drown trace log with "Poll"! */
@@ -2292,12 +2292,12 @@ wait_again:
2292 schedule_timeout_interruptible(1); 2292 schedule_timeout_interruptible(1);
2293 2293
2294 /* Rescan in case we were a victim of memory ordering. */ 2294 /* Rescan in case we were a victim of memory ordering. */
2295 my_rdp->nocb_leader_wake = false; 2295 my_rdp->nocb_leader_sleep = true;
2296 smp_mb(); /* Ensure _wake false before scan. */ 2296 smp_mb(); /* Ensure _sleep true before scan. */
2297 for (rdp = my_rdp; rdp; rdp = rdp->nocb_next_follower) 2297 for (rdp = my_rdp; rdp; rdp = rdp->nocb_next_follower)
2298 if (ACCESS_ONCE(rdp->nocb_head)) { 2298 if (ACCESS_ONCE(rdp->nocb_head)) {
2299 /* Found CB, so short-circuit next wait. */ 2299 /* Found CB, so short-circuit next wait. */
2300 my_rdp->nocb_leader_wake = true; 2300 my_rdp->nocb_leader_sleep = false;
2301 break; 2301 break;
2302 } 2302 }
2303 goto wait_again; 2303 goto wait_again;
@@ -2307,17 +2307,17 @@ wait_again:
2307 rcu_nocb_wait_gp(my_rdp); 2307 rcu_nocb_wait_gp(my_rdp);
2308 2308
2309 /* 2309 /*
2310 * We left ->nocb_leader_wake set to reduce cache thrashing. 2310 * We left ->nocb_leader_sleep unset to reduce cache thrashing.
2311 * We clear it now, but recheck for new callbacks while 2311 * We set it now, but recheck for new callbacks while
2312 * traversing our follower list. 2312 * traversing our follower list.
2313 */ 2313 */
2314 my_rdp->nocb_leader_wake = false; 2314 my_rdp->nocb_leader_sleep = true;
2315 smp_mb(); /* Ensure _wake false before scan of ->nocb_head. */ 2315 smp_mb(); /* Ensure _sleep true before scan of ->nocb_head. */
2316 2316
2317 /* Each pass through the following loop wakes a follower, if needed. */ 2317 /* Each pass through the following loop wakes a follower, if needed. */
2318 for (rdp = my_rdp; rdp; rdp = rdp->nocb_next_follower) { 2318 for (rdp = my_rdp; rdp; rdp = rdp->nocb_next_follower) {
2319 if (ACCESS_ONCE(rdp->nocb_head)) 2319 if (ACCESS_ONCE(rdp->nocb_head))
2320 my_rdp->nocb_leader_wake = true; /* No need to wait. */ 2320 my_rdp->nocb_leader_sleep = false;/* No need to sleep.*/
2321 if (!rdp->nocb_gp_head) 2321 if (!rdp->nocb_gp_head)
2322 continue; /* No CBs, so no need to wake follower. */ 2322 continue; /* No CBs, so no need to wake follower. */
2323 2323
diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
index 4aec4a457431..a7077d3ae52f 100644
--- a/kernel/time/alarmtimer.c
+++ b/kernel/time/alarmtimer.c
@@ -464,18 +464,26 @@ static enum alarmtimer_type clock2alarm(clockid_t clockid)
464static enum alarmtimer_restart alarm_handle_timer(struct alarm *alarm, 464static enum alarmtimer_restart alarm_handle_timer(struct alarm *alarm,
465 ktime_t now) 465 ktime_t now)
466{ 466{
467 unsigned long flags;
467 struct k_itimer *ptr = container_of(alarm, struct k_itimer, 468 struct k_itimer *ptr = container_of(alarm, struct k_itimer,
468 it.alarm.alarmtimer); 469 it.alarm.alarmtimer);
469 if (posix_timer_event(ptr, 0) != 0) 470 enum alarmtimer_restart result = ALARMTIMER_NORESTART;
470 ptr->it_overrun++; 471
472 spin_lock_irqsave(&ptr->it_lock, flags);
473 if ((ptr->it_sigev_notify & ~SIGEV_THREAD_ID) != SIGEV_NONE) {
474 if (posix_timer_event(ptr, 0) != 0)
475 ptr->it_overrun++;
476 }
471 477
472 /* Re-add periodic timers */ 478 /* Re-add periodic timers */
473 if (ptr->it.alarm.interval.tv64) { 479 if (ptr->it.alarm.interval.tv64) {
474 ptr->it_overrun += alarm_forward(alarm, now, 480 ptr->it_overrun += alarm_forward(alarm, now,
475 ptr->it.alarm.interval); 481 ptr->it.alarm.interval);
476 return ALARMTIMER_RESTART; 482 result = ALARMTIMER_RESTART;
477 } 483 }
478 return ALARMTIMER_NORESTART; 484 spin_unlock_irqrestore(&ptr->it_lock, flags);
485
486 return result;
479} 487}
480 488
481/** 489/**
@@ -541,18 +549,22 @@ static int alarm_timer_create(struct k_itimer *new_timer)
541 * @new_timer: k_itimer pointer 549 * @new_timer: k_itimer pointer
542 * @cur_setting: itimerspec data to fill 550 * @cur_setting: itimerspec data to fill
543 * 551 *
544 * Copies the itimerspec data out from the k_itimer 552 * Copies out the current itimerspec data
545 */ 553 */
546static void alarm_timer_get(struct k_itimer *timr, 554static void alarm_timer_get(struct k_itimer *timr,
547 struct itimerspec *cur_setting) 555 struct itimerspec *cur_setting)
548{ 556{
549 memset(cur_setting, 0, sizeof(struct itimerspec)); 557 ktime_t relative_expiry_time =
558 alarm_expires_remaining(&(timr->it.alarm.alarmtimer));
559
560 if (ktime_to_ns(relative_expiry_time) > 0) {
561 cur_setting->it_value = ktime_to_timespec(relative_expiry_time);
562 } else {
563 cur_setting->it_value.tv_sec = 0;
564 cur_setting->it_value.tv_nsec = 0;
565 }
550 566
551 cur_setting->it_interval = 567 cur_setting->it_interval = ktime_to_timespec(timr->it.alarm.interval);
552 ktime_to_timespec(timr->it.alarm.interval);
553 cur_setting->it_value =
554 ktime_to_timespec(timr->it.alarm.alarmtimer.node.expires);
555 return;
556} 568}
557 569
558/** 570/**
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index 99aa6ee3908f..f654a8a298fa 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -225,6 +225,20 @@ static DEFINE_PER_CPU(struct irq_work, nohz_full_kick_work) = {
225}; 225};
226 226
227/* 227/*
228 * Kick this CPU if it's full dynticks in order to force it to
229 * re-evaluate its dependency on the tick and restart it if necessary.
230 * This kick, unlike tick_nohz_full_kick_cpu() and tick_nohz_full_kick_all(),
231 * is NMI safe.
232 */
233void tick_nohz_full_kick(void)
234{
235 if (!tick_nohz_full_cpu(smp_processor_id()))
236 return;
237
238 irq_work_queue(&__get_cpu_var(nohz_full_kick_work));
239}
240
241/*
228 * Kick the CPU if it's full dynticks in order to force it to 242 * Kick the CPU if it's full dynticks in order to force it to
229 * re-evaluate its dependency on the tick and restart it if necessary. 243 * re-evaluate its dependency on the tick and restart it if necessary.
230 */ 244 */
diff --git a/kernel/time/time.c b/kernel/time/time.c
index f0294ba14634..a9ae20fb0b11 100644
--- a/kernel/time/time.c
+++ b/kernel/time/time.c
@@ -559,17 +559,20 @@ EXPORT_SYMBOL(usecs_to_jiffies);
559 * that a remainder subtract here would not do the right thing as the 559 * that a remainder subtract here would not do the right thing as the
560 * resolution values don't fall on second boundries. I.e. the line: 560 * resolution values don't fall on second boundries. I.e. the line:
561 * nsec -= nsec % TICK_NSEC; is NOT a correct resolution rounding. 561 * nsec -= nsec % TICK_NSEC; is NOT a correct resolution rounding.
562 * Note that due to the small error in the multiplier here, this
563 * rounding is incorrect for sufficiently large values of tv_nsec, but
564 * well formed timespecs should have tv_nsec < NSEC_PER_SEC, so we're
565 * OK.
562 * 566 *
563 * Rather, we just shift the bits off the right. 567 * Rather, we just shift the bits off the right.
564 * 568 *
565 * The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec 569 * The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec
566 * value to a scaled second value. 570 * value to a scaled second value.
567 */ 571 */
568unsigned long 572static unsigned long
569timespec_to_jiffies(const struct timespec *value) 573__timespec_to_jiffies(unsigned long sec, long nsec)
570{ 574{
571 unsigned long sec = value->tv_sec; 575 nsec = nsec + TICK_NSEC - 1;
572 long nsec = value->tv_nsec + TICK_NSEC - 1;
573 576
574 if (sec >= MAX_SEC_IN_JIFFIES){ 577 if (sec >= MAX_SEC_IN_JIFFIES){
575 sec = MAX_SEC_IN_JIFFIES; 578 sec = MAX_SEC_IN_JIFFIES;
@@ -580,6 +583,13 @@ timespec_to_jiffies(const struct timespec *value)
580 (NSEC_JIFFIE_SC - SEC_JIFFIE_SC))) >> SEC_JIFFIE_SC; 583 (NSEC_JIFFIE_SC - SEC_JIFFIE_SC))) >> SEC_JIFFIE_SC;
581 584
582} 585}
586
587unsigned long
588timespec_to_jiffies(const struct timespec *value)
589{
590 return __timespec_to_jiffies(value->tv_sec, value->tv_nsec);
591}
592
583EXPORT_SYMBOL(timespec_to_jiffies); 593EXPORT_SYMBOL(timespec_to_jiffies);
584 594
585void 595void
@@ -596,31 +606,27 @@ jiffies_to_timespec(const unsigned long jiffies, struct timespec *value)
596} 606}
597EXPORT_SYMBOL(jiffies_to_timespec); 607EXPORT_SYMBOL(jiffies_to_timespec);
598 608
599/* Same for "timeval" 609/*
600 * 610 * We could use a similar algorithm to timespec_to_jiffies (with a
601 * Well, almost. The problem here is that the real system resolution is 611 * different multiplier for usec instead of nsec). But this has a
602 * in nanoseconds and the value being converted is in micro seconds. 612 * problem with rounding: we can't exactly add TICK_NSEC - 1 to the
603 * Also for some machines (those that use HZ = 1024, in-particular), 613 * usec value, since it's not necessarily integral.
604 * there is a LARGE error in the tick size in microseconds. 614 *
605 615 * We could instead round in the intermediate scaled representation
606 * The solution we use is to do the rounding AFTER we convert the 616 * (i.e. in units of 1/2^(large scale) jiffies) but that's also
607 * microsecond part. Thus the USEC_ROUND, the bits to be shifted off. 617 * perilous: the scaling introduces a small positive error, which
608 * Instruction wise, this should cost only an additional add with carry 618 * combined with a division-rounding-upward (i.e. adding 2^(scale) - 1
609 * instruction above the way it was done above. 619 * units to the intermediate before shifting) leads to accidental
620 * overflow and overestimates.
621 *
622 * At the cost of one additional multiplication by a constant, just
623 * use the timespec implementation.
610 */ 624 */
611unsigned long 625unsigned long
612timeval_to_jiffies(const struct timeval *value) 626timeval_to_jiffies(const struct timeval *value)
613{ 627{
614 unsigned long sec = value->tv_sec; 628 return __timespec_to_jiffies(value->tv_sec,
615 long usec = value->tv_usec; 629 value->tv_usec * NSEC_PER_USEC);
616
617 if (sec >= MAX_SEC_IN_JIFFIES){
618 sec = MAX_SEC_IN_JIFFIES;
619 usec = 0;
620 }
621 return (((u64)sec * SEC_CONVERSION) +
622 (((u64)usec * USEC_CONVERSION + USEC_ROUND) >>
623 (USEC_JIFFIE_SC - SEC_JIFFIE_SC))) >> SEC_JIFFIE_SC;
624} 630}
625EXPORT_SYMBOL(timeval_to_jiffies); 631EXPORT_SYMBOL(timeval_to_jiffies);
626 632
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index fb4a9c2cf8d9..ec1791fae965 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -442,11 +442,12 @@ static void timekeeping_update(struct timekeeper *tk, unsigned int action)
442 tk->ntp_error = 0; 442 tk->ntp_error = 0;
443 ntp_clear(); 443 ntp_clear();
444 } 444 }
445 update_vsyscall(tk);
446 update_pvclock_gtod(tk, action & TK_CLOCK_WAS_SET);
447 445
448 tk_update_ktime_data(tk); 446 tk_update_ktime_data(tk);
449 447
448 update_vsyscall(tk);
449 update_pvclock_gtod(tk, action & TK_CLOCK_WAS_SET);
450
450 if (action & TK_MIRROR) 451 if (action & TK_MIRROR)
451 memcpy(&shadow_timekeeper, &tk_core.timekeeper, 452 memcpy(&shadow_timekeeper, &tk_core.timekeeper,
452 sizeof(tk_core.timekeeper)); 453 sizeof(tk_core.timekeeper));
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index b38fb2b9e237..2d75c94ae87d 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -3359,7 +3359,7 @@ static void rb_iter_reset(struct ring_buffer_iter *iter)
3359 iter->head = cpu_buffer->reader_page->read; 3359 iter->head = cpu_buffer->reader_page->read;
3360 3360
3361 iter->cache_reader_page = iter->head_page; 3361 iter->cache_reader_page = iter->head_page;
3362 iter->cache_read = iter->head; 3362 iter->cache_read = cpu_buffer->read;
3363 3363
3364 if (iter->head) 3364 if (iter->head)
3365 iter->read_stamp = cpu_buffer->read_stamp; 3365 iter->read_stamp = cpu_buffer->read_stamp;