Re: [PATCH v3 3/3] selftests: add zswapin and no zswap tests

2024-02-05 Thread Yosry Ahmed
kernel crash on the zswapin path in our internal kernel, > which went undetected because of a lack of test coverage for this path. > > Add a selftest to verify that when memory.zswap.max = 0, no pages can go > to the zswap pool for the cgroup. > > Suggested-by: Rik van Rie

Re: [PATCH v2 3/3] selftests: add zswapin and no zswap tests

2024-02-02 Thread Yosry Ahmed
> > > +{ > > > + size_t size = (size_t)arg; > > > + char *mem = (char *)malloc(size); > > > + int ret = 0; > > > + > > > + if (!mem) > > > + return -1; > > > + for (int i = 0; i < size; i += 4095) > > > + mem[i] = 'a'; > > > > cgroup_util.h defines

Re: [PATCH v2 3/3] selftests: add zswapin and no zswap tests

2024-02-01 Thread Yosry Ahmed
memory.zswap.max = 0, no pages can go > to the zswap pool for the cgroup. > > Suggested-by: Rik van Riel > Suggested-by: Yosry Ahmed > Signed-off-by: Nhat Pham > --- > tools/testing/selftests/cgroup/test_zswap.c | 97 + > 1 file changed, 97 insertions

Re: [PATCH 1/3] selftests: zswap: add zswap selftest file to zswap maintainer entry

2024-01-30 Thread Yosry Ahmed
On Tue, Jan 30, 2024 at 10:37:15AM -0800, Nhat Pham wrote: > On Mon, Jan 29, 2024 at 5:02 PM Yosry Ahmed wrote: > > > > On Mon, Jan 29, 2024 at 02:45:40PM -0800, Nhat Pham wrote: > > > Make it easier for contributors to find the zswap maintainers when they >

Re: [PATCH 3/3] selftests: add test for zswapin

2024-01-30 Thread Yosry Ahmed
On Tue, Jan 30, 2024 at 10:31:24AM -0800, Nhat Pham wrote: > On Mon, Jan 29, 2024 at 5:24 PM Yosry Ahmed wrote: > > [..] > > > -static int allocate_bytes(const char *cgroup, void *arg) > > > +static int allocate_bytes_and_read(const char *cgroup,

Re: [PATCH 3/3] selftests: add test for zswapin

2024-01-29 Thread Yosry Ahmed
On Mon, Jan 29, 2024 at 02:45:42PM -0800, Nhat Pham wrote: > We recently encountered a kernel crash on the zswapin path in our > internal kernel, which went undetected because of a lack of test > coverage for this path. Add a selftest to cover this code path, > allocating more memories than the

Re: [PATCH 2/3] selftests: fix the zswap invasive shrink test

2024-01-29 Thread Yosry Ahmed
ha...@gmail.com/ > > Fixes: a697dc2be925 ("selftests: cgroup: update per-memcg zswap writeback > selftest") Looks like this should go into v6.8 too. > Signed-off-by: Nhat Pham Acked-by: Yosry Ahmed

Re: [PATCH 1/3] selftests: zswap: add zswap selftest file to zswap maintainer entry

2024-01-29 Thread Yosry Ahmed
On Mon, Jan 29, 2024 at 02:45:40PM -0800, Nhat Pham wrote: > Make it easier for contributors to find the zswap maintainers when they > update the zswap tests. > > Signed-off-by: Nhat Pham I guess I had to check the zswap tests at some point :) Acked-by: Yosry Ahmed > --- >

Re: [PATCH v8 6/6] zswap: shrinks zswap pool based on memory pressure

2023-12-06 Thread Yosry Ahmed
On Wed, Dec 6, 2023 at 11:47 AM Nhat Pham wrote: > > [...] > > > > Hmm so how should we proceed from here? How about this: > > > > a) I can send a fixlet to move the enablement check above the stats > > flushing + use mem_cgroup_flush_stats > > b) Then maybe, you can send a fixlet to update this

Re: [PATCH v8 6/6] zswap: shrinks zswap pool based on memory pressure

