From patchwork Mon Jan 23 17:37:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13112643 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 A5081C38142 for ; Mon, 23 Jan 2023 17:38:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2D9456B0088; Mon, 23 Jan 2023 12:38:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 288AF6B0089; Mon, 23 Jan 2023 12:38:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0B4326B008A; Mon, 23 Jan 2023 12:38:22 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id D92276B0089 for ; Mon, 23 Jan 2023 12:38:22 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id B4163C2206 for ; Mon, 23 Jan 2023 17:38:22 +0000 (UTC) X-FDA: 80386772844.10.D7A6FEA Received: from 66-220-144-178.mail-mxout.facebook.com (66-220-144-178.mail-mxout.facebook.com [66.220.144.178]) by imf27.hostedemail.com (Postfix) with ESMTP id F14004001F for ; Mon, 23 Jan 2023 17:38:20 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=none; spf=neutral (imf27.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=1674495501; 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:in-reply-to:references:references; bh=8P5nJvBBBXt+f7B98ljEhcX6LRnkeWeqEmjDASSaXMo=; b=74Hh4F3ER2mquWvxoUlXApcIIUne9MlW75prEl3I/EkHDZWC31GPp79u3k1Vd5xYN9m3kV 6yt5eyfwBB+IjyQmCmYo8s1ixbEFTPpl1/v7K7iLB5Qlf2jRed9fcqjomiGdBO/i77+Kyu 1fI2OHgB859Z3dLgUjOzD2QwQ6Ssle0= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=none; spf=neutral (imf27.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1674495501; a=rsa-sha256; cv=none; b=WfU9mzfxVSriP76pVpVUTnyfTUElFzIiJlj0JqFHUBbdPsPUuc19RtwlB+q20LHSjt32w7 Yl8ZOlM0z4p9lJcnd6D046QC9I1pK8k4ucTixOahndWhRrfDt15dR72V3kA7xg0iMfw7wv P2VfUtI72DMSvfdpQjtqq2C5zJgjUKw= Received: by dev0134.prn3.facebook.com (Postfix, from userid 425415) id 6F5EE5616BE9; Mon, 23 Jan 2023 09:37:56 -0800 (PST) From: Stefan Roesch To: linux-mm@kvack.org Cc: shr@devkernel.io, linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-trace-kernel@vger.kernel.org Subject: [RESEND RFC PATCH v1 12/20] mm: add ksm_merge_type() function Date: Mon, 23 Jan 2023 09:37:40 -0800 Message-Id: <20230123173748.1734238-13-shr@devkernel.io> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230123173748.1734238-1-shr@devkernel.io> References: <20230123173748.1734238-1-shr@devkernel.io> MIME-Version: 1.0 X-Stat-Signature: i8tikc43g3o5ymky17w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Qn7je aojhBwQp elX2LEJzKXG6gpOg1iPdgFfFglHkxKVwNVbszlt6jLntR3cP6W8QJOXCCisGe2k8U1WX+ID6hJoqNskqRGj9o7uwRE8ckGq27yWVG X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This adds the ksm_merge_type function. The function returns the merge type for the process. For madvise it returns "madvise", for prctl it returns "process" and otherwise it returns "none". Signed-off-by: Stefan Roesch --- include/linux/ksm.h | 1 + mm/ksm.c | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/include/linux/ksm.h b/include/linux/ksm.h index a18cd03efcfb..d5f69f18ee5a 100644 --- a/include/linux/ksm.h +++ b/include/linux/ksm.h @@ -57,6 +57,7 @@ void folio_migrate_ksm(struct folio *newfolio, struct folio *folio); #ifdef CONFIG_PROC_FS long ksm_process_profit(struct mm_struct *); +const char *ksm_merge_type(struct mm_struct *mm); #endif /* CONFIG_PROC_FS */ #else /* !CONFIG_KSM */ diff --git a/mm/ksm.c b/mm/ksm.c index 288689b59527..57183deaf529 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -2941,6 +2941,17 @@ long ksm_process_profit(struct mm_struct *mm) return (long)mm->ksm_merging_pages * PAGE_SIZE - mm->ksm_rmap_items * sizeof(struct ksm_rmap_item); } + +/* Return merge type name as string. */ +const char *ksm_merge_type(struct mm_struct *mm) +{ + if (test_bit(MMF_VM_MERGE_ANY, &mm->flags)) + return "process"; + else if (test_bit(MMF_VM_MERGEABLE, &mm->flags)) + return "madvise"; + else + return "none"; +} #endif /* CONFIG_PROC_FS */ #ifdef CONFIG_SYSFS