From mboxrd@z Thu Jan 1 00:00:00 1970 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 5E045C3271E for ; Thu, 11 Jul 2024 06:33:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CE8E56B008A; Thu, 11 Jul 2024 02:33:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C981D6B0092; Thu, 11 Jul 2024 02:33:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B5F4A6B0095; Thu, 11 Jul 2024 02:33:08 -0400 (EDT) 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 966666B008A for ; Thu, 11 Jul 2024 02:33:08 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 1511B8038B for ; Thu, 11 Jul 2024 06:33:08 +0000 (UTC) X-FDA: 82326504456.13.B23C7E2 Received: from out-187.mta1.migadu.com (out-187.mta1.migadu.com [95.215.58.187]) by imf30.hostedemail.com (Postfix) with ESMTP id C6C3680004 for ; Thu, 11 Jul 2024 06:33:05 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=wJN6yJ8A; spf=pass (imf30.hostedemail.com: domain of chengming.zhou@linux.dev designates 95.215.58.187 as permitted sender) smtp.mailfrom=chengming.zhou@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1720679542; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=VJHH7Wx3XHEyE7veqN7gpho4Y8N6hqLK1Tgti03sgZc=; b=2tH9N/K8XsN80FbyFUeuxyJJvJlXOWP0t6qffHVySI30BThYfSXfnEvOmvA+ZccV6E1CKN W5pOjcYIcWR0pS713vSgHUzhTJi4PBe0V4G8AOuxzBYAF32BSOwukZtr2A+Q5X9TU/ua6r FVTggy8i7PBDzbfoGBjwMRk+3XxmyCw= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=wJN6yJ8A; spf=pass (imf30.hostedemail.com: domain of chengming.zhou@linux.dev designates 95.215.58.187 as permitted sender) smtp.mailfrom=chengming.zhou@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1720679542; a=rsa-sha256; cv=none; b=vjprdXZ1NXBYprZKywb7Lzw8qI0zL8YhUbrSFpks4yn1zhKtH1u99DQ7sb0tHUAJYQDHBe ZtQ2mQxqs9sgZCyXLjLWwVBOas4lpEc1+tFiPyBWzUEMlhzdHG2yJhueIaSbcwg13xXQRa 8NPBVbjOIac0kYOmWasmakViOpbzI1Q= X-Envelope-To: sfoon.kim@samsung.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1720679583; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VJHH7Wx3XHEyE7veqN7gpho4Y8N6hqLK1Tgti03sgZc=; b=wJN6yJ8AwEjQrHAMBxovjJH1aA524Y3x3n+HaUdWA/d2QCA2r4IyJuzh1uaOn41G3kjFOn 0rnbU+7YZTa/ET7HKz+4D0it0QUcsjaupNVzZYBdtRqTnBpRmofirQMSbULP6Fc2kLOuRG 383WD88G2+qApR6QLIHtoJHyDYWepFY= X-Envelope-To: david@redhat.com X-Envelope-To: linux-mm@kvack.org X-Envelope-To: linux-kernel@vger.kernel.org X-Envelope-To: sungguk.na@samsung.com X-Envelope-To: sw0312.kim@samsung.com X-Envelope-To: sebuns@gmail.com X-Envelope-To: akpm@linux-foundation.org Message-ID: <727feddd-bc2d-4b70-aa0a-148b73a62948@linux.dev> Date: Thu, 11 Jul 2024 14:32:53 +0800 MIME-Version: 1.0 Subject: Re: [PATCH v2] mm: ksm: Consider the number of ksm_mm_slot in the general_profit calculation To: Sung-hun Kim , 'David Hildenbrand' , linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: sungguk.na@samsung.com, sw0312.kim@samsung.com, sebuns@gmail.com, akpm@linux-foundation.org References: <20240620043914.249768-1-sfoon.kim@samsung.com> <254bf3e0-0056-4593-94ee-8431a1bfc430@redhat.com> <0fe501dad351$ef692cb0$ce3b8610$@samsung.com> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Chengming Zhou In-Reply-To: <0fe501dad351$ef692cb0$ce3b8610$@samsung.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: C6C3680004 X-Stat-Signature: 1cd6i1hi8pinac1sop35eexu8h91wwft X-Rspam-User: X-HE-Tag: 1720679585-27459 X-HE-Meta: U2FsdGVkX19j7lfaAdnVKm++3wOObe0JmpDKORgPAPdDqlnGG0Nyteh3teSFYxOdZ0ulz6aUCnX0xMVI2unJGazmI2cQ5/kRbk/ktwgOEaV7Mb0ofybXUMyfspZr5A57RbxIDoTKwtsW5rPRerf+l5LeXzHMqVUEcvm3RbSdesz6oEZd+YAu9dO4t9JFKKLHsbyh9Fs1/rjMc4H9wYwYmCe+oRr+8aOPlce+6N/jNPg1ZdRqCRJQmxWkvBs2D9SU6Pp6WZZMvMT4Kq6hKcZy/y97mtYsepRAFAU9dx9iX53cPO3DWY56inzc8cenx9Gc/V4k4zi7X7C+OVwkO58VhGKQPCGSTmNmqn9T+yy5/RBwRWnw45Lz0U0xFyupYDPUUSHBBZ9ixNkfScD0QrIz2bLNP6d5gWwqftG9bnDcly1uCjJ+JIhLYxuUZdjCl85GjkPer6IPlHonT9FCB9thUk+OAIDASlvIwb7l8UHmVf1z2pmxkW1JYs0LeCXDodMfE2chmR3qCc65sDzDHqpnx7zWrtwdN9PuvAOHt6IGUvft4rCOp0tncyosRlam7kz/wCm8CSkUJzt2/wuRL/dvx4RhKZ0/yJkbIKugYDeJlTp6zhig8sp19j9Lq2iXuyyH6xWOKRd2Fg6vuM5zVUitVtaXOJFF39PHKYMFbskhgrZ7HnBnt2Rsx0tIJwGTaGlxxgtsnMWhlp1wr9CAIALiUzVXtCtil+NGnqZVBu5PKKRTMi/bvRMF+ETQdteWEdDD9T5UEK/+hGkXrOJzAeVtj4SoVpz6kUowM5+HD7wF+BcAi3MLsiKN+RRV98HcgVG/MAu9pHGcGBiqz0v7k2VCX0+VB6TaA3XE+Xqepr8QJHHyb1BDyuDh4heu/dC8FuYm3zNC2tMpvLMgqPcNIcnn8V+LYHFMssxqTf2/UCRcdcdqCFVYtWqe9R95cJs1VRwoTxwVerO0RWdXgZVsjRM 9Na7DMgo lH9dg9gTAqBg7aT6T7pJpq8kEpZLA34yUasVhMnOKp59v4CFpb8R/2oe5YwCPEE2TtGu/By/+vqNMBntqJEluVUVymk5XqeJcR55+Q7PS+cdSlEJNZKcurQIfUsD7pJiFzu4U9YM7svSllBuKiVMK1BpMDvuCyR7BtxQ7PZ5oJw+RdYM/Gb/GnpnJ6tLwI9qRvT0EcxvpVZt4pDNL0LkNmWr8FT8FBPNqtGQQuUFJc6acpW8eggPQuvePIeVhCZ/AbrxD 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: List-Subscribe: List-Unsubscribe: On 2024/7/11 13:19, Sung-hun Kim wrote: > Hello, > I'm sorry for late reply, because there was an issue in the mail system of my company. > > In my humble opinion, this problem can be considered due to the objective of the value > that can be gotten through general_profit. > I think that there is no problem in getting the more accurate value through general_profit > because it involves only negligible overhead due to the accounting of allocated metadata. > Even the difference is small, it could affect the decision in the use of KSM on the > memory-restricted device. Seems reasonable, not sure how does it matters with a few more pages consumption in your case. > Since KSM only wastes the CPU time to find identical pages if the gain is small, so more > accurate information is needed to decide whether KSM is used or not. Apart from the CPU time for scanning and merging, another important consideration is how dynamic changing of your merged pages, since it has to CoW when fault on writing. (And if you have swap enabled, KSM rmap can also bring some performance affects, since it breaks CoW unconditionally.) > Even though ksm_mm_slot and ksm_stable_node occupy few pages (or tens of pages), if KSM > found small amount of pages_sharing, it can affect the gained profit. > Because of that, I think that including other metadata in general_profit calculation is > not a big problem if tracking such metadata causes negligible overhead. > > It's my mistake in omitting the consideration of ksm_stable_node. The patch should include > the calculation of the amount of ksm_stable_node. FYI: I sent a patch that includes ksm_stable_node in general_profit some time ago. You can take it as you want: https://lore.kernel.org/all/20240508-b4-ksm-counters-v1-4-e2a9b13f70c5@linux.dev/ Thanks.