linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Nikolay Borisov <nborisov@suse.com>
Cc: Chris Mason <clm@fb.com>, Josef Bacik <josef@toxicpanda.com>,
	David Sterba <dsterba@suse.com>,
	Changbin Du <changbin.du@gmail.com>,
	Anand Jain <anand.jain@oracle.com>,
	Misono Tomohiro <misono.tomohiro@jp.fujitsu.com>,
	Qu Wenruo <wqu@suse.com>, Gu Jinxiang <gujx@cn.fujitsu.com>,
	linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] btrfs: avoid link error with CONFIG_NO_AUTO_INLINE
Date: Sat, 3 Nov 2018 22:25:14 +0100	[thread overview]
Message-ID: <CAK8P3a0FnpZ4pOyvXiQbhw5F116SqjwiYMY5Ry1k4J+Cvh=_nw@mail.gmail.com> (raw)
In-Reply-To: <8e3a668d-79d2-6fc0-6291-b3d19b793d6f@suse.com>

On 11/3/18, Nikolay Borisov <nborisov@suse.com> wrote:
> On 3.11.18 г. 17:39 ч., Arnd Bergmann wrote:
>> On 32-bit ARM with gcc-8, I see a link error with the addition of the
>> CONFIG_NO_AUTO_INLINE option:
>>
>> fs/btrfs/super.o: In function `btrfs_statfs':
>> super.c:(.text+0x67b8): undefined reference to `__aeabi_uldivmod'
>> super.c:(.text+0x67fc): undefined reference to `__aeabi_uldivmod'
>> super.c:(.text+0x6858): undefined reference to `__aeabi_uldivmod'
>> super.c:(.text+0x6920): undefined reference to `__aeabi_uldivmod'
>> super.c:(.text+0x693c): undefined reference to `__aeabi_uldivmod'
>> fs/btrfs/super.o:super.c:(.text+0x6958): more undefined references to
>> `__aeabi_uldivmod' follow
>>
>> So far this is the only file that shows the behavior, so I'd propose
>> to just work around it by marking the functions as 'static inline'
>> that normally get inlined here.
>>
>> The reference to __aeabi_uldivmod comes from a div_u64() which has an
>> optimization for a constant division that uses a straight '/' operator
>> when the result should be known to the compiler. My interpretation is
>> that as we turn off inlining, gcc still expects the result to be constant
>> but fails to use that constant value.
>
> I read this as "this is a compiler bug", no ? So you are providing a
> hack around a compiler bug?

Mostly, yes. The do_div() macro is really pushing the boundaries
of what we can expect the compiler to do in terms of optimizations,
and we've had problems with it in the past.

IIRC the gcc developers would not classify this as a bug because
the result of __builtin_constant_p() is not guaranteed to work the
way we expect, it just does so most of the time.

        Arnd

  reply	other threads:[~2018-11-03 21:25 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-03 15:39 [PATCH] btrfs: avoid link error with CONFIG_NO_AUTO_INLINE Arnd Bergmann
2018-11-03 20:41 ` Nikolay Borisov
2018-11-03 21:25   ` Arnd Bergmann [this message]
2018-11-04  0:38 ` Qu Wenruo
2018-11-04 22:32   ` Arnd Bergmann
2018-11-05 16:51     ` David Sterba
2018-11-05 21:27       ` Arnd Bergmann
2018-11-06 15:04         ` David Sterba
2018-11-05  9:20 ` Nikolay Borisov
2018-11-05 14:37 ` Changbin Du

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='CAK8P3a0FnpZ4pOyvXiQbhw5F116SqjwiYMY5Ry1k4J+Cvh=_nw@mail.gmail.com' \
    --to=arnd@arndb.de \
    --cc=anand.jain@oracle.com \
    --cc=changbin.du@gmail.com \
    --cc=clm@fb.com \
    --cc=dsterba@suse.com \
    --cc=gujx@cn.fujitsu.com \
    --cc=josef@toxicpanda.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=misono.tomohiro@jp.fujitsu.com \
    --cc=nborisov@suse.com \
    --cc=wqu@suse.com \
    /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;
as well as URLs for NNTP newsgroup(s).