linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Suren Baghdasaryan <surenb@google.com>
To: Michal Hocko <mhocko@suse.com>
Cc: Sudarshan Rajagopalan <quic_sudaraja@quicinc.com>,
	David Hildenbrand <david@redhat.com>,
	 Johannes Weiner <hannes@cmpxchg.org>,
	Mike Rapoport <rppt@kernel.org>,
	Oscar Salvador <osalvador@suse.de>,
	 Anshuman Khandual <anshuman.khandual@arm.com>,
	mark.rutland@arm.com, will@kernel.org,
	 virtualization@lists.linux-foundation.org, linux-mm@kvack.org,
	 linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	 linux-arm-msm@vger.kernel.org,
	Trilok Soni <quic_tsoni@quicinc.com>,
	 Sukadev Bhattiprolu <quic_sukadev@quicinc.com>,
	Srivatsa Vaddagiri <quic_svaddagi@quicinc.com>,
	 Patrick Daly <quic_pdaly@quicinc.com>,
	johunt@akamai.com
Subject: Re: [PATCH] psi: reduce min window size to 50ms
Date: Tue, 28 Feb 2023 17:49:18 -0800	[thread overview]
Message-ID: <CAJuCfpE604=5QtPBFFhhgNf43iXJvobE3uvaN_yFFHS-n4fKZw@mail.gmail.com> (raw)
In-Reply-To: <CAJuCfpEn-W5ffO7sEJPpu3TXeqK-XE1+TTVNnWcTcDBuoNUhGA@mail.gmail.com>

On Tue, Feb 28, 2023 at 10:18 AM Suren Baghdasaryan <surenb@google.com> wrote:
>
> On Tue, Feb 28, 2023 at 5:50 AM Michal Hocko <mhocko@suse.com> wrote:
> >
> > On Mon 27-02-23 11:50:48, Suren Baghdasaryan wrote:
> > > On Mon, Feb 27, 2023 at 11:11 AM Michal Hocko <mhocko@suse.com> wrote:
> > > >
> > > > On Mon 27-02-23 09:49:59, Suren Baghdasaryan wrote:
> > > > > On Mon, Feb 27, 2023 at 5:34 AM Michal Hocko <mhocko@suse.com> wrote:
> > > > > >
> > > > > > On Fri 24-02-23 13:07:57, Suren Baghdasaryan wrote:
> > > > > > > On Fri, Feb 24, 2023 at 4:47 AM Michal Hocko <mhocko@suse.com> wrote:
> > > > [...]
> > > > > > > > Btw. it seems that there is is only a limit on a single trigger per fd
> > > > > > > > but no limits per user so it doesn't sound too hard to end up with too
> > > > > > > > much polling even with a larger timeouts. To me it seems like we need to
> > > > > > > > contain the polling thread to be bound by the cpu controller.
> > > > > > >
> > > > > > > Hmm. We have one "psimon" thread per cgroup (+1 system-level one) and
> > > > > > > poll_min_period for each thread is chosen as the min() of polling
> > > > > > > periods between triggers created in that group. So, a bad trigger that
> > > > > > > causes overly aggressive polling and polling thread being throttled,
> > > > > > > might affect other triggers in that cgroup.
> > > > > >
> > > > > > Yes, and why that would be a problem?
> > > > >
> > > > > If unprivileged processes are allowed to add new triggers then a
> > > > > malicious process can add a bad trigger and affect other legit
> > > > > processes. That sounds like a problem to me.
> > > >
> > > > Hmm, I am not sure we are on the same page. My argument was that the
> > > > monitoring kernel thread should be bound by the same cpu controller so
> > > > even if it was excessive it would be bound to the cgroup constrains.
> > >
> > > Right. But if cgroup constraints are violated then the psimon thread's
> > > activity will be impacted by throttling. In such cases won't that
> > > affect other "good" triggers served by that thread even if they are
> > > using higher polling periods?
> >
> > That is no different from any other part of the workload running within
> > the same cpu bound cgroup running overboard with the cpu consumption. I
> > do not see why psimon or anything else should be any different.
> >
> > Actually the only difference here is that the psi monitoring is
> > outsourced to a kernel thread which is running ourside of any constrains.
> > I am not sure where do we stand with kernel thread cpu cgroup accounting
> > and I suspect this is not a trivial thing to do ATM. Hence longer term
> > plan.
>
> Yeah, that sounds right.
> In the meantime I think the prudent thing to do is to add
> CAP_SYS_RESOURCE check for cgroup interface for consistency with
> system-wide one. After that we can change the min period to be
> anything more than 0 and let userspace privileged services implement
> policies to limit trigger cpu consumption (might be via cpu
> controller, limiting the number of triggers/their periods, etc).
> Sudarshan, I'll post the CAP_SYS_RESOURCE change shortly and you can
> follow up with the change to the min trigger period.

Patch to require CAP_SYS_RESOURCE for writing per-cgroup psi files is
posted at https://lore.kernel.org/all/20230301014651.1370939-1-surenb@google.com/

> Thanks for the input folks!
>
> > --
> > Michal Hocko
> > SUSE Labs


  reply	other threads:[~2023-03-01  1:49 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-10 22:31 [PATCH] psi: reduce min window size to 50ms Sudarshan Rajagopalan
2023-02-10 22:31 ` Sudarshan Rajagopalan
2023-02-10 23:03 ` Suren Baghdasaryan
2023-02-11  0:44   ` Sudarshan Rajagopalan
2023-02-11  1:09     ` Suren Baghdasaryan
2023-02-11  1:46       ` Sudarshan Rajagopalan
2023-02-11  2:13         ` Suren Baghdasaryan
2023-02-14  2:12           ` Sudarshan Rajagopalan
2023-02-14 19:34             ` Suren Baghdasaryan
2023-02-24 12:47               ` Michal Hocko
2023-02-24 21:07                 ` Suren Baghdasaryan
2023-02-27 13:34                   ` Michal Hocko
2023-02-27 17:49                     ` Suren Baghdasaryan
2023-02-27 19:11                       ` Michal Hocko
2023-02-27 19:50                         ` Suren Baghdasaryan
2023-02-28 13:50                           ` Michal Hocko
2023-02-28 18:18                             ` Suren Baghdasaryan
2023-03-01  1:49                               ` Suren Baghdasaryan [this message]
2023-02-27 19:19                       ` Josh Hunt
2023-02-27 19:51                         ` Suren Baghdasaryan

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='CAJuCfpE604=5QtPBFFhhgNf43iXJvobE3uvaN_yFFHS-n4fKZw@mail.gmail.com' \
    --to=surenb@google.com \
    --cc=anshuman.khandual@arm.com \
    --cc=david@redhat.com \
    --cc=hannes@cmpxchg.org \
    --cc=johunt@akamai.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mark.rutland@arm.com \
    --cc=mhocko@suse.com \
    --cc=osalvador@suse.de \
    --cc=quic_pdaly@quicinc.com \
    --cc=quic_sudaraja@quicinc.com \
    --cc=quic_sukadev@quicinc.com \
    --cc=quic_svaddagi@quicinc.com \
    --cc=quic_tsoni@quicinc.com \
    --cc=rppt@kernel.org \
    --cc=virtualization@lists.linux-foundation.org \
    --cc=will@kernel.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;
as well as URLs for NNTP newsgroup(s).