public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "willy tarreau" <wtarreau@yahoo.fr>
To: vda@port.imtp.ilyichevsk.odessa.ua,
	Willy TARREAU <willy@w.ods.org>,
	willy@meta-x.org, linux-kernel@vger.kernel.org,
	Ronald.Wahl@informatik.tu-chemnitz.de
Subject: Re: [ANNOUNCE] CMOV emulation for 2.4.19-rc1
Date: Mon, 1 Jul 2002 15:03:27 +0200 (CEST)	[thread overview]
Message-ID: <20020701130327.38962.qmail@web20506.mail.yahoo.com> (raw)
In-Reply-To: <200207010858.g618wdT17736@Port.imtp.ilyichevsk.odessa.ua>

Hello Denis,

> This code is performance critical.
> With this in mind,

Yes and no. In fact, I first wanted to code some
parts in assembler because GCC is sub-optimal
on bit-fields calculations. But then, I realized that
I could save, say 10 cycles, while the trap costs
about 400 cycles.

> +static void *modrm_address(struct pt_regs *regs,
> unsigned char **from, char w, char bit32,
> w seems to be unused

Well, you're right, it's not used anymore. It was
used to check if the instruction applies to a byte
or a word.

> Why? i86 can do unaligned accesses:
> 	offset = *(u32*)(*from); *from += 4;

that's simply because I'm not sure if the kernel
runs with AC flag on or off. I quickly checked
that it's OK from userland.

> +       /* we'll first read all known opcode
> prefixes, and discard obviously
> +          invalid combinations.*/
> Prefixes are rarer than plain opcodes. Maybe:
> 1.check opcodes
> 2.no? check prefixes
> 3.yes? check opcodes again

perhaps a good idea, I don't know. I think the
current code doesn't cost much in case there
is no prefix (only 3 failed IFs). I also wrote a
prefix bitmap to directly map opcodes to prefixes/
known instructions, but thought it was not really
usefull and costed 32 bytes, so I removed it.
 
> +                               if (prefixes &
PREFIX_LOCK)
> +                                       goto
invalid_opcode;
> Cycles burned for nothing.
> What harm can be done if we managed to emulate
> 	lock lock lock xadd a,b

simply avoid that someone filling 16Meg of code
with prefixes spends all his time in the kernel.
When I did this, I had checked and noticed that
an instruction with a repeated prefix is invalid.

> +                       case 0xF3: /* rep */
> These prefixes are invalid for commands we emulate.
> No GCC will ever generate such code, don't check for
> them.

Yes, I agree with you. The only instructions that
support these prefixes are stable and it's not likely
that others will come in the future, so we may
handle them in the general case of invalid
instruction.

> eliminate 'reg = (modrm >> 3) & 7', move calculation
> to <<<1
> eliminate 'modrm &= 0xC7', move to <<<2 or drop it
> (I think modrm_adr() will work fine with unmasked
> modrm)

I know this part can be reworked. I just need a bit
of time to check redundant calculations between
the main function and modrm_addr(), and I think
I can simplify even more.

Like I said above, I didn't insist on optimizations,
I prefered to get a clear code first. If I want to
optimize, I think most of this will be assembler.

Thanks a lot for your feedback,
Willy


___________________________________________________________
Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
Yahoo! Mail : http://fr.mail.yahoo.com

  reply	other threads:[~2002-07-01 13:01 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-06-30  4:39 [ANNOUNCE] CMOV emulation for 2.4.19-rc1 Willy TARREAU
2002-07-01 13:58 ` Denis Vlasenko
2002-07-01 13:03   ` willy tarreau [this message]
2002-07-01 15:55     ` Bill Davidsen
2002-07-02 10:46       ` Denis Vlasenko
2002-07-02  6:31         ` willy tarreau
2002-07-02 12:03           ` Denis Vlasenko
2002-07-01 16:25     ` Gabriel Paubert
2002-07-01 17:08       ` willy tarreau
2002-07-01 18:16     ` Denis Vlasenko
2002-07-01 13:25       ` willy tarreau
2002-07-02 20:00       ` Willy TARREAU
2002-07-03  0:36         ` jw schultz
2002-07-18 19:15           ` Robert de Bath
2002-07-18 20:44             ` jw schultz
2002-07-01 18:25 ` Denis Vlasenko

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=20020701130327.38962.qmail@web20506.mail.yahoo.com \
    --to=wtarreau@yahoo.fr \
    --cc=Ronald.Wahl@informatik.tu-chemnitz.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vda@port.imtp.ilyichevsk.odessa.ua \
    --cc=willy@meta-x.org \
    --cc=willy@w.ods.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