linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Sung-hun Kim" <sfoon.kim@samsung.com>
To: "'Andrew Morton'" <akpm@linux-foundation.org>
Cc: <linux-mm@kvack.org>, <linux-kernel@vger.kernel.org>,
	<sungguk.na@samsung.com>, <sw0312.kim@samsung.com>,
	<sebuns@gmail.com>, "'Stefan	Roesch'" <shr@devkernel.io>,
	<sfoon.kim@samsung.com>
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	[thread overview]
Message-ID: <0ff401dad359$08b54b20$1a1fe160$@samsung.com> (raw)
In-Reply-To: 

> > On Thu, 20 Jun 2024 13:39:14 +0900 Sung-hun Kim <sfoon.kim@samsung.com> 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



      parent reply	other threads:[~2024-07-11  6:10 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20240620043920epcas1p1b57dce789304aa96fd83e5b2b194d244@epcas1p1.samsung.com>
2024-06-20  4:39 ` Sung-hun Kim
2024-06-20 19:38   ` David Hildenbrand
2024-06-21  2:30     ` Chengming Zhou
2024-07-11  5:19     ` Sung-hun Kim
2024-07-11  6:32       ` Chengming Zhou
2024-06-20 20:47   ` Andrew Morton
2024-07-11  5:25     ` Sung-hun Kim
2024-07-11  6:10     ` Sung-hun Kim [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='0ff401dad359$08b54b20$1a1fe160$@samsung.com' \
    --to=sfoon.kim@samsung.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=sebuns@gmail.com \
    --cc=shr@devkernel.io \
    --cc=sungguk.na@samsung.com \
    --cc=sw0312.kim@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox