LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Waiman Long <longman@redhat.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>, Will Deacon <will.deacon@arm.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Borislav Petkov <bp@alien8.de>, "H. Peter Anvin" <hpa@zytor.com>,
	Linux List Kernel Mailing <linux-kernel@vger.kernel.org>,
	the arch/x86 maintainers <x86@kernel.org>,
	Davidlohr Bueso <dave@stgolabs.net>,
	Tim Chen <tim.c.chen@linux.intel.com>,
	huang ying <huang.ying.caritas@gmail.com>
Subject: Re: [PATCH] locking/lock_events: Use this_cpu_add() when necessary
Date: Wed, 22 May 2019 16:50:30 -0400	[thread overview]
Message-ID: <65f36604-898d-2649-5a41-078ccdc08dc4@redhat.com> (raw)
In-Reply-To: <CAHk-=wjit1=wf-JxUebS4_9WUCKbnfGPt0QF13-LijmumMEB-Q@mail.gmail.com>

On 5/22/19 3:54 PM, Linus Torvalds wrote:
> On Wed, May 22, 2019 at 8:40 AM Waiman Long <longman@redhat.com> wrote:
>> +#if defined(CONFIG_PREEMPT) && \
>> +   (defined(CONFIG_DEBUG_PREEMPT) || !defined(CONFIG_X86))
>> +#define lockevent_percpu_inc(x)                this_cpu_inc(x)
>> +#define lockevent_percpu_add(x, v)     this_cpu_add(x, v)
> Why that CONFIG_X86 special case?
>
> On x86, the regular non-underscore versionm is perfectly fine, and the
> underscore is no faster or simpler.

The condition is to use non-underscore version only when

1) It is a preempt kernel; AND
2) It either have CONFIG_DEBUG_PREEMPT on, OR it is a non-x86 system.


> So just make it be
>
>    #if defined(CONFIG_PREEMPT)
>      .. non-underscore versions..
>    #else
>      .. underscore versions ..
>    #endif
>
> and realize that x86 simply doesn't _care_. On x86, it will be one
> single instruction regardless.
>
> Non-x86 may prefer the underscore versions for the non-preempt case.

I was thinking of doing that originally, but then change it so x86
preempt kernel will also use the underscore version as long as
CONFIG_DEBUG_PREEMPT is not set.

I can change it back if that makes it less confusing.

Cheers,
Longman


  reply	other threads:[~2019-05-22 20:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-22 15:39 Waiman Long
2019-05-22 19:54 ` Linus Torvalds
2019-05-22 20:50   ` Waiman Long [this message]
2019-05-23 14:58   ` Will Deacon
2019-05-24 17:00     ` Waiman Long

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=65f36604-898d-2649-5a41-078ccdc08dc4@redhat.com \
    --to=longman@redhat.com \
    --cc=bp@alien8.de \
    --cc=dave@stgolabs.net \
    --cc=hpa@zytor.com \
    --cc=huang.ying.caritas@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=tim.c.chen@linux.intel.com \
    --cc=torvalds@linux-foundation.org \
    --cc=will.deacon@arm.com \
    --cc=x86@kernel.org \
    --subject='Re: [PATCH] locking/lock_events: Use this_cpu_add() when necessary' \
    /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

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).