Contents of /trunk/kernel-alx/patches-3.10/0156-3.10.57-all-fixes.patch
Parent Directory | Revision Log
Revision 2644 -
(show annotations)
(download)
Tue Jul 21 16:20:20 2015 UTC (9 years, 2 months ago) by niro
File size: 21960 byte(s)
Tue Jul 21 16:20:20 2015 UTC (9 years, 2 months ago) by niro
File size: 21960 byte(s)
-linux-3.10.57
1 | diff --git a/Makefile b/Makefile |
2 | index 03bd927522f7..9df630a513b7 100644 |
3 | --- a/Makefile |
4 | +++ b/Makefile |
5 | @@ -1,6 +1,6 @@ |
6 | VERSION = 3 |
7 | PATCHLEVEL = 10 |
8 | -SUBLEVEL = 56 |
9 | +SUBLEVEL = 57 |
10 | EXTRAVERSION = |
11 | NAME = TOSSUG Baby Fish |
12 | |
13 | diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c |
14 | index 9e3f441e7e84..9c37f3d896a2 100644 |
15 | --- a/drivers/block/drbd/drbd_nl.c |
16 | +++ b/drivers/block/drbd/drbd_nl.c |
17 | @@ -514,6 +514,12 @@ void conn_try_outdate_peer_async(struct drbd_tconn *tconn) |
18 | struct task_struct *opa; |
19 | |
20 | kref_get(&tconn->kref); |
21 | + /* We may just have force_sig()'ed this thread |
22 | + * to get it out of some blocking network function. |
23 | + * Clear signals; otherwise kthread_run(), which internally uses |
24 | + * wait_on_completion_killable(), will mistake our pending signal |
25 | + * for a new fatal signal and fail. */ |
26 | + flush_signals(current); |
27 | opa = kthread_run(_try_outdate_peer_async, tconn, "drbd_async_h"); |
28 | if (IS_ERR(opa)) { |
29 | conn_err(tconn, "out of mem, failed to invoke fence-peer helper\n"); |
30 | diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c |
31 | index 28a0b32c73b3..27b0e2a295ea 100644 |
32 | --- a/drivers/cpufreq/cpufreq_governor.c |
33 | +++ b/drivers/cpufreq/cpufreq_governor.c |
34 | @@ -97,7 +97,7 @@ void dbs_check_cpu(struct dbs_data *dbs_data, int cpu) |
35 | |
36 | policy = cdbs->cur_policy; |
37 | |
38 | - /* Get Absolute Load (in terms of freq for ondemand gov) */ |
39 | + /* Get Absolute Load */ |
40 | for_each_cpu(j, policy->cpus) { |
41 | struct cpu_dbs_common_info *j_cdbs; |
42 | u64 cur_wall_time, cur_idle_time; |
43 | @@ -148,14 +148,6 @@ void dbs_check_cpu(struct dbs_data *dbs_data, int cpu) |
44 | |
45 | load = 100 * (wall_time - idle_time) / wall_time; |
46 | |
47 | - if (dbs_data->cdata->governor == GOV_ONDEMAND) { |
48 | - int freq_avg = __cpufreq_driver_getavg(policy, j); |
49 | - if (freq_avg <= 0) |
50 | - freq_avg = policy->cur; |
51 | - |
52 | - load *= freq_avg; |
53 | - } |
54 | - |
55 | if (load > max_load) |
56 | max_load = load; |
57 | } |
58 | diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h |
59 | index 0d9e6befe1d5..4a9058aeb57e 100644 |
60 | --- a/drivers/cpufreq/cpufreq_governor.h |
61 | +++ b/drivers/cpufreq/cpufreq_governor.h |
62 | @@ -169,7 +169,6 @@ struct od_dbs_tuners { |
63 | unsigned int sampling_rate; |
64 | unsigned int sampling_down_factor; |
65 | unsigned int up_threshold; |
66 | - unsigned int adj_up_threshold; |
67 | unsigned int powersave_bias; |
68 | unsigned int io_is_busy; |
69 | }; |
70 | diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c |
71 | index c087347d6688..25438bbf96bb 100644 |
72 | --- a/drivers/cpufreq/cpufreq_ondemand.c |
73 | +++ b/drivers/cpufreq/cpufreq_ondemand.c |
74 | @@ -29,11 +29,9 @@ |
75 | #include "cpufreq_governor.h" |
76 | |
77 | /* On-demand governor macros */ |
78 | -#define DEF_FREQUENCY_DOWN_DIFFERENTIAL (10) |
79 | #define DEF_FREQUENCY_UP_THRESHOLD (80) |
80 | #define DEF_SAMPLING_DOWN_FACTOR (1) |
81 | #define MAX_SAMPLING_DOWN_FACTOR (100000) |
82 | -#define MICRO_FREQUENCY_DOWN_DIFFERENTIAL (3) |
83 | #define MICRO_FREQUENCY_UP_THRESHOLD (95) |
84 | #define MICRO_FREQUENCY_MIN_SAMPLE_RATE (10000) |
85 | #define MIN_FREQUENCY_UP_THRESHOLD (11) |
86 | @@ -161,14 +159,10 @@ static void dbs_freq_increase(struct cpufreq_policy *p, unsigned int freq) |
87 | |
88 | /* |
89 | * Every sampling_rate, we check, if current idle time is less than 20% |
90 | - * (default), then we try to increase frequency. Every sampling_rate, we look |
91 | - * for the lowest frequency which can sustain the load while keeping idle time |
92 | - * over 30%. If such a frequency exist, we try to decrease to this frequency. |
93 | - * |
94 | - * Any frequency increase takes it to the maximum frequency. Frequency reduction |
95 | - * happens at minimum steps of 5% (default) of current frequency |
96 | + * (default), then we try to increase frequency. Else, we adjust the frequency |
97 | + * proportional to load. |
98 | */ |
99 | -static void od_check_cpu(int cpu, unsigned int load_freq) |
100 | +static void od_check_cpu(int cpu, unsigned int load) |
101 | { |
102 | struct od_cpu_dbs_info_s *dbs_info = &per_cpu(od_cpu_dbs_info, cpu); |
103 | struct cpufreq_policy *policy = dbs_info->cdbs.cur_policy; |
104 | @@ -178,29 +172,17 @@ static void od_check_cpu(int cpu, unsigned int load_freq) |
105 | dbs_info->freq_lo = 0; |
106 | |
107 | /* Check for frequency increase */ |
108 | - if (load_freq > od_tuners->up_threshold * policy->cur) { |
109 | + if (load > od_tuners->up_threshold) { |
110 | /* If switching to max speed, apply sampling_down_factor */ |
111 | if (policy->cur < policy->max) |
112 | dbs_info->rate_mult = |
113 | od_tuners->sampling_down_factor; |
114 | dbs_freq_increase(policy, policy->max); |
115 | return; |
116 | - } |
117 | - |
118 | - /* Check for frequency decrease */ |
119 | - /* if we cannot reduce the frequency anymore, break out early */ |
120 | - if (policy->cur == policy->min) |
121 | - return; |
122 | - |
123 | - /* |
124 | - * The optimal frequency is the frequency that is the lowest that can |
125 | - * support the current CPU usage without triggering the up policy. To be |
126 | - * safe, we focus 10 points under the threshold. |
127 | - */ |
128 | - if (load_freq < od_tuners->adj_up_threshold |
129 | - * policy->cur) { |
130 | + } else { |
131 | + /* Calculate the next frequency proportional to load */ |
132 | unsigned int freq_next; |
133 | - freq_next = load_freq / od_tuners->adj_up_threshold; |
134 | + freq_next = load * policy->cpuinfo.max_freq / 100; |
135 | |
136 | /* No longer fully busy, reset rate_mult */ |
137 | dbs_info->rate_mult = 1; |
138 | @@ -374,9 +356,6 @@ static ssize_t store_up_threshold(struct dbs_data *dbs_data, const char *buf, |
139 | input < MIN_FREQUENCY_UP_THRESHOLD) { |
140 | return -EINVAL; |
141 | } |
142 | - /* Calculate the new adj_up_threshold */ |
143 | - od_tuners->adj_up_threshold += input; |
144 | - od_tuners->adj_up_threshold -= od_tuners->up_threshold; |
145 | |
146 | od_tuners->up_threshold = input; |
147 | return count; |
148 | @@ -525,8 +504,6 @@ static int od_init(struct dbs_data *dbs_data) |
149 | if (idle_time != -1ULL) { |
150 | /* Idle micro accounting is supported. Use finer thresholds */ |
151 | tuners->up_threshold = MICRO_FREQUENCY_UP_THRESHOLD; |
152 | - tuners->adj_up_threshold = MICRO_FREQUENCY_UP_THRESHOLD - |
153 | - MICRO_FREQUENCY_DOWN_DIFFERENTIAL; |
154 | /* |
155 | * In nohz/micro accounting case we set the minimum frequency |
156 | * not depending on HZ, but fixed (very low). The deferred |
157 | @@ -535,8 +512,6 @@ static int od_init(struct dbs_data *dbs_data) |
158 | dbs_data->min_sampling_rate = MICRO_FREQUENCY_MIN_SAMPLE_RATE; |
159 | } else { |
160 | tuners->up_threshold = DEF_FREQUENCY_UP_THRESHOLD; |
161 | - tuners->adj_up_threshold = DEF_FREQUENCY_UP_THRESHOLD - |
162 | - DEF_FREQUENCY_DOWN_DIFFERENTIAL; |
163 | |
164 | /* For correct statistics, we need 10 ticks for each measure */ |
165 | dbs_data->min_sampling_rate = MIN_SAMPLING_RATE_RATIO * |
166 | diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c |
167 | index bfd6273fd873..7fb600239059 100644 |
168 | --- a/drivers/cpufreq/cpufreq_stats.c |
169 | +++ b/drivers/cpufreq/cpufreq_stats.c |
170 | @@ -81,7 +81,7 @@ static ssize_t show_time_in_state(struct cpufreq_policy *policy, char *buf) |
171 | for (i = 0; i < stat->state_num; i++) { |
172 | len += sprintf(buf + len, "%u %llu\n", stat->freq_table[i], |
173 | (unsigned long long) |
174 | - cputime64_to_clock_t(stat->time_in_state[i])); |
175 | + jiffies_64_to_clock_t(stat->time_in_state[i])); |
176 | } |
177 | return len; |
178 | } |
179 | diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c |
180 | index 774f81423d78..2332b5ced0dd 100644 |
181 | --- a/drivers/md/raid5.c |
182 | +++ b/drivers/md/raid5.c |
183 | @@ -60,6 +60,10 @@ |
184 | #include "raid0.h" |
185 | #include "bitmap.h" |
186 | |
187 | +static bool devices_handle_discard_safely = false; |
188 | +module_param(devices_handle_discard_safely, bool, 0644); |
189 | +MODULE_PARM_DESC(devices_handle_discard_safely, |
190 | + "Set to Y if all devices in each array reliably return zeroes on reads from discarded regions"); |
191 | /* |
192 | * Stripe cache |
193 | */ |
194 | @@ -5611,7 +5615,7 @@ static int run(struct mddev *mddev) |
195 | mddev->queue->limits.discard_granularity = stripe; |
196 | /* |
197 | * unaligned part of discard request will be ignored, so can't |
198 | - * guarantee discard_zerors_data |
199 | + * guarantee discard_zeroes_data |
200 | */ |
201 | mddev->queue->limits.discard_zeroes_data = 0; |
202 | |
203 | @@ -5636,6 +5640,18 @@ static int run(struct mddev *mddev) |
204 | !bdev_get_queue(rdev->bdev)-> |
205 | limits.discard_zeroes_data) |
206 | discard_supported = false; |
207 | + /* Unfortunately, discard_zeroes_data is not currently |
208 | + * a guarantee - just a hint. So we only allow DISCARD |
209 | + * if the sysadmin has confirmed that only safe devices |
210 | + * are in use by setting a module parameter. |
211 | + */ |
212 | + if (!devices_handle_discard_safely) { |
213 | + if (discard_supported) { |
214 | + pr_info("md/raid456: discard support disabled due to uncertainty.\n"); |
215 | + pr_info("Set raid456.devices_handle_discard_safely=Y to override.\n"); |
216 | + } |
217 | + discard_supported = false; |
218 | + } |
219 | } |
220 | |
221 | if (discard_supported && |
222 | diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c |
223 | index e3bdc3be91e1..5e47ba479e53 100644 |
224 | --- a/drivers/media/v4l2-core/videobuf2-core.c |
225 | +++ b/drivers/media/v4l2-core/videobuf2-core.c |
226 | @@ -666,6 +666,7 @@ static int __reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req) |
227 | * to the userspace. |
228 | */ |
229 | req->count = allocated_buffers; |
230 | + q->waiting_for_buffers = !V4L2_TYPE_IS_OUTPUT(q->type); |
231 | |
232 | return 0; |
233 | } |
234 | @@ -714,6 +715,7 @@ static int __create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create |
235 | memset(q->plane_sizes, 0, sizeof(q->plane_sizes)); |
236 | memset(q->alloc_ctx, 0, sizeof(q->alloc_ctx)); |
237 | q->memory = create->memory; |
238 | + q->waiting_for_buffers = !V4L2_TYPE_IS_OUTPUT(q->type); |
239 | } |
240 | |
241 | num_buffers = min(create->count, VIDEO_MAX_FRAME - q->num_buffers); |
242 | @@ -1355,6 +1357,7 @@ int vb2_qbuf(struct vb2_queue *q, struct v4l2_buffer *b) |
243 | * dequeued in dqbuf. |
244 | */ |
245 | list_add_tail(&vb->queued_entry, &q->queued_list); |
246 | + q->waiting_for_buffers = false; |
247 | vb->state = VB2_BUF_STATE_QUEUED; |
248 | |
249 | /* |
250 | @@ -1724,6 +1727,7 @@ int vb2_streamoff(struct vb2_queue *q, enum v4l2_buf_type type) |
251 | * and videobuf, effectively returning control over them to userspace. |
252 | */ |
253 | __vb2_queue_cancel(q); |
254 | + q->waiting_for_buffers = !V4L2_TYPE_IS_OUTPUT(q->type); |
255 | |
256 | dprintk(3, "Streamoff successful\n"); |
257 | return 0; |
258 | @@ -2009,9 +2013,16 @@ unsigned int vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait) |
259 | } |
260 | |
261 | /* |
262 | - * There is nothing to wait for if no buffers have already been queued. |
263 | + * There is nothing to wait for if the queue isn't streaming. |
264 | */ |
265 | - if (list_empty(&q->queued_list)) |
266 | + if (!vb2_is_streaming(q)) |
267 | + return res | POLLERR; |
268 | + /* |
269 | + * For compatibility with vb1: if QBUF hasn't been called yet, then |
270 | + * return POLLERR as well. This only affects capture queues, output |
271 | + * queues will always initialize waiting_for_buffers to false. |
272 | + */ |
273 | + if (q->waiting_for_buffers) |
274 | return res | POLLERR; |
275 | |
276 | if (list_empty(&q->done_list)) |
277 | diff --git a/fs/udf/inode.c b/fs/udf/inode.c |
278 | index b6d15d349810..aa023283cc8a 100644 |
279 | --- a/fs/udf/inode.c |
280 | +++ b/fs/udf/inode.c |
281 | @@ -1270,13 +1270,22 @@ update_time: |
282 | return 0; |
283 | } |
284 | |
285 | +/* |
286 | + * Maximum length of linked list formed by ICB hierarchy. The chosen number is |
287 | + * arbitrary - just that we hopefully don't limit any real use of rewritten |
288 | + * inode on write-once media but avoid looping for too long on corrupted media. |
289 | + */ |
290 | +#define UDF_MAX_ICB_NESTING 1024 |
291 | + |
292 | static void __udf_read_inode(struct inode *inode) |
293 | { |
294 | struct buffer_head *bh = NULL; |
295 | struct fileEntry *fe; |
296 | uint16_t ident; |
297 | struct udf_inode_info *iinfo = UDF_I(inode); |
298 | + unsigned int indirections = 0; |
299 | |
300 | +reread: |
301 | /* |
302 | * Set defaults, but the inode is still incomplete! |
303 | * Note: get_new_inode() sets the following on a new inode: |
304 | @@ -1313,28 +1322,26 @@ static void __udf_read_inode(struct inode *inode) |
305 | ibh = udf_read_ptagged(inode->i_sb, &iinfo->i_location, 1, |
306 | &ident); |
307 | if (ident == TAG_IDENT_IE && ibh) { |
308 | - struct buffer_head *nbh = NULL; |
309 | struct kernel_lb_addr loc; |
310 | struct indirectEntry *ie; |
311 | |
312 | ie = (struct indirectEntry *)ibh->b_data; |
313 | loc = lelb_to_cpu(ie->indirectICB.extLocation); |
314 | |
315 | - if (ie->indirectICB.extLength && |
316 | - (nbh = udf_read_ptagged(inode->i_sb, &loc, 0, |
317 | - &ident))) { |
318 | - if (ident == TAG_IDENT_FE || |
319 | - ident == TAG_IDENT_EFE) { |
320 | - memcpy(&iinfo->i_location, |
321 | - &loc, |
322 | - sizeof(struct kernel_lb_addr)); |
323 | - brelse(bh); |
324 | - brelse(ibh); |
325 | - brelse(nbh); |
326 | - __udf_read_inode(inode); |
327 | + if (ie->indirectICB.extLength) { |
328 | + brelse(bh); |
329 | + brelse(ibh); |
330 | + memcpy(&iinfo->i_location, &loc, |
331 | + sizeof(struct kernel_lb_addr)); |
332 | + if (++indirections > UDF_MAX_ICB_NESTING) { |
333 | + udf_err(inode->i_sb, |
334 | + "too many ICBs in ICB hierarchy" |
335 | + " (max %d supported)\n", |
336 | + UDF_MAX_ICB_NESTING); |
337 | + make_bad_inode(inode); |
338 | return; |
339 | } |
340 | - brelse(nbh); |
341 | + goto reread; |
342 | } |
343 | } |
344 | brelse(ibh); |
345 | diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h |
346 | index 7b5d4a8ab199..c039fe1315eb 100644 |
347 | --- a/include/linux/jiffies.h |
348 | +++ b/include/linux/jiffies.h |
349 | @@ -254,23 +254,11 @@ extern unsigned long preset_lpj; |
350 | #define SEC_JIFFIE_SC (32 - SHIFT_HZ) |
351 | #endif |
352 | #define NSEC_JIFFIE_SC (SEC_JIFFIE_SC + 29) |
353 | -#define USEC_JIFFIE_SC (SEC_JIFFIE_SC + 19) |
354 | #define SEC_CONVERSION ((unsigned long)((((u64)NSEC_PER_SEC << SEC_JIFFIE_SC) +\ |
355 | TICK_NSEC -1) / (u64)TICK_NSEC)) |
356 | |
357 | #define NSEC_CONVERSION ((unsigned long)((((u64)1 << NSEC_JIFFIE_SC) +\ |
358 | TICK_NSEC -1) / (u64)TICK_NSEC)) |
359 | -#define USEC_CONVERSION \ |
360 | - ((unsigned long)((((u64)NSEC_PER_USEC << USEC_JIFFIE_SC) +\ |
361 | - TICK_NSEC -1) / (u64)TICK_NSEC)) |
362 | -/* |
363 | - * USEC_ROUND is used in the timeval to jiffie conversion. See there |
364 | - * for more details. It is the scaled resolution rounding value. Note |
365 | - * that it is a 64-bit value. Since, when it is applied, we are already |
366 | - * in jiffies (albit scaled), it is nothing but the bits we will shift |
367 | - * off. |
368 | - */ |
369 | -#define USEC_ROUND (u64)(((u64)1 << USEC_JIFFIE_SC) - 1) |
370 | /* |
371 | * The maximum jiffie value is (MAX_INT >> 1). Here we translate that |
372 | * into seconds. The 64-bit case will overflow if we are not careful, |
373 | diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h |
374 | index d88a098d1aff..2cc4e0df9c5d 100644 |
375 | --- a/include/media/videobuf2-core.h |
376 | +++ b/include/media/videobuf2-core.h |
377 | @@ -318,6 +318,9 @@ struct v4l2_fh; |
378 | * @done_wq: waitqueue for processes waiting for buffers ready to be dequeued |
379 | * @alloc_ctx: memory type/allocator-specific contexts for each plane |
380 | * @streaming: current streaming state |
381 | + * @waiting_for_buffers: used in poll() to check if vb2 is still waiting for |
382 | + * buffers. Only set for capture queues if qbuf has not yet been |
383 | + * called since poll() needs to return POLLERR in that situation. |
384 | * @fileio: file io emulator internal data, used only if emulator is active |
385 | */ |
386 | struct vb2_queue { |
387 | @@ -350,6 +353,7 @@ struct vb2_queue { |
388 | unsigned int plane_sizes[VIDEO_MAX_PLANES]; |
389 | |
390 | unsigned int streaming:1; |
391 | + unsigned int waiting_for_buffers:1; |
392 | |
393 | struct vb2_fileio_data *fileio; |
394 | }; |
395 | diff --git a/init/Kconfig b/init/Kconfig |
396 | index 5d6febaea56d..8fa4f758821a 100644 |
397 | --- a/init/Kconfig |
398 | +++ b/init/Kconfig |
399 | @@ -1367,6 +1367,7 @@ config FUTEX |
400 | |
401 | config HAVE_FUTEX_CMPXCHG |
402 | bool |
403 | + depends on FUTEX |
404 | help |
405 | Architectures should select this if futex_atomic_cmpxchg_inatomic() |
406 | is implemented and always working. This removes a couple of runtime |
407 | diff --git a/kernel/events/core.c b/kernel/events/core.c |
408 | index 6bf387a60399..0b4733447151 100644 |
409 | --- a/kernel/events/core.c |
410 | +++ b/kernel/events/core.c |
411 | @@ -7482,8 +7482,10 @@ int perf_event_init_task(struct task_struct *child) |
412 | |
413 | for_each_task_context_nr(ctxn) { |
414 | ret = perf_event_init_context(child, ctxn); |
415 | - if (ret) |
416 | + if (ret) { |
417 | + perf_event_free_task(child); |
418 | return ret; |
419 | + } |
420 | } |
421 | |
422 | return 0; |
423 | diff --git a/kernel/fork.c b/kernel/fork.c |
424 | index 2c76e11ba939..514dbc40f98f 100644 |
425 | --- a/kernel/fork.c |
426 | +++ b/kernel/fork.c |
427 | @@ -1324,7 +1324,7 @@ static struct task_struct *copy_process(unsigned long clone_flags, |
428 | goto bad_fork_cleanup_policy; |
429 | retval = audit_alloc(p); |
430 | if (retval) |
431 | - goto bad_fork_cleanup_policy; |
432 | + goto bad_fork_cleanup_perf; |
433 | /* copy all the process information */ |
434 | retval = copy_semundo(clone_flags, p); |
435 | if (retval) |
436 | @@ -1522,8 +1522,9 @@ bad_fork_cleanup_semundo: |
437 | exit_sem(p); |
438 | bad_fork_cleanup_audit: |
439 | audit_free(p); |
440 | -bad_fork_cleanup_policy: |
441 | +bad_fork_cleanup_perf: |
442 | perf_event_free_task(p); |
443 | +bad_fork_cleanup_policy: |
444 | #ifdef CONFIG_NUMA |
445 | mpol_put(p->mempolicy); |
446 | bad_fork_cleanup_cgroup: |
447 | diff --git a/kernel/time.c b/kernel/time.c |
448 | index d3617dbd3dca..d21398e6da87 100644 |
449 | --- a/kernel/time.c |
450 | +++ b/kernel/time.c |
451 | @@ -496,17 +496,20 @@ EXPORT_SYMBOL(usecs_to_jiffies); |
452 | * that a remainder subtract here would not do the right thing as the |
453 | * resolution values don't fall on second boundries. I.e. the line: |
454 | * nsec -= nsec % TICK_NSEC; is NOT a correct resolution rounding. |
455 | + * Note that due to the small error in the multiplier here, this |
456 | + * rounding is incorrect for sufficiently large values of tv_nsec, but |
457 | + * well formed timespecs should have tv_nsec < NSEC_PER_SEC, so we're |
458 | + * OK. |
459 | * |
460 | * Rather, we just shift the bits off the right. |
461 | * |
462 | * The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec |
463 | * value to a scaled second value. |
464 | */ |
465 | -unsigned long |
466 | -timespec_to_jiffies(const struct timespec *value) |
467 | +static unsigned long |
468 | +__timespec_to_jiffies(unsigned long sec, long nsec) |
469 | { |
470 | - unsigned long sec = value->tv_sec; |
471 | - long nsec = value->tv_nsec + TICK_NSEC - 1; |
472 | + nsec = nsec + TICK_NSEC - 1; |
473 | |
474 | if (sec >= MAX_SEC_IN_JIFFIES){ |
475 | sec = MAX_SEC_IN_JIFFIES; |
476 | @@ -517,6 +520,13 @@ timespec_to_jiffies(const struct timespec *value) |
477 | (NSEC_JIFFIE_SC - SEC_JIFFIE_SC))) >> SEC_JIFFIE_SC; |
478 | |
479 | } |
480 | + |
481 | +unsigned long |
482 | +timespec_to_jiffies(const struct timespec *value) |
483 | +{ |
484 | + return __timespec_to_jiffies(value->tv_sec, value->tv_nsec); |
485 | +} |
486 | + |
487 | EXPORT_SYMBOL(timespec_to_jiffies); |
488 | |
489 | void |
490 | @@ -533,31 +543,27 @@ jiffies_to_timespec(const unsigned long jiffies, struct timespec *value) |
491 | } |
492 | EXPORT_SYMBOL(jiffies_to_timespec); |
493 | |
494 | -/* Same for "timeval" |
495 | +/* |
496 | + * We could use a similar algorithm to timespec_to_jiffies (with a |
497 | + * different multiplier for usec instead of nsec). But this has a |
498 | + * problem with rounding: we can't exactly add TICK_NSEC - 1 to the |
499 | + * usec value, since it's not necessarily integral. |
500 | * |
501 | - * Well, almost. The problem here is that the real system resolution is |
502 | - * in nanoseconds and the value being converted is in micro seconds. |
503 | - * Also for some machines (those that use HZ = 1024, in-particular), |
504 | - * there is a LARGE error in the tick size in microseconds. |
505 | - |
506 | - * The solution we use is to do the rounding AFTER we convert the |
507 | - * microsecond part. Thus the USEC_ROUND, the bits to be shifted off. |
508 | - * Instruction wise, this should cost only an additional add with carry |
509 | - * instruction above the way it was done above. |
510 | + * We could instead round in the intermediate scaled representation |
511 | + * (i.e. in units of 1/2^(large scale) jiffies) but that's also |
512 | + * perilous: the scaling introduces a small positive error, which |
513 | + * combined with a division-rounding-upward (i.e. adding 2^(scale) - 1 |
514 | + * units to the intermediate before shifting) leads to accidental |
515 | + * overflow and overestimates. |
516 | + * |
517 | + * At the cost of one additional multiplication by a constant, just |
518 | + * use the timespec implementation. |
519 | */ |
520 | unsigned long |
521 | timeval_to_jiffies(const struct timeval *value) |
522 | { |
523 | - unsigned long sec = value->tv_sec; |
524 | - long usec = value->tv_usec; |
525 | - |
526 | - if (sec >= MAX_SEC_IN_JIFFIES){ |
527 | - sec = MAX_SEC_IN_JIFFIES; |
528 | - usec = 0; |
529 | - } |
530 | - return (((u64)sec * SEC_CONVERSION) + |
531 | - (((u64)usec * USEC_CONVERSION + USEC_ROUND) >> |
532 | - (USEC_JIFFIE_SC - SEC_JIFFIE_SC))) >> SEC_JIFFIE_SC; |
533 | + return __timespec_to_jiffies(value->tv_sec, |
534 | + value->tv_usec * NSEC_PER_USEC); |
535 | } |
536 | EXPORT_SYMBOL(timeval_to_jiffies); |
537 | |
538 | diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c |
539 | index 0bc181b0524c..3d9fee3a80b3 100644 |
540 | --- a/kernel/trace/ring_buffer.c |
541 | +++ b/kernel/trace/ring_buffer.c |
542 | @@ -3371,7 +3371,7 @@ static void rb_iter_reset(struct ring_buffer_iter *iter) |
543 | iter->head = cpu_buffer->reader_page->read; |
544 | |
545 | iter->cache_reader_page = iter->head_page; |
546 | - iter->cache_read = iter->head; |
547 | + iter->cache_read = cpu_buffer->read; |
548 | |
549 | if (iter->head) |
550 | iter->read_stamp = cpu_buffer->read_stamp; |
551 | diff --git a/mm/huge_memory.c b/mm/huge_memory.c |
552 | index eb00e81601a5..d21c9ef0943c 100644 |
553 | --- a/mm/huge_memory.c |
554 | +++ b/mm/huge_memory.c |
555 | @@ -1733,21 +1733,24 @@ static int __split_huge_page_map(struct page *page, |
556 | if (pmd) { |
557 | pgtable = pgtable_trans_huge_withdraw(mm); |
558 | pmd_populate(mm, &_pmd, pgtable); |
559 | + if (pmd_write(*pmd)) |
560 | + BUG_ON(page_mapcount(page) != 1); |
561 | |
562 | haddr = address; |
563 | for (i = 0; i < HPAGE_PMD_NR; i++, haddr += PAGE_SIZE) { |
564 | pte_t *pte, entry; |
565 | BUG_ON(PageCompound(page+i)); |
566 | + /* |
567 | + * Note that pmd_numa is not transferred deliberately |
568 | + * to avoid any possibility that pte_numa leaks to |
569 | + * a PROT_NONE VMA by accident. |
570 | + */ |
571 | entry = mk_pte(page + i, vma->vm_page_prot); |
572 | entry = maybe_mkwrite(pte_mkdirty(entry), vma); |
573 | if (!pmd_write(*pmd)) |
574 | entry = pte_wrprotect(entry); |
575 | - else |
576 | - BUG_ON(page_mapcount(page) != 1); |
577 | if (!pmd_young(*pmd)) |
578 | entry = pte_mkold(entry); |
579 | - if (pmd_numa(*pmd)) |
580 | - entry = pte_mknuma(entry); |
581 | pte = pte_offset_map(&_pmd, haddr); |
582 | BUG_ON(!pte_none(*pte)); |
583 | set_pte_at(mm, haddr, pte, entry); |
584 | diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c |
585 | index 448c034184e2..62aebed7c6e2 100644 |
586 | --- a/net/wireless/nl80211.c |
587 | +++ b/net/wireless/nl80211.c |
588 | @@ -6568,6 +6568,9 @@ int cfg80211_testmode_reply(struct sk_buff *skb) |
589 | void *hdr = ((void **)skb->cb)[1]; |
590 | struct nlattr *data = ((void **)skb->cb)[2]; |
591 | |
592 | + /* clear CB data for netlink core to own from now on */ |
593 | + memset(skb->cb, 0, sizeof(skb->cb)); |
594 | + |
595 | if (WARN_ON(!rdev->testmode_info)) { |
596 | kfree_skb(skb); |
597 | return -EINVAL; |
598 | @@ -6594,6 +6597,9 @@ void cfg80211_testmode_event(struct sk_buff *skb, gfp_t gfp) |
599 | void *hdr = ((void **)skb->cb)[1]; |
600 | struct nlattr *data = ((void **)skb->cb)[2]; |
601 | |
602 | + /* clear CB data for netlink core to own from now on */ |
603 | + memset(skb->cb, 0, sizeof(skb->cb)); |
604 | + |
605 | nla_nest_end(skb, data); |
606 | genlmsg_end(skb, hdr); |
607 | genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), skb, 0, |