From: Alex Shi <alex.shi@intel.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: Arnd Bergmann <arnd@arndb.de>,
tglx@linutronix.com, "mingo@redhat.com" <mingo@redhat.com>,
hpa@zytor.com, akpm@linux-foundation.org,
linux-kernel@vger.kernel.org, x86@kernel.org,
andi.kleen@intel.com, gcc-help@gcc.gnu.org
Subject: Re: [RFC patch] spindep: add cross cache lines checking
Date: Tue, 06 Mar 2012 14:13:34 +0800 [thread overview]
Message-ID: <1331014414.18835.254.camel@debian> (raw)
In-Reply-To: <20120305104311.GA18556@elte.hu>
On Mon, 2012-03-05 at 11:43 +0100, Ingo Molnar wrote:
> * Arnd Bergmann <arnd@arndb.de> wrote:
>
> > On Monday 05 March 2012, Alex Shi wrote:
> > > Subject: [PATCH] lockdep: add cross cache lines checking
> > >
> > > Modern x86 CPU won't hold whole memory bus when executing
> > > 'lock' prefixed instructions unless the instruction
> > > destination is crossing 2 cache lines. If so, it is disaster
> > > of system performance.
> > >
> > > Actually if the lock is not in the 'packed' structure, gcc
> > > places it safely under x86 arch. But seems add this checking
> > > in CONFIG_DEBUG_LOCK_ALLOC is harmless.
> >
> > Have you tried making this a compile-time check using
> > __alignof__? I would say that any spinlock in a packed data
> > structure is basically a bug, even more so on most other
> > architectures besides x86.
I have one concern and one questions here:
concern: maybe the lock is in a well designed 'packed' struct, and it is
safe for cross lines issue. but __alignof__ will return 1;
struct abc{
raw_spinlock_t lock1;
char a;
char b;
}__attribute__((packed));
Since the lock is the first object of struct, usually it is well placed.
question: I am a idiot on gcc, I tried some parameters of gcc " --param
l1-cache-line-size=1 -mno-align-double" and can not make a cross lines
variable without 'packed' structure, but I still don't find a grantee
why gcc can avoid the cross line variable if it's not in 'packed'
structure?
> agreed.
>
> Thanks,
>
> Ingo
next prev parent reply other threads:[~2012-03-06 6:13 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-05 3:20 [RFC patch] spin_lock: add cross cache lines checking Alex Shi
2012-03-05 3:24 ` Alex Shi
2012-03-05 5:43 ` [RFC patch] spindep: " Alex Shi
2012-03-05 5:48 ` Alex Shi
2012-03-05 9:41 ` Arnd Bergmann
2012-03-05 10:43 ` Ingo Molnar
2012-03-06 6:13 ` Alex Shi [this message]
2012-03-06 6:18 ` Alex Shi
2012-03-06 9:32 ` Arnd Bergmann
2012-03-07 8:23 ` Alex Shi
2012-03-07 11:54 ` Arnd Bergmann
2012-03-07 13:13 ` Alex Shi
2012-03-07 13:39 ` Ingo Molnar
2012-03-08 2:21 ` Alex Shi
2012-03-08 7:13 ` Ingo Molnar
2012-03-09 1:20 ` Alex Shi
2012-03-08 2:30 ` Alex Shi
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=1331014414.18835.254.camel@debian \
--to=alex.shi@intel.com \
--cc=akpm@linux-foundation.org \
--cc=andi.kleen@intel.com \
--cc=arnd@arndb.de \
--cc=gcc-help@gcc.gnu.org \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.com \
--cc=x86@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