From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3AD40824B1 for ; Thu, 11 Jul 2024 06:10:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720678238; cv=none; b=OTqvZBqAqvToDRh6SCdFOfwQ+PUjev9MdorSk/uwyLPZRwEC+Kc9q0bJw4IOU4mfAqVtLrwE4i+cgzHIq2N+SczhsciWD3GPVkb77lTxqzMYoZ85M8Uw9VnJswKkYjT8jG2ojNYBHXQSw/TuEI6pbXdIiAfJy/ojnf0JjTVYhlw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720678238; c=relaxed/simple; bh=NFcPF7cszQID+chKYHNaTPZrfL8AE62lG/dtTI1BBwE=; h=From:To:Cc:In-Reply-To:Subject:Date:Message-ID:MIME-Version: Content-Type:References; b=UQbzgxp/xElFj4V2nP8WMiPc8VkZ4Q20MT5LEldY+IdnrisFkKsFPSgBpFPGZOKl1fEdOZbLBWo9N9J8WAORAossji0dWCLzYVgcOfPiN1BfrMYzuqdNoo6QPN30AYW5ZWWzwxV62F2qhh/mnf/kb8EhePFwPdYov45Ud0cqhEU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=lKYxVgN/; arc=none smtp.client-ip=203.254.224.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="lKYxVgN/" Received: from epcas1p2.samsung.com (unknown [182.195.41.46]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20240711061033epoutp04907d658afc4b3a115e1be7243bae5f6f~hE7yRD_ol3044630446epoutp04Q for ; Thu, 11 Jul 2024 06:10:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20240711061033epoutp04907d658afc4b3a115e1be7243bae5f6f~hE7yRD_ol3044630446epoutp04Q DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1720678233; bh=LBHZqqdhoRlrj5cqadLXf9+CXx2D7o7g6vvEoWJ4zqQ=; h=From:To:Cc:In-Reply-To:Subject:Date:References:From; b=lKYxVgN/bgdOzvzfYL+j9zl+Ws+PO72a7HTZdv0yle96OBFw2pIzEapOm6IGDcaKj aTkbQhnehYhxPLoTpG7RozJFMQKHKIZt7cEvLA6QGxq/SRFRwBnVVO8qZLRQ3uau/O ncxN1WByEXZO0plWHF49065wJvLxToCc7ILOAOKo= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas1p4.samsung.com (KnoxPortal) with ESMTP id 20240711061032epcas1p42d405bbb54b044b581e4b204fb07555b~hE7x7p2Xr0217802178epcas1p4K; Thu, 11 Jul 2024 06:10:32 +0000 (GMT) Received: from epsmges1p1.samsung.com (unknown [182.195.38.235]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4WKPTz6L3Rz4x9Q5; Thu, 11 Jul 2024 06:10:31 +0000 (GMT) Received: from epcas1p2.samsung.com ( [182.195.41.46]) by epsmges1p1.samsung.com (Symantec Messaging Gateway) with SMTP id 69.37.34823.7577F866; Thu, 11 Jul 2024 15:10:31 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas1p4.samsung.com (KnoxPortal) with ESMTPA id 20240711061031epcas1p440ca44c1b22b425482063ea641dc8d93~hE7wrMEoD0053600536epcas1p4K; Thu, 11 Jul 2024 06:10:31 +0000 (GMT) Received: from epsmgmc1p1new.samsung.com (unknown [182.195.42.40]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20240711061031epsmtrp2e67613cac152ab19bea258d67d20add4~hE7wqerNG1608016080epsmtrp2g; Thu, 11 Jul 2024 06:10:31 +0000 (GMT) X-AuditID: b6c32a35-e8dff70000018807-6f-668f7757e9fa Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgmc1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 28.2D.07412.7577F866; Thu, 11 Jul 2024 15:10:31 +0900 (KST) Received: from sfoonkim02 (unknown [10.113.222.42]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240711061031epsmtip172c00644b3059d1410c8aab6f804c4b0~hE7wdyg3Y0362903629epsmtip1o; Thu, 11 Jul 2024 06:10:31 +0000 (GMT) From: "Sung-hun Kim" To: "'Andrew Morton'" Cc: , , , , , "'Stefan Roesch'" , In-Reply-To: Subject: RE: [PATCH v2] mm: ksm: Consider the number of ksm_mm_slot in the general_profit calculation Date: Thu, 11 Jul 2024 15:10:31 +0900 Message-ID: <0ff401dad359$08b54b20$1a1fe160$@samsung.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQGcuK2mUct4l8vOyf6OuFEls7CcWwIwXU5MAt0bt+WyRMcJsIAACuUQ Content-Language: ko X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrIJsWRmVeSWpSXmKPExsWy7bCmnm54eX+aQfMffYs569ewWVzeNYfN 4t6a/6wWzRdeMlo0TlvObrGiZz2jxY55BxktZkx+yebA4fGl+S+Tx85Zd9k9Nn2axO5xYsZv Fo++LasYPT5vkgtgi8q2yUhNTEktUkjNS85PycxLt1XyDo53jjc1MzDUNbS0MFdSyE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-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240620043920epcas1p1b57dce789304aa96fd83e5b2b194d244 References: <20240620043914.249768-1-sfoon.kim@samsung.com> <20240620134752.9a63c12403282c0c7e728764@linux-foundation.org> > > On Thu, 20 Jun 2024 13:39:14 +0900 Sung-hun Kim wrote: > > > > > The current version of KSM does not take into account the number of > > > used ksm_mm_slot. Therefore, when users want to obtain profits of > > > KSM, KSM omits the memory used for allocating ksm_mm_slots. > > > > > > This patch introduces a new variable to keep track of the number of > > > allocated ksm_mm_slots. By doing so, KSM will be able to provide a > > > more accurate number of the gains made. > > > > > > > By how much does the improve the accuracy? In other words, how much difference does this make? > > > > I think it makes only small difference. (few kilobytes for hundreds of processes) > > > > > @@ -3672,7 +3680,8 @@ static ssize_t general_profit_show(struct kobject *kobj, > > > long general_profit; > > > > > > general_profit = (ksm_pages_sharing + atomic_long_read(&ksm_zero_pages)) * PAGE_SIZE - > > > - ksm_rmap_items * sizeof(struct ksm_rmap_item); > > > + ksm_rmap_items * sizeof(struct ksm_rmap_item) - > > > + atomic_long_read(&ksm_mm_slots) * sizeof(struct ksm_mm_slot); > > > > > > return sysfs_emit(buf, "%ld\n", general_profit); > > > > This assumes perfect slab packing, no? Should it use ksize()? > > Ah, thanks for your recommendation. It should be fixed. > I'm sorry. I found a mistake in my previous mail. I think ksize() does not fit in this context. ksize() should be used for the allocated object. But the calculation just uses the number of allocated ksm_mm_slots and sizeof() for the data structure like ksm_rmap_item. The calculated profit is an approximation of real value because the object does not be perfectly packed as you said. Best regards, Sung-hun Kim