From patchwork Tue Oct 8 13:23:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 1994265 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=S4pX7b6C; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XNGxl3qb6z1xvB for ; Wed, 9 Oct 2024 00:26:19 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B338D386182B for ; Tue, 8 Oct 2024 13:26:17 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by sourceware.org (Postfix) with ESMTPS id F1F763861839 for ; Tue, 8 Oct 2024 13:24:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F1F763861839 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 F1F763861839 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1030 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728393896; cv=none; b=HfQ+XzOnUXZyMeiLbXQ+yaQB7T7KSmDXILAG3auwjissV+0qhF+aCI2sY3oCN3dbQ3bBdfUofKfsXea422CF/IFlwujy/zAmoGjceXC8N27hLk99RnPDDDIpnmLfl1KtfkYDd/HzsFbV6NsEKZhEcohOmEjAkKkpOJVp+uAkDMc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728393896; c=relaxed/simple; bh=fgd82q6X0bInuvp1Bk+vVjE/3khMSRLm1PG8fKgdTFg=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=MeCaw2Zn0mYHVkbAM6xKsV1HDVN7Yd1gGOfAKe6AZ62Z90E8MOdtp0ou9u38qdwFcrFKJHf4u1qEL+B1dYmoMdaLgyd1HF1mXjHD8fBDx/P00HK5LyE6Bglh51GzzxHUKa6+Qh07H1A0AsJBa/rr1J3niONvelzzPIuDBULkVUM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pj1-x1030.google.com with SMTP id 98e67ed59e1d1-2e2916a92ffso274109a91.1 for ; Tue, 08 Oct 2024 06:24:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728393893; x=1728998693; 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=UFOWrTvUvTPPO3aHRMJ7fQ/rfyXcYKEKa79Bp/GFXCQ=; b=S4pX7b6CZeS0elHcMcTRJjD2vXReURvBSf69fyQlG00+7x4XIfSMwvY72PfAEBmTaR lXJrZ0SH5sp4ApXAvPStAtXTzT/kC1M7Pa9Tqg4AJC4cWqvmeYKuzy53I8lLzzX8MUR7 kykS7+Zd9uuZyBZ+RMoxL6fCA2vj4WNhgjSoicupfp5pFADsk0YfaVvJAQMqJeH1rACO Y2cBiwRnhysSv5SSXN+u4rW1o9iYbWxsU49ybDYvR6qlOVtgTeGtPgEL/u4ARN9thz8K 2ruwAuPSftSfmCzLvCR8+w9GJFx5t+BH1ADN32vbPgP3FfIL+LlcFyw4W+azIJ4BrUaC L0Ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728393893; x=1728998693; 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=UFOWrTvUvTPPO3aHRMJ7fQ/rfyXcYKEKa79Bp/GFXCQ=; b=hi1z0vYroUAmtAs55oo/pLvcuqCasG++q00Yv1q/vmphab3p+x5SMS3wJ4Q4l9mn7A KsvuVWKeOM2PjgnokMb698hbc3nPohc4yuwGn7varWY1VNvb2RN4YTTaYIMWZfU+yiXZ Don76UlBG3P87+ALlvmiZBtjqD1zELw/LkEowqPJRXevMUrKzHlX5ig3egOkmVFUEVi0 vGbNh7Hra/D+2vViH/QAZVA/B3K4LlfHb0qvc65HnPDfIqrDz66HQ7ZSQemjfgO86/c7 uB01MWzjdKteJ7rodZzuHlsw+APebXufSm6gSISl1DNMrPTodMu/mu0vaiBd1lMbyPsJ ZHaw== X-Gm-Message-State: AOJu0YyZBcTP7AZ6McEuXnQ5pyeJBq3mlTvFyS+KhxaNyuFmWrtlWpLl oibHiiE8fI01bnBHqCkoLPO74IXaoAnhNS2zxujlVvXBkXV3Y5qseBsndfcW7hLCwErsr6SxfSf ezp6coA== X-Google-Smtp-Source: AGHT+IHN/y62I+Jhh1eGF+7MVlF3KEAxvzraZ2Ub2M5l4nS/fY3bD4Asv2RU/3pjvMXpCxZnKQN0aA== X-Received: by 2002:a17:90a:c287:b0:2d8:7edb:fd2 with SMTP id 98e67ed59e1d1-2e1e6267484mr17993845a91.22.1728393892663; Tue, 08 Oct 2024 06:24:52 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c2:68d6:61bb:ff14:bcb3:8ace]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e20ae7177esm7597909a91.3.2024.10.08.06.24.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 06:24:52 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 6/6] linux: Add MAP_DROPPABLE from Linux 6.11 Date: Tue, 8 Oct 2024 10:23:46 -0300 Message-ID: <20241008132440.722309-7-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241008132440.722309-1-adhemerval.zanella@linaro.org> References: <20241008132440.722309-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, 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~incoming=patchwork.ozlabs.org@sourceware.org This request the page to be never written out to swap, it will be zeroed under memory pressure (so kernel can just drop the page), it is inherited by fork, it is not counted against @code{mlock} budget, and if there is no enough memory to service a page faults there is no fatal error (so not signal is sent). Tested with build-many-glibcs.py. --- manual/llio.texi | 9 +++++++++ sysdeps/unix/sysv/linux/bits/mman-linux.h | 1 + 2 files changed, 10 insertions(+) diff --git a/manual/llio.texi b/manual/llio.texi index a035c3e20f..c8e6e07ea0 100644 --- a/manual/llio.texi +++ b/manual/llio.texi @@ -1762,6 +1762,15 @@ write dirty metadata out whenever dirty data is written out. Unlike most other flags, this one will fail unless @code{MAP_SHARED_VALIDATE} is also given. +@item MAP_DROPPABLE +This request the page to be never written out to swap, it will be zeroed +under memory pressure (so kernel can just drop the page), it is inherited +by fork, it is not counted against @code{mlock} budget, and if there is +no enough memory to service a page faults there is no fatal error (so not +signal is sent). + +The @code{MAP_DROPPABLE} flag is specific to Linux. + @end vtable @code{mmap} returns the address of the new mapping, or diff --git a/sysdeps/unix/sysv/linux/bits/mman-linux.h b/sysdeps/unix/sysv/linux/bits/mman-linux.h index 522333c50a..161a885096 100644 --- a/sysdeps/unix/sysv/linux/bits/mman-linux.h +++ b/sysdeps/unix/sysv/linux/bits/mman-linux.h @@ -43,6 +43,7 @@ #define MAP_PRIVATE 0x02 /* Changes are private. */ #define MAP_SHARED_VALIDATE 0x03 /* Share changes and validate extension flags. */ +#define MAP_DROPPABLE 0x08 /* Zero memory under memory pressure. */ #define MAP_TYPE 0x0f /* Mask for type of mapping. */ /* Other flags. */