linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Vyukov <dvyukov@google.com>
To: Andrey Konovalov <andreyknvl@google.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Alan Stern <stern@rowland.harvard.edu>,
	Andrew Morton <akpm@linux-foundation.org>,
	USB list <linux-usb@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Alexander Potapenko <glider@google.com>,
	Marco Elver <elver@google.com>
Subject: Re: [PATCH v4 5/7] kcov: use t->kcov_mode as enabled indicator
Date: Thu, 4 Jun 2020 15:07:33 +0200	[thread overview]
Message-ID: <CACT4Y+axz_FHFBg7nfDt8C4p5uuUR21_22A_kwKMYTh2mW9FZw@mail.gmail.com> (raw)
In-Reply-To: <f70377945d1d8e6e4916cbce871a12303d6186b4.1585233617.git.andreyknvl@google.com>

On Thu, Mar 26, 2020 at 3:44 PM Andrey Konovalov <andreyknvl@google.com> wrote:
>
> Currently kcov_remote_start() and kcov_remote_stop() check t->kcov to
> find out whether the coverage is already being collected by the
> current task. Use t->kcov_mode for that instead. This doesn't change
> the overall behavior in any way, but serves as a preparation for the
> following softirq coverage collection support patch.
>
> Signed-off-by: Andrey Konovalov <andreyknvl@google.com>

Reviewed-by: Dmitry Vyukov <dvyukov@google.com>

> ---
>  kernel/kcov.c | 32 +++++++++++++++++++++++---------
>  1 file changed, 23 insertions(+), 9 deletions(-)
>
> diff --git a/kernel/kcov.c b/kernel/kcov.c
> index b985b7a72870..e43f06b5b2e4 100644
> --- a/kernel/kcov.c
> +++ b/kernel/kcov.c
> @@ -746,26 +746,33 @@ static const struct file_operations kcov_fops = {
>   * In turns kcov_remote_stop() clears those pointers from task_struct to stop
>   * collecting coverage and copies all collected coverage into the kcov area.
>   */
> +
> +static inline bool kcov_mode_enabled(unsigned int mode)
> +{
> +       return (mode & ~KCOV_IN_CTXSW) != KCOV_MODE_DISABLED;
> +}
> +
>  void kcov_remote_start(u64 handle)
>  {
> +       struct task_struct *t = current;
>         struct kcov_remote *remote;
>         struct kcov *kcov;
> +       unsigned int mode;
>         void *area;
> -       struct task_struct *t;
>         unsigned int size;
> -       enum kcov_mode mode;
>         int sequence;
>
>         if (WARN_ON(!kcov_check_handle(handle, true, true, true)))
>                 return;
>         if (WARN_ON(!in_task()))
>                 return;
> -       t = current;
> +
>         /*
>          * Check that kcov_remote_start is not called twice
>          * nor called by user tasks (with enabled kcov).
>          */
> -       if (WARN_ON(t->kcov))
> +       mode = READ_ONCE(t->kcov_mode);
> +       if (WARN_ON(kcov_mode_enabled(mode)))
>                 return;
>
>         kcov_debug("handle = %llx\n", handle);
> @@ -863,13 +870,20 @@ static void kcov_move_area(enum kcov_mode mode, void *dst_area,
>  void kcov_remote_stop(void)
>  {
>         struct task_struct *t = current;
> -       struct kcov *kcov = t->kcov;
> -       void *area = t->kcov_area;
> -       unsigned int size = t->kcov_size;
> -       int sequence = t->kcov_sequence;
> +       struct kcov *kcov;
> +       unsigned int mode;
> +       void *area;
> +       unsigned int size;
> +       int sequence;
>
> -       if (!kcov)
> +       mode = READ_ONCE(t->kcov_mode);
> +       barrier();
> +       if (!kcov_mode_enabled(mode))
>                 return;
> +       kcov = t->kcov;
> +       area = t->kcov_area;
> +       size = t->kcov_size;
> +       sequence = t->kcov_sequence;
>
>         kcov_stop(t);
>
> --
> 2.26.0.rc2.310.g2932bb562d-goog
>

  reply	other threads:[~2020-06-04 13:07 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-26 14:43 [PATCH v4 0/7] kcov: collect coverage from usb soft interrupts Andrey Konovalov
2020-03-26 14:44 ` [PATCH v4 1/7] kcov: cleanup debug messages Andrey Konovalov
2020-06-04 12:05   ` Dmitry Vyukov
2020-03-26 14:44 ` [PATCH v4 2/7] kcov: fix potential use-after-free in kcov_remote_start Andrey Konovalov
2020-06-04 12:06   ` Dmitry Vyukov
2020-03-26 14:44 ` [PATCH v4 3/7] kcov: move t->kcov assignments into kcov_start/stop Andrey Konovalov
2020-06-04 12:09   ` Dmitry Vyukov
2020-03-26 14:44 ` [PATCH v4 4/7] kcov: move t->kcov_sequence assignment Andrey Konovalov
2020-06-04 13:07   ` Dmitry Vyukov
2020-03-26 14:44 ` [PATCH v4 5/7] kcov: use t->kcov_mode as enabled indicator Andrey Konovalov
2020-06-04 13:07   ` Dmitry Vyukov [this message]
2020-03-26 14:44 ` [PATCH v4 6/7] kcov: collect coverage from interrupts Andrey Konovalov
2020-06-04 13:11   ` Dmitry Vyukov
2020-03-26 14:44 ` [PATCH v4 7/7] usb: core: kcov: collect coverage from usb complete callback Andrey Konovalov
2020-06-04 13:12   ` Dmitry Vyukov
2020-06-04 13:46 ` [PATCH v4 0/7] kcov: collect coverage from usb soft interrupts Andrey Konovalov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CACT4Y+axz_FHFBg7nfDt8C4p5uuUR21_22A_kwKMYTh2mW9FZw@mail.gmail.com \
    --to=dvyukov@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=andreyknvl@google.com \
    --cc=elver@google.com \
    --cc=glider@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).