Skip to content

Commit

Permalink
stress-sysinval: add some UNLIKELY branch hints
Browse files Browse the repository at this point in the history
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
  • Loading branch information
ColinIanKing committed Jan 30, 2025
1 parent f4b4bb3 commit 2275b62
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions stress-sysinval.c
Original file line number Diff line number Diff line change
Expand Up @@ -2386,7 +2386,7 @@ static void hash_table_add(
{
stress_syscall_arg_hash_t *h;

if (hash_table->index >= HASH_TABLE_POOL_SIZE)
if (UNLIKELY(hash_table->index >= HASH_TABLE_POOL_SIZE))
return;
h = &hash_table->pool[hash_table->index];
h->hash = hash;
Expand Down Expand Up @@ -2477,7 +2477,7 @@ static void syscall_permute(
unsigned long int rnd_values[4];
size_t num_values = 0;

if (stress_time_now() > args->time_end)
if (UNLIKELY(stress_time_now() > args->time_end))
_exit(EXIT_SUCCESS);

if (arg_num >= stress_syscall_arg->num_args) {
Expand Down Expand Up @@ -2615,7 +2615,7 @@ static void syscall_permute(
/*
* This should not fail!
*/
if (!num_values) {
if (UNLIKELY(!num_values)) {
pr_dbg("%s: argument %d has bad bitmask %lx\n", args->name, arg_num, arg_bitmask);
current_context->args[arg_num] = 0;
return;
Expand Down Expand Up @@ -2643,7 +2643,7 @@ static inline int stress_do_syscall(stress_args_t *args)

(void)stress_mwc32();

if (!stress_continue_flag())
if (UNLIKELY(!stress_continue_flag()))
return 0;

if (stress_drop_capabilities(args->name) < 0)
Expand All @@ -2666,11 +2666,11 @@ static inline int stress_do_syscall(stress_args_t *args)
_exit(EXIT_NO_RESOURCE);
}
for (i = 0; i < SIZEOF_ARRAY(sigs); i++) {
if (stress_sighandler(args->name, sigs[i], stress_sig_handler_exit, NULL) < 0)
if (UNLIKELY(stress_sighandler(args->name, sigs[i], stress_sig_handler_exit, NULL) < 0))
_exit(EXIT_FAILURE);
}

if (stress_sighandler(args->name, SIGALRM, stress_syscall_itimer_handler, NULL) < 0)
if (UNLIKELY(stress_sighandler(args->name, SIGALRM, stress_syscall_itimer_handler, NULL) < 0))
_exit(EXIT_FAILURE);

stress_parent_died_alarm();
Expand Down Expand Up @@ -2743,7 +2743,7 @@ static inline int stress_do_syscall(stress_args_t *args)
current_context->args,
SYSCALL_CRASH);

if (idx < SYSCALL_ARGS_SIZE)
if (LIKELY(idx < SYSCALL_ARGS_SIZE))
current_context->crash_count[idx]++;
}
rc = WEXITSTATUS(status);
Expand Down Expand Up @@ -2787,7 +2787,7 @@ static int stress_sysinval(stress_args_t *args)
* Run-time sanity check of zero syscalls, maybe __NR or SYS_ is not
* defined.
*/
if (SYSCALL_ARGS_SIZE == (0)) {
if (UNLIKELY(SYSCALL_ARGS_SIZE == (0))) {
if (args->instance == 0)
pr_inf_skip("%s: no system calls detected during build, skipping stressor\n",
args->name);
Expand Down

0 comments on commit 2275b62

Please sign in to comment.