From patchwork Thu Oct 26 17:11:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 738333 Delivered-To: patch@linaro.org Received: by 2002:ab3:1905:0:b0:23f:8cfb:5ad7 with SMTP id u5csp1311873ltc; Thu, 26 Oct 2023 10:12:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGDCREEMxgJ7iHkAclN8FhCTlTzmgE8uADR0o0lThnOt/+cHqB1oP6jdfJLEo6iUT9pIHWu X-Received: by 2002:a05:622a:1a91:b0:418:af7:e001 with SMTP id s17-20020a05622a1a9100b004180af7e001mr159580qtc.41.1698340350911; Thu, 26 Oct 2023 10:12:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1698340350; cv=pass; d=google.com; s=arc-20160816; b=jRgUfuZNzobDoO4yJ8p2bv7SBKZLrFMANq6MGL/WryKGATwqXdqFh9xzLgziQk5lMU GtYhe3VEDfVExmvbJ7CPzGL1bsibBG4+I+qScMupqNi/HogyC20qmHFtpitn/nv/uvJx LxfB+LWZEcZLHvEJ8J0yPSCQC2sqv0CmzU7c2190rrztQ6gGW0uQFgnYdZRM2gku89yI u2PswOfhPAgZaVV2miAUvqdB3FyIpuK3LvotI+S7j1A+omUQ42Ws0OuaOunRcsyOMNwo fW4DuyWDneCxySRm8lfyMCAT9ArWfChb5POREIKf/HyJYDKc3eA+a7joN6XWATArIWhF +Mfw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=s8RVhP5i91O39KSQjCyRzBdQQD/6GnedOsUOtoDrF/Y=; fh=Lbqp+rs2mRBTG5C9ik7cirOzlOF2+U9yLxjtEQVqExY=; b=cBQNvI61b4xfAT7Wi8E5jKXRsPkI0lQxoVV4BNBIHODnKQfNf0EO2W/h7vlKjVrIUg 97H42SqisicyuURR2rREYgza/DqOiT5ady+oNIrucjes2UaML4yMlnjz5UdPrhKHkirL kUJtle7gONNQUOfSG2N3pBNmbJJ4liDBGTlvNLbHZIbeCGO37V6oyNlKCwI+46TDRLrG VOppRuY/wu9/sigz1ofLAYqEF/DL2Q6o5GmgQ0EHhUppt7HIZbvAyhA8pKEBGnTFZBlg 03YX66eDQcUiGDXMOxudSFCgD01eXPkE+iCnFmCOAoNTibL77u0zkMlwSzav7ZOtzS6e L0rQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Vb6kBX/6"; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id d9-20020a05622a05c900b0041972df884fsi10013136qtb.578.2023.10.26.10.12.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 10:12:30 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Vb6kBX/6"; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 82FF13861835 for ; Thu, 26 Oct 2023 17:12:29 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by sourceware.org (Postfix) with ESMTPS id 99A0A3858C2B for ; Thu, 26 Oct 2023 17:11:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 99A0A3858C2B Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 99A0A3858C2B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::42e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698340320; cv=none; b=RG9kekIo3MK/2dsji/dXsC50db60J90aSuw6agA80CF+q/rzTQEuiIMyPX9IrIStg4NvUwbti+aBV3SaEeV7HvJYG8FSU2JEQ4W7/9xMQhvdqStIQtyd8oaqDOMU3rBtmToU6aTjLvYy9Tshjpy+lWyMbyy6KBQ56R8uMLv2jsA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698340320; c=relaxed/simple; bh=8RRL5kABKc1J1lzV6b7gDsG4ZHPjL9tbGRf2dOdaMtU=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=BI1UDC8yujIYvwpD7gcRmkl+VqQNJnvdp2PziJiw6kA73X51MMP8Cchn7S2OYAW7aKC55dHboSvqQ0lTZhyWlOsIL7T4O50rNiEs6niKlwdn78iCpvj6EqxZNjIYw92c7191OEF6oA7owfU1MtP6kbCm6xsm9HckMqdb58Kv6K8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-6b5af4662b7so1091249b3a.3 for ; Thu, 26 Oct 2023 10:11:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698340314; x=1698945114; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=s8RVhP5i91O39KSQjCyRzBdQQD/6GnedOsUOtoDrF/Y=; b=Vb6kBX/6m/BYulPE58ToeYGawvgef9EUPqx/tf5Tci5jXvXH8WlRKTsazqpY4XcXMn gxjHbqatMo0VXTm172ut+X2hZiSVYb092m7uCXxd65odg4zWwpfv+w/hI34zWv4WB/YW EqAQp0ujGlfXq0BuqpLZAHXC/fqzS8GB12Q4tExgJrUqlUMoQxaL+4vlW6cSJg6W6v9+ mdtI026G88Ybk962mh+wTgr6oHFfwUjp8t450s/z30rnzPBmHuipzE4qRPFyOXk+/EUa lr+AeJ/XGq3T7z11eS+qvgdC3nCiClODqoo1G2vIsmpArk2j+dLHK3WH5NxhrfoXIqyM P/qQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698340314; x=1698945114; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=s8RVhP5i91O39KSQjCyRzBdQQD/6GnedOsUOtoDrF/Y=; b=C0vql8bsiBrY0QfqdwrknjtpD8p2fgaQZdorzABID/Mz7UgM2ZewwqCgZw1B3NEykP v4cREUHV2d42mmEubEMfD8tl+hZnqTYhEqZCJPnlxWDLRd2Vhhtk7LNH/Xlw1NgJFeg7 wRrrxYiiVZp4uMSc20huE55Iaz5lbcz3PAPUSSPKA8XAXXtcoyLUuloUq+mL+GXHgQ+x KwLDjHpBAqLy3oxLREi01tTyJBcUT4uI8OmooM8Hk+pH7hFfjSAd4L9KeXBPGbIZPdax WfM/44rMuQOOZQ4HVCA4/74XX7MxJMmFBLwt3Nc+KgdM+1waELpbzhUT48nYA5LPsfZ6 pRrg== X-Gm-Message-State: AOJu0YwVKcflQQoqJcLFu5Qey1EJJkQehYACEEfawqoCsxCXA7ldSlwv srUks5utx8quDjpZVUwmXpCwerm2mMFDapLM5LV2uw== X-Received: by 2002:a05:6a00:1142:b0:692:af9c:d96a with SMTP id b2-20020a056a00114200b00692af9cd96amr140932pfm.5.1698340314098; Thu, 26 Oct 2023 10:11:54 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c3:a647:ad90:6e37:bd13:fb33]) by smtp.gmail.com with ESMTPSA id w18-20020aa78592000000b006bee5ad4efasm11516394pfn.67.2023.10.26.10.11.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 10:11:53 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org, Ian Rogers , Francesco Nigro , Carlos O'Donell , Siddhesh Poyarekar Subject: [PATCH 2/5] support: Add support_set_vma_name Date: Thu, 26 Oct 2023 14:11:41 -0300 Message-Id: <20231026171144.2188549-3-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231026171144.2188549-1-adhemerval.zanella@linaro.org> References: <20231026171144.2188549-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patch=linaro.org@sourceware.org Check if kernel supports prctl (PR_SET_VMA, PR_SET_VMA_ANON_NAME, ...). --- support/Makefile | 1 + support/support.h | 4 +++ support/support_set_vma_name.c | 49 ++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 support/support_set_vma_name.c diff --git a/support/Makefile b/support/Makefile index 917a858bd1..54a8cc30ac 100644 --- a/support/Makefile +++ b/support/Makefile @@ -80,6 +80,7 @@ libsupport-routines = \ support_select_modifies_timeout \ support_select_normalizes_timeout \ support_set_small_thread_stack_size \ + support_set_vma_name \ support_shared_allocate \ support_small_stack_thread_attribute \ support_socket_so_timestamp_time64 \ diff --git a/support/support.h b/support/support.h index b7f76bf080..659ef25b06 100644 --- a/support/support.h +++ b/support/support.h @@ -235,6 +235,10 @@ void support_stack_free (struct support_stack *stack); The returned value is the lowest file descriptor number. */ int support_open_dev_null_range (int num, int flags, mode_t mode); + +/* Check if kernel supports set VMA range name. */ +extern bool support_set_vma_name (void); + __END_DECLS #endif /* SUPPORT_H */ diff --git a/support/support_set_vma_name.c b/support/support_set_vma_name.c new file mode 100644 index 0000000000..41f5dea409 --- /dev/null +++ b/support/support_set_vma_name.c @@ -0,0 +1,49 @@ +/* Check if kernel supports set VMA range name. + Copyright (C) 2023 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include +#include +#ifdef __linux__ +# include +#endif + +bool +support_set_vma_name (void) +{ +#ifdef __linux__ + size_t size = sysconf (_SC_PAGESIZE); + if (size == -1) + FAIL_EXIT1 ("sysconf (_SC_PAGESIZE): %m\n"); + + void *vma = xmmap (0, + size, + PROT_NONE, + MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, + -1); + + int r = prctl (PR_SET_VMA, PR_SET_VMA_ANON_NAME, vma, size, "vmaname"); + + xmunmap (vma, size); + + return r == 0; +#else + return false; +#endif +}