linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mark Rutland <mark.rutland@arm.com>
To: Kefeng Wang <wangkefeng.wang@huawei.com>
Cc: linux-kernel@vger.kernel.org, Dmitry Vyukov <dvyukov@google.com>,
	Andrey Ryabinin <aryabinin@virtuozzo.com>,
	James Morse <james.morse@arm.com>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] kcov: add missing #include <linux/sched.h>
Date: Tue, 6 Dec 2016 11:09:05 +0000	[thread overview]
Message-ID: <20161206110905.GA24177@leverpostej> (raw)
In-Reply-To: <1481007384-27529-1-git-send-email-wangkefeng.wang@huawei.com>

On Tue, Dec 06, 2016 at 02:56:24PM +0800, Kefeng Wang wrote:
> It is needed by struct task_struct, fixes the following build problem
> with old gcc:
> 
> ../kernel/kcov.c: In function ‘__sanitizer_cov_trace_pc’:
> ../kernel/kcov.c:66: error: dereferencing pointer to incomplete type
> 	......
> ../kernel/kcov.c:239: error: dereferencing pointer to incomplete type
> 

It's somewhat confusing to strip the useful part of the error message
(which mentions task struct).

How about:

  In __sanitizer_cov_trace_pc we use task_struct and fields within it,
  but as we haven't included <linux/sched.h>, it is not guaranteed to be
  defined. While we usually happen to acquire the definition through a
  transitive include, this is fragile (and hasn't been true in the past,
  causing issues with backports).

  Include <linux/sched.h> to avoid any fragility.

Either way this looks like a sensible fix/cleanup, so FWIW:

Acked-by: Mark Rutland <mark.rutland@arm.com>

It looks like we're missing some other headers (e.g. <linux/export.h>
for EXPORT_SYMBOL(), <linux/preempt.h> for preempt_count() and friends).
It may be worth fixing all of those at once.

Thanks,
Mark.

> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> ---
> 
> note:
> - Build error occurred when I backported kcov to an old kernel version
>   with an old gcc
> 
>  kernel/kcov.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/kernel/kcov.c b/kernel/kcov.c
> index 30e6d05..3cbb0c8 100644
> --- a/kernel/kcov.c
> +++ b/kernel/kcov.c
> @@ -7,6 +7,7 @@
>  #include <linux/fs.h>
>  #include <linux/mm.h>
>  #include <linux/printk.h>
> +#include <linux/sched.h>
>  #include <linux/slab.h>
>  #include <linux/spinlock.h>
>  #include <linux/vmalloc.h>
> -- 
> 1.7.12.4
> 

  reply	other threads:[~2016-12-06 11:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-06  6:56 [PATCH] kcov: add missing #include <linux/sched.h> Kefeng Wang
2016-12-06 11:09 ` Mark Rutland [this message]
2016-12-08  2:13   ` [PATCH] kcov: add more missing include Kefeng Wang

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=20161206110905.GA24177@leverpostej \
    --to=mark.rutland@arm.com \
    --cc=akpm@linux-foundation.org \
    --cc=aryabinin@virtuozzo.com \
    --cc=dvyukov@google.com \
    --cc=james.morse@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=wangkefeng.wang@huawei.com \
    /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).