forked from checkpoint-restore/criu
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6f131aa
commit 5e6f1e4
Showing
1 changed file
with
35 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,14 +8,16 @@ const char *test_author = "Michał Mirosław <[email protected]>"; | |
|
||
/* | ||
* Define membarrier() CMDs to avoid depending on exact kernel header version. | ||
* FIXME: use MEMBARRIER_CMD_GET_REGISTRATIONS if supported by kernel. | ||
*/ | ||
#define MEMBARRIER_CMD_GLOBAL_EXPEDITED (1 << 1) | ||
#define MEMBARRIER_CMD_REGISTER_GLOBAL_EXPEDITED (1 << 2) | ||
#define MEMBARRIER_CMD_PRIVATE_EXPEDITED (1 << 3) | ||
#define MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED (1 << 4) | ||
#define MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE (1 << 5) | ||
#define MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_CORE (1 << 6) | ||
#define MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ (1 << 7) | ||
#define MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_RSEQ (1 << 8) | ||
#define MEMBARRIER_CMD_GET_REGISTRATIONS (1 << 9) | ||
|
||
static int membarrier(int cmd, unsigned int flags, int cpu_id) | ||
{ | ||
|
@@ -27,9 +29,14 @@ static const struct { | |
int register_cmd; | ||
int execute_cmd; | ||
} membarrier_cmds[] = { | ||
{ "", MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED, MEMBARRIER_CMD_PRIVATE_EXPEDITED }, | ||
{ "_SYNC_CORE", MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_CORE, MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE }, | ||
{ "_RSEQ", MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_RSEQ, MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ }, | ||
{ "GLOBAL", MEMBARRIER_CMD_REGISTER_GLOBAL_EXPEDITED, | ||
MEMBARRIER_CMD_GLOBAL_EXPEDITED }, | ||
{ "PRIVATE", MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED, | ||
MEMBARRIER_CMD_PRIVATE_EXPEDITED }, | ||
{ "PRIVATE_SYNC_CORE", MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_CORE, | ||
MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE }, | ||
{ "PRIVATE_RSEQ", MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_RSEQ, | ||
MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ }, | ||
}; | ||
static const int n_membarrier_cmds = sizeof(membarrier_cmds) / sizeof(*membarrier_cmds); | ||
|
||
|
@@ -71,7 +78,7 @@ static int register_membarriers(void) | |
return barriers_registered; | ||
} | ||
|
||
static bool check_membarriers(int barriers_registered) | ||
static bool check_membarriers_compat(int barriers_registered) | ||
{ | ||
bool all_ok = true; | ||
|
||
|
@@ -90,6 +97,26 @@ static bool check_membarriers(int barriers_registered) | |
return all_ok; | ||
} | ||
|
||
static bool check_membarriers_get_registrations(int barriers_registered) | ||
{ | ||
int ret = membarrier(MEMBARRIER_CMD_GET_REGISTRATIONS, 0, 0) | ||
if (ret < 0) { | ||
if (errno == EINVAL) { | ||
pr_info("membarrier(MEMBARRIER_CMD_GET_REGISTRATIONS) not supported by running kernel"); | ||
return true; | ||
} | ||
fail("membarrier(MEMBARRIER_CMD_GET_REGISTRATIONS)"); | ||
return false; | ||
} | ||
if (ret != barriers_registered) { | ||
fail("MEMBARRIER_CMD_GET_REGISTRATIONS check failed, expected: %d, got: %d", | ||
barriers_registered, ret); | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
int barriers_registered; | ||
|
@@ -108,7 +135,9 @@ int main(int argc, char **argv) | |
test_waitsig(); | ||
|
||
test_msg("Post-migration membarriers check\n"); | ||
if (!check_membarriers(barriers_registered)) | ||
if (!check_membarriers_compat(barriers_registered)) | ||
return 1; | ||
if (!check_membarriers_get_registrations(barriers_registered)) | ||
return 1; | ||
|
||
pass(); | ||
|