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: Wed, 16 Nov 2022 15:57:14 +0100 [thread overview]
Message-ID: <Y3T6SqZvAmSG5I6W@dhcp22.suse.cz> (raw)
In-Reply-To: <0bd0b744-3d97-b4c3-a4fb-6040f8f8024a@bytedance.com>
On Wed 16-11-22 19:28:10, Zhongkun He wrote:
> Hi Michal, I've done the performance testing, please check it out.
>
> > > Yes this is all understood but the level of the overhead is not really
> > > clear. So the question is whether this will induce a visible overhead.
> > > Because from the maintainability point of view it is much less costly to
> > > have a clear life time model. Right now we have a mix of reference
> > > counting and per-task requirements which is rather subtle and easy to
> > > get wrong. In an ideal world we would have get_vma_policy always
> > > returning a reference counted policy or NULL. If we really need to
> > > optimize for cache line bouncing we can go with per cpu reference
> > > counters (something that was not available at the time the mempolicy
> > > code has been introduced).
> > >
> > > So I am not saying that the task_work based solution is not possible I
> > > just think that this looks like a good opportunity to get from the
> > > existing subtle model.
>
> Test tools:
> numactl -m 0-3 ./run-mmtests.sh -n -c configs/config-workload-
> aim9-pagealloc test_name
>
> Modification:
> Get_vma_policy(), get_task_policy() always returning a reference
> counted policy, except for the static policy(default_policy and
> preferred_node_policy[nid]).
It would be better to add the patch that has been tested.
> All vma manipulation is protected by a down_read, so mpol_get()
> can be called directly to take a refcount on the mpol. but there
> is no lock in task->mempolicy context.
> so task->mempolicy should be protected by task_lock.
>
> struct mempolicy *get_task_policy(struct task_struct *p)
> {
> struct mempolicy *pol;
> int node;
>
> if (p->mempolicy) {
> task_lock(p);
> pol = p->mempolicy;
> mpol_get(pol);
> task_unlock(p);
> if (pol)
> return pol;
> }
One way to deal with that would be to use a similar model as css_tryget
Btw. have you tried to profile those slowdowns to identify hotspots?
Thanks
--
Michal Hocko
SUSE Labs
next prev parent reply other threads:[~2022-11-16 14:57 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-11 8:40 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 [this message]
2022-11-17 7:19 ` Zhongkun He
2022-11-21 14:38 ` Michal Hocko
2022-11-22 8:33 ` Zhongkun He
2022-11-22 8:40 ` Michal Hocko
2022-11-14 9:24 ` Zhongkun He
2022-11-12 2:09 ` kernel test robot
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=Y3T6SqZvAmSG5I6W@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