[libc-commits] [libc] [libc] revert all process_mrelease changes (PR #118650)
Schrodinger ZHU Yifan via libc-commits
libc-commits at lists.llvm.org
Wed Dec 4 06:48:19 PST 2024
https://github.com/SchrodingerZhu created https://github.com/llvm/llvm-project/pull/118650
None
>From bfb8fbdd3150ac64bfaf0e4467cfa4e0a27f3fff Mon Sep 17 00:00:00 2001
From: Schrodinger ZHU Yifan <yifanzhu at rochester.edu>
Date: Wed, 4 Dec 2024 09:42:29 -0500
Subject: [PATCH 1/4] Revert "[libc] always clean up child process to avoid
hanging ninja (#118049)"
This reverts commit cf478bf744fa2aacb634b151b7f6c9844f0d3851.
---
libc/test/src/sys/mman/linux/process_mrelease_test.cpp | 2 --
1 file changed, 2 deletions(-)
diff --git a/libc/test/src/sys/mman/linux/process_mrelease_test.cpp b/libc/test/src/sys/mman/linux/process_mrelease_test.cpp
index 865056c05f8dbc..71cde7a85a6711 100644
--- a/libc/test/src/sys/mman/linux/process_mrelease_test.cpp
+++ b/libc/test/src/sys/mman/linux/process_mrelease_test.cpp
@@ -60,8 +60,6 @@ TEST(LlvmLibcProcessMReleaseTest, ErrorNotKilled) {
EXPECT_THAT(LIBC_NAMESPACE::process_mrelease(pidfd, 0), Fails(EINVAL));
- LIBC_NAMESPACE::kill(child_pid, SIGKILL);
-
LIBC_NAMESPACE::close(pidfd);
}
}
>From 84353f2874ee0cc8a001bd4cd8836b42e5c86617 Mon Sep 17 00:00:00 2001
From: Schrodinger ZHU Yifan <yifanzhu at rochester.edu>
Date: Wed, 4 Dec 2024 09:42:59 -0500
Subject: [PATCH 2/4] Revert "[libc] disable process_mrelease for riscv
(#117956)"
This reverts commit 700d9ac9ef82fa5aa6b2972e8656ab5055a90d15.
---
libc/config/linux/riscv/entrypoints.txt | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt
index fedc5002d8c246..7bdb7f4d1ec61b 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -251,8 +251,7 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.sys.mman.munmap
libc.src.sys.mman.remap_file_pages
libc.src.sys.mman.posix_madvise
- # TODO: disabled due to buildbot failure. further investigation needed.
- # libc.src.sys.mman.process_mrelease
+ libc.src.sys.mman.process_mrelease
libc.src.sys.mman.shm_open
libc.src.sys.mman.shm_unlink
>From 35059be4e46a9a90f5f5d51400f13e347b2f8a17 Mon Sep 17 00:00:00 2001
From: Schrodinger ZHU Yifan <yifanzhu at rochester.edu>
Date: Wed, 4 Dec 2024 09:43:26 -0500
Subject: [PATCH 3/4] Revert "[libc] skip test and return ENOSYS when
processm_release unavailable (#117951)"
This reverts commit 819b155c2a18460d2f22482975d33d77bb4f8831.
---
libc/src/sys/mman/linux/process_mrelease.cpp | 8 --------
libc/test/src/sys/mman/linux/CMakeLists.txt | 1 -
.../sys/mman/linux/process_mrelease_test.cpp | 18 +++++++++++-------
3 files changed, 11 insertions(+), 16 deletions(-)
diff --git a/libc/src/sys/mman/linux/process_mrelease.cpp b/libc/src/sys/mman/linux/process_mrelease.cpp
index 7660f1e23ece2a..e86bbec1b1b661 100644
--- a/libc/src/sys/mman/linux/process_mrelease.cpp
+++ b/libc/src/sys/mman/linux/process_mrelease.cpp
@@ -19,7 +19,6 @@
namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(int, process_mrelease, (int pidfd, unsigned int flags)) {
-#ifdef SYS_process_mrelease
long ret =
LIBC_NAMESPACE::syscall_impl<int>(SYS_process_mrelease, pidfd, flags);
@@ -29,13 +28,6 @@ LLVM_LIBC_FUNCTION(int, process_mrelease, (int pidfd, unsigned int flags)) {
}
return 0;
-#else
- // The system call is not available.
- (void)pidfd;
- (void)flags;
- libc_errno = ENOSYS;
- return -1;
-#endif
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/test/src/sys/mman/linux/CMakeLists.txt b/libc/test/src/sys/mman/linux/CMakeLists.txt
index 6362b46a6fe090..1a5ff3af8eb117 100644
--- a/libc/test/src/sys/mman/linux/CMakeLists.txt
+++ b/libc/test/src/sys/mman/linux/CMakeLists.txt
@@ -197,7 +197,6 @@ add_libc_unittest(
libc.src.signal.kill
libc.include.signal
libc.src.stdlib.exit
- libc.src.signal.raise
libc.src.__support.OSUtil.osutil
libc.src.__support.threads.sleep
libc.test.UnitTest.ErrnoSetterMatcher
diff --git a/libc/test/src/sys/mman/linux/process_mrelease_test.cpp b/libc/test/src/sys/mman/linux/process_mrelease_test.cpp
index 71cde7a85a6711..56a7d66ee7a5ac 100644
--- a/libc/test/src/sys/mman/linux/process_mrelease_test.cpp
+++ b/libc/test/src/sys/mman/linux/process_mrelease_test.cpp
@@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
+#include "src/__support/threads/sleep.h"
#include "src/errno/libc_errno.h"
#include "src/signal/kill.h"
-#include "src/signal/raise.h"
#include "src/stdlib/exit.h"
#include "src/sys/mman/process_mrelease.h"
#include "src/unistd/close.h"
@@ -18,7 +18,7 @@
#include "test/UnitTest/LibcTest.h"
#include <sys/syscall.h>
-#if defined(SYS_process_mrelease) && defined(SYS_pidfd_open)
+
using namespace LIBC_NAMESPACE::testing::ErrnoSetterMatcher;
int pidfd_open(pid_t pid, unsigned int flags) {
@@ -30,11 +30,13 @@ TEST(LlvmLibcProcessMReleaseTest, NoError) {
EXPECT_GE(child_pid, 0);
if (child_pid == 0) {
- // pause the child process
- LIBC_NAMESPACE::raise(SIGSTOP);
+ // Child process: wait a bit then exit gracefully.
+ LIBC_NAMESPACE::sleep_briefly();
+ LIBC_NAMESPACE::exit(0);
} else {
// Parent process: wait a bit and then kill the child.
// Give child process some time to start.
+ LIBC_NAMESPACE::sleep_briefly();
int pidfd = pidfd_open(child_pid, 0);
EXPECT_GE(pidfd, 0);
@@ -52,9 +54,12 @@ TEST(LlvmLibcProcessMReleaseTest, ErrorNotKilled) {
EXPECT_GE(child_pid, 0);
if (child_pid == 0) {
- // pause the child process
- LIBC_NAMESPACE::raise(SIGSTOP);
+ // Child process: wait a bit then exit gracefully.
+ LIBC_NAMESPACE::sleep_briefly();
+ LIBC_NAMESPACE::exit(0);
} else {
+ // Give child process some time to start.
+ LIBC_NAMESPACE::sleep_briefly();
int pidfd = pidfd_open(child_pid, 0);
EXPECT_GE(pidfd, 0);
@@ -67,4 +72,3 @@ TEST(LlvmLibcProcessMReleaseTest, ErrorNotKilled) {
TEST(LlvmLibcProcessMReleaseTest, ErrorNonExistingPidfd) {
EXPECT_THAT(LIBC_NAMESPACE::process_mrelease(-1, 0), Fails(EBADF));
}
-#endif
>From cc299c2828ca99a6d4c0016e294c53652bc7f205 Mon Sep 17 00:00:00 2001
From: Schrodinger ZHU Yifan <yifanzhu at rochester.edu>
Date: Wed, 4 Dec 2024 09:47:09 -0500
Subject: [PATCH 4/4] Revert "[libc] (reland #117503) Implement
process_mrelease (#117851)"
This reverts commit d2b482b0efd1d523852c9add8ed6b2035ce1acd9.
---
libc/config/linux/aarch64/entrypoints.txt | 1 -
libc/config/linux/riscv/entrypoints.txt | 1 -
libc/config/linux/x86_64/entrypoints.txt | 1 -
libc/include/sys/syscall.h.def | 7 --
libc/newhdrgen/yaml/sys/mman.yaml | 7 --
libc/src/sys/mman/CMakeLists.txt | 6 --
libc/src/sys/mman/linux/CMakeLists.txt | 12 +--
libc/src/sys/mman/linux/process_mrelease.cpp | 33 ---------
libc/src/sys/mman/process_mrelease.h | 21 ------
libc/test/src/sys/mman/linux/CMakeLists.txt | 20 -----
.../sys/mman/linux/process_mrelease_test.cpp | 74 -------------------
11 files changed, 1 insertion(+), 182 deletions(-)
delete mode 100644 libc/src/sys/mman/linux/process_mrelease.cpp
delete mode 100644 libc/src/sys/mman/process_mrelease.h
delete mode 100644 libc/test/src/sys/mman/linux/process_mrelease_test.cpp
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index aa0b8ba0490e98..effa5b12d87ac4 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -252,7 +252,6 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.sys.mman.munlockall
libc.src.sys.mman.munmap
libc.src.sys.mman.remap_file_pages
- libc.src.sys.mman.process_mrelease
libc.src.sys.mman.posix_madvise
libc.src.sys.mman.shm_open
libc.src.sys.mman.shm_unlink
diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt
index 7bdb7f4d1ec61b..5a48baf104159f 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -251,7 +251,6 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.sys.mman.munmap
libc.src.sys.mman.remap_file_pages
libc.src.sys.mman.posix_madvise
- libc.src.sys.mman.process_mrelease
libc.src.sys.mman.shm_open
libc.src.sys.mman.shm_unlink
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index 5e9cc71279ab16..1bedc25a9d0291 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -252,7 +252,6 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.sys.mman.munmap
libc.src.sys.mman.remap_file_pages
libc.src.sys.mman.posix_madvise
- libc.src.sys.mman.process_mrelease
libc.src.sys.mman.shm_open
libc.src.sys.mman.shm_unlink
diff --git a/libc/include/sys/syscall.h.def b/libc/include/sys/syscall.h.def
index 11758ea8336ddf..03c19eb0885ed6 100644
--- a/libc/include/sys/syscall.h.def
+++ b/libc/include/sys/syscall.h.def
@@ -2349,12 +2349,5 @@
#define SYS_writev __NR_writev
#endif
-#ifdef __NR_process_mrelease
-#define SYS_process_mrelease __NR_process_mrelease
-#endif
-
-#ifdef __NR_pidfd_open
-#define SYS_pidfd_open __NR_pidfd_open
-#endif
#endif // LLVM_LIBC_SYS_SYSCALL_H
diff --git a/libc/newhdrgen/yaml/sys/mman.yaml b/libc/newhdrgen/yaml/sys/mman.yaml
index dd53eb60d1ec57..962ca3591917f7 100644
--- a/libc/newhdrgen/yaml/sys/mman.yaml
+++ b/libc/newhdrgen/yaml/sys/mman.yaml
@@ -132,10 +132,3 @@ functions:
return_type: int
arguments:
- type: const char *
- - name: process_mrelease
- standards:
- - Linux
- return_type: int
- arguments:
- - type: int
- - type: unsigned int
diff --git a/libc/src/sys/mman/CMakeLists.txt b/libc/src/sys/mman/CMakeLists.txt
index 281efc0ffcdf20..4d4c2ad376050e 100644
--- a/libc/src/sys/mman/CMakeLists.txt
+++ b/libc/src/sys/mman/CMakeLists.txt
@@ -113,9 +113,3 @@ add_entrypoint_object(
DEPENDS
.${LIBC_TARGET_OS}.mremap
)
-
-add_entrypoint_object(
- process_mrelease
- ALIAS
- DEPENDS
- .${LIBC_TARGET_OS}.process_mrelease)
diff --git a/libc/src/sys/mman/linux/CMakeLists.txt b/libc/src/sys/mman/linux/CMakeLists.txt
index aa2ca4b160181a..89a0ad1527a065 100644
--- a/libc/src/sys/mman/linux/CMakeLists.txt
+++ b/libc/src/sys/mman/linux/CMakeLists.txt
@@ -36,6 +36,7 @@ add_entrypoint_object(
libc.src.__support.OSUtil.osutil
libc.src.errno.errno
)
+
add_entrypoint_object(
munmap
SRCS
@@ -213,14 +214,3 @@ add_entrypoint_object(
libc.src.unistd.unlink
.shm_common
)
-
-add_entrypoint_object(
- process_mrelease
- SRCS
- process_mrelease.cpp
- HDRS
- ../process_mrelease.h
- DEPENDS
- libc.include.sys_syscall
- libc.src.__support.OSUtil.osutil
- libc.src.errno.errno)
diff --git a/libc/src/sys/mman/linux/process_mrelease.cpp b/libc/src/sys/mman/linux/process_mrelease.cpp
deleted file mode 100644
index e86bbec1b1b661..00000000000000
--- a/libc/src/sys/mman/linux/process_mrelease.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-//===---------- Linux implementation of the mrelease function -----------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#include "src/sys/mman/process_mrelease.h"
-
-#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
-#include "src/__support/common.h"
-
-#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
-#include <linux/param.h> // For EXEC_PAGESIZE.
-#include <sys/syscall.h> // For syscall numbers.
-
-namespace LIBC_NAMESPACE_DECL {
-
-LLVM_LIBC_FUNCTION(int, process_mrelease, (int pidfd, unsigned int flags)) {
- long ret =
- LIBC_NAMESPACE::syscall_impl<int>(SYS_process_mrelease, pidfd, flags);
-
- if (ret < 0) {
- libc_errno = static_cast<int>(-ret);
- return -1;
- }
-
- return 0;
-}
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/sys/mman/process_mrelease.h b/libc/src/sys/mman/process_mrelease.h
deleted file mode 100644
index 6c800f2d0eab86..00000000000000
--- a/libc/src/sys/mman/process_mrelease.h
+++ /dev/null
@@ -1,21 +0,0 @@
-//===-- Implementation header for process_mrelease function -*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===------------------------------------------------------------------===//
-
-#ifndef LLVM_LIBC_SRC_SYS_MMAN_PROCESS_MRELEASE_H
-#define LLVM_LIBC_SRC_SYS_MMAN_PROCESS_MRELEASE_H
-
-#include "src/__support/macros/config.h"
-#include <sys/mman.h> // For size_t and off_t
-
-namespace LIBC_NAMESPACE_DECL {
-
-int process_mrelease(int pidfd, unsigned int flags);
-
-} // namespace LIBC_NAMESPACE_DECL
-
-#endif // LLVM_LIBC_SRC_SYS_MMAN_PROCESS_MRELEASE_H
diff --git a/libc/test/src/sys/mman/linux/CMakeLists.txt b/libc/test/src/sys/mman/linux/CMakeLists.txt
index 1a5ff3af8eb117..44ed11aadfe8b7 100644
--- a/libc/test/src/sys/mman/linux/CMakeLists.txt
+++ b/libc/test/src/sys/mman/linux/CMakeLists.txt
@@ -181,23 +181,3 @@ add_libc_unittest(
libc.hdr.fcntl_macros
libc.test.UnitTest.ErrnoSetterMatcher
)
-
-add_libc_unittest(
- process_mrelease_test
- SUITE
- libc_sys_mman_unittests
- SRCS
- process_mrelease_test.cpp
- DEPENDS
- libc.include.sys_mman
- libc.include.sys_syscall
- libc.src.errno.errno
- libc.src.sys.mman.process_mrelease
- libc.src.unistd.close
- libc.src.signal.kill
- libc.include.signal
- libc.src.stdlib.exit
- libc.src.__support.OSUtil.osutil
- libc.src.__support.threads.sleep
- libc.test.UnitTest.ErrnoSetterMatcher
-)
diff --git a/libc/test/src/sys/mman/linux/process_mrelease_test.cpp b/libc/test/src/sys/mman/linux/process_mrelease_test.cpp
deleted file mode 100644
index 56a7d66ee7a5ac..00000000000000
--- a/libc/test/src/sys/mman/linux/process_mrelease_test.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-//===-- Unittests for process_mrelease ------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
-#include "src/__support/threads/sleep.h"
-#include "src/errno/libc_errno.h"
-#include "src/signal/kill.h"
-#include "src/stdlib/exit.h"
-#include "src/sys/mman/process_mrelease.h"
-#include "src/unistd/close.h"
-#include "src/unistd/fork.h"
-#include "test/UnitTest/ErrnoSetterMatcher.h"
-#include "test/UnitTest/LibcTest.h"
-
-#include <sys/syscall.h>
-
-using namespace LIBC_NAMESPACE::testing::ErrnoSetterMatcher;
-
-int pidfd_open(pid_t pid, unsigned int flags) {
- return LIBC_NAMESPACE::syscall_impl(SYS_pidfd_open, pid, flags);
-}
-
-TEST(LlvmLibcProcessMReleaseTest, NoError) {
- pid_t child_pid = fork();
- EXPECT_GE(child_pid, 0);
-
- if (child_pid == 0) {
- // Child process: wait a bit then exit gracefully.
- LIBC_NAMESPACE::sleep_briefly();
- LIBC_NAMESPACE::exit(0);
- } else {
- // Parent process: wait a bit and then kill the child.
- // Give child process some time to start.
- LIBC_NAMESPACE::sleep_briefly();
- int pidfd = pidfd_open(child_pid, 0);
- EXPECT_GE(pidfd, 0);
-
- // Send SIGKILL to child process
- LIBC_NAMESPACE::kill(child_pid, SIGKILL);
-
- EXPECT_THAT(LIBC_NAMESPACE::process_mrelease(pidfd, 0), Succeeds());
-
- LIBC_NAMESPACE::close(pidfd);
- }
-}
-
-TEST(LlvmLibcProcessMReleaseTest, ErrorNotKilled) {
- pid_t child_pid = fork();
- EXPECT_GE(child_pid, 0);
-
- if (child_pid == 0) {
- // Child process: wait a bit then exit gracefully.
- LIBC_NAMESPACE::sleep_briefly();
- LIBC_NAMESPACE::exit(0);
- } else {
- // Give child process some time to start.
- LIBC_NAMESPACE::sleep_briefly();
- int pidfd = pidfd_open(child_pid, 0);
- EXPECT_GE(pidfd, 0);
-
- EXPECT_THAT(LIBC_NAMESPACE::process_mrelease(pidfd, 0), Fails(EINVAL));
-
- LIBC_NAMESPACE::close(pidfd);
- }
-}
-
-TEST(LlvmLibcProcessMReleaseTest, ErrorNonExistingPidfd) {
- EXPECT_THAT(LIBC_NAMESPACE::process_mrelease(-1, 0), Fails(EBADF));
-}
More information about the libc-commits
mailing list