From 096a5c2b6a26db36c09b56d635ff12a41da47fbc Mon Sep 17 00:00:00 2001 From: Ksawlii Date: Sun, 24 Nov 2024 00:23:05 +0100 Subject: [PATCH] Revert "selftests/mm: fix charge_reserved_hugetlb.sh test" This reverts commit ad18f8f867675ca81bb04f3cdeff8e6e48b6397b. --- .../selftests/vm/charge_reserved_hugetlb.sh | 2 +- .../testing/selftests/vm/write_to_hugetlbfs.c | 21 ++++++++----------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/tools/testing/selftests/vm/charge_reserved_hugetlb.sh b/tools/testing/selftests/vm/charge_reserved_hugetlb.sh index 28192ec98..d0107f8ae 100755 --- a/tools/testing/selftests/vm/charge_reserved_hugetlb.sh +++ b/tools/testing/selftests/vm/charge_reserved_hugetlb.sh @@ -249,7 +249,7 @@ function cleanup_hugetlb_memory() { local cgroup="$1" if [[ "$(pgrep -f write_to_hugetlbfs)" != "" ]]; then echo killing write_to_hugetlbfs - killall -2 --wait write_to_hugetlbfs + killall -2 write_to_hugetlbfs wait_for_hugetlb_memory_to_get_depleted $cgroup fi set -e diff --git a/tools/testing/selftests/vm/write_to_hugetlbfs.c b/tools/testing/selftests/vm/write_to_hugetlbfs.c index 1289d311e..6a2caba19 100755 --- a/tools/testing/selftests/vm/write_to_hugetlbfs.c +++ b/tools/testing/selftests/vm/write_to_hugetlbfs.c @@ -28,7 +28,7 @@ enum method { /* Global variables. */ static const char *self; -static int *shmaddr; +static char *shmaddr; static int shmid; /* @@ -47,17 +47,15 @@ void sig_handler(int signo) { printf("Received %d.\n", signo); if (signo == SIGINT) { - if (shmaddr) { - printf("Deleting the memory\n"); - if (shmdt((const void *)shmaddr) != 0) { - perror("Detach failure"); - shmctl(shmid, IPC_RMID, NULL); - exit(4); - } - + printf("Deleting the memory\n"); + if (shmdt((const void *)shmaddr) != 0) { + perror("Detach failure"); shmctl(shmid, IPC_RMID, NULL); - printf("Done deleting the memory\n"); + exit(4); } + + shmctl(shmid, IPC_RMID, NULL); + printf("Done deleting the memory\n"); } exit(2); } @@ -213,8 +211,7 @@ int main(int argc, char **argv) shmctl(shmid, IPC_RMID, NULL); exit(2); } - shmaddr = ptr; - printf("shmaddr: %p\n", shmaddr); + printf("shmaddr: %p\n", ptr); break; default: