Re: [PATCH] - Reduce TLB flushing during process migration

From: John Richard Moser
Date: Wed Jul 07 2004 - 08:53:33 EST


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1



David Mosberger wrote:
|>>>>>On Fri, 2 Jul 2004 12:39:05 -0500, Jack Steiner <steiner@xxxxxxx>
said:
|
| Well, then it's not a true no-op. The other no-ops are all for
| init-type stuff, so they're not at all performance critical. Even
| when compiling a non-generic kernel, those no-op functions will be
| called. This is really a limitation in the current machvec-scheme. I
| think what we need is a way to explicitly declare a no-op callback,
| such that it can be optimized away completely for platforms that don't
| need it. Perhaps there could be something along the lines of:
|
| #ifdef CONFIG_IA64_GENERIC
| # define machvec_noop(noop_function) noop_function
| #else
| # define machvec_noop(noop_function) /* empty */
| #endif
|

?????

1. At any -O level, I'd assume the loop optimizer or something along
those lines would see a 1 iteration loop and remove the actual loop
instruction:

MOV CX,1 ; 1 iteration
...
LOOP ; Just DEC CX and falls through

In the pseudocode above, we can clearly see that the MOV and the LOOP
perform no real function. The optimizer *should* AFAIK notice that a
do{...}while(0) generates useless looping instructions and thus prevent
those instructions from being generated. In the case of do{}while(0),
this generates 0 instructions.

2. A function call to a no-op is an unoptimizable and excessive
overhead compared to do{}while(0) in most cases; the no-op would need to
be inline assembly, thus maintained for each arch, AFAIK.

3. An actual no-op instruction still needs to be iterated past by the
processor. Usually, no-op is only generated by the compiler for
padding, AFAIK; and even then, there's some kind of jump before the load
of no-ops to get past them. I don't know if inline assembly is
optimized out; but I would assume not.

4. I don't think /* empty */; is an error; but the following block has
problems:

if (foo)
~ ;
else
~ do_something();

So, we need something that gets parsed to exactly nothing.

Thus, as far as I can understand, because we use -O2 or -Os, we will
always get exactly 0 instructions from do{}while(0). This is the best
solution to the problem.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFA7AAchDd4aOud5P8RAtYeAJ9rdKb4ZE4KPT15C2O8TvlrL82A/gCdFm2b
fslXb9dDCj6ccW7tSFpogzw=
=v4oX
-----END PGP SIGNATURE-----
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/