From patchwork Thu Nov 8 08:27:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 994685 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-489319-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="bHgTV3wQ"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42rGc96RXqz9s9G for ; Thu, 8 Nov 2018 19:27:21 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :subject:to:cc:message-id:date:mime-version:content-type; q=dns; s=default; b=CADJuQkU81G2NbpSO+wol/DQmCVXLDj8Vkt3nKrT7wFql6xb9q i7orrq2460VLB5YFG2G2ZWHfiaZNX4FcEzRLnzwqE7a3ODXluF7gguMyss491AJx wWbGKkwaK1DBNv8Z1BTHUw7oo6DXGoj1gxV2wc5eVtBBVFC/GmU5RA5Mk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :subject:to:cc:message-id:date:mime-version:content-type; s= default; bh=RRv6Eu3WX4BFhzrutlPhKZVjLzU=; b=bHgTV3wQUXI5VJxgFYoD pQJZGLrsAQkfPwyrG4a5oyowaTAaPObIdCUUA6yBYIOocSwn9tZ0SNBFQP8Bt1ec Sqv7x3gZuo4875AMefUlNhTE6BeQ2Rpj+YgwWqrFTQ6T1ZG7OLZfqfghcyGh7SUp 4JEOpuLFruW3iy+gJysI958= Received: (qmail 38884 invoked by alias); 8 Nov 2018 08:27:13 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 38871 invoked by uid 89); 8 Nov 2018 08:27:12 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, SPF_PASS autolearn=ham version=3.3.2 spammy=sk:sched_g, *operator, CPUs, UD:sanitizer_linux_libcdep.cc X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 08 Nov 2018 08:27:10 +0000 Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 8A79DAE02; Thu, 8 Nov 2018 08:27:08 +0000 (UTC) From: =?utf-8?q?Martin_Li=C5=A1ka?= Subject: [PATCH] Revert libsanitizer r318802 as we don't use Scudo allocator (PR sanitizer/87892). To: gcc-patches@gcc.gnu.org Cc: Jakub Jelinek Message-ID: Date: Thu, 8 Nov 2018 09:27:08 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 X-IsSubscribed: yes Hi. The GetNumberOfCPUs functionality is only used from Scudo allocator: https://llvm.org/docs/ScudoHardenedAllocator.html The hardening allocator is not used from GCC, thus I recommend to remove the function. Ready for trunk? Martin libsanitizer/ChangeLog: 2018-11-08 Martin Liska PR sanitizer/87892 * (all files): Revert upstream r318802. --- .../sanitizer_common/sanitizer_common.cc | 1 - .../sanitizer_common/sanitizer_common.h | 9 --- .../sanitizer_common/sanitizer_fuchsia.cc | 4 -- .../sanitizer_linux_libcdep.cc | 69 ------------------- .../sanitizer_common/sanitizer_mac.cc | 4 -- .../sanitizer_common/sanitizer_win.cc | 6 -- 6 files changed, 93 deletions(-) diff --git a/libsanitizer/sanitizer_common/sanitizer_common.cc b/libsanitizer/sanitizer_common/sanitizer_common.cc index 7f0f47c005d..29f35bb599a 100644 --- a/libsanitizer/sanitizer_common/sanitizer_common.cc +++ b/libsanitizer/sanitizer_common/sanitizer_common.cc @@ -23,7 +23,6 @@ const char *SanitizerToolName = "SanitizerTool"; atomic_uint32_t current_verbosity; uptr PageSizeCached; -u32 NumberOfCPUsCached; // PID of the tracer task in StopTheWorld. It shares the address space with the // main process, but has a different PID and thus requires special handling. diff --git a/libsanitizer/sanitizer_common/sanitizer_common.h b/libsanitizer/sanitizer_common/sanitizer_common.h index 603d922b969..d57434ae1dd 100644 --- a/libsanitizer/sanitizer_common/sanitizer_common.h +++ b/libsanitizer/sanitizer_common/sanitizer_common.h @@ -939,15 +939,6 @@ void CheckNoDeepBind(const char *filename, int flag); // be used to seed a PRNG. Defaults to blocking like the underlying syscall. bool GetRandom(void *buffer, uptr length, bool blocking = true); -// Returns the number of logical processors on the system. -u32 GetNumberOfCPUs(); -extern u32 NumberOfCPUsCached; -INLINE u32 GetNumberOfCPUsCached() { - if (!NumberOfCPUsCached) - NumberOfCPUsCached = GetNumberOfCPUs(); - return NumberOfCPUsCached; -} - } // namespace __sanitizer inline void *operator new(__sanitizer::operator_new_size_type size, diff --git a/libsanitizer/sanitizer_common/sanitizer_fuchsia.cc b/libsanitizer/sanitizer_common/sanitizer_fuchsia.cc index 6602f97b40b..d38151d2711 100644 --- a/libsanitizer/sanitizer_common/sanitizer_fuchsia.cc +++ b/libsanitizer/sanitizer_common/sanitizer_fuchsia.cc @@ -482,10 +482,6 @@ bool GetRandom(void *buffer, uptr length, bool blocking) { return true; } -u32 GetNumberOfCPUs() { - return zx_system_get_num_cpus(); -} - uptr GetRSS() { UNIMPLEMENTED(); } } // namespace __sanitizer diff --git a/libsanitizer/sanitizer_common/sanitizer_linux_libcdep.cc b/libsanitizer/sanitizer_common/sanitizer_linux_libcdep.cc index 32f335eaf23..0cdc97111f4 100644 --- a/libsanitizer/sanitizer_common/sanitizer_linux_libcdep.cc +++ b/libsanitizer/sanitizer_common/sanitizer_linux_libcdep.cc @@ -35,17 +35,14 @@ #if SANITIZER_FREEBSD #include #include -#include #define pthread_getattr_np pthread_attr_get_np #endif #if SANITIZER_OPENBSD #include -#include #endif #if SANITIZER_NETBSD -#include #include #endif @@ -55,16 +52,6 @@ #if SANITIZER_ANDROID #include -#if !defined(CPU_COUNT) && !defined(__aarch64__) -#include -#include -struct __sanitizer::linux_dirent { - long d_ino; - off_t d_off; - unsigned short d_reclen; - char d_name[]; -}; -#endif #endif #if !SANITIZER_ANDROID @@ -644,62 +631,6 @@ uptr GetRSS() { return rss * GetPageSizeCached(); } -// sysconf(_SC_NPROCESSORS_{CONF,ONLN}) cannot be used on most platforms as -// they allocate memory. -u32 GetNumberOfCPUs() { -#if SANITIZER_FREEBSD || SANITIZER_NETBSD || SANITIZER_OPENBSD - u32 ncpu; - int req[2]; - uptr len = sizeof(ncpu); - req[0] = CTL_HW; - req[1] = HW_NCPU; - CHECK_EQ(internal_sysctl(req, 2, &ncpu, &len, NULL, 0), 0); - return ncpu; -#elif SANITIZER_ANDROID && !defined(CPU_COUNT) && !defined(__aarch64__) - // Fall back to /sys/devices/system/cpu on Android when cpu_set_t doesn't - // exist in sched.h. That is the case for toolchains generated with older - // NDKs. - // This code doesn't work on AArch64 because internal_getdents makes use of - // the 64bit getdents syscall, but cpu_set_t seems to always exist on AArch64. - uptr fd = internal_open("/sys/devices/system/cpu", O_RDONLY | O_DIRECTORY); - if (internal_iserror(fd)) - return 0; - InternalMmapVector buffer(4096); - uptr bytes_read = buffer.size(); - uptr n_cpus = 0; - u8 *d_type; - struct linux_dirent *entry = (struct linux_dirent *)&buffer[bytes_read]; - while (true) { - if ((u8 *)entry >= &buffer[bytes_read]) { - bytes_read = internal_getdents(fd, (struct linux_dirent *)buffer.data(), - buffer.size()); - if (internal_iserror(bytes_read) || !bytes_read) - break; - entry = (struct linux_dirent *)buffer.data(); - } - d_type = (u8 *)entry + entry->d_reclen - 1; - if (d_type >= &buffer[bytes_read] || - (u8 *)&entry->d_name[3] >= &buffer[bytes_read]) - break; - if (entry->d_ino != 0 && *d_type == DT_DIR) { - if (entry->d_name[0] == 'c' && entry->d_name[1] == 'p' && - entry->d_name[2] == 'u' && - entry->d_name[3] >= '0' && entry->d_name[3] <= '9') - n_cpus++; - } - entry = (struct linux_dirent *)(((u8 *)entry) + entry->d_reclen); - } - internal_close(fd); - return n_cpus; -#elif SANITIZER_SOLARIS - return sysconf(_SC_NPROCESSORS_ONLN); -#else - cpu_set_t CPUs; - CHECK_EQ(sched_getaffinity(0, sizeof(cpu_set_t), &CPUs), 0); - return CPU_COUNT(&CPUs); -#endif -} - #if SANITIZER_LINUX # if SANITIZER_ANDROID diff --git a/libsanitizer/sanitizer_common/sanitizer_mac.cc b/libsanitizer/sanitizer_common/sanitizer_mac.cc index 28b2906e226..bd4949c1b75 100644 --- a/libsanitizer/sanitizer_common/sanitizer_mac.cc +++ b/libsanitizer/sanitizer_common/sanitizer_mac.cc @@ -1082,10 +1082,6 @@ bool GetRandom(void *buffer, uptr length, bool blocking) { return true; } -u32 GetNumberOfCPUs() { - return (u32)sysconf(_SC_NPROCESSORS_ONLN); -} - } // namespace __sanitizer #endif // SANITIZER_MAC diff --git a/libsanitizer/sanitizer_common/sanitizer_win.cc b/libsanitizer/sanitizer_common/sanitizer_win.cc index ebc6c503036..74c04050a7a 100644 --- a/libsanitizer/sanitizer_common/sanitizer_win.cc +++ b/libsanitizer/sanitizer_common/sanitizer_win.cc @@ -1047,12 +1047,6 @@ bool GetRandom(void *buffer, uptr length, bool blocking) { UNIMPLEMENTED(); } -u32 GetNumberOfCPUs() { - SYSTEM_INFO sysinfo = {}; - GetNativeSystemInfo(&sysinfo); - return sysinfo.dwNumberOfProcessors; -} - } // namespace __sanitizer #endif // _WIN32