From patchwork Thu Sep 21 16:47:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13394032 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 0B5B5E71094 for ; Thu, 21 Sep 2023 16:47:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7B9D26B01F1; Thu, 21 Sep 2023 12:47:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 76A0F6B01F9; Thu, 21 Sep 2023 12:47:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 659966B0204; Thu, 21 Sep 2023 12:47:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 59B076B01F1 for ; Thu, 21 Sep 2023 12:47:25 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 2ABEBA0371 for ; Thu, 21 Sep 2023 16:47:25 +0000 (UTC) X-FDA: 81261185250.27.E293738 Received: from 66-220-144-178.mail-mxout.facebook.com (66-220-144-178.mail-mxout.facebook.com [66.220.144.178]) by imf01.hostedemail.com (Postfix) with ESMTP id 97E3140018 for ; Thu, 21 Sep 2023 16:47:23 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=none; spf=neutral (imf01.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1695314843; 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=Q5eXsN6o+cp0dRU6wJOSguQAuugpqR6at+DPeLAQPVg=; b=q7M9Y3rI/LaZH4FcZXih4FBK6MDXmRwIdH1WmYOxmnSqRoRaAYEmhDuxzkplQkaK5SIB03 wZgp0kzuhoH1yoKB28fivrQnAvsLvKUA7Fs9ore2h2H/EQ49iK5rwdsWW+ROHT3JHU6sib Q0LoQmC02JYmHfe3A32kTq1kp8d1BaY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1695314843; a=rsa-sha256; cv=none; b=aeCt7rrmYmdcNH3ox+3QgvCfkcpjThAtZmmwPeJM2KZsbK2Rm7Jd1kN76fbB3Nn1YAbIyg H1STnjjBwchNaQd6dzeGNIe5owhi6bm8/sW5T9z5P5DINsFHt2a2GL9pPpyB3DZ+oK0UfV G4VwJCA6ddv58IexF4oKMy4ZRRNMmdY= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=none; spf=neutral (imf01.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io; dmarc=none Received: by devbig1114.prn1.facebook.com (Postfix, from userid 425415) id 6C37DC502486; Thu, 21 Sep 2023 09:47:11 -0700 (PDT) From: Stefan Roesch To: kernel-team@fb.com Cc: shr@devkernel.io, akpm@linux-foundation.org, david@redhat.com, hannes@cmpxchg.org, riel@surriel.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v3 0/2] mm/ksm: add fork-exec support for prctl Date: Thu, 21 Sep 2023 09:47:07 -0700 Message-Id: <20230921164709.3627565-1-shr@devkernel.io> X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 X-Stat-Signature: 4at8rmosy169nzb11mcnunfnrmtk54pu X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 97E3140018 X-Rspam-User: X-HE-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amicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: A process can enable KSM with the prctl system call. When the process is forked the KSM flag is inherited by the child process. However if the process is executing an exec system call directly after the fork, the KSM setting is cleared. This patch series addresses this problem. 1) Change the mask in coredump.h for execing a new process 2) Add a new test case in ksm_functional_tests Changes: - V3: - Combined two lines in function ksm_fork_exec_child() - V2: - Removed the child program from the patch series - Child program is implemented by the program itself - Added a new command line parameter for the child program - Removed new section from Makefile - Removed duplicate ; charaters - Added return in if clause - Used PR_GET_MEMORY_MERGE instead of magic numbers - Resetting PR_SET_MEMROY_MERGE at the end. Stefan Roesch (2): mm/ksm: support fork/exec for prctl mm/ksm: Test case for prctl fork/exec workflow include/linux/sched/coredump.h | 7 +- .../selftests/mm/ksm_functional_tests.c | 66 ++++++++++++++++++- 2 files changed, 70 insertions(+), 3 deletions(-) base-commit: 15bcc9730fcd7526a3b92eff105d6701767a53bb