From: Michal Hocko <mhocko@suse.com>
To: Zhongkun He <hezhongkun.hzk@bytedance.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
corbet@lwn.net, linux-mm@kvack.org, linux-kernel@vger.kernel.org,
linux-api@vger.kernel.org, linux-doc@vger.kernel.org
Subject: Re: [External] Re: [PATCH v2] mm: add new syscall pidfd_set_mempolicy().
Date: Mon, 21 Nov 2022 15:38:17 +0100 [thread overview]
Message-ID: <Y3uNWbPmwHtytKzY@dhcp22.suse.cz> (raw)
In-Reply-To: <6433156f-34a8-400f-e282-91268b242279@bytedance.com>
On Thu 17-11-22 15:19:20, Zhongkun He wrote:
> Hi Michal, thanks for your replay.
>
> >
> > It would be better to add the patch that has been tested.
>
> OK.
>
> >
> > One way to deal with that would be to use a similar model as css_tryget
>
> Percpu_ref is a good way to reduce memory footprint in fast path.But it
> has the potential to make mempolicy heavy. the sizeof mempolicy is 32
> bytes and it may not have a long life time, which duplicated from the
> parent in fork().If we modify atomic_t to percpu_ref, the efficiency of
> reading in fastpath will increase, the efficiency of creation and
> deletion will decrease, and the occupied space will increase
> significantly.I am not really sure it is worth it.
>
> atomic_t; 4
> sizeof(percpu_ref + percpu_ref_data + cpus* unsigned long)
> 16+56+cpus*8
Yes the memory consumption is going to increase but the question is
whether this is something that is a real problem. Is it really common to
have many vmas with a dedicated policy?
What I am arguing here is that there are essentially 2 ways forward.
Either we continue to build up on top of the existing and arguably very
fragile code and make it even more subtle or follow a general pattern of
a proper reference counting (with usual tricks to reduce cache line
bouncing and similar issues). I do not really see why memory policies
should be any different and require very special treatment.
> > Btw. have you tried to profile those slowdowns to identify hotspots?
> >
> > Thanks
>
> Yes, it will degrade performance about 2%-%3 may because of the task_lock
> and atomic operations on the reference count as shown
> in the previous email.
>
> new hotspots in perf.
> 1.34% [kernel] [k] __mpol_put
> 0.53% [kernel] [k] _raw_spin_lock
> 0.44% [kernel] [k] get_task_policy
Thanks!
--
Michal Hocko
SUSE Labs
next prev parent reply other threads:[~2022-11-21 14:40 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-11 8:40 [PATCH v2] mm: add new syscall pidfd_set_mempolicy() Zhongkun He
2022-11-11 19:27 ` Andrew Morton
2022-11-13 16:41 ` [External] " Zhongkun He
2022-11-14 11:44 ` Michal Hocko
2022-11-14 11:46 ` Michal Hocko
2022-11-14 17:52 ` Michal Hocko
2022-11-14 15:12 ` Zhongkun He
2022-11-14 18:12 ` Michal Hocko
2022-11-15 7:39 ` Zhongkun He
2022-11-16 11:28 ` Zhongkun He
2022-11-16 14:57 ` Michal Hocko
2022-11-17 7:19 ` Zhongkun He
2022-11-21 14:38 ` Michal Hocko [this message]
2022-11-22 8:33 ` Zhongkun He
2022-11-22 8:40 ` Michal Hocko
2022-11-14 9:24 ` Zhongkun He
2022-11-16 7:04 ` Huang, Ying
2022-11-16 9:38 ` [External] " Zhongkun He
2022-11-16 9:44 ` Michal Hocko
2022-11-17 6:29 ` Huang, Ying
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=Y3uNWbPmwHtytKzY@dhcp22.suse.cz \
--to=mhocko@suse.com \
--cc=akpm@linux-foundation.org \
--cc=corbet@lwn.net \
--cc=hezhongkun.hzk@bytedance.com \
--cc=linux-api@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
/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