10
10
#include "shuffle.h"
11
11
12
12
DEFINE_STATIC_KEY_FALSE (page_alloc_shuffle_key );
13
- static unsigned long shuffle_state __ro_after_init ;
14
-
15
- /*
16
- * Depending on the architecture, module parameter parsing may run
17
- * before, or after the cache detection. SHUFFLE_FORCE_DISABLE prevents,
18
- * or reverts the enabling of the shuffle implementation. SHUFFLE_ENABLE
19
- * attempts to turn on the implementation, but aborts if it finds
20
- * SHUFFLE_FORCE_DISABLE already set.
21
- */
22
- __meminit void page_alloc_shuffle (enum mm_shuffle_ctl ctl )
23
- {
24
- if (ctl == SHUFFLE_FORCE_DISABLE )
25
- set_bit (SHUFFLE_FORCE_DISABLE , & shuffle_state );
26
-
27
- if (test_bit (SHUFFLE_FORCE_DISABLE , & shuffle_state )) {
28
- if (test_and_clear_bit (SHUFFLE_ENABLE , & shuffle_state ))
29
- static_branch_disable (& page_alloc_shuffle_key );
30
- } else if (ctl == SHUFFLE_ENABLE
31
- && !test_and_set_bit (SHUFFLE_ENABLE , & shuffle_state ))
32
- static_branch_enable (& page_alloc_shuffle_key );
33
- }
34
13
35
14
static bool shuffle_param ;
36
15
static int shuffle_show (char * buffer , const struct kernel_param * kp )
37
16
{
38
- return sprintf (buffer , "%c\n" , test_bit (SHUFFLE_ENABLE , & shuffle_state )
39
- ? 'Y' : 'N' );
17
+ return sprintf (buffer , "%c\n" , shuffle_param ? 'Y' : 'N' );
40
18
}
41
19
42
20
static __meminit int shuffle_store (const char * val ,
@@ -47,9 +25,7 @@ static __meminit int shuffle_store(const char *val,
47
25
if (rc < 0 )
48
26
return rc ;
49
27
if (shuffle_param )
50
- page_alloc_shuffle (SHUFFLE_ENABLE );
51
- else
52
- page_alloc_shuffle (SHUFFLE_FORCE_DISABLE );
28
+ static_branch_enable (& page_alloc_shuffle_key );
53
29
return 0 ;
54
30
}
55
31
module_param_call (shuffle , shuffle_store , shuffle_show , & shuffle_param , 0400 );
0 commit comments