lkml.org 
[lkml]   [2012]   [Mar]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [RFC patch] spindep: add cross cache lines checking
Date
On Tuesday 06 March 2012, Alex Shi wrote:
> 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.

No, it's actually not. The structure has an external alignment of 1, so
if you have an array of these or put it into another struct like

struct xyz {
char x;
struct abc a;
};

then it will be misaligned. Thre is no such thing as a well designed 'packed'
struct. The only reason to use packing is to describe structures we have no
control over such as hardware layouts and on-wire formats that have unusal
alignments, and those will never have a spinlock on them.

Arnd


\
 
 \ /
  Last update: 2012-03-06 10:37    [W:0.051 / U:33.336 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site