[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191008152408.GI14765@zn.tnic>
Date: Tue, 8 Oct 2019 17:24:08 +0200
From: Borislav Petkov <bp@...en8.de>
To: Steven Rostedt <rostedt@...dmis.org>
Cc: Peter Zijlstra <peterz@...radead.org>, x86@...nel.org,
linux-kernel@...r.kernel.org, mhiramat@...nel.org,
bristot@...hat.com, jbaron@...mai.com,
torvalds@...ux-foundation.org, tglx@...utronix.de,
mingo@...nel.org, namit@...are.com, hpa@...or.com, luto@...nel.org,
ard.biesheuvel@...aro.org, jpoimboe@...hat.com
Subject: Re: [PATCH v3 1/6] x86/alternatives: Teach text_poke_bp() to emulate
instructions
On Tue, Oct 08, 2019 at 11:04:12AM -0400, Steven Rostedt wrote:
> The difference between do_sync and i is that i gets incremented at
> every iteration, where do_sync gets incremented only when the first
> conditional is false. But I still see do_sync as a loop variable.
I'd prefer it this way:
do_sync = 0;
for (i = 0; i < nr_entries; i++) {
if (tp[i].text[0] == INT3_INSN_OPCODE)
continue;
text_poke(tp[i].addr, tp[i].text, sizeof(int3));
do_sync++;
}
if (do_sync)
on_each_cpu(do_sync_core, NULL, 1);
Clear and simple. We clear it, the loop runs and we check it after the
loop ends. Clear and simple pattern which you see everywhere in code.
All well known and uneventful.
Now if the do_sync clearing is in the for () brackets, you have to stop
and look for it and wonder, why is that thing there, is there anything
special about it?
And with the amount of code going through us every day, I'd prefer well
known and uneventful in any day of the week.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
Powered by blists - more mailing lists