Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp2177928rdb; Thu, 21 Sep 2023 10:35:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEUFMPV4fRGm/M5RK0MXqcTVtMR4O4DRE0oxZNXgewRurRF+hJj4LAowsLR+x2W8BA6h9PD X-Received: by 2002:a05:6a20:42a6:b0:13e:9dba:ea43 with SMTP id o38-20020a056a2042a600b0013e9dbaea43mr492015pzj.2.1695317750948; Thu, 21 Sep 2023 10:35:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695317750; cv=none; d=google.com; s=arc-20160816; b=vnu8OjRyuuGk0AkSrzUuS+8MCn3P5gInwmyKUCg0WqzpPw+z3MP09LJ4S0PDtfIVlw XrhjgzFNclWsMdIppk1zE/O7ZBzJa32hZAUTazMDi/ng2LIZi5v/XZanM5prorTMnDAs 7z6jw+q9r9dJ94mFEZOuhPcveMhpa4G6EzH2ZTGdHoRMy2T2+V1br40RDxvaXxgTIkKN i0r/ofXMdh378i0evsTH4rtwKsLGl+SLruEthU5yKuVMEp6ry58QfE+3kO/R3USG4YLC OvP8Zy8TjC5QcBIZksxeGMHeT2pXRuVTGp3Kand0AslbNZF0eqgQSVW2Ynh7Npl1HRJ4 +pAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=2Ui9HQp2pxPJ3NIxebx6kuSf7rRkN1tIaYoms9ZvXGw=; fh=trQN94Iqca1GMQF1AkSOofuqg8pe0AKHPTTlJaXdYFw=; b=EpAG8yXxE7erhM+E72j0N3EJbFVJPoRbd/h7A8bqmusekzw0Q/zj4yLhrwT9UgX+od Tnu+IvVSlgYoJvbQxEBhjWulYcZQRNTAqruUh211Hd5BwMVpb87Sjh4mHj1hjDs7SYgB eIrneZM6APLzOtUxzW3D5tTC/bw/nQ9rL6QFIzQx1P42eYCVZLm6asOTCHrMU5woeGxQ 41vivc9K/YNndybFoDwZDpFwTKUoox4eMThNMnczgQe4bKHM4i7CShXx9aNub/Fdsc8E 6veX1+A79t+T/I/qOiw8f7KSKWEqxOn1ujcxfRsce0TxW5XyRIaHudhEJFzchEwGazfr krEQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id z19-20020a63e113000000b0057768a32896si1767746pgh.365.2023.09.21.10.35.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 10:35:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 67FD982295D4; Thu, 21 Sep 2023 10:29:05 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230303AbjIUR2n (ORCPT + 99 others); Thu, 21 Sep 2023 13:28:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230249AbjIUR16 (ORCPT ); Thu, 21 Sep 2023 13:27:58 -0400 Received: from 66-220-144-179.mail-mxout.facebook.com (66-220-144-179.mail-mxout.facebook.com [66.220.144.179]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A48224853 for ; Thu, 21 Sep 2023 10:11:30 -0700 (PDT) Received: by devbig1114.prn1.facebook.com (Postfix, from userid 425415) id 74B35C502489; 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, Carl Klemm Subject: [PATCH v3 1/2] mm/ksm: support fork/exec for prctl Date: Thu, 21 Sep 2023 09:47:08 -0700 Message-Id: <20230921164709.3627565-2-shr@devkernel.io> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20230921164709.3627565-1-shr@devkernel.io> References: <20230921164709.3627565-1-shr@devkernel.io> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Thu, 21 Sep 2023 10:29:05 -0700 (PDT) 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 addresses this problem. Signed-off-by: Stefan Roesch Fixes: d7597f59d1d3 ("mm: add new api to enable ksm per process") Reviewed-by: David Hildenbrand Reported-by: Carl Klemm Tested-by: Carl Klemm --- include/linux/sched/coredump.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/include/linux/sched/coredump.h b/include/linux/sched/coredum= p.h index 0ee96ea7a0e9..205aa9917394 100644 --- a/include/linux/sched/coredump.h +++ b/include/linux/sched/coredump.h @@ -87,8 +87,11 @@ static inline int get_dumpable(struct mm_struct *mm) =20 #define MMF_DISABLE_THP_MASK (1 << MMF_DISABLE_THP) =20 +#define MMF_VM_MERGE_ANY 29 +#define MMF_VM_MERGE_ANY_MASK (1 << MMF_VM_MERGE_ANY) + #define MMF_INIT_MASK (MMF_DUMPABLE_MASK | MMF_DUMP_FILTER_MASK |\ - MMF_DISABLE_THP_MASK | MMF_HAS_MDWE_MASK) + MMF_DISABLE_THP_MASK | MMF_HAS_MDWE_MASK |\ + MMF_VM_MERGE_ANY_MASK) =20 -#define MMF_VM_MERGE_ANY 29 #endif /* _LINUX_SCHED_COREDUMP_H */ --=20 2.39.3