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

Configure Feed

Select the types of activity you want to include in your feed.

vhost, kcov: collect coverage from vhost_worker

Add kcov_remote_start()/kcov_remote_stop() annotations to the
vhost_worker() function, which is responsible for processing vhost
works.

Since vhost_worker() threads are spawned per vhost device instance the
common kcov handle is used for kcov_remote_start()/stop() annotations
(see Documentation/dev-tools/kcov.rst for details). As the result kcov
can now be used to collect coverage from vhost worker threads.

Link: http://lkml.kernel.org/r/e49d5d154e5da6c9ada521d2b7ce10a49ce9f98b.1572366574.git.andreyknvl@google.com
Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Alexander Potapenko <glider@google.com>
Cc: Anders Roxell <anders.roxell@linaro.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: David Windsor <dwindsor@gmail.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Elena Reshetova <elena.reshetova@intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jason Wang <jasowang@redhat.com>
Cc: Marco Elver <elver@google.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Andrey Konovalov and committed by
Linus Torvalds
8f6a7f96 95d23dc2

+7
+6
drivers/vhost/vhost.c
··· 30 30 #include <linux/sched/signal.h> 31 31 #include <linux/interval_tree_generic.h> 32 32 #include <linux/nospec.h> 33 + #include <linux/kcov.h> 33 34 34 35 #include "vhost.h" 35 36 ··· 358 357 llist_for_each_entry_safe(work, work_next, node, node) { 359 358 clear_bit(VHOST_WORK_QUEUED, &work->flags); 360 359 __set_current_state(TASK_RUNNING); 360 + kcov_remote_start_common(dev->kcov_handle); 361 361 work->fn(work); 362 + kcov_remote_stop(); 362 363 if (need_resched()) 363 364 schedule(); 364 365 } ··· 549 546 550 547 /* No owner, become one */ 551 548 dev->mm = get_task_mm(current); 549 + dev->kcov_handle = kcov_common_handle(); 552 550 worker = kthread_create(vhost_worker, dev, "vhost-%d", current->pid); 553 551 if (IS_ERR(worker)) { 554 552 err = PTR_ERR(worker); ··· 575 571 if (dev->mm) 576 572 mmput(dev->mm); 577 573 dev->mm = NULL; 574 + dev->kcov_handle = 0; 578 575 err_mm: 579 576 return err; 580 577 } ··· 687 682 if (dev->worker) { 688 683 kthread_stop(dev->worker); 689 684 dev->worker = NULL; 685 + dev->kcov_handle = 0; 690 686 } 691 687 if (dev->mm) 692 688 mmput(dev->mm);
+1
drivers/vhost/vhost.h
··· 173 173 int iov_limit; 174 174 int weight; 175 175 int byte_weight; 176 + u64 kcov_handle; 176 177 }; 177 178 178 179 bool vhost_exceeds_weight(struct vhost_virtqueue *vq, int pkts, int total_len);