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 5DD77C00140 for ; Wed, 24 Aug 2022 04:42:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9F2566B0073; Wed, 24 Aug 2022 00:42:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9A1EB6B0074; Wed, 24 Aug 2022 00:42:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 84346940007; Wed, 24 Aug 2022 00:42:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 7213B6B0073 for ; Wed, 24 Aug 2022 00:42:27 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 476941404DB for ; Wed, 24 Aug 2022 04:42:27 +0000 (UTC) X-FDA: 79833239934.30.3F10AFB Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) by imf02.hostedemail.com (Postfix) with ESMTP id EE6CD80012 for ; Wed, 24 Aug 2022 04:42:26 +0000 (UTC) Received: by mail-pf1-f177.google.com with SMTP id y15so11408859pfr.9 for ; Tue, 23 Aug 2022 21:42:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc; bh=ocxT1JDH7H0ayD0p5Sl9WUobRg+2sXtb14mCi8PzQ8w=; b=axccxcBG8/CAMaLGLSv268V8rfdZWKaDj95406vRQRgAQhNOZPt1wT0SBBCyT0YmoB bd6LfEGWvD/4FH8UTO4lin1REhLHhla15pIKDjZM+eODuQr2DCjZ2NZmkQAD9rLFlhYD PoKSL/vFJsi2X7uxUw79KDfis5i3leyqV4iN9iXvT3X2KpNtLSg0gAoRcJroUJedjH1z 7Womim6DlC/hrp2L41vfvEpZMM0Fd0HPW7Fiy7Km2It9662JboNC+sLk0jC8BBU5fAlr 5Yaxk6AVDqzOoiuRq4M11bdhhZUqDB9z6U5ZQpnbA23tvckBEHyAofPoZGjs/EZBdZwF EdcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc; bh=ocxT1JDH7H0ayD0p5Sl9WUobRg+2sXtb14mCi8PzQ8w=; b=ytIiML7thWi7M5W8uxoUfkwDxhHs/G0ZSYapChKucIwG75Tu9d2geKNjtvXNpGwBKQ OBrdTSy4FVBG6iH0wX0WC49rKohaS6D0iVMf6XYlWwjviRSZwNO6kTDhEFz97CBE21W8 m5bE2waEsYI9YBsLI0yVm+dHMeD/WbtS6KsRCdjsyWD/2ONejeuDEUbFsEBgFDbSNPZv lrTAQbjjReOT7ROdMd2E31p47X0V91FJ3cXhZCypiFqg5R5r8ntBVy/f9aAPA8SMfrC6 ZFo99dQZvZpkwHjDn2On4FmzxtaMf81xK4AgFiJiuKOcAyAnbWtqSWmEbyxd2JS3qO1A Tj7A== X-Gm-Message-State: ACgBeo1Z2XNv2J1kyKKp+fH6UNQ+WlZF8Yg5oi07+giKYnYNSmYMauuW faGFOLAd0gShQVpkyvmFfII= X-Google-Smtp-Source: AA6agR5Sn4qcNQPF8JA9bDbZ4W3bArYh5fq/M2t1WkLaKzSjjkZzIpEDD/YJt9wjurvSIsGwfDSROQ== X-Received: by 2002:a05:6a00:10ca:b0:536:ec31:827c with SMTP id d10-20020a056a0010ca00b00536ec31827cmr7336655pfu.67.1661316145858; Tue, 23 Aug 2022 21:42:25 -0700 (PDT) Received: from debian.me (subs28-116-206-12-51.three.co.id. [116.206.12.51]) by smtp.gmail.com with ESMTPSA id c15-20020a170903234f00b00172897952a0sm11460568plh.283.2022.08.23.21.42.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Aug 2022 21:42:25 -0700 (PDT) Received: by debian.me (Postfix, from userid 1000) id 995C9103D8E; Wed, 24 Aug 2022 11:42:22 +0700 (WIB) Date: Wed, 24 Aug 2022 11:42:22 +0700 From: Bagas Sanjaya To: xu xin Cc: akpm@linux-foundation.org, adobriyan@gmail.com, willy@infradead.org, hughd@google.com, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, xu xin , Xiaokai Ran , Yang Yang Subject: Re: [PATCH v2 1/2] ksm: count allocated ksm rmap_items for each process Message-ID: References: <20220824040036.215002-1-xu.xin16@zte.com.cn> <20220824040153.215059-1-xu.xin16@zte.com.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20220824040153.215059-1-xu.xin16@zte.com.cn> ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661316146; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ocxT1JDH7H0ayD0p5Sl9WUobRg+2sXtb14mCi8PzQ8w=; b=je0RZJK8LhmyreaiGOhWmRI716/gosFZdnzbyfPgVrl4F/Me3oTBdRiaMZ/JI8/qGHfIlG SyBGcpQMOOqdVV4ZYBm0ovMcZPNmmvrx6yttAdYZDLJZ1EeFYuCOsZYedXRnVWxgasXbUX 9W7HYEWsawbmKkBXA49Q9Ji2uFpqyuQ= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=axccxcBG; spf=pass (imf02.hostedemail.com: domain of bagasdotme@gmail.com designates 209.85.210.177 as permitted sender) smtp.mailfrom=bagasdotme@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661316146; a=rsa-sha256; cv=none; b=Ry/Ix0AMxBJUePDt6hzdnDpN01TSCpGQYC/Ann2GRA0MsG+mPaP63+A//pB+ernylZsAh8 OSzzHN//le8Ox06w9YyVtll1/ROOtEuuQWETeVgca6cvNhwJYw1Ah+El0V/m3awTinXFCs Sy8IHuvjtYnYYxJGCMWcCQRkz6Q7EtM= X-Stat-Signature: 8x771bw4osyypjgpry4ksf8t6ef3h7bg X-Rspamd-Queue-Id: EE6CD80012 X-Rspam-User: Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=axccxcBG; spf=pass (imf02.hostedemail.com: domain of bagasdotme@gmail.com designates 209.85.210.177 as permitted sender) smtp.mailfrom=bagasdotme@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam01 X-HE-Tag: 1661316146-54761 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000009, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, Aug 24, 2022 at 04:01:53AM +0000, xu xin wrote: > KSM can save memory by merging identical pages, but also can consume > additional memory, because it needs to generate rmap_items to save > each scanned page's brief rmap information. Some of these pages may > be merged, but some may not be abled to be merged after being checked > several times, which are unprofitable memory consumed. > > The information about whether KSM save memory or consume memory in > system-wide range can be determined by the comprehensive calculation > of pages_sharing, pages_shared, pages_unshared and pages_volatile. > A simple approximate calculation: > > profit =~ pages_sharing * sizeof(page) - (all_rmap_items) * > sizeof(rmap_item); > > where all_rmap_items equals to the sum of pages_sharing, pages_shared, > pages_unshared and pages_volatile. > > But we cannot calculate this kind of ksm profit inner single-process wide > because the information of ksm rmap_item's number of a process is lacked. > For user applications, if this kind of information could be obtained, > it helps upper users know how beneficial the ksm-policy (like madvise) > they are using brings, and then optimize their app code. For example, > one application madvise 1000 pages as MERGEABLE, while only a few pages > are really merged, then it's not cost-efficient. > > So we add a new interface /proc//ksm_rmp_items for each process to > indicate the total allocated ksm rmap_items of this process. Similarly, > we can calculate the ksm profit approximately for a single-process by: > > profit =~ ksm_merging_pages * sizeof(page) - ksm_rmp_items * > sizeof(rmap_item); > > where ksm_merging_pages and ksm_rmp_items are both under /proc//. > Hmm... I can't apply this patch on linux-next. On what commit this patch series is based on? When submitting patches, don't forget to include --base to git format-patch. Thanks. -- An old man doll... just what I always wanted! - Clara