jump_label: Batch updates if arch supports it
[sfrench/cifs-2.6.git] / kernel / jump_label.c
index ca00ac10d9b9ee7bcc434e00e4df2652722d996d..df3008419a1d0a34229580d86a2aec2f0e305d2a 100644 (file)
@@ -414,6 +414,7 @@ static bool jump_label_can_update(struct jump_entry *entry, bool init)
        return true;
 }
 
+#ifndef HAVE_JUMP_LABEL_BATCH
 static void __jump_label_update(struct static_key *key,
                                struct jump_entry *entry,
                                struct jump_entry *stop,
@@ -424,6 +425,28 @@ static void __jump_label_update(struct static_key *key,
                        arch_jump_label_transform(entry, jump_label_type(entry));
        }
 }
+#else
+static void __jump_label_update(struct static_key *key,
+                               struct jump_entry *entry,
+                               struct jump_entry *stop,
+                               bool init)
+{
+       for (; (entry < stop) && (jump_entry_key(entry) == key); entry++) {
+
+               if (!jump_label_can_update(entry, init))
+                       continue;
+
+               if (!arch_jump_label_transform_queue(entry, jump_label_type(entry))) {
+                       /*
+                        * Queue is full: Apply the current queue and try again.
+                        */
+                       arch_jump_label_transform_apply();
+                       BUG_ON(!arch_jump_label_transform_queue(entry, jump_label_type(entry)));
+               }
+       }
+       arch_jump_label_transform_apply();
+}
+#endif
 
 void __init jump_label_init(void)
 {