Re: [PATCH V5 6/7] jump_label: Batch updates if arch supports it

From: Peter Zijlstra
Date: Mon Apr 15 2019 - 07:51:02 EST


On Mon, Apr 01, 2019 at 10:58:18AM +0200, Daniel Bristot de Oliveira wrote:
> +int fallback_batch __read_mostly;
> +static void __jump_label_update(struct static_key *key,
> + struct jump_entry *entry,
> + struct jump_entry *stop,
> + bool init)
> +{
> + for_each_label_entry(key, entry, stop) {
> +
> + if (!jump_label_can_update(entry, init))
> + continue;
> +
> + if (unlikely(fallback_batch)) {
> + arch_jump_label_transform(entry, jump_label_type(entry));
> + continue;
> + }
> +
> + if (!arch_jump_label_transform_queue(entry, jump_label_type(entry)))
> + continue;

That reads wrong; 'if we cannot queue, continue'

> +
> + /*
> + * Queue's overflow: Apply the current queue, and then try to
> + * queue again. If it stills fail to queue, fallback to the
> + * non-batch mode!
> + */
> + arch_jump_label_transform_apply();
> +
> + if (arch_jump_label_transform_queue(entry, jump_label_type(entry))) {
> + WARN(1, "jump_label: batch mode failure!\n");
> + fallback_batch = 1;
> + arch_jump_label_transform(entry, jump_label_type(entry));
> + }
> + }
> + arch_jump_label_transform_apply();
> +}

Hurmph...

for_each_whatever(entry, stop, key) {
if (!jump_label_can_update(entry, init))
continue;

if (!arch_jump_label_transform_queue(entry)) {
/* queue full, flush */
arch_jump_label_transform_apply();
BUG_ON(!arch_jump_label_transform_queue(entry));
}
}
arch_jump_label_transform_apply();

Also, see next patch.