public inbox for cgroups@vger.kernel.org
 help / color / mirror / Atom feed
From: Michal Hocko <mhocko-IBi9RG/b67k@public.gmane.org>
To: Yosry Ahmed <yosryahmed-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
Cc: Andrew Morton
	<akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>,
	Johannes Weiner <hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org>,
	Roman Gushchin
	<roman.gushchin-fxUVXftIFDnyG1zEObXtfA@public.gmane.org>,
	Shakeel Butt <shakeelb-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>,
	Muchun Song <muchun.song-fxUVXftIFDnyG1zEObXtfA@public.gmane.org>,
	Ivan Babrou <ivan-lDpJ742SOEtZroRs9YW3xA@public.gmane.org>,
	Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org,
	cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 3/3] mm: memcg: use non-unified stats flushing for userspace reads
Date: Tue, 22 Aug 2023 11:06:03 +0200	[thread overview]
Message-ID: <ZOR6eyYfJYlxdMet@dhcp22.suse.cz> (raw)
In-Reply-To: <20230821205458.1764662-4-yosryahmed-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>

On Mon 21-08-23 20:54:58, Yosry Ahmed wrote:
> Unified flushing allows for great concurrency for paths that attempt to
> flush the stats, at the expense of potential staleness and a single
> flusher paying the extra cost of flushing the full tree.
> 
> This tradeoff makes sense for in-kernel flushers that may observe high
> concurrency (e.g. reclaim, refault). For userspace readers, stale stats
> may be unexpected and problematic, especially when such stats are used
> for critical paths such as userspace OOM handling. Additionally, a
> userspace reader will occasionally pay the cost of flushing the entire
> hierarchy, which also causes problems in some cases [1].
> 
> Opt userspace reads out of unified flushing. This makes the cost of
> reading the stats more predictable (proportional to the size of the
> subtree), as well as the freshness of the stats. Since userspace readers
> are not expected to have similar concurrency to in-kernel flushers,
> serializing them among themselves and among in-kernel flushers should be
> okay.
> 
> This was tested on a machine with 256 cpus by running a synthetic test
> The script that creates 50 top-level cgroups, each with 5 children (250
> leaf cgroups). Each leaf cgroup has 10 processes running that allocate
> memory beyond the cgroup limit, invoking reclaim (which is an in-kernel
> unified flusher). Concurrently, one thread is spawned per-cgroup to read
> the stats every second (including root, top-level, and leaf cgroups --
> so total 251 threads). No regressions were observed in the total running
> time; which means that non-unified userspace readers are not slowing
> down in-kernel unified flushers:

