From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 05673C433F5 for ; Thu, 13 Jan 2022 13:08:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4E44C6B009F; Thu, 13 Jan 2022 08:08:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 494156B00A1; Thu, 13 Jan 2022 08:08:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 35BC76B00A4; Thu, 13 Jan 2022 08:08:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0040.hostedemail.com [216.40.44.40]) by kanga.kvack.org (Postfix) with ESMTP id 257856B009F for ; Thu, 13 Jan 2022 08:08:15 -0500 (EST) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id CBC281820BA65 for ; Thu, 13 Jan 2022 13:08:14 +0000 (UTC) X-FDA: 79025292108.17.4C74AC2 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by imf23.hostedemail.com (Postfix) with ESMTP id 2CD93140005 for ; Thu, 13 Jan 2022 13:08:14 +0000 (UTC) Date: Thu, 13 Jan 2022 14:08:10 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1642079291; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fYgLEwvs5VRdvN1sFaMXFPXbTNezugG6bv5lyd4Ctj4=; b=v1uyQhmEmw9G5cmDCunfbkUxXr32EpMeccAD1gd6U6W+73VwRBiba9y14BQAX1/ZTUmJ1a d/3HnbGf2cgsuUnoe/WY2GSOkznC3Sn6RDV1PxEAXJHFTAZOzew+4s5qDV/qHlRoHq5T6I rwX/+EC6H/DVSeD2ut/PazZ8EHI2P3r5tIG4CumOj/9RKKsPVano8a0FSrWBDd1GPxsbp8 w6OKtu1+Bumi+4qS6RNrBRzhGSQanBDP2ue4KBTrewUcQcHL6f0uNLj0oIT0WTpgL6AzAs jkHTvMTUS+pvGd9s8D5lPHD6OsTaVXhe/fWrWopfUnGCcUgji65PAI5rUWWd8g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1642079291; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fYgLEwvs5VRdvN1sFaMXFPXbTNezugG6bv5lyd4Ctj4=; b=e8hxGV5XP7MuUwHHDk4O9a9OrESgBC00df0u70Hyf7ZMiqhZbPf1spzi+CdMAKxlt8sfKo jOqH5hlwCstqJcAw== From: Sebastian Andrzej Siewior To: Michal =?utf-8?Q?Koutn=C3=BD?= Cc: cgroups@vger.kernel.org, linux-mm@kvack.org, Johannes Weiner , Michal Hocko , Vladimir Davydov , Andrew Morton , Thomas Gleixner , Waiman Long , Peter Zijlstra Subject: Re: [RFC PATCH 1/3] mm/memcg: Protect per-CPU counter by disabling preemption on PREEMPT_RT Message-ID: References: <20211222114111.2206248-1-bigeasy@linutronix.de> <20211222114111.2206248-2-bigeasy@linutronix.de> <20220105141653.GA6464@blackbody.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: <20220105141653.GA6464@blackbody.suse.cz> X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 2CD93140005 X-Stat-Signature: sagw5ddyhfb7mzx35ub1gzf4tb9c8btd Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=v1uyQhmE; dkim=pass header.d=linutronix.de header.s=2020e header.b=e8hxGV5X; spf=pass (imf23.hostedemail.com: domain of bigeasy@linutronix.de designates 193.142.43.55 as permitted sender) smtp.mailfrom=bigeasy@linutronix.de; dmarc=pass (policy=none) header.from=linutronix.de X-HE-Tag: 1642079294-473688 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 2022-01-05 15:16:53 [+0100], Michal Koutn=C3=BD wrote: > On Wed, Dec 22, 2021 at 12:41:09PM +0100, Sebastian Andrzej Siewior wrote: > > The sections with disabled preemption must exclude > > memcg_check_events() so that spinlock_t locks can still be acquired > > (for instance in eventfd_signal()). >=20 > The resulting construct in uncharge_batch() raises eybrows. If you can de= couple > per-cpu updates from memcg_check_events() on PREEMPT_RT, why not tackle > it the same way on !PREEMPT_RT too (and have just one variant of the > block)? That would mean that mem_cgroup_event_ratelimit() needs a local_irq_save(). If that is okay then sure I can move it that way. > (Actually, it doesn't seem to me that memcg_check_events() can be > extracted like this from the preempt disabled block since > mem_cgroup_event_ratelimit() relies on similar RMW pattern. > Things would be simpler if PREEMPT_RT didn't allow the threshold event > handlers (akin to Michal Hocko's suggestion of rejecting soft limit).) I added a preempt-disable() section restricted to RT to mem_cgroup_event_ratelimit(). I had to exclude memcg_check_events() from the block because of the spinlock_t locks involved down the road (eventfd_signal() for instance). I remember Michal (Hocko) suggested excluding/ rejecting soft limit but I didn't know where exactly and its implications. In this block here I just followed the replacement of irq-off with preempt-off for RT. > Thanks, > Michal Sebastian