From patchwork Mon Feb 27 22:02:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13154229 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 038F0C64ED6 for ; Mon, 27 Feb 2023 22:02:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 49FCC6B0074; Mon, 27 Feb 2023 17:02:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 450D16B0075; Mon, 27 Feb 2023 17:02:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3191E6B0078; Mon, 27 Feb 2023 17:02:26 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 20B8A6B0074 for ; Mon, 27 Feb 2023 17:02:26 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id CDDF9160B82 for ; Mon, 27 Feb 2023 22:02:25 +0000 (UTC) X-FDA: 80514446250.16.1790F0B Received: from 66-220-144-178.mail-mxout.facebook.com (66-220-144-178.mail-mxout.facebook.com [66.220.144.178]) by imf21.hostedemail.com (Postfix) with ESMTP id CC59F1C0002 for ; Mon, 27 Feb 2023 22:02:22 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf21.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1677535343; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references; bh=veJZGyPdTByegBY8iazgEduZcixkDSF5PeeLxLVCxGk=; b=ZPKw5JTjEZNB7lY8LsSnKftxakqcI4EJOUiaGinxHyJfsNACOv1kCIHzlplsq2v4ny/o7I u47BGPclSb77bWweMoRoWe+P+UWhKcfgVylM1J5bPncv82aDDtvhCnCwbprTA2SRdGJx3t 6T5vZ44bsW9ajDZrsXacUkeKp4aqnZc= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf21.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677535343; a=rsa-sha256; cv=none; b=zMmzPoSGCqIRbKnTIhIFhvjzagWHjpiHG3URGTtDmlBgZnauQ9AJ3K7Ie9vMO57AEiVLA/ o5t4azSOu+KJnpa/oUIX32/OafoT9ku6gk7ENxqCbeeICt21bVqIsGVII0hDYGiB9yiqnN RafBfs/jkCqRlEx/ynjqFQiguNSd0vo= Received: by dev0134.prn3.facebook.com (Postfix, from userid 425415) id AA33C80546BA; Mon, 27 Feb 2023 14:02:08 -0800 (PST) From: Stefan Roesch To: kernel-team@fb.com Cc: shr@devkernel.io, linux-mm@kvack.org, riel@surriel.com, hannes@cmpxchg.org, linux-man@vger.kernel.org, akpm@linux-foundation.org Subject: [PATCH v1] prctl: add flags to enable KSM at the process level Date: Mon, 27 Feb 2023 14:02:06 -0800 Message-Id: <20230227220206.436662-1-shr@devkernel.io> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: CC59F1C0002 X-Stat-Signature: 5n3ntkuqij3guibzxyffi9j3wbmyur8k X-Rspam-User: X-HE-Tag: 1677535342-415144 X-HE-Meta: U2FsdGVkX18f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ner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This adds two new flags to the prctl documentation: PR_SET_MEMORY_MERGE and PR_GET_MEMORY_MERGE. The flags allow to enable KSM (kernel samepage merging) at the process level and query is state. The "mm: process/cgroup ksm support" patch series has been posted to the mm mailing list and it enables this feature. Signed-off-by: Stefan Roesch --- man2/prctl.2 | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) base-commit: 53a7e5dfc3554a2e8dbdfdc4504e99652e1d6382 diff --git a/man2/prctl.2 b/man2/prctl.2 index 2212331af0e4..d10334484bf7 100644 --- a/man2/prctl.2 +++ b/man2/prctl.2 @@ -591,6 +591,26 @@ the current per-process machine check kill policy. All unused .BR prctl () arguments must be zero. +.\" prctl PR_SET_MEMORY_MERGE +.TP +.BR PR_SET_MEMORY_MERGE " (since Linux 6.4)" +Enable the KSM (kernel samepage merging) feature for this process. If +.I arg2 +is nonzero, KSM gets enabled for this process. Child processes will inherit the +setting. +.IP +The calling process must have the +.B CAP_SYS_RESOURCE +capability. +.\" prctl PR_GET_MEMORY_MERGE +.TP +.BR PR_GET_MEMORY_MERGE " (since Linux 6.4)" +Return (as the function result) if KSM (kernel samepage merging) has been +enabled for this process. All unused prctl() arguments must be NULL. +.IP +The calling process must have the +.B CAP_SYS_RESOURCE +capability. .\" prctl PR_SET_MM .TP .BR PR_SET_MM " (since Linux 3.3)"