From: "Luis R. Rodriguez" <mcgrof@suse.com>
To: Stephen Warren <swarren@wwwdotorg.org>
Cc: "Luis R. Rodriguez" <mcgrof@do-not-panic.com>,
hpa@linux.intel.com, akpm@linux-foundation.org,
linux-kernel@vger.kernel.org, Andrew Lunn <andrew@lunn.ch>,
Michal Hocko <mhocko@suse.cz>, Petr Mladek <pmladek@suse.cz>,
Joe Perches <joe@perches.com>, Arun KS <arunks.linux@gmail.com>,
Kees Cook <keescook@chromium.org>,
Davidlohr Bueso <davidlohr@hp.com>,
Chris Metcalf <cmetcalf@tilera.com>
Subject: Re: [RFT 1/2] printk: make dynamic kernel ring buffer alignemnt explicit
Date: Wed, 18 Jun 2014 22:03:33 +0200 [thread overview]
Message-ID: <20140618200333.GP4841@wotan.suse.de> (raw)
In-Reply-To: <53A1EC8A.3070209@wwwdotorg.org>
On Wed, Jun 18, 2014 at 01:46:18PM -0600, Stephen Warren wrote:
> On 06/18/2014 01:33 PM, Luis R. Rodriguez wrote:
> > On Wed, Jun 18, 2014 at 09:56:03AM -0600, Stephen Warren wrote:
> >> On 06/18/2014 05:14 AM, Luis R. Rodriguez wrote:
> >>> From: "Luis R. Rodriguez" <mcgrof@suse.com>
> >>>
> >>> We have to consider alignment for the ring buffer both for the
> >>> default static size, and then also for when an dynamic allocation
> >>> is made when the log_buf_len=n kernel parameter is passed to set
> >>> the size specifically to a size larger than the default size set
> >>> by the architecture through CONFIG_LOG_BUF_SHIFT.
> >>>
> >>> The default static kernel ring buffer can be aligned properly if
> >>> architectures set CONFIG_LOG_BUF_SHIFT properly, we provide ranges
> >>> for the size though so even if CONFIG_LOG_BUF_SHIFT has a sensible
> >>> aligned value it can be reduced to a non aligned value. Commit
> >>> 6ebb017de9 by Andrew ensures the static buffer is always aligned
> >>> and the decision of alignment is done by the compiler by using
> >>> __alignof__(struct log) (curious what value caused the crash?).
> >>
> >> IIRC the issue was that __log_buf's type is char[] so without the
> >> __aligned it could have any alignment at all, e.g. 1 or 2. However,
> >> struct printk_log is stored in the buffer rather than just char*, and so
> >> if __log_buf isn't aligned to the required alignment for that structure,
> >> that can caused unaligned accesses to fields in the structure, which
> >> isn't supported on ARM in at least some cases.
> >>
> >> As such, I think the change to setup_log_buf() in this patch makes sense
> >> (although I suppose in practice memblock_virt_alloc() probably has some
> >> minimum internal alignment that dwards LOG_ALIGN, but that's an
> >> implementation detail we shouldn't rely on).
> >
> > Thanks for the feedback.
> >
> > memblock_virt_alloc() will by default align to L1 cache, so if that satisfies
> > the architecture alignment it should be safe, but perhaps not optimal for
> > saving a few bytes. Still curious if without this patch a crash can be
> > triggered somehow with some log_buf_len=n, if so this can go to stable.
>
> If memblock_virt_alloc() aligns to L1 cache, then I believe that the
> crash would never trigger.
By default it does, that is, if no alignment requirement is passed.
Luis
prev parent reply other threads:[~2014-06-18 20:03 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-18 11:14 [RFT 1/2] printk: make dynamic kernel ring buffer alignemnt explicit Luis R. Rodriguez
2014-06-18 11:14 ` [RFT 2/2] printk: allow increasing the ring buffer depending on the number of CPUs Luis R. Rodriguez
2014-06-18 15:42 ` Petr Mládek
2014-06-18 20:43 ` Luis R. Rodriguez
2014-06-18 18:11 ` Davidlohr Bueso
2014-06-18 18:14 ` Davidlohr Bueso
2014-06-18 19:21 ` Luis R. Rodriguez
2014-06-18 15:40 ` [RFT 1/2] printk: make dynamic kernel ring buffer alignemnt explicit Petr Mládek
2014-06-18 15:56 ` Stephen Warren
2014-06-18 19:33 ` Luis R. Rodriguez
2014-06-18 19:46 ` Stephen Warren
2014-06-18 20:03 ` Luis R. Rodriguez [this message]
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=20140618200333.GP4841@wotan.suse.de \
--to=mcgrof@suse.com \
--cc=akpm@linux-foundation.org \
--cc=andrew@lunn.ch \
--cc=arunks.linux@gmail.com \
--cc=cmetcalf@tilera.com \
--cc=davidlohr@hp.com \
--cc=hpa@linux.intel.com \
--cc=joe@perches.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mcgrof@do-not-panic.com \
--cc=mhocko@suse.cz \
--cc=pmladek@suse.cz \
--cc=swarren@wwwdotorg.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