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] [thread-next>] [day] [month] [year] [list]
Message-ID: <SJ1PR11MB6083F3355446B7879177A1FBFCAFA@SJ1PR11MB6083.namprd11.prod.outlook.com>
Date:   Thu, 9 Nov 2023 21:27:44 +0000
From:   "Luck, Tony" <tony.luck@...el.com>
To:     "Chatre, Reinette" <reinette.chatre@...el.com>
CC:     "Yu, Fenghua" <fenghua.yu@...el.com>,
        Peter Newman <peternewman@...gle.com>,
        Jonathan Corbet <corbet@....net>,
        Shuah Khan <skhan@...uxfoundation.org>,
        "x86@...nel.org" <x86@...nel.org>,
        Shaopeng Tan <tan.shaopeng@...itsu.com>,
        James Morse <james.morse@....com>,
        Jamie Iles <quic_jiles@...cinc.com>,
        Babu Moger <babu.moger@....com>,
        Randy Dunlap <rdunlap@...radead.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "linux-doc@...r.kernel.org" <linux-doc@...r.kernel.org>,
        "patches@...ts.linux.dev" <patches@...ts.linux.dev>
Subject: RE: [PATCH v3] x86/resctrl: mba_MBps: Fall back to total b/w if local
 b/w unavailable

>> Maybe additional an mount option "mba_MBps_total" so the user can pick
>> total instead of local?
>
> Is this something for which a remount is required? Can it not perhaps be
> changed at runtime?

In theory, yes. But I've been playing with a patch that adds a writable info/
file to allow runtime switch:

# ls -l /sys/fs/resctrl/info/MB/mba_MBps_control
-rw-r--r--. 1 root root 0 Nov  9 10:57 /sys/fs/resctrl/info/MB/mba_MBps_control
]# cat /sys/fs/resctrl/info/MB/mba_MBps_control
total

and found that it's a bit tricky to switch out the MBM event from the
state machine driving the feedback loop. I think the problem is in the
code that tries to stop the control loop from switching between two
throttling levels every second:

        if (cur_msr_val > r_mba->membw.min_bw && user_bw < cur_bw) {
                new_msr_val = cur_msr_val - r_mba->membw.bw_gran;
        } else if (cur_msr_val < MAX_MBA_BW &&
                   (user_bw > (cur_bw + delta_bw))) {
                new_msr_val = cur_msr_val + r_mba->membw.bw_gran;
        } else {
                return;
        }

The code drops down one percentage step if current bandwidth is above
the desired target. But stepping back up checks to see if "cur_bw + delta_bw"
is below the target.

Where does "delta_bw" come from? Code uses the Boolean flag "pmbm_data->delta_comp"
to request the once-per-second polling compute the change in bandwidth on the
next poll after adjusting throttling MSRs.

All of these values are in the "struct mbm_state" which is a per-event-id structure.

Picking an event at boot time works fine. Likely also fine at mount time. But
switching at run-time seems to frequently end up with a very large value in
"delta_bw" (as it compares current & previous for this event ... and it looks
like things changed from zero).  Net effect is that throttling is increased when
processes go over their target for the resctrl group, but throttling is never decreased.

The whole heuristic seems a bit fragile. It works well for test processes that have
constant memory bandwidth. But I could see it failing in scenarios like this:

1) Process is over MB limit
2) Linux increases throttling, and sets flag to compute delta_bw on next poll
3) Process blocks on some event and uses no bandwidth in next one second
4) Next poll. Linux computes delta_bw as abs(cur_bw - m->prev_bw). cur_bw is zero,
    so delta_bw is set to full value of bandwidth that process used when over budget
5) Process resumes running
6) Linux sees process using less than target, but cur_bw + delta_bw is above target,
   so Linux doesn't adjust throttling

I think the goal was to avoid relaxing throttling and letting a resctrl group go back over
target bandwidth. But that doesn't work either for groups with highly variable bandwidth
requirements.

1) Group is over budget
2) Linux increases throttling, and sets flag to compute delta_bw on next poll
3) Group forks additional processes. New bandwidth from those offsets the reduction due to throttling
4) Next poll. Linux sees bandwidth is unchanged. Sets delta_bw = 0.
5) Next poll. Groups aggregate bandwidth is fractionally below target. Because delta_bw=0, Linux
   reduces throttling.
6) Group goes over target.

-Tony



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