mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Christoph Lameter <cl@linux.com>
Cc: Tejun Heo <tj@kernel.org>,
	akpm@linuxfoundation.org, Steven Rostedt <srostedt@redhat.com>,
	linux-kernel@vger.kernel.org, Ingo Molnar <mingo@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [pchecks v2 2/2] percpu: Add preemption checks to __this_cpu ops
Date: Fri, 4 Oct 2013 10:27:28 +0200	[thread overview]
Message-ID: <20131004082728.GG3081@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <000001417f93fb74-f307f391-26a4-431a-8295-04c5319d1373-000000@email.amazonses.com>

On Thu, Oct 03, 2013 at 06:28:26PM +0000, Christoph Lameter wrote:
> @@ -538,7 +544,8 @@ do {									\
>  # ifndef __this_cpu_read_8
>  #  define __this_cpu_read_8(pcp)	(*__this_cpu_ptr(&(pcp)))
>  # endif
> -# define __this_cpu_read(pcp)	__pcpu_size_call_return(__this_cpu_read_, (pcp))
> +# define __this_cpu_read(pcp) \
> +	(__this_cpu_preempt_check(),__pcpu_size_call_return(__this_cpu_read_, (pcp)))
>  #endif

Would it not be move convenient to implement it in terms of the
raw_this_cpu*() thingies? That way you're sure they actually do the same
thing and there's only 1 site to change when changing the
implementation.

Something like:

#define __this_cpu_read(pcp) 						\
({									\
	__this_cpu_preempt_check();					\
	raw_this_cpu_read(pcp);						\
})



> @@ -39,8 +39,8 @@ notrace unsigned int debug_smp_processor
>  	if (!printk_ratelimit())
>  		goto out_enable;
>  
> -	printk(KERN_ERR "BUG: using smp_processor_id() in preemptible [%08x] "
> -			"code: %s/%d\n",
> +	printk(KERN_ERR "%s in preemptible [%08x] "
> +			"code: %s/%d\n", what,
>  			preempt_count() - 1, current->comm, current->pid);

I would argue for keeping the "BUG" string intact and in front of the
%s.

>  	print_symbol("caller is %s\n", (long)__builtin_return_address(0));
>  	dump_stack();
> @@ -51,5 +51,17 @@ out:
>  	return this_cpu;
>  }
>  
> +notrace unsigned int debug_smp_processor_id(void)
> +{
> +	return check_preemption_disabled("BUG: using smp_processor_id()");
> +}
>  EXPORT_SYMBOL(debug_smp_processor_id);
>  
> +notrace void __this_cpu_preempt_check(void)
> +{
> +#ifdef CONFIG_DEBUG_THIS_CPU_OPERATIONS
> +	check_preemption_disabled("__this_cpu operation");
> +#endif

Because here you've forgotten it..

> +}
> +EXPORT_SYMBOL(__this_cpu_preempt_check);

  reply	other threads:[~2013-10-04  8:27 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20131003182902.174251532@linux.com>
2013-10-03 18:28 ` Christoph Lameter
2013-10-04  8:27   ` Peter Zijlstra [this message]
2013-10-04  8:37     ` Ingo Molnar
2013-10-04 15:27     ` Christoph Lameter
2013-10-04 16:52       ` Peter Zijlstra
2013-10-04 17:26         ` Christoph Lameter
2013-10-03 18:28 ` [pchecks v2 1/2] percpu: Add raw_cpu_ops Christoph Lameter
     [not found] <20130924154159.855373283@linux.com>
2013-09-24 15:41 ` [pchecks v2 2/2] percpu: Add preemption checks to __this_cpu ops Christoph Lameter
2013-09-24 17:10   ` Ingo Molnar
2013-09-25 16:40     ` Christoph Lameter
2013-09-25 18:11       ` Ingo Molnar
2013-09-27 13:54         ` Christoph Lameter
2013-09-28  8:39           ` Ingo Molnar
2013-10-02 15:11             ` Christoph Lameter
2013-10-03  7:26               ` Ingo Molnar
2013-09-28  8:44           ` Ingo Molnar
2013-10-02 15:08             ` Christoph Lameter
2013-10-03  7:21               ` Ingo Molnar
2013-10-03 13:55                 ` Peter Zijlstra
2013-10-03 14:15                 ` Christoph Lameter
2013-10-03 15:35                   ` Ingo Molnar
2013-10-03 15:59                     ` Christoph Lameter
2013-10-03 16:44                       ` Ingo Molnar

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=20131004082728.GG3081@twins.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=akpm@linuxfoundation.org \
    --cc=cl@linux.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=srostedt@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=tj@kernel.org \
    /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

Powered by JetHome