From: Pavel Begunkov <[email protected]>
To: Andres Freund <[email protected]>
Cc: Jens Axboe <[email protected]>, [email protected]
Subject: Re: Deduplicate io_*_prep calls?
Date: Mon, 24 Feb 2020 20:16:24 +0300 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
[-- Attachment #1.1: Type: text/plain, Size: 1263 bytes --]
On 24/02/2020 20:08, Andres Freund wrote:
> Hi,
>
> On 2020-02-24 19:18:26 +0300, Pavel Begunkov wrote:
>> On 24/02/2020 19:02, Jens Axboe wrote:
>>>> Usually doesn't work because of such possible "hackier assignments".
>>>> Ok, I have to go and experiment a bit. Anyway, it probably generates a lot of
>>>> useless stuff, e.g. for req->ctx
>>>
>>> Tried this, and it generates the same code...
>>
>> Maybe it wasn't able to optimise in the first place
>>
>> E.g. for the following code any compiler generates 2 reads (thanks godbolt).
>>
>> extern void foo(int);
>> int bar(const int *v)
>> {
>> foo(*v);
>> return *v;
>> }
>
> Yea, the compiler really can't assume anything for this kind of
> thing.
> a) It's valid C to cast away the const here, as long as it's guaranteed
> that v isn't pointing to to actually const memory.
> b) foo() could actually have access to *v without the argument,
> e.g. through a global.
> and even in the case of a const member of a struct, as far as I know
> it's legal to change the values, as long as the allocation isn't const.
Yep, regular stuff. And that's why I want to find a way to force compilers to
think otherwise. e.g. kind of __attribute__
--
Pavel Begunkov
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2020-02-24 17:17 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-24 1:07 Deduplicate io_*_prep calls? Andres Freund
2020-02-24 3:17 ` Jens Axboe
2020-02-24 3:33 ` Andres Freund
2020-02-24 3:52 ` Jens Axboe
2020-02-24 7:12 ` Andres Freund
2020-02-24 9:10 ` Pavel Begunkov
2020-02-24 15:40 ` Jens Axboe
2020-02-24 15:44 ` Pavel Begunkov
2020-02-24 15:46 ` Jens Axboe
2020-02-24 15:50 ` Pavel Begunkov
2020-02-24 15:53 ` Jens Axboe
2020-02-24 15:56 ` Pavel Begunkov
2020-02-24 16:02 ` Jens Axboe
2020-02-24 16:18 ` Pavel Begunkov
2020-02-24 17:08 ` Andres Freund
2020-02-24 17:16 ` Pavel Begunkov [this message]
2020-02-25 9:26 ` Pavel Begunkov
2020-02-27 21:06 ` Andres Freund
2020-02-24 16:53 ` Andres Freund
2020-02-24 17:19 ` Jens Axboe
2020-02-24 17:30 ` Jens Axboe
2020-02-24 17:37 ` Pavel Begunkov
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 \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
/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