2023-12-05 Thread Yosry Ahmed
On Tue, Dec 5, 2023 at 10:43 PM Chengming Zhou wrote: > > On 2023/12/6 13:59, Yosry Ahmed wrote: > > [..] > >>> @@ -526,6 +582,102 @@ static struct zswap_entry > >>> *zswap_entry_find_get(struct rb_

Re: [PATCH v8 6/6] zswap: shrinks zswap pool based on memory pressure

2023-12-05 Thread Yosry Ahmed
[..] > > @@ -526,6 +582,102 @@ static struct zswap_entry > > *zswap_entry_find_get(struct rb_root *root, > > return entry; > > } > > > > +/* > > +* shrinker functions > > +**/ > > +static enum lru_status shrink_memcg_cb(struct

Re: [PATCH v8 4/6] mm: memcg: add per-memcg zswap writeback stat (fix)

2023-12-05 Thread Yosry Ahmed
On Tue, Dec 5, 2023 at 11:33 AM Nhat Pham wrote: > > Rename ZSWP_WB to ZSWPWB to better match the existing counters naming > scheme. > > Suggested-by: Johannes Weiner > Signed-off-by: Nhat Pham For the original patch + this fix: Reviewed-by: Yosry Ahmed >

Re: [PATCH v8 3/6] zswap: make shrinking memcg-aware

2023-12-05 Thread Yosry Ahmed
[..] > > > static void shrink_worker(struct work_struct *w) > > > { > > > struct zswap_pool *pool = container_of(w, typeof(*pool), > > > shrink_work); > > > + struct mem_cgroup *memcg; > > > int ret, failures = 0; > > > > > >

Re: [PATCH v8 4/6] mm: memcg: add per-memcg zswap writeback stat

2023-12-05 Thread Yosry Ahmed
On Thu, Nov 30, 2023 at 11:40 AM Nhat Pham wrote: > > From: Domenico Cerasuolo > > Since zswap now writes back pages from memcg-specific LRUs, we now need a > new stat to show writebacks count for each memcg. > > Suggested-by: Nhat Pham > Signed-off-by: Domenico Cerasuolo > Signed-off-by: Nhat

Re: [PATCH v8 3/6] zswap: make shrinking memcg-aware

2023-12-05 Thread Yosry Ahmed
On Thu, Nov 30, 2023 at 11:40 AM Nhat Pham wrote: > > From: Domenico Cerasuolo > > Currently, we only have a single global LRU for zswap. This makes it > impossible to perform worload-specific shrinking - an memcg cannot > determine which pages in the pool it owns, and often ends up writing >

Re: [PATCH v8 2/6] memcontrol: implement mem_cgroup_tryget_online()

2023-12-05 Thread Yosry Ahmed
nlineness check. In the !CONFIG_MEMCG case, it always returns > true, analogous to mem_cgroup_tryget(). This is useful for e.g to the > new zswap writeback scheme, where we need to select the next online > memcg as a candidate for the global limit reclaim. > > Signed-off-by: Nhat P

Re: [PATCH v5 0/6] workload-specific and memory pressure-driven zswap writeback

2023-11-17 Thread Yosry Ahmed
On Fri, Nov 17, 2023 at 8:23 AM Nhat Pham wrote: > > On Thu, Nov 16, 2023 at 4:57 PM Chris Li wrote: > > > > Hi Nhat, > > > > I want want to share the high level feedback we discussed here in the > > mailing list as well. > > > > It is my observation that each memcg LRU list can't compare the

Re: [PATCH v5 3/6] zswap: make shrinking memcg-aware

2023-11-06 Thread Yosry Ahmed
> > > > This lock is only needed to synchronize updating pool->next_shrink, > > right? Can we just use atomic operations instead? (e.g. cmpxchg()). > > I'm not entirely sure. I think in the pool destroy path, we have to also > put the next_shrink memcg, so there's that. We can use xchg() to

Re: [PATCH v5 3/6] zswap: make shrinking memcg-aware

2023-11-06 Thread Yosry Ahmed
On Mon, Nov 6, 2023 at 10:32 AM Nhat Pham wrote: > > From: Domenico Cerasuolo > > Currently, we only have a single global LRU for zswap. This makes it > impossible to perform worload-specific shrinking - an memcg cannot > determine which pages in the pool it owns, and often ends up writing >

Re: [PATCH v4 2/5] zswap: make shrinking memcg-aware

2023-10-30 Thread Yosry Ahmed
> > [..] > > > +/* > > > +* lru functions > > > +**/ > > > +static bool zswap_lru_add(struct list_lru *list_lru, struct zswap_entry > > > *entry) > > > +{ > > > + struct mem_cgroup *memcg = get_mem_cgroup_from_entry(entry); > >

Re: [PATCH v4 2/5] zswap: make shrinking memcg-aware

2023-10-24 Thread Yosry Ahmed
On Tue, Oct 24, 2023 at 1:33 PM Nhat Pham wrote: > > From: Domenico Cerasuolo > > Currently, we only have a single global LRU for zswap. This makes it > impossible to perform worload-specific shrinking - an memcg cannot > determine which pages in the pool it owns, and often ends up writing >

Re: [PATCH v3 0/5] workload-specific and memory pressure-driven zswap writeback

2023-10-19 Thread Yosry Ahmed
On Thu, Oct 19, 2023 at 10:12 AM Andrew Morton wrote: > > On Tue, 17 Oct 2023 16:21:47 -0700 Nhat Pham wrote: > > > Subject: [PATCH v3 0/5] workload-specific and memory pressure-driven zswap > > writeback > > We're at -rc6 and I'd prefer to drop this series from mm.git, have > another go during

Re: [PATCH v3 2/5] zswap: make shrinking memcg-aware

2023-10-19 Thread Yosry Ahmed
On Thu, Oct 19, 2023 at 5:47 AM Domenico Cerasuolo wrote: > > On Thu, Oct 19, 2023 at 3:12 AM Yosry Ahmed wrote: > > > > On Wed, Oct 18, 2023 at 4:47 PM Nhat Pham wrote: > > > > > > On Wed, Oct 18, 2023 at 4:20 PM Yosry Ahmed wrote: > > > > &

Re: [PATCH v3 2/5] zswap: make shrinking memcg-aware

2023-10-19 Thread Yosry Ahmed
[..] > > > > > > +/* > > > +* lru functions > > > +**/ > > > +static bool zswap_lru_add(struct list_lru *list_lru, struct zswap_entry > > > *entry) > > > +{ > > > + struct mem_cgroup *memcg = get_mem_cgroup_from_entry(entry); >

Re: [PATCH v3 2/5] zswap: make shrinking memcg-aware

2023-10-18 Thread Yosry Ahmed
On Wed, Oct 18, 2023 at 4:47 PM Nhat Pham wrote: > > On Wed, Oct 18, 2023 at 4:20 PM Yosry Ahmed wrote: > > > > On Tue, Oct 17, 2023 at 4:21 PM Nhat Pham wrote: > > > > > > From: Domenico Cerasuolo > > > > > > Currently,

Re: [PATCH v3 5/5] zswap: shrinks zswap pool based on memory pressure

2023-10-18 Thread Yosry Ahmed
On Tue, Oct 17, 2023 at 4:21 PM Nhat Pham wrote: > > Currently, we only shrink the zswap pool when the user-defined limit is > hit. This means that if we set the limit too high, cold data that are > unlikely to be used again will reside in the pool, wasting precious > memory. It is hard to

Re: [PATCH v3 3/5] mm: memcg: add per-memcg zswap writeback stat

2023-10-18 Thread Yosry Ahmed
On Tue, Oct 17, 2023 at 4:21 PM Nhat Pham wrote: > > From: Domenico Cerasuolo > > Since zswap now writes back pages from memcg-specific LRUs, we now need a > new stat to show writebacks count for each memcg. > > Suggested-by: Nhat Pham > Signed-off-by: Domenico Cerasuolo > Signed-off-by: Nhat

Re: [PATCH v3 2/5] zswap: make shrinking memcg-aware

2023-10-18 Thread Yosry Ahmed
On Tue, Oct 17, 2023 at 4:21 PM Nhat Pham wrote: > > From: Domenico Cerasuolo > > Currently, we only have a single global LRU for zswap. This makes it > impossible to perform worload-specific shrinking - an memcg cannot > determine which pages in the pool it owns, and often ends up writing >

Re: [PATCH v3 1/5] mm: list_lru: allow external numa node and cgroup tracking

2023-10-18 Thread Yosry Ahmed
On Tue, Oct 17, 2023 at 4:21 PM Nhat Pham wrote: > > The interface of list_lru is based on the assumption that objects are > allocated on the correct node/memcg, with this change it is introduced the > possibility to explicitly specify numa node and memcgroup when adding and > removing objects.