Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1536692 > unrolled thread
| Started by | Kefeng Wang <wangkefeng.wang@huawei.com> |
|---|---|
| First post | 2016-12-06 08:10 +0100 |
| Last post | 2016-12-08 03:30 +0100 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH] kcov: add missing #include <linux/sched.h> Kefeng Wang <wangkefeng.wang@huawei.com> - 2016-12-06 08:10 +0100
Re: [PATCH] kcov: add missing #include <linux/sched.h> Mark Rutland <mark.rutland@arm.com> - 2016-12-06 12:20 +0100
[PATCH] kcov: add more missing include Kefeng Wang <wangkefeng.wang@huawei.com> - 2016-12-08 03:30 +0100
| From | Kefeng Wang <wangkefeng.wang@huawei.com> |
|---|---|
| Date | 2016-12-06 08:10 +0100 |
| Subject | [PATCH] kcov: add missing #include <linux/sched.h> |
| Message-ID | <sLi2Z-7j4-11@gated-at.bofh.it> |
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 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
[toc] | [next] | [standalone]
| From | Mark Rutland <mark.rutland@arm.com> |
|---|---|
| Date | 2016-12-06 12:20 +0100 |
| Message-ID | <sLlWV-1jt-11@gated-at.bofh.it> |
| In reply to | #1536692 |
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 >
[toc] | [prev] | [next] | [standalone]
| From | Kefeng Wang <wangkefeng.wang@huawei.com> |
|---|---|
| Date | 2016-12-08 03:30 +0100 |
| Subject | [PATCH] kcov: add more missing include |
| Message-ID | <sLWD7-8sB-15@gated-at.bofh.it> |
| In reply to | #1536871 |
It is fragile that some definitions acquired via transitive dependencies, as shown in below: atomic_* (<linux/atomic.h>) ENOMEM/EN* (<linux/errno.h>) EXPORT_SYMBOL (<linux/export.h>) device_initcall (<linux/init.h>) preempt_* (<linux/preempt.h>) Include them to prevent possible issues. Suggested-by: Mark Rutland <mark.rutland@arm.com> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com> --- kernel/kcov.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kernel/kcov.c b/kernel/kcov.c index 3cbb0c8..cc2fa35ca 100644 --- a/kernel/kcov.c +++ b/kernel/kcov.c @@ -1,11 +1,16 @@ #define pr_fmt(fmt) "kcov: " fmt #define DISABLE_BRANCH_PROFILING +#include <linux/atomic.h> #include <linux/compiler.h> +#include <linux/errno.h> +#include <linux/export.h> #include <linux/types.h> #include <linux/file.h> #include <linux/fs.h> +#include <linux/init.h> #include <linux/mm.h> +#include <linux/preempt.h> #include <linux/printk.h> #include <linux/sched.h> #include <linux/slab.h> -- 1.7.12.4
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web