Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge remote-tracking branch 'torvalds/master' into perf/core

To pick up fixes.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

+259 -120
+2 -1
MAINTAINERS
··· 15952 15952 B: https://bugzilla.kernel.org 15953 15953 C: irc://irc.oftc.net/linux-pci 15954 15954 T: git git://git.kernel.org/pub/scm/linux/kernel/git/lpieralisi/pci.git 15955 + F: Documentation/devicetree/bindings/pci/ 15955 15956 F: drivers/pci/controller/ 15956 15957 F: drivers/pci/pci-bridge-emul.c 15957 15958 F: drivers/pci/pci-bridge-emul.h ··· 16059 16058 F: drivers/pci/controller/*microchip* 16060 16059 16061 16060 PCIE DRIVER FOR QUALCOMM MSM 16062 - M: Stanimir Varbanov <svarbanov@mm-sol.com> 16061 + M: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> 16063 16062 L: linux-pci@vger.kernel.org 16064 16063 L: linux-arm-msm@vger.kernel.org 16065 16064 S: Maintained
+1 -1
Makefile
··· 2 2 VERSION = 6 3 3 PATCHLEVEL = 1 4 4 SUBLEVEL = 0 5 - EXTRAVERSION = -rc5 5 + EXTRAVERSION = -rc6 6 6 NAME = Hurr durr I'ma ninja sloth 7 7 8 8 # *DOCUMENTATION*
+1 -1
arch/powerpc/kernel/vmlinux.lds.S
··· 142 142 #endif 143 143 144 144 .data.rel.ro : AT(ADDR(.data.rel.ro) - LOAD_OFFSET) { 145 - *(.data.rel.ro*) 145 + *(.data.rel.ro .data.rel.ro.*) 146 146 } 147 147 148 148 .branch_lt : AT(ADDR(.branch_lt) - LOAD_OFFSET) {
+2 -3
arch/x86/events/amd/core.c
··· 861 861 pmu_enabled = cpuc->enabled; 862 862 cpuc->enabled = 0; 863 863 864 - /* stop everything (includes BRS) */ 865 - amd_pmu_disable_all(); 864 + amd_brs_disable_all(); 866 865 867 866 /* Drain BRS is in use (could be inactive) */ 868 867 if (cpuc->lbr_users) ··· 872 873 873 874 cpuc->enabled = pmu_enabled; 874 875 if (pmu_enabled) 875 - amd_pmu_enable_all(0); 876 + amd_brs_enable_all(); 876 877 877 878 return amd_pmu_adjust_nmi_window(handled); 878 879 }
+1
arch/x86/events/amd/uncore.c
··· 553 553 554 554 hlist_for_each_entry_safe(uncore, n, &uncore_unused_list, node) { 555 555 hlist_del(&uncore->node); 556 + kfree(uncore->events); 556 557 kfree(uncore); 557 558 } 558 559 }
+9
arch/x86/events/intel/pt.c
··· 1263 1263 if (1 << order != nr_pages) 1264 1264 goto out; 1265 1265 1266 + /* 1267 + * Some processors cannot always support single range for more than 1268 + * 4KB - refer errata TGL052, ADL037 and RPL017. Future processors might 1269 + * also be affected, so for now rather than trying to keep track of 1270 + * which ones, just disable it for all. 1271 + */ 1272 + if (nr_pages > 1) 1273 + goto out; 1274 + 1266 1275 buf->single = true; 1267 1276 buf->nr_pages = nr_pages; 1268 1277 ret = 0;
+1 -1
arch/x86/include/asm/qspinlock_paravirt.h
··· 37 37 * rsi = lockval (second argument) 38 38 * rdx = internal variable (set to 0) 39 39 */ 40 - asm (".pushsection .spinlock.text;" 40 + asm (".pushsection .spinlock.text, \"ax\";" 41 41 ".globl " PV_UNLOCK ";" 42 42 ".type " PV_UNLOCK ", @function;" 43 43 ".align 4,0x90;"
+3
arch/x86/kernel/cpu/sgx/ioctl.c
··· 356 356 if (!length || !IS_ALIGNED(length, PAGE_SIZE)) 357 357 return -EINVAL; 358 358 359 + if (offset + length < offset) 360 + return -EINVAL; 361 + 359 362 if (offset + length - PAGE_SIZE >= encl->size) 360 363 return -EINVAL; 361 364
+1 -1
arch/x86/kernel/fpu/core.c
··· 605 605 if (test_thread_flag(TIF_NEED_FPU_LOAD)) 606 606 fpregs_restore_userregs(); 607 607 save_fpregs_to_fpstate(dst_fpu); 608 + fpregs_unlock(); 608 609 if (!(clone_flags & CLONE_THREAD)) 609 610 fpu_inherit_perms(dst_fpu); 610 - fpregs_unlock(); 611 611 612 612 /* 613 613 * Children never inherit PASID state.
+3
drivers/spi/spi-dw-dma.c
··· 128 128 129 129 dw_spi_dma_sg_burst_init(dws); 130 130 131 + pci_dev_put(dma_dev); 132 + 131 133 return 0; 132 134 133 135 free_rxchan: 134 136 dma_release_channel(dws->rxchan); 135 137 dws->rxchan = NULL; 136 138 err_exit: 139 + pci_dev_put(dma_dev); 137 140 return -EBUSY; 138 141 } 139 142
+8 -5
drivers/spi/spi-imx.c
··· 444 444 unsigned int pre, post; 445 445 unsigned int fin = spi_imx->spi_clk; 446 446 447 - if (unlikely(fspi > fin)) 448 - return 0; 447 + fspi = min(fspi, fin); 449 448 450 449 post = fls(fin) - fls(fspi); 451 450 if (fin > fspi << post) ··· 1607 1608 return spi_imx_pio_transfer_slave(spi, transfer); 1608 1609 1609 1610 /* 1611 + * If we decided in spi_imx_can_dma() that we want to do a DMA 1612 + * transfer, the SPI transfer has already been mapped, so we 1613 + * have to do the DMA transfer here. 1614 + */ 1615 + if (spi_imx->usedma) 1616 + return spi_imx_dma_transfer(spi_imx, transfer); 1617 + /* 1610 1618 * Calculate the estimated time in us the transfer runs. Find 1611 1619 * the number of Hz per byte per polling limit. 1612 1620 */ ··· 1623 1617 /* run in polling mode for short transfers */ 1624 1618 if (transfer->len < byte_limit) 1625 1619 return spi_imx_poll_transfer(spi, transfer); 1626 - 1627 - if (spi_imx->usedma) 1628 - return spi_imx_dma_transfer(spi_imx, transfer); 1629 1620 1630 1621 return spi_imx_pio_transfer(spi, transfer); 1631 1622 }
+7 -1
drivers/spi/spi-mt65xx.c
··· 1273 1273 { 1274 1274 struct spi_master *master = platform_get_drvdata(pdev); 1275 1275 struct mtk_spi *mdata = spi_master_get_devdata(master); 1276 + int ret; 1276 1277 1277 - pm_runtime_disable(&pdev->dev); 1278 + ret = pm_runtime_resume_and_get(&pdev->dev); 1279 + if (ret < 0) 1280 + return ret; 1278 1281 1279 1282 mtk_spi_reset(mdata); 1280 1283 ··· 1285 1282 clk_unprepare(mdata->spi_clk); 1286 1283 clk_unprepare(mdata->spi_hclk); 1287 1284 } 1285 + 1286 + pm_runtime_put_noidle(&pdev->dev); 1287 + pm_runtime_disable(&pdev->dev); 1288 1288 1289 1289 return 0; 1290 1290 }
+2 -1
drivers/spi/spi-tegra210-quad.c
··· 924 924 static struct tegra_qspi_client_data *tegra_qspi_parse_cdata_dt(struct spi_device *spi) 925 925 { 926 926 struct tegra_qspi_client_data *cdata; 927 + struct tegra_qspi *tqspi = spi_master_get_devdata(spi->master); 927 928 928 - cdata = devm_kzalloc(&spi->dev, sizeof(*cdata), GFP_KERNEL); 929 + cdata = devm_kzalloc(tqspi->dev, sizeof(*cdata), GFP_KERNEL); 929 930 if (!cdata) 930 931 return NULL; 931 932
+5 -2
fs/fscache/volume.c
··· 203 203 struct fscache_volume *volume; 204 204 struct fscache_cache *cache; 205 205 size_t klen, hlen; 206 - char *key; 206 + u8 *key; 207 + 208 + klen = strlen(volume_key); 209 + if (klen > NAME_MAX) 210 + return NULL; 207 211 208 212 if (!coherency_data) 209 213 coherency_len = 0; ··· 233 229 /* Stick the length on the front of the key and pad it out to make 234 230 * hashing easier. 235 231 */ 236 - klen = strlen(volume_key); 237 232 hlen = round_up(1 + klen + 1, sizeof(__le32)); 238 233 key = kzalloc(hlen, GFP_KERNEL); 239 234 if (!key)
+1 -1
include/linux/fscache.h
··· 75 75 atomic_t n_accesses; /* Number of cache accesses in progress */ 76 76 unsigned int debug_id; 77 77 unsigned int key_hash; /* Hash of key string */ 78 - char *key; /* Volume ID, eg. "afs@example.com@1234" */ 78 + u8 *key; /* Volume ID, eg. "afs@example.com@1234" */ 79 79 struct list_head proc_link; /* Link in /proc/fs/fscache/volumes */ 80 80 struct hlist_bl_node hash_link; /* Link in hash table */ 81 81 struct work_struct work;
+1 -1
include/linux/ring_buffer.h
··· 100 100 101 101 int ring_buffer_wait(struct trace_buffer *buffer, int cpu, int full); 102 102 __poll_t ring_buffer_poll_wait(struct trace_buffer *buffer, int cpu, 103 - struct file *filp, poll_table *poll_table); 103 + struct file *filp, poll_table *poll_table, int full); 104 104 void ring_buffer_wake_waiters(struct trace_buffer *buffer, int cpu); 105 105 106 106 #define RING_BUFFER_ALL_CPUS -1
+2 -2
include/linux/trace.h
··· 26 26 int flags; 27 27 }; 28 28 29 + struct trace_array; 30 + 29 31 #ifdef CONFIG_TRACING 30 32 31 33 int register_ftrace_export(struct trace_export *export); 32 34 int unregister_ftrace_export(struct trace_export *export); 33 - 34 - struct trace_array; 35 35 36 36 void trace_printk_init_buffers(void); 37 37 __printf(3, 4)
+19 -6
kernel/events/core.c
··· 9306 9306 } 9307 9307 9308 9308 if (event->attr.sigtrap) { 9309 - /* 9310 - * Should not be able to return to user space without processing 9311 - * pending_sigtrap (kernel events can overflow multiple times). 9312 - */ 9313 - WARN_ON_ONCE(event->pending_sigtrap && event->attr.exclude_kernel); 9309 + unsigned int pending_id = 1; 9310 + 9311 + if (regs) 9312 + pending_id = hash32_ptr((void *)instruction_pointer(regs)) ?: 1; 9314 9313 if (!event->pending_sigtrap) { 9315 - event->pending_sigtrap = 1; 9314 + event->pending_sigtrap = pending_id; 9316 9315 local_inc(&event->ctx->nr_pending); 9316 + } else if (event->attr.exclude_kernel) { 9317 + /* 9318 + * Should not be able to return to user space without 9319 + * consuming pending_sigtrap; with exceptions: 9320 + * 9321 + * 1. Where !exclude_kernel, events can overflow again 9322 + * in the kernel without returning to user space. 9323 + * 9324 + * 2. Events that can overflow again before the IRQ- 9325 + * work without user space progress (e.g. hrtimer). 9326 + * To approximate progress (with false negatives), 9327 + * check 32-bit hash of the current IP. 9328 + */ 9329 + WARN_ON_ONCE(event->pending_sigtrap != pending_id); 9317 9330 } 9318 9331 event->pending_addr = data->addr; 9319 9332 irq_work_queue(&event->pending_irq);
+7 -1
kernel/kprobes.c
··· 1766 1766 if ((list_p != p) && (list_p->post_handler)) 1767 1767 goto noclean; 1768 1768 } 1769 - ap->post_handler = NULL; 1769 + /* 1770 + * For the kprobe-on-ftrace case, we keep the 1771 + * post_handler setting to identify this aggrprobe 1772 + * armed with kprobe_ipmodify_ops. 1773 + */ 1774 + if (!kprobe_ftrace(ap)) 1775 + ap->post_handler = NULL; 1770 1776 } 1771 1777 noclean: 1772 1778 /*
+17 -2
kernel/rseq.c
··· 171 171 return 0; 172 172 } 173 173 174 + static bool rseq_warn_flags(const char *str, u32 flags) 175 + { 176 + u32 test_flags; 177 + 178 + if (!flags) 179 + return false; 180 + test_flags = flags & RSEQ_CS_NO_RESTART_FLAGS; 181 + if (test_flags) 182 + pr_warn_once("Deprecated flags (%u) in %s ABI structure", test_flags, str); 183 + test_flags = flags & ~RSEQ_CS_NO_RESTART_FLAGS; 184 + if (test_flags) 185 + pr_warn_once("Unknown flags (%u) in %s ABI structure", test_flags, str); 186 + return true; 187 + } 188 + 174 189 static int rseq_need_restart(struct task_struct *t, u32 cs_flags) 175 190 { 176 191 u32 flags, event_mask; 177 192 int ret; 178 193 179 - if (WARN_ON_ONCE(cs_flags & RSEQ_CS_NO_RESTART_FLAGS) || cs_flags) 194 + if (rseq_warn_flags("rseq_cs", cs_flags)) 180 195 return -EINVAL; 181 196 182 197 /* Get thread flags. */ ··· 199 184 if (ret) 200 185 return ret; 201 186 202 - if (WARN_ON_ONCE(flags & RSEQ_CS_NO_RESTART_FLAGS) || flags) 187 + if (rseq_warn_flags("rseq", flags)) 203 188 return -EINVAL; 204 189 205 190 /*
+35 -17
kernel/sched/core.c
··· 4200 4200 return success; 4201 4201 } 4202 4202 4203 + static bool __task_needs_rq_lock(struct task_struct *p) 4204 + { 4205 + unsigned int state = READ_ONCE(p->__state); 4206 + 4207 + /* 4208 + * Since pi->lock blocks try_to_wake_up(), we don't need rq->lock when 4209 + * the task is blocked. Make sure to check @state since ttwu() can drop 4210 + * locks at the end, see ttwu_queue_wakelist(). 4211 + */ 4212 + if (state == TASK_RUNNING || state == TASK_WAKING) 4213 + return true; 4214 + 4215 + /* 4216 + * Ensure we load p->on_rq after p->__state, otherwise it would be 4217 + * possible to, falsely, observe p->on_rq == 0. 4218 + * 4219 + * See try_to_wake_up() for a longer comment. 4220 + */ 4221 + smp_rmb(); 4222 + if (p->on_rq) 4223 + return true; 4224 + 4225 + #ifdef CONFIG_SMP 4226 + /* 4227 + * Ensure the task has finished __schedule() and will not be referenced 4228 + * anymore. Again, see try_to_wake_up() for a longer comment. 4229 + */ 4230 + smp_rmb(); 4231 + smp_cond_load_acquire(&p->on_cpu, !VAL); 4232 + #endif 4233 + 4234 + return false; 4235 + } 4236 + 4203 4237 /** 4204 4238 * task_call_func - Invoke a function on task in fixed state 4205 4239 * @p: Process for which the function is to be invoked, can be @current. ··· 4251 4217 int task_call_func(struct task_struct *p, task_call_f func, void *arg) 4252 4218 { 4253 4219 struct rq *rq = NULL; 4254 - unsigned int state; 4255 4220 struct rq_flags rf; 4256 4221 int ret; 4257 4222 4258 4223 raw_spin_lock_irqsave(&p->pi_lock, rf.flags); 4259 4224 4260 - state = READ_ONCE(p->__state); 4261 - 4262 - /* 4263 - * Ensure we load p->on_rq after p->__state, otherwise it would be 4264 - * possible to, falsely, observe p->on_rq == 0. 4265 - * 4266 - * See try_to_wake_up() for a longer comment. 4267 - */ 4268 - smp_rmb(); 4269 - 4270 - /* 4271 - * Since pi->lock blocks try_to_wake_up(), we don't need rq->lock when 4272 - * the task is blocked. Make sure to check @state since ttwu() can drop 4273 - * locks at the end, see ttwu_queue_wakelist(). 4274 - */ 4275 - if (state == TASK_RUNNING || state == TASK_WAKING || p->on_rq) 4225 + if (__task_needs_rq_lock(p)) 4276 4226 rq = __task_rq_lock(p, &rf); 4277 4227 4278 4228 /*
+3 -2
kernel/trace/ftrace.c
··· 1289 1289 if (!ftrace_mod) 1290 1290 return -ENOMEM; 1291 1291 1292 + INIT_LIST_HEAD(&ftrace_mod->list); 1292 1293 ftrace_mod->func = kstrdup(func, GFP_KERNEL); 1293 1294 ftrace_mod->module = kstrdup(module, GFP_KERNEL); 1294 1295 ftrace_mod->enable = enable; ··· 3191 3190 /* if we can't allocate this size, try something smaller */ 3192 3191 if (!order) 3193 3192 return -ENOMEM; 3194 - order >>= 1; 3193 + order--; 3195 3194 goto again; 3196 3195 } 3197 3196 ··· 7392 7391 } 7393 7392 7394 7393 pr_info("ftrace: allocating %ld entries in %ld pages\n", 7395 - count, count / ENTRIES_PER_PAGE + 1); 7394 + count, DIV_ROUND_UP(count, ENTRIES_PER_PAGE)); 7396 7395 7397 7396 ret = ftrace_process_locs(NULL, 7398 7397 __start_mcount_loc,
+32 -16
kernel/trace/kprobe_event_gen_test.c
··· 73 73 #define KPROBE_GEN_TEST_ARG3 NULL 74 74 #endif 75 75 76 + static bool trace_event_file_is_valid(struct trace_event_file *input) 77 + { 78 + return input && !IS_ERR(input); 79 + } 76 80 77 81 /* 78 82 * Test to make sure we can create a kprobe event, then add more ··· 143 139 kfree(buf); 144 140 return ret; 145 141 delete: 142 + if (trace_event_file_is_valid(gen_kprobe_test)) 143 + gen_kprobe_test = NULL; 146 144 /* We got an error after creating the event, delete it */ 147 145 ret = kprobe_event_delete("gen_kprobe_test"); 148 146 goto out; ··· 208 202 kfree(buf); 209 203 return ret; 210 204 delete: 205 + if (trace_event_file_is_valid(gen_kretprobe_test)) 206 + gen_kretprobe_test = NULL; 211 207 /* We got an error after creating the event, delete it */ 212 208 ret = kprobe_event_delete("gen_kretprobe_test"); 213 209 goto out; ··· 225 217 226 218 ret = test_gen_kretprobe_cmd(); 227 219 if (ret) { 228 - WARN_ON(trace_array_set_clr_event(gen_kretprobe_test->tr, 229 - "kprobes", 230 - "gen_kretprobe_test", false)); 231 - trace_put_event_file(gen_kretprobe_test); 220 + if (trace_event_file_is_valid(gen_kretprobe_test)) { 221 + WARN_ON(trace_array_set_clr_event(gen_kretprobe_test->tr, 222 + "kprobes", 223 + "gen_kretprobe_test", false)); 224 + trace_put_event_file(gen_kretprobe_test); 225 + } 232 226 WARN_ON(kprobe_event_delete("gen_kretprobe_test")); 233 227 } 234 228 ··· 239 229 240 230 static void __exit kprobe_event_gen_test_exit(void) 241 231 { 242 - /* Disable the event or you can't remove it */ 243 - WARN_ON(trace_array_set_clr_event(gen_kprobe_test->tr, 244 - "kprobes", 245 - "gen_kprobe_test", false)); 232 + if (trace_event_file_is_valid(gen_kprobe_test)) { 233 + /* Disable the event or you can't remove it */ 234 + WARN_ON(trace_array_set_clr_event(gen_kprobe_test->tr, 235 + "kprobes", 236 + "gen_kprobe_test", false)); 246 237 247 - /* Now give the file and instance back */ 248 - trace_put_event_file(gen_kprobe_test); 238 + /* Now give the file and instance back */ 239 + trace_put_event_file(gen_kprobe_test); 240 + } 241 + 249 242 250 243 /* Now unregister and free the event */ 251 244 WARN_ON(kprobe_event_delete("gen_kprobe_test")); 252 245 253 - /* Disable the event or you can't remove it */ 254 - WARN_ON(trace_array_set_clr_event(gen_kretprobe_test->tr, 255 - "kprobes", 256 - "gen_kretprobe_test", false)); 246 + if (trace_event_file_is_valid(gen_kretprobe_test)) { 247 + /* Disable the event or you can't remove it */ 248 + WARN_ON(trace_array_set_clr_event(gen_kretprobe_test->tr, 249 + "kprobes", 250 + "gen_kretprobe_test", false)); 257 251 258 - /* Now give the file and instance back */ 259 - trace_put_event_file(gen_kretprobe_test); 252 + /* Now give the file and instance back */ 253 + trace_put_event_file(gen_kretprobe_test); 254 + } 255 + 260 256 261 257 /* Now unregister and free the event */ 262 258 WARN_ON(kprobe_event_delete("gen_kretprobe_test"));
+3 -1
kernel/trace/rethook.c
··· 83 83 { 84 84 struct rethook *rh = kzalloc(sizeof(struct rethook), GFP_KERNEL); 85 85 86 - if (!rh || !handler) 86 + if (!rh || !handler) { 87 + kfree(rh); 87 88 return NULL; 89 + } 88 90 89 91 rh->data = data; 90 92 rh->handler = handler;
+50 -21
kernel/trace/ring_buffer.c
··· 519 519 local_t committing; 520 520 local_t commits; 521 521 local_t pages_touched; 522 + local_t pages_lost; 522 523 local_t pages_read; 523 524 long last_pages_touch; 524 525 size_t shortest_full; ··· 895 894 size_t ring_buffer_nr_dirty_pages(struct trace_buffer *buffer, int cpu) 896 895 { 897 896 size_t read; 897 + size_t lost; 898 898 size_t cnt; 899 899 900 900 read = local_read(&buffer->buffers[cpu]->pages_read); 901 + lost = local_read(&buffer->buffers[cpu]->pages_lost); 901 902 cnt = local_read(&buffer->buffers[cpu]->pages_touched); 903 + 904 + if (WARN_ON_ONCE(cnt < lost)) 905 + return 0; 906 + 907 + cnt -= lost; 908 + 902 909 /* The reader can read an empty page, but not more than that */ 903 910 if (cnt < read) { 904 911 WARN_ON_ONCE(read > cnt + 1); ··· 914 905 } 915 906 916 907 return cnt - read; 908 + } 909 + 910 + static __always_inline bool full_hit(struct trace_buffer *buffer, int cpu, int full) 911 + { 912 + struct ring_buffer_per_cpu *cpu_buffer = buffer->buffers[cpu]; 913 + size_t nr_pages; 914 + size_t dirty; 915 + 916 + nr_pages = cpu_buffer->nr_pages; 917 + if (!nr_pages || !full) 918 + return true; 919 + 920 + dirty = ring_buffer_nr_dirty_pages(buffer, cpu); 921 + 922 + return (dirty * 100) > (full * nr_pages); 917 923 } 918 924 919 925 /* ··· 1070 1046 !ring_buffer_empty_cpu(buffer, cpu)) { 1071 1047 unsigned long flags; 1072 1048 bool pagebusy; 1073 - size_t nr_pages; 1074 - size_t dirty; 1049 + bool done; 1075 1050 1076 1051 if (!full) 1077 1052 break; 1078 1053 1079 1054 raw_spin_lock_irqsave(&cpu_buffer->reader_lock, flags); 1080 1055 pagebusy = cpu_buffer->reader_page == cpu_buffer->commit_page; 1081 - nr_pages = cpu_buffer->nr_pages; 1082 - dirty = ring_buffer_nr_dirty_pages(buffer, cpu); 1056 + done = !pagebusy && full_hit(buffer, cpu, full); 1057 + 1083 1058 if (!cpu_buffer->shortest_full || 1084 1059 cpu_buffer->shortest_full > full) 1085 1060 cpu_buffer->shortest_full = full; 1086 1061 raw_spin_unlock_irqrestore(&cpu_buffer->reader_lock, flags); 1087 - if (!pagebusy && 1088 - (!nr_pages || (dirty * 100) > full * nr_pages)) 1062 + if (done) 1089 1063 break; 1090 1064 } 1091 1065 ··· 1109 1087 * @cpu: the cpu buffer to wait on 1110 1088 * @filp: the file descriptor 1111 1089 * @poll_table: The poll descriptor 1090 + * @full: wait until the percentage of pages are available, if @cpu != RING_BUFFER_ALL_CPUS 1112 1091 * 1113 1092 * If @cpu == RING_BUFFER_ALL_CPUS then the task will wake up as soon 1114 1093 * as data is added to any of the @buffer's cpu buffers. Otherwise ··· 1119 1096 * zero otherwise. 1120 1097 */ 1121 1098 __poll_t ring_buffer_poll_wait(struct trace_buffer *buffer, int cpu, 1122 - struct file *filp, poll_table *poll_table) 1099 + struct file *filp, poll_table *poll_table, int full) 1123 1100 { 1124 1101 struct ring_buffer_per_cpu *cpu_buffer; 1125 1102 struct rb_irq_work *work; 1126 1103 1127 - if (cpu == RING_BUFFER_ALL_CPUS) 1104 + if (cpu == RING_BUFFER_ALL_CPUS) { 1128 1105 work = &buffer->irq_work; 1129 - else { 1106 + full = 0; 1107 + } else { 1130 1108 if (!cpumask_test_cpu(cpu, buffer->cpumask)) 1131 1109 return -EINVAL; 1132 1110 ··· 1135 1111 work = &cpu_buffer->irq_work; 1136 1112 } 1137 1113 1138 - poll_wait(filp, &work->waiters, poll_table); 1139 - work->waiters_pending = true; 1114 + if (full) { 1115 + poll_wait(filp, &work->full_waiters, poll_table); 1116 + work->full_waiters_pending = true; 1117 + } else { 1118 + poll_wait(filp, &work->waiters, poll_table); 1119 + work->waiters_pending = true; 1120 + } 1121 + 1140 1122 /* 1141 1123 * There's a tight race between setting the waiters_pending and 1142 1124 * checking if the ring buffer is empty. Once the waiters_pending bit ··· 1157 1127 * will fix it later. 1158 1128 */ 1159 1129 smp_mb(); 1130 + 1131 + if (full) 1132 + return full_hit(buffer, cpu, full) ? EPOLLIN | EPOLLRDNORM : 0; 1160 1133 1161 1134 if ((cpu == RING_BUFFER_ALL_CPUS && !ring_buffer_empty(buffer)) || 1162 1135 (cpu != RING_BUFFER_ALL_CPUS && !ring_buffer_empty_cpu(buffer, cpu))) ··· 1802 1769 1803 1770 free_buffer_page(cpu_buffer->reader_page); 1804 1771 1805 - rb_head_page_deactivate(cpu_buffer); 1806 - 1807 1772 if (head) { 1773 + rb_head_page_deactivate(cpu_buffer); 1774 + 1808 1775 list_for_each_entry_safe(bpage, tmp, head, list) { 1809 1776 list_del_init(&bpage->list); 1810 1777 free_buffer_page(bpage); ··· 2040 2007 */ 2041 2008 local_add(page_entries, &cpu_buffer->overrun); 2042 2009 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes); 2010 + local_inc(&cpu_buffer->pages_lost); 2043 2011 } 2044 2012 2045 2013 /* ··· 2525 2491 */ 2526 2492 local_add(entries, &cpu_buffer->overrun); 2527 2493 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes); 2494 + local_inc(&cpu_buffer->pages_lost); 2528 2495 2529 2496 /* 2530 2497 * The entries will be zeroed out when we move the ··· 3190 3155 static __always_inline void 3191 3156 rb_wakeups(struct trace_buffer *buffer, struct ring_buffer_per_cpu *cpu_buffer) 3192 3157 { 3193 - size_t nr_pages; 3194 - size_t dirty; 3195 - size_t full; 3196 - 3197 3158 if (buffer->irq_work.waiters_pending) { 3198 3159 buffer->irq_work.waiters_pending = false; 3199 3160 /* irq_work_queue() supplies it's own memory barriers */ ··· 3213 3182 3214 3183 cpu_buffer->last_pages_touch = local_read(&cpu_buffer->pages_touched); 3215 3184 3216 - full = cpu_buffer->shortest_full; 3217 - nr_pages = cpu_buffer->nr_pages; 3218 - dirty = ring_buffer_nr_dirty_pages(buffer, cpu_buffer->cpu); 3219 - if (full && nr_pages && (dirty * 100) <= full * nr_pages) 3185 + if (!full_hit(buffer, cpu_buffer->cpu, cpu_buffer->shortest_full)) 3220 3186 return; 3221 3187 3222 3188 cpu_buffer->irq_work.wakeup_full = true; ··· 5276 5248 local_set(&cpu_buffer->committing, 0); 5277 5249 local_set(&cpu_buffer->commits, 0); 5278 5250 local_set(&cpu_buffer->pages_touched, 0); 5251 + local_set(&cpu_buffer->pages_lost, 0); 5279 5252 local_set(&cpu_buffer->pages_read, 0); 5280 5253 cpu_buffer->last_pages_touch = 0; 5281 5254 cpu_buffer->shortest_full = 0;
+6 -10
kernel/trace/synth_event_gen_test.c
··· 120 120 121 121 /* Now generate a gen_synth_test event */ 122 122 ret = synth_event_trace_array(gen_synth_test, vals, ARRAY_SIZE(vals)); 123 - out: 123 + free: 124 + kfree(buf); 124 125 return ret; 125 126 delete: 126 127 /* We got an error after creating the event, delete it */ 127 128 synth_event_delete("gen_synth_test"); 128 - free: 129 - kfree(buf); 130 - 131 - goto out; 129 + goto free; 132 130 } 133 131 134 132 /* ··· 225 227 226 228 /* Now trace an empty_synth_test event */ 227 229 ret = synth_event_trace_array(empty_synth_test, vals, ARRAY_SIZE(vals)); 228 - out: 230 + free: 231 + kfree(buf); 229 232 return ret; 230 233 delete: 231 234 /* We got an error after creating the event, delete it */ 232 235 synth_event_delete("empty_synth_test"); 233 - free: 234 - kfree(buf); 235 - 236 - goto out; 236 + goto free; 237 237 } 238 238 239 239 static struct synth_field_desc create_synth_test_fields[] = {
+7 -5
kernel/trace/trace.c
··· 6657 6657 mutex_unlock(&trace_types_lock); 6658 6658 6659 6659 free_cpumask_var(iter->started); 6660 + kfree(iter->fmt); 6660 6661 mutex_destroy(&iter->mutex); 6661 6662 kfree(iter); 6662 6663 ··· 6682 6681 return EPOLLIN | EPOLLRDNORM; 6683 6682 else 6684 6683 return ring_buffer_poll_wait(iter->array_buffer->buffer, iter->cpu_file, 6685 - filp, poll_table); 6684 + filp, poll_table, iter->tr->buffer_percent); 6686 6685 } 6687 6686 6688 6687 static __poll_t ··· 7803 7802 int len) 7804 7803 { 7805 7804 struct tracing_log_err *err; 7805 + char *cmd; 7806 7806 7807 7807 if (tr->n_err_log_entries < TRACING_LOG_ERRS_MAX) { 7808 7808 err = alloc_tracing_log_err(len); ··· 7812 7810 7813 7811 return err; 7814 7812 } 7815 - 7813 + cmd = kzalloc(len, GFP_KERNEL); 7814 + if (!cmd) 7815 + return ERR_PTR(-ENOMEM); 7816 7816 err = list_first_entry(&tr->err_log, struct tracing_log_err, list); 7817 7817 kfree(err->cmd); 7818 - err->cmd = kzalloc(len, GFP_KERNEL); 7819 - if (!err->cmd) 7820 - return ERR_PTR(-ENOMEM); 7818 + err->cmd = cmd; 7821 7819 list_del(&err->list); 7822 7820 7823 7821 return err;
+6 -2
kernel/trace/trace_eprobe.c
··· 52 52 kfree(ep->event_system); 53 53 if (ep->event) 54 54 trace_event_put_ref(ep->event); 55 + kfree(ep->filter_str); 55 56 kfree(ep); 56 57 } 57 58 ··· 564 563 { 565 564 struct eprobe_data *edata = data->private_data; 566 565 566 + if (unlikely(!rec)) 567 + return; 568 + 567 569 __eprobe_trace_func(edata, rec); 568 570 } 569 571 ··· 646 642 INIT_LIST_HEAD(&trigger->list); 647 643 648 644 if (ep->filter_str) { 649 - ret = create_event_filter(file->tr, file->event_call, 645 + ret = create_event_filter(file->tr, ep->event, 650 646 ep->filter_str, false, &filter); 651 647 if (ret) 652 648 goto error; ··· 904 900 905 901 static int trace_eprobe_parse_filter(struct trace_eprobe *ep, int argc, const char *argv[]) 906 902 { 907 - struct event_filter *dummy; 903 + struct event_filter *dummy = NULL; 908 904 int i, ret, len = 0; 909 905 char *p; 910 906
+2 -3
kernel/trace/trace_events_synth.c
··· 828 828 } 829 829 830 830 ret = set_synth_event_print_fmt(call); 831 - if (ret < 0) { 831 + /* unregister_trace_event() will be called inside */ 832 + if (ret < 0) 832 833 trace_remove_event_call(call); 833 - goto err; 834 - } 835 834 out: 836 835 return ret; 837 836 err:
-2
kernel/trace/trace_syscalls.c
··· 201 201 return trace_handle_return(s); 202 202 } 203 203 204 - extern char *__bad_type_size(void); 205 - 206 204 #define SYSCALL_FIELD(_type, _name) { \ 207 205 .type = #_type, .name = #_name, \ 208 206 .size = sizeof(_type), .align = __alignof__(_type), \
+13 -11
net/9p/trans_fd.c
··· 120 120 struct list_head unsent_req_list; 121 121 struct p9_req_t *rreq; 122 122 struct p9_req_t *wreq; 123 - char tmp_buf[7]; 123 + char tmp_buf[P9_HDRSZ]; 124 124 struct p9_fcall rc; 125 125 int wpos; 126 126 int wsize; ··· 202 202 203 203 list_for_each_entry_safe(req, rtmp, &m->req_list, req_list) { 204 204 list_move(&req->req_list, &cancel_list); 205 + req->status = REQ_STATUS_ERROR; 205 206 } 206 207 list_for_each_entry_safe(req, rtmp, &m->unsent_req_list, req_list) { 207 208 list_move(&req->req_list, &cancel_list); 209 + req->status = REQ_STATUS_ERROR; 208 210 } 209 211 210 212 spin_unlock(&m->req_lock); ··· 293 291 if (!m->rc.sdata) { 294 292 m->rc.sdata = m->tmp_buf; 295 293 m->rc.offset = 0; 296 - m->rc.capacity = 7; /* start by reading header */ 294 + m->rc.capacity = P9_HDRSZ; /* start by reading header */ 297 295 } 298 296 299 297 clear_bit(Rpending, &m->wsched); ··· 316 314 p9_debug(P9_DEBUG_TRANS, "got new header\n"); 317 315 318 316 /* Header size */ 319 - m->rc.size = 7; 317 + m->rc.size = P9_HDRSZ; 320 318 err = p9_parse_header(&m->rc, &m->rc.size, NULL, NULL, 0); 321 319 if (err) { 322 320 p9_debug(P9_DEBUG_ERROR, 323 321 "error parsing header: %d\n", err); 324 - goto error; 325 - } 326 - 327 - if (m->rc.size >= m->client->msize) { 328 - p9_debug(P9_DEBUG_ERROR, 329 - "requested packet size too big: %d\n", 330 - m->rc.size); 331 - err = -EIO; 332 322 goto error; 333 323 } 334 324 ··· 332 338 if (!m->rreq || (m->rreq->status != REQ_STATUS_SENT)) { 333 339 p9_debug(P9_DEBUG_ERROR, "Unexpected packet tag %d\n", 334 340 m->rc.tag); 341 + err = -EIO; 342 + goto error; 343 + } 344 + 345 + if (m->rc.size > m->rreq->rc.capacity) { 346 + p9_debug(P9_DEBUG_ERROR, 347 + "requested packet size too big: %d for tag %d with capacity %zd\n", 348 + m->rc.size, m->rc.tag, m->rreq->rc.capacity); 335 349 err = -EIO; 336 350 goto error; 337 351 }
+9
net/9p/trans_xen.c
··· 208 208 continue; 209 209 } 210 210 211 + if (h.size > req->rc.capacity) { 212 + dev_warn(&priv->dev->dev, 213 + "requested packet size too big: %d for tag %d with capacity %zd\n", 214 + h.size, h.tag, req->rc.capacity); 215 + req->status = REQ_STATUS_ERROR; 216 + goto recv_error; 217 + } 218 + 211 219 memcpy(&req->rc, &h, sizeof(h)); 212 220 req->rc.offset = 0; 213 221 ··· 225 217 masked_prod, &masked_cons, 226 218 XEN_9PFS_RING_SIZE(ring)); 227 219 220 + recv_error: 228 221 virt_mb(); 229 222 cons += h.size; 230 223 ring->intf->in_cons = cons;