From: Michal =?iso-8859-1?Q?Koutn=FD?= Subject: Re: [PATCH v3 3/5] mm/memcg: Protect per-CPU counter by disabling preemption on PREEMPT_RT where needed. Date: Mon, 21 Feb 2022 14:18:25 +0100 Message-ID: <20220221131825.GA7534@blackbody.suse.cz> References: <20220217094802.3644569-1-bigeasy@linutronix.de> <20220217094802.3644569-4-bigeasy@linutronix.de> Mime-Version: 1.0 Return-path: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1645449507; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=aRXcFsOUSSMa2BGcwAaU3jThpHs0aCs0hHkKe3j5Nk0=; b=iSPAuStelADUpXCvEe6gFVGnj6K+QDQusZ4BDFfdwORGpDkOAjfsZiTn85OAbt4uLT9ihu 5K++/pWtAOqwrTi2yYTl10O9i9URTzTtP5pb8q964FMvvCAgqmMRi+3wEmzFgFtfeRhbWQ y0ie2MMVgIl2g2HE25jHlMCQrk115Ng= Content-Disposition: inline In-Reply-To: List-ID: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Sebastian Andrzej Siewior Cc: Shakeel Butt , Cgroups , Linux MM , Andrew Morton , Johannes Weiner , Michal Hocko , Peter Zijlstra , Thomas Gleixner , Vladimir Davydov , Waiman Long , Roman Gushchin On Mon, Feb 21, 2022 at 12:31:17PM +0100, Sebastian Andrzej Siewior wrote: > What about memcg_rstat_updated()? It does: > > | x = __this_cpu_add_return(stats_updates, abs(val)); > | if (x > MEMCG_CHARGE_BATCH) { > | atomic_add(x / MEMCG_CHARGE_BATCH, &stats_flush_threshold); > | __this_cpu_write(stats_updates, 0); > | } > > The writes to stats_updates can happen from IRQ-context and with > disabled preemption only. So this is not good, right? These counters serve as a hint for aggregating per-cpu per-cgroup stats. If they were systematically mis-updated, it could manifest by missing "refresh signal" from the given CPU. OTOH, this lagging is also meant to by limited by elapsed time thanks to periodic flushing. This could affect freshness of the stats not their accuracy though. HTH, Michal