lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAF8kJuNW2kmxKYRE9t8WvSOad9JkLYt0WSAcFOQ9r9=2=XGc9Q@mail.gmail.com>
Date: Sat, 6 Sep 2025 05:56:46 -0700
From: Chris Li <chrisl@...nel.org>
To: YoungJun Park <youngjun.park@....com>
Cc: Michal Koutný <mkoutny@...e.com>, 
	akpm@...ux-foundation.org, hannes@...xchg.org, mhocko@...nel.org, 
	roman.gushchin@...ux.dev, shakeel.butt@...ux.dev, muchun.song@...ux.dev, 
	shikemeng@...weicloud.com, kasong@...cent.com, nphamcs@...il.com, 
	bhe@...hat.com, baohua@...nel.org, cgroups@...r.kernel.org, 
	linux-mm@...ck.org, linux-kernel@...r.kernel.org, gunho.lee@....com, 
	iamjoonsoo.kim@....com, taejoon.song@....com, 
	Matthew Wilcox <willy@...radead.org>, David Hildenbrand <david@...hat.com>, Kairui Song <ryncsn@...il.com>, 
	Wei Xu <weixugc@...gle.com>
Subject: Re: [PATCH 1/4] mm/swap, memcg: Introduce infrastructure for
 cgroup-based swap priority

On Fri, Sep 5, 2025 at 4:45 PM Chris Li <chrisl@...nel.org> wrote:
> >   - Mask computation: precompute at interface write-time vs runtime
> >     recomputation. (TBD; preference?)
>
> Let's start with runtime. We can have a runtime and cached with
> generation numbers on the toplevel. Any change will reset the top
> level general number then the next lookup will drop the cache value
> and re-evaluate.

Scratch that cache value idea. I found the run time evaluation can be
very simple and elegant.
Each memcg just needs to store the tier onoff value for the local
swap.tiers operation. Also a mask to indicate which of those tiers
present.
e.g. bits 0-1: default, on bit 0 and off bit 1
       bits 2-3: zswap, on bit 2 and off bit3
       bits 4-6: first custom tier
       ...

The evaluation of the current tier "memcg" to the parent with the
default tier shortcut can be:

        onoff = memcg->tiers_onoff;
        mask = memcg->tiers_mask;

        for (p = memcg->parent; p && !has_default(onoff); p = p->parent) {
                merge = mask | p->tiers_mask;
                new = merge ^ mask;
                onoff |= p->tiers_onoff & new;
                mask = merge;
        }
        if (onoff & DEFAULT_OFF) {
                // default off, look for the on tiers to turn on
        } else {
                // default on, look for the off tiers to turn off
        }

It is an all bit operation that does not need caching at all. This can
take advantage of the short cut of the default tier. If the default
tier overwrite exists, no need to search the parent further.

Chris

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