[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1415985728.5912.17.camel@perches.com>
Date: Fri, 14 Nov 2014 09:22:08 -0800
From: Joe Perches <joe@...ches.com>
To: Andrey Ryabinin <a.ryabinin@...sung.com>
Cc: linux-kernel@...r.kernel.org,
Andrew Morton <akpm@...ux-foundation.org>,
Peter Zijlstra <peterz@...radead.org>,
Sasha Levin <sasha.levin@...cle.com>,
Randy Dunlap <rdunlap@...radead.org>,
Rasmus Villemoes <linux@...musvillemoes.dk>,
Jonathan Corbet <corbet@....net>,
Michal Marek <mmarek@...e.cz>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>,
"H. Peter Anvin" <hpa@...or.com>,
Yury Gribov <y.gribov@...sung.com>,
Dmitry Vyukov <dvyukov@...gle.com>,
Konstantin Khlebnikov <koct9i@...il.com>, x86@...nel.org,
linux-doc@...r.kernel.org, linux-kbuild@...r.kernel.org
Subject: Re: [PATCH v2 1/2] kernel: printk: specify alignment for struct
printk_log
On Fri, 2014-11-14 at 15:50 +0300, Andrey Ryabinin wrote:
> On architectures that have support for efficient unaligned access
> struct printk_log has 4-byte alignment.
> Specify alignment attribute in type declaration.
>
> The whole point of this patch is to fix deadlock which happening
> when UBSan detects unaligned access in printk() thus UBSan recursively
> calls printk() with logbuf_lock held by top printk() call.
[]
> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
[]
> @@ -223,7 +223,11 @@ struct printk_log {
> u8 facility; /* syslog facility */
> u8 flags:5; /* internal record flags */
> u8 level:3; /* syslog level */
> -};
> +}
> +#ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
> +__packed __aligned(4)
> +#endif
Why is adding __packed useful or __aligned(4) useful?
The struct is naturally aligned on u64 and should be
the size of 2 u64s.
struct printk_log {
u64 ts_nsec; /* timestamp in nanoseconds */
u16 len; /* length of entire record */
u16 text_len; /* length of text buffer */
u16 dict_len; /* length of dictionary buffer */
u8 facility; /* syslog facility */
u8 flags:5; /* internal record flags */
u8 level:3; /* syslog level */
};
Is there any case when it's not sizeof(u64) * 2?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists