From: Sergei Shtylyov <sshtylyov@ru.mvista.com>
To: petkovbb@gmail.com, Sergei Shtylyov <sshtylyov@ru.mvista.com>,
Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>,
linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 5/6] ide: remove ide_execute_pkt_cmd()
Date: Mon, 16 Feb 2009 02:18:01 +0300 [thread overview]
Message-ID: <4998A2A9.2060607@ru.mvista.com> (raw)
In-Reply-To: <20090215173901.GA5156@gollum.tnic>
Hello.
Borislav Petkov wrote:
>> I still don't undestand why you assume that such variable will be
>> alloceted on stack -- gcc has 3 registers available for local variables
>> (which doesn't have to save across function calls). However, the
>> register variables have to take stack space indeed as they need to be
>> saved on funciton entry... though I'm not sure that gcc will necessary
>> put such variable in one of those 3 registers if it figures out that
>> there are no function calls going to happen during its life time.
>>
>>> and the code is more readable. A win-win situation, I'd say :).
>>>
>> You haven't presented the code which gets generated when the local
>> variable is used, so it's impossible to compare.
>>
>
> Here's another example from ide-disk.c where you have stack variables cashing
> those flags checks:
>
They are caching the result of !! in 'u8' variables -- which is not
the same as cahing the flags. I suspect gcc avoid putting byte-sized
variables into registers...
> <ide-disk.c>
> static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq,
> sector_t block)
> {
> ide_hwif_t *hwif = drive->hwif;
> u16 nsectors = (u16)rq->nr_sectors;
> u8 lba48 = !!(drive->dev_flags & IDE_DFLAG_LBA48);
> u8 dma = !!(drive->dev_flags & IDE_DFLAG_USING_DMA);
> ide_task_t task;
> struct ide_taskfile *tf = &task.tf;
> ide_startstop_t rc;
>
> if ((hwif->host_flags & IDE_HFLAG_NO_LBA48_DMA) && lba48 && dma) {
> if (block + rq->nr_sectors > 1ULL << 28)
> dma = 0;
> else
> lba48 = 0;
> }
> </ide-disk.c>
>
> Corresponding asm (this time i386 but I don't think it matters since we
> need at least one arch to prove my point).
>
> <ide-disk.s>
> .LVL48:
> .loc 1 94 0
> movl %eax, %edx # D.32119, tmp93
> .loc 1 95 0
> shrl %eax # D.32119
>
Where's the shift count I wonder?
> andb $1, %al #,
> movb %al, -58(%ebp) #, dma
> .LVL49:
> .loc 1 100 0
> movl -52(%ebp), %eax # hwif,
> .loc 1 94 0
> shrl $21, %edx #, tmp93
> andb $1, %dl #,
> movb %dl, -57(%ebp) #, lba48
> .LVL50:
> .loc 1 100 0
> testb $4, 90(%eax) #, <variable>.host_flags
> je .L37 #,
> testb %dl, %dl #
> je .L37 #,
> cmpb $0, -58(%ebp) # dma
> movb $1, -57(%ebp) #, lba48
> .LVL51:
> </ide-disk.s>
>
> Now look at the last lines at labels .LVL48 and .LVL49 - they both save
> those 1-byte u8's called dma and lba48 on the stack at -57(%ebp) and
> -58(%ebp), respectively. And guess what, later on label LVL50 they get
> accessed in the check.
If you look better, you'll see that the copy of 'lba48' in the %dl
register gets used.
> And several times more later, which in most sane
> architectures still means cache accesses but when you have registers its
> even faster :).
Didn't quite get that statement.
Well, this example wasn't very convincing...
MBR. Sergei
next prev parent reply other threads:[~2009-02-15 23:18 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-09 23:19 [PATCH 0/6] ide: more unifications of ATA and ATAPI support Bartlomiej Zolnierkiewicz
2009-02-09 23:19 ` [PATCH 1/6] ide: pass command to ide_map_sg() Bartlomiej Zolnierkiewicz
2009-02-11 6:36 ` Borislav Petkov
2009-02-11 16:28 ` Bartlomiej Zolnierkiewicz
2009-02-09 23:19 ` [PATCH 2/6] ide: use do_rw_taskfile() for ATA_CMD_PACKET commands Bartlomiej Zolnierkiewicz
2009-02-09 23:20 ` [PATCH 3/6] ide: set hwif->expiry prior to calling [__]ide_set_handler() Bartlomiej Zolnierkiewicz
2009-03-16 14:23 ` Sergei Shtylyov
2009-02-09 23:20 ` [PATCH 4/6] ide: add ->dma_expiry method and remove ->dma_exec_cmd one Bartlomiej Zolnierkiewicz
2009-02-10 18:18 ` Sergei Shtylyov
2009-02-11 16:30 ` Bartlomiej Zolnierkiewicz
2009-02-11 17:30 ` Sergei Shtylyov
2009-02-17 14:16 ` Bartlomiej Zolnierkiewicz
2009-02-17 14:29 ` Sergei Shtylyov
2009-02-09 23:20 ` [PATCH 5/6] ide: remove ide_execute_pkt_cmd() Bartlomiej Zolnierkiewicz
2009-02-11 6:55 ` Borislav Petkov
2009-02-11 13:22 ` Sergei Shtylyov
2009-02-11 13:37 ` Borislav Petkov
2009-02-11 13:49 ` Sergei Shtylyov
2009-02-11 16:32 ` Borislav Petkov
2009-02-15 12:24 ` Sergei Shtylyov
2009-02-15 17:39 ` Borislav Petkov
2009-02-15 23:18 ` Sergei Shtylyov [this message]
2009-02-16 8:56 ` Borislav Petkov
2009-02-11 16:37 ` Bartlomiej Zolnierkiewicz
2009-02-09 23:20 ` [PATCH 6/6] ide: keep track of number of bytes instead of sectors in struct ide_cmd Bartlomiej Zolnierkiewicz
2009-02-11 7:16 ` [PATCH 0/6] ide: more unifications of ATA and ATAPI support Borislav Petkov
2009-02-23 22:51 ` Bartlomiej Zolnierkiewicz
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=4998A2A9.2060607@ru.mvista.com \
--to=sshtylyov@ru.mvista.com \
--cc=bzolnier@gmail.com \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=petkovbb@gmail.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