All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <srostedt@redhat.com>
To: Jaswinder Singh Rajput <jaswinder@kernel.org>
Cc: Ingo Molnar <mingo@elte.hu>,
	Stephen Rothwell <sfr@canb.auug.org.au>,
	Thomas Gleixner <tglx@linutronix.de>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Peter Zijlstra <peterz@infradead.org>,
	linux-next@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-sparse@vger.kernel.org, Christopher Li <sparse@chrisli.org>,
	Josh Triplett <josh@freedesktop.org>
Subject: Re: Warning from ring buffer code (Was: Re: linux-next: tip tree build warning)
Date: Mon, 14 Sep 2009 11:16:56 -0400	[thread overview]
Message-ID: <1252941416.2964.143.camel@localhost.localdomain> (raw)
In-Reply-To: <1252753957.12217.10.camel@ht.satnam>

On Sat, 2009-09-12 at 16:42 +0530, Jaswinder Singh Rajput wrote:

> 
> Here are some more trace related warnings in current linus (as well as
> -tip) tree :
> 
>   CHECK   arch/x86/kernel/ptrace.c
> include/trace/events/syscalls.h:18:1: warning: symbol 'ftrace_raw_output_sys_enter' was not declared. Should it be static?
> include/trace/events/syscalls.h:42:1: warning: symbol 'ftrace_raw_output_sys_exit' was not declared. Should it be static?
> include/trace/events/syscalls.h:18:1: warning: symbol 'ftrace_define_fields_sys_enter' was not declared. Should it be static?
> include/trace/events/syscalls.h:42:1: warning: symbol 'ftrace_define_fields_sys_exit' was not declared. Should it be static?

I just wrote a patch to fix the above.

> include/trace/events/syscalls.h:18:1: error: bad constant expression
> include/trace/events/syscalls.h:42:1: error: bad constant expression

Not sure why sparse is failing on this. Looking at the sched.c code, I
ran "make kernel/sched.i" and then removed the CPP expressions and then
expanded the macros and here's where it is failing:

static void ftrace_profile_sched_kthread_stop(struct task_struct *t)
{
	struct ftrace_data_offsets_sched_kthread_stop __attribute__((unused)) __data_offsets;
	struct ftrace_event_call *event_call = &event_sched_kthread_stop;
	extern void perf_tpcounter_event(int, u64, u64, void *, int);
	struct ftrace_raw_sched_kthread_stop *entry;
	u64 __addr = 0, __count = 1;
	unsigned long irq_flags;
	
	int __entry_size;
	int __data_size;
	int pc;

	do { ({ unsigned long __dummy;
				typeof(irq_flags) __dummy2;
				(void)(&__dummy == &__dummy2);
				1;
			});
		do { (irq_flags) = __raw_local_save_flags();
		} while (0);
	} while (0);
	pc = (current_thread_info()->preempt_count);
	__data_size = ftrace_get_offsets_sched_kthread_stop(&__data_offsets, t);
	__entry_size = (((__data_size + sizeof(*entry) + sizeof(u32))+((typeof(__data_size + sizeof(*entry) + sizeof(u32)))(sizeof(u64))-1))&~((typeof(__data_size + sizeof(*entry) + sizeof(u32)))(sizeof(u64))-1));
	__entry_size -= sizeof(u32);
	do {
		char raw_data[__entry_size];   <<<<----------- FAILURE HERE
		struct trace_entry *ent;
		*(u64 *)(&raw_data[__entry_size - sizeof(u64)]) = 0ULL;
		entry = (struct ftrace_raw_sched_kthread_stop *)raw_data;
		ent = &entry->ent;
		tracing_generic_entry_update(ent, irq_flags, pc);
		ent->type = event_call->id;
		{ memcpy(entry->comm, t->comm, 16);
			entry->pid = t->pid;
			;
		} perf_tpcounter_event(event_call->id, __addr, __count, entry, __entry_size);
	} while (0);
};

Sure enough, sparse does not like the __entry_size. I replaced it with
"10" and sparse was happy with it. That is a perfectly legal entry, so
this looks more like a bug with sparse.

I just tested this too:

static void func(int size_me) {
	char array[size_me];

	memcpy(array, "hello", size);
};

and sparse failed on it as well. Note, you need to have something call
func, or sparse will ignore it.


-- Steve



  reply	other threads:[~2009-09-14 15:16 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-04  6:16 linux-next: tip tree build warning Stephen Rothwell
2009-08-04 16:24 ` Steven Rostedt
2009-09-12  6:53   ` Warning from ring buffer code (Was: Re: linux-next: tip tree build warning) Stephen Rothwell
2009-09-12  7:39     ` Ingo Molnar
2009-09-12 10:46       ` Stephen Rothwell
2009-09-12 11:12       ` Jaswinder Singh Rajput
2009-09-14 15:16         ` Steven Rostedt [this message]
2009-09-14 17:09           ` Christopher Li
2009-09-14 17:09             ` Christopher Li
2009-09-14 18:17             ` Steven Rostedt
2009-09-14 18:17               ` Steven Rostedt
2009-09-14 18:23               ` Peter Zijlstra
2009-09-14 18:23                 ` Peter Zijlstra
2009-09-14 18:31                 ` Steven Rostedt
2009-09-14 18:31                   ` Steven Rostedt
2009-09-14 18:41                   ` Frederic Weisbecker
2009-09-15  7:16                     ` Peter Zijlstra
2009-09-15  9:01                       ` Frédéric Weisbecker
2009-09-15  9:01                         ` Frédéric Weisbecker
2009-09-14 18:38               ` Frederic Weisbecker
2009-09-14 13:50       ` Steven Rostedt
2009-09-14 13:53         ` Ingo Molnar
2009-09-14 22:36         ` Stephen Rothwell

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=1252941416.2964.143.camel@localhost.localdomain \
    --to=srostedt@redhat.com \
    --cc=hpa@zytor.com \
    --cc=jaswinder@kernel.org \
    --cc=josh@freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=linux-sparse@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=peterz@infradead.org \
    --cc=sfr@canb.auug.org.au \
    --cc=sparse@chrisli.org \
    --cc=tglx@linutronix.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.