From: James Hogan <james.hogan@imgtec.com>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org,
Peter Zijlstra <peterz@infradead.org>,
Daniel Santos <daniel.santos@pobox.com>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
linux-next <linux-next@vger.kernel.org>,
linux-metag <linux-metag@vger.kernel.org>
Subject: Re: [PATCH] compiler.h: don't use temporary variable in __compiletime_assert()
Date: Mon, 12 May 2014 15:56:57 +0100 [thread overview]
Message-ID: <5370E139.50806@imgtec.com> (raw)
In-Reply-To: <1399905481.4337.16.camel@jlt4.sipsolutions.net>
Hi Johannes,
On 12/05/14 15:38, Johannes Berg wrote:
>> Unfortunately this breaks the build of today's linux-next for the Meta
>> architecture (arch/metag), which happens to use a fairly old compiler
>> (based on gcc 4.2.4) which I presume is the reason why.
>
> That's very odd.
>
> Unfortunately, I don't have most of arch/metag, it seems, where could I
> get it? In particular no gup.c exists for metag in Linus's current tree.
Hmm, mm/gup.c appears to be a new addition in linux-next from commit
3284cee59933 (mm: move get_user_pages()-related code to separate file)
so probably wasn't the best example.
My build output was from commit 0bed496ac091 (compiler.h: don't use
temporary variable in __compiletime_assert()) which is the first bad
commit according to a bisection of linux-next/stable..linux-next/master.
>> A bunch of compile time asserts fail, even in code which should be
>> optimised out. E.g. here's one which I analysed:
>>
>> mm/gup.c: In function ‘follow_page_mask’:
>> mm/gup.c:208: error: size of array ‘type name’ is negative
>>
>> Line 208 uses HPAGE_PMD_NR which expands to a HPAGE_PMD_SHIFT, which
>> expands to a BUILD_BUG(). However that line is inside an if block
>> conditioned on pmd_trans_huge(*pmd) which include/asm-generic/pgtable.h
>> defines inline to return 0, so the whole block should already be being
>> optimised out.
>>
>> I don't understand why your patch should break things, I suspect it's
>> related to the sparse behaviour you're trying to work around, but can we
>> please drop this patch until a more portable workaround can be found?
>> I'm happy to test further patches with metag if it helps.
>
> I don't really understand that either - if the compiler could prove that
> the assignment to __cond was a constant, and remember that __cond is now
> constant, I don't really see why it can't follow that through and
> consider "!(condition)" a const??
>
> I suppose the other option for the original problem is to ignore
> _compiletime_assert() for sparse, like we do for BUG_ON(), but it'd
> probably be good to analyse more why this particular code is broken now.
The first one I analysed was strange too (the fixmap.h one). It appears
that this particular assert was questionable anyway for metag which is
why I didn't mention it, the case above is much more clear cut.
Given an unsigned int idx argument the inline function fix_to_virt
basically did:
BUILD_BUG_ON(idx >= __end_of_fixed_addresses)
where __end_of_fixed_addresses is an enum value which is 0 when
CONFIG_HIGHMEM=n. In that case it took your patch for the compiler to
apparently realise that an unsigned int is always >= 0, therefore the
BUILD_BUG_ON will always fire, even though nothing actually called
fix_to_virt from that source file so the code wasn't being used. I
briefly attempted to reproduce this issue on other arches with newer
compilers without success.
Cheers
James
next prev parent reply other threads:[~2014-05-12 14:57 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1399530685-7749-1-git-send-email-johannes@sipsolutions.net>
2014-05-12 13:42 ` [PATCH] compiler.h: don't use temporary variable in __compiletime_assert() James Hogan
2014-05-12 14:38 ` Johannes Berg
2014-05-12 14:56 ` James Hogan [this message]
2014-05-12 21:16 ` Andrew Morton
2014-05-13 7:31 ` Johannes Berg
2014-05-13 8:53 ` James Hogan
2014-05-13 9:26 ` Johannes Berg
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=5370E139.50806@imgtec.com \
--to=james.hogan@imgtec.com \
--cc=akpm@linux-foundation.org \
--cc=daniel.santos@pobox.com \
--cc=johannes@sipsolutions.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-metag@vger.kernel.org \
--cc=linux-next@vger.kernel.org \
--cc=paulmck@linux.vnet.ibm.com \
--cc=peterz@infradead.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