From patchwork Sat Oct 28 19:55:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 738983 Delivered-To: patch@linaro.org Received: by 2002:a5d:4c47:0:b0:32d:baff:b0ca with SMTP id n7csp482807wrt; Sat, 28 Oct 2023 12:56:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHg9VRG9m+P2UeMBbyNcaEGR6tpBVgeDf/3Lrf4eq8m1ozox68PAhazsdI6T7u/msKCXjNI X-Received: by 2002:a05:6214:4001:b0:65d:f1d:d383 with SMTP id kd1-20020a056214400100b0065d0f1dd383mr9297785qvb.3.1698522986935; Sat, 28 Oct 2023 12:56:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1698522986; cv=pass; d=google.com; s=arc-20160816; b=ZOMP0CuA/tvNAV+Y8DFzEOpUkBKjyM3lJrUDbzyw1DtWaxSiJcviudFXP04tm4WfFq i6KJ42KlbZY7NQqAoQTskaE9yedIFx48JUt+HTQJHthRLFEGQ993iYLCNwS8PZsUzZ8x cOD+5Y1khzq+/1eoWGVxzcCJT+RWQcVM1+sUINfJnzmOIZgMri/TRXEqD63rDhcrxIRU IhyMeM4gWOBb7BlYXlMHXYRmAzrTbS2ar5G6tdLFp3cSRNBQ6UKJXV3e/Mt//kHQK7wJ PE+kqLf59MuEgAucZGvMJtesgVQnU0FMcgapK7j8vUt30DviWfcW9I6WAHaHK1jlHOfz F0Nw== 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=puuGT2pr2dVYZu65gR2pxdQKGbYolq+pz7DGwE+QWB6pf6sGw+nTuYOK4y0LZC7PPg MWXyfT+auxAMXk2D2VcTpLAOFOBLba9s9TsZOcXZz9vQ9MEcJV62QlfoSlFGmAPsOvmH ZOkRMCRBKhgryU4THz5qzoPCBfVgOQ+VCbuJ/9pqy7sIsnEQGnmG2jcHuNWagvmiRoDe LFgz22rFpPbryW3EPB8+7a/Kn8+rj2vErcO3eanD1Un3A2jewm6GXtg+6jbpzrpWrhtk V7ZimcOdCvtGmlCjGhUi37g8EF6QT677mvIdUtKOIzs3LHP42/fAMu1tlARJDNV+WGwg IoVw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mdRGuARZ; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c 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. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id x13-20020a0cfe0d000000b0066d0543b654si2874133qvr.341.2023.10.28.12.56.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 12:56:26 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mdRGuARZ; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c 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 97D3238618F4 for ; Sat, 28 Oct 2023 19:56:26 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oi1-x22b.google.com (mail-oi1-x22b.google.com [IPv6:2607:f8b0:4864:20::22b]) by sourceware.org (Postfix) with ESMTPS id 2B5AE385F02B for ; Sat, 28 Oct 2023 19:56:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2B5AE385F02B 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 2B5AE385F02B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::22b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698522974; cv=none; b=sk4dtVpYbUaL+ph6xmXC3YRyEODFYMjPYhSDPcAXunJ12puoXwvMRx/fuRDNFjr98V2kD00oxLvc2P/5Df/Fyc+TJi8yPmGoGmn0FuiBB8NyumfT5usviuJf3+rWwB17Lx/aNlqJQ8hjUcQBBs8GSvIj0zivWfF5Bpt9XgAnoUo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698522974; c=relaxed/simple; bh=8RRL5kABKc1J1lzV6b7gDsG4ZHPjL9tbGRf2dOdaMtU=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=T2ETlhLRnD3llbJ3rF6K/LoftlNpcO/ixQ1ENY/czXRh/rG5572EzSAjylttjBeLIIllvi7G1nFaVeTiYirAv5tRbetXGN6xCP6RE+OfWWInCVN/eRP9npeJ6Yg5AuKuX1TXPF1nzZBBKz1mPsJLXIs4Wxp7ig2Y7wWtrYzucUY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-oi1-x22b.google.com with SMTP id 5614622812f47-3af609c4dfeso2081584b6e.1 for ; Sat, 28 Oct 2023 12:56:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698522972; x=1699127772; 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=mdRGuARZw2oRzR7okgocJlpq4IuPdQV0vasNl1z7eacsGou4JLa6ZLL9ey/2Mtvzn+ X7XUkwjAO9v41r5d93b5MgJ3f4EsXrDyFxbM1Hnvn6lGDSKpu4MQrsbolrsh/UNP6vqO BjzNLRz9FRWFceaf9yX/lKXSCn0K56vU1d/RcAR4HXAcr3VG2PfQzQbRwflarN/ftExM ebCl+u63jTYOZ+UP8YRBwi6IkBCFvzQ+jHHf6kACWBZwNBtOa6r8RlWBSxoa/vAR+F+M Wlbr1lRD44xoe0zsi9G7sZtTrV9CS8cmUHJb2nrGNQTHgKt1+MEIG8QRcThg/WqZziuM /iQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698522972; x=1699127772; 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=qeTcEPtrilgnnwDZx9qv1oiusLP/58qyLFGj+kZEhPKYQwSJy9iA+NgvRplK1MsCaP O2FfBMk77MXO8ACqGCYKb2+uruuZgJi7ZBIaW70KfxTTC6H8vxzKn4r8s/R/j3xo5a0w R+XEoqLz21Lh6acIfLxrcVbKoNEmnzaCcIg3RCbsgOFB0oZjGLvlm5Id+r/qZOkuMQA8 LDeeP1Yd4BqXh3ewlMcgaIJPw6LL0a7z/4L+AOixFcJbePYfKdfU8QRDH89ykgmb0Fxj fAxmNBACOmgx1JBgf0WwDofUnXYeUbiaW6MU6zBgvnI3fvEH9es4KQ70XJRlefsHqr5Z akgA== X-Gm-Message-State: AOJu0Yw2dxyPiNiN7w3qX/mJksp8gxGGEH7kbQP6wJTI5TqrLFBtNLya JJAC5dgE+m57voiWWrgFpmpkoeZi+K3MecSRTgbfx7GP X-Received: by 2002:a05:6808:2981:b0:3ad:fc0f:e852 with SMTP id ex1-20020a056808298100b003adfc0fe852mr6731076oib.23.1698522971814; Sat, 28 Oct 2023 12:56:11 -0700 (PDT) Received: from localhost.localdomain ([139.178.84.207]) by smtp.gmail.com with ESMTPSA id w20-20020a056830411400b006b8c87551e8sm763181ott.35.2023.10.28.12.56.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 12:56:10 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org, Ian Rogers , Francesco Nigro , Carlos O'Donell , Siddhesh Poyarekar Subject: [PATCH v2 2/7] support: Add support_set_vma_name Date: Sat, 28 Oct 2023 19:55:54 +0000 Message-Id: <20231028195559.390407-3-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231028195559.390407-1-adhemerval.zanella@linaro.org> References: <20231028195559.390407-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.7 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 +}