I have to admit I am rather confused by cgroup_rstat_flush (and
cgroup_rstat_flush_locked). The former says it can block but the later
doesn't ever block and even if it drops the cgroup_rstat_lock it merely
cond_rescheds or busy loops. How much of a contention and yielding can
you see with this patch? What is the worst case? How bad a random user
can make the situation by going crazy and trying to flush from many
different contexts?
-- 
Michal Hocko
SUSE Labs

  parent reply	other threads:[~2023-08-22  9:06 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-21 20:54 [PATCH 0/3] memcg: non-unified flushing for userspace stats Yosry Ahmed
2023-08-21 20:54 ` [PATCH 1/3] mm: memcg: properly name and document unified stats flushing Yosry Ahmed
2023-08-21 20:54 ` [PATCH 2/3] mm: memcg: add a helper for non-unified " Yosry Ahmed
     [not found]   ` <20230821205458.1764662-3-yosryahmed-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2023-08-22 13:01     ` Michal Koutný
2023-08-22 16:00       ` Yosry Ahmed
     [not found]         ` <CAJD7tkaVuiMU-ifJiyH5d_W1hi9DnAymYJxzBxEKCVX+tU=OCA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2023-08-22 16:35           ` Michal Koutný
2023-08-22 16:48             ` Yosry Ahmed
     [not found] ` <20230821205458.1764662-1-yosryahmed-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2023-08-21 20:54   ` [PATCH 3/3] mm: memcg: use non-unified stats flushing for userspace reads Yosry Ahmed
     [not found]     ` <20230821205458.1764662-4-yosryahmed-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2023-08-22  9:06       ` Michal Hocko [this message]
     [not found]         ` <ZOR6eyYfJYlxdMet-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2023-08-22 15:30           ` Yosry Ahmed
     [not found]             ` <CAJD7tka13M-zVZTyQJYL1iUAYvuQ1fcHbCjcOBZcz6POYTV-4g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2023-08-23  7:33               ` Michal Hocko
2023-08-23 14:55                 ` Yosry Ahmed
2023-08-24  7:13                   ` Michal Hocko
2023-08-24 18:15                     ` Yosry Ahmed
2023-08-24 18:50                       ` Yosry Ahmed
2023-08-25  7:05                         ` Michal Hocko
2023-08-25 15:14                           ` Yosry Ahmed
     [not found]                             ` <CAJD7tkYPyb+2zOKqctQw-vhuwYRg85e6v2Y44xWJofHZ+F+YQw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2023-08-25 18:17                               ` Michal Hocko
2023-08-25 18:21                                 ` Yosry Ahmed
     [not found]                                   ` <CAJD7tka=60_vPMY9Tg8tH+55g-feV1B24VNmDpp_3iMHqrUh7Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2023-08-25 18:43                                     ` Michal Hocko
     [not found]                                       ` <ZOj2NeU5yYhrTZPJ-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2023-08-25 18:44                                         ` Michal Hocko
2023-08-28 15:47                               ` Michal Hocko
2023-08-28 16:15                                 ` Yosry Ahmed
2023-08-28 17:00                                   ` Shakeel Butt
     [not found]                                     ` <CALvZod7uxDd3Lrd3VwTTC-SDvqhdj2Ly-dYVswO=TBM=XTnkcg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2023-08-28 17:07                                       ` Yosry Ahmed
2023-08-28 17:27                                         ` Waiman Long
2023-08-28 17:28                                           ` Yosry Ahmed
     [not found]                                             ` <CAJD7tkZsGfYXkWM5aa67v3JytTO04LS7_x+ooMDK82cBZ-C8eQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2023-08-28 17:35                                               ` Waiman Long
     [not found]                                                 ` <307cbcf6-dca2-0b5d-93e8-11368a931d2f-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2023-08-28 17:43                                                   ` Waiman Long
2023-08-28 18:35                                                     ` Yosry Ahmed
     [not found]                                           ` <599b167c-deaf-4b92-aa8b-5767b8608483-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2023-08-29  7:27                                             ` Michal Hocko
     [not found]                                               ` <ZO2d7dT8gulMyb8g-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2023-08-29 15:05                                                 ` Waiman Long
2023-08-29 15:17                                                   ` Michal Hocko
     [not found]                                                     ` <ZO4MBNzsbhsi7adb-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2023-08-29 16:04                                                       ` Yosry Ahmed
     [not found]                           ` <ZOhSyvDxAyYUJ45i-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2023-08-29 18:44                             ` Tejun Heo
     [not found]                               ` <ZO48h7c9qwQxEPPA-NiLfg/pYEd1N0TnZuCh8vA@public.gmane.org>
2023-08-29 19:13                                 ` Yosry Ahmed
2023-08-29 19:36                                   ` Tejun Heo
     [not found]                                     ` <ZO5IuULSCXMe9_pN-NiLfg/pYEd1N0TnZuCh8vA@public.gmane.org>
2023-08-29 19:54                                       ` Yosry Ahmed
     [not found]                                         ` <CAJD7tkYtnhemCLBqFqOVurfWEaCjKtyEM745JYRxFS0r5cpZwQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2023-08-29 20:12                                           ` Tejun Heo
2023-08-29 20:20                                             ` Yosry Ahmed
     [not found]                                               ` <CAJD7tkZn_7ppFB1B1V8tBEw12LXCnEOue2Beq6e19PkUAVHUSQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2023-08-31  9:05                                                 ` Michal Hocko
2023-08-22 13:00 ` [PATCH 0/3] memcg: non-unified flushing for userspace stats Michal Koutný
2023-08-22 15:43   ` Yosry Ahmed

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=ZOR6eyYfJYlxdMet@dhcp22.suse.cz \
    --to=mhocko-ibi9rg/b67k@public.gmane.org \
    --cc=akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
    --cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org \
    --cc=ivan-lDpJ742SOEtZroRs9YW3xA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org \
    --cc=muchun.song-fxUVXftIFDnyG1zEObXtfA@public.gmane.org \
    --cc=roman.gushchin-fxUVXftIFDnyG1zEObXtfA@public.gmane.org \
    --cc=shakeelb-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
    --cc=tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=yosryahmed-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.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