From patchwork Tue Oct 8 18:45:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 833603 Delivered-To: patch@linaro.org Received: by 2002:adf:a1d9:0:b0:367:895a:4699 with SMTP id v25csp447946wrv; Tue, 8 Oct 2024 11:47:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVBT3VVDdEquMJmlaiSLLYBU994EjygHVogBYuzQ5Hsk68iRd/zIsArZKefBwp5Edh1w7+yew==@linaro.org X-Google-Smtp-Source: AGHT+IGDdpmL0xJMs88DwR4JA6FZFOnLY52gx3qItmNjxFYCCiKj1In3B8hR65BVqaGMbOq6jE2k X-Received: by 2002:a05:6214:4505:b0:6cb:2fa7:48cd with SMTP id 6a1803df08f44-6cb9a4556b2mr236264966d6.36.1728413228478; Tue, 08 Oct 2024 11:47:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1728413228; cv=pass; d=google.com; s=arc-20240605; b=h72RxUvDA1Y1lECGpHUB1vHu+2IiMpzEz7xtRzywIAzRGEICsAv7p+l4cdq/2djQ5u 5XtPglWM8yFyRD+GjEnKaUn2xqth8cOJlaUXv/7Z2Ow61E+1FsSxEhLfJDBGWsbtk5G7 dFGQyS0VlOjaPeIzk89PrAJ6fNrUjanOe1Gj6ctL4r7c0sKH63BPRr8aMKpx477jSGcR b1e8svZuaBECJ3hU9XYDUL1jsX0O1chYxuQc00j0q1sG5UIcNtQ7n9gxZrvMJy6ovc0z OymhBPFQresgUiIoJVmh6wkaraenWM/3+4dU3iQUpQm67VM3tqY6CFuk2zzX7yjzeb7y ZFcA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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:cc:to :from:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=zWfiDe0ZNitlZHfjFiHD7lXXoKeBoYkzXyjyTMszaSk=; fh=y8c+zjefmHK4fStUusN64Sx8n6mpTt8O9P1WOVzrReM=; b=GsxoAJvnubUUeQ3WvXU5DGhfK5pJRk0KxO5cTchZ2ganF+TLKafhQ/KbTvQkvtpYRU k1iHJwfuqN9qOZGBSMF+khzGecMT5UxBDRBuGkAaUIQjt3Fe8froIP8B64cew9yLwi38 2WNi+8Of3huW0GfqfJ6rjD0LiCvcltWQYX8ZZM8OW7a31XQBS5g4QEaNm/uyDMNFO96S ldjZaLwUcT6a9Hnq5N7xgNN+uTTNP9cFSnS6d3B/6QxRCbr0QWdJh/PKeLHLlCXgNn9F woiw94JQGoXzazkif1bGThJuxxj+IZOy+TpsKCQHWSNy1rZZGjY7n7xEpXDXpUiKWXJV TFRA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=m1EJaoJ2; 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 6a1803df08f44-6cba4771420si91226216d6.319.2024.10.08.11.47.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 11:47:08 -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=m1EJaoJ2; 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 0D77A384F4BA for ; Tue, 8 Oct 2024 18:47:08 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by sourceware.org (Postfix) with ESMTPS id 5C6F43861826 for ; Tue, 8 Oct 2024 18:46:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5C6F43861826 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 5C6F43861826 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::634 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728413210; cv=none; b=lsAUqPz6JlyeFUwWXekWjrWbTcgH5a8IicXGg3oc2uDDv44QPAIF12GmGwy7ruaRCQwGeF9TJZbhE0RgYXZK1p9ro7uaRLs71u5TY3K9ud2ITv0ams3idZ5aQfJ/niRA0rZMOHn2cflPkEvGsOktHAL2ZtReT/hN8gNY0+xFIYs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728413210; c=relaxed/simple; bh=i5NlRaj+0fmbSKTrdiTcADazcCm9acCFbKldxfjA2EM=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=x1qF1p7/Jt6++crbs5oPDrNpuI5elH40IyQRW3bbfedzUvT2mVJLJhx6lceIH7wjLJuTytrqBZ5+vzeVMjMrUWnvwId2Fivsvo94W21YIg3whwf0Skp+so2f1sNPcoix4IGtgztC39ebTuOiqPpj82HzngXGETWNfbowOFcjSIo= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-20b7259be6fso66203095ad.0 for ; Tue, 08 Oct 2024 11:46:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728413204; x=1729018004; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zWfiDe0ZNitlZHfjFiHD7lXXoKeBoYkzXyjyTMszaSk=; b=m1EJaoJ2ug/zVSkepzUsU/oMOtgGT4yH6Co74Bj8Cq6M1Ffmbx2B38CCkbFrFcKIic i6Pj4Y6+dVrmKXJrkYTCBT40A4zJW61fZnqCGZzQsspRGhUxZhfW5YldE/tNjGrw9uu+ hMz2foWfQiqhHh9gYhn6H2nwR9nozU4pHt7Ji6zCbHzkGQjylxpeVV/o8s/jP9T+Bugp ikrwqjvi8nzVmwc0sQV+tNMQ/VcRqKWujI4yNpwarvEaEqAEYDSvxqaKHiwTCaCvzuRU rNgfjnbPCHa4vKoACzI0VF8wJoo7dt8PyAKm6dEfA3agRmZwmNT2Y+p+8/B/1jkk+ZJy QSkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728413204; x=1729018004; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zWfiDe0ZNitlZHfjFiHD7lXXoKeBoYkzXyjyTMszaSk=; b=cuW+jl4ZcUvhjMyawGWBlM/qGFnT+Cdt0mK66tiCUT4Wed0tED1u6SHNq7CQIp8lgq xKdDuQIPE0qKRKU19M46ihkZd9GTbuoGWm9g5h3ztrGXvdSNX2SFjwgiLGmCrQzkvn4X NBIO3Ra0gQ9AQnBASJ7ptoFFAXBLKGIP7z+VXlbVFNnGCCIWyJ56TSo+HAoq0uwT9k0X 7A9Kqz48TkFtG15jQ3JjiTA7QrhEoYY9XL/O69THQL4JUjX297oM8kNPnvzCo9XOI0sW Z2BSQnAebY/BOTrZTdY84fzLOBffrR7614F3fTVEmWzl6oeorGmvlCWZdmHZMEFsauye fAAA== X-Gm-Message-State: AOJu0Yy68DF4eYFPqdqgbXL1Wik/eXeLEHI6nlxTRtOJhjH2eQ46T/aJ I+bxHGTJptaWmRA+GhRltpZAme7vU1TjbjQqAWq5BQUI9qtnpKA8coh22sGiUh5uYthvPn7N5uA TA9s= X-Received: by 2002:a17:902:ecca:b0:20c:5fd7:d71 with SMTP id d9443c01a7336-20c5fd70e4cmr13548975ad.22.1728413203855; Tue, 08 Oct 2024 11:46:43 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c2:68d6:61bb:ff14:bcb3:8ace]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c1395dc41sm58068535ad.217.2024.10.08.11.46.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 11:46:43 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Joseph Myers Subject: [PATCH v2 4/8] linux: Add MAP_DROPPABLE from Linux 6.11 Date: Tue, 8 Oct 2024 15:45:26 -0300 Message-ID: <20241008184634.245607-5-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241008184634.245607-1-adhemerval.zanella@linaro.org> References: <20241008184634.245607-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~patch=linaro.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. Reviewed-by: H.J. Lu --- manual/llio.texi | 9 +++++++++ sysdeps/unix/sysv/linux/bits/mman-linux.h | 1 + sysdeps/unix/sysv/linux/tst-mman-consts.py | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/manual/llio.texi b/manual/llio.texi index a035c3e20f..05ab44c6e7 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 +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 +not enough memory to service a page fault there is no fatal error (so no +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. */ diff --git a/sysdeps/unix/sysv/linux/tst-mman-consts.py b/sysdeps/unix/sysv/linux/tst-mman-consts.py index a1137eb1d5..2191bea36f 100644 --- a/sysdeps/unix/sysv/linux/tst-mman-consts.py +++ b/sysdeps/unix/sysv/linux/tst-mman-consts.py @@ -33,7 +33,7 @@ def main(): help='C compiler (including options) to use') args = parser.parse_args() linux_version_headers = glibcsyscalls.linux_kernel_version(args.cc) - linux_version_glibc = (6, 10) + linux_version_glibc = (6, 11) sys.exit(glibcextract.compare_macro_consts( '#define _GNU_SOURCE 1\n' '#include \n',