From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A31F9606A32F for ; Thu, 3 Dec 2026 20:42:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.a=rsa-sha256 header.s=google header.b=gaI69kj6 Received: by kanga.kvack.org (Postfix) id BC7C06B05B8; Thu, 3 Dec 2026 15:42:31 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B78CF6B05B9; Thu, 3 Dec 2026 15:42:31 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A670D6B05BA; Thu, 3 Dec 2026 15:42:31 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 3BE886B05B8 for ; Thu, 3 Dec 2026 15:42:31 -0500 (EST) Received: from smtpin09.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay04.hostedemail.com (Postfix) with ESMTP id D23061A0162 for ; Thu, 3 Dec 2026 20:42:30 +0000 (UTC) X-FDA: 85503844860.09.5D8EA47 Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) by imf03.hostedemail.com (Postfix) with ESMTP id B066720009 for ; Thu, 3 Dec 2026 20:42:28 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=suse.com header.s=google header.b=gaI69kj6; spf=pass (imf03.hostedemail.com: domain of mhocko@suse.com designates 209.85.221.51 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1796330549; b=8GGuEJ8PHVGwIK5Op32qEvYjWuNdyn8XXVKwsO274TyLm4Ac3xPbe+6BBxsypDyRove2jj 8vG5guymYSSVBsPRhm4mTMtQojFTRAU6QcsDo5wE8auVcGx1tRoWsIra6wNpNt1bBcSdqw wsJVEP3QR26I7eMrZGBe3Njo7Fuwoh0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1796330549; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=X178MMx1A1q7ptdUp1IR+RVfrsGqn2FZZ8eu0SAC3nE=; b=FZWarc80E5YZ8tS1tsbepX1OXpw8+s2QwLSpPHNtP/jFsWshZkNysnUoJxljTZX72tGFHj zIvFGlJr/vJ6Bd9b+2BDcMGHxNJ9Zx/hKQKRJlEDhvc7sEQOKN3MxvNZ0Wl+9ZiIIIoQdh eWX9K8qZTc6PJINLbnRI86x6SJl/gE8= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=suse.com header.s=google header.b=gaI69kj6; spf=pass (imf03.hostedemail.com: domain of mhocko@suse.com designates 209.85.221.51 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-4c3f0acc1easo160310f8f.0 for ; Thu, 03 Dec 2026 12:42:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1796330547; x=1796935347; darn=kvack.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=X178MMx1A1q7ptdUp1IR+RVfrsGqn2FZZ8eu0SAC3nE=; b=gaI69kj610kI1Ln8lq0+YnjIlTU6h2FMlVPyFAkSIgS61KfQn0Bj9G8YNWlX2kXpLQ GXhC+o7x+Uux3+HCMlPOQTjI7w0uEgQZd67LjHnXhsw6LjF/UXPhxxitFgLykfpBdPmN q5oq/TtosZkzmicCpnqLXxoj1O9u5jWwSz5bWJBO8vc3AdRKfoBo+KcVSDzqbvt1Iej8 t126iGuAhXTXoHugSOhAdCtLgx0FwIb9W6uBZ1xKO+BLdxaSCFXkfW47csNbdHXt8tnk O0X7CF+rKuhyzl9gfTNhIRpSkLXfBjwzRAEgtp1nvpPOR6RydUqYFFXtYsXDiyzMCfOR t6+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796330547; x=1796935347; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=X178MMx1A1q7ptdUp1IR+RVfrsGqn2FZZ8eu0SAC3nE=; b=lysMWW0uXZayXgN5uIBfZin6A7deLq5P8bYzy1t3/szas7hzxL8IZTykSE6lLoGc9h 50uT8z+j8l2iOiCpAlCOBZoRaYCGAL4GGe4Oxz119HEOZgKqTdDm/be+23cyn8R9OUUO jfSZSLCWEAxN81Mz6DAYWreJ/+JufKMWkDmlB88u5XZtrTlUtGAavgsy28r0PLozpaRw hY7+BhltTX9hw0IidlSuZ9AB0ftivk/BF4cToy6JV1sqiBg3lPC/0OSNT5860SYmdIqE r2K1EhAbWoGG9JVJ5XSxsu/vuScOEeUHcq6KVmi5fA3Py3txS7scsTtAWhBqgKOZGaIi r73A== X-Forwarded-Encrypted: i=1; AL+hErFuEYJzvuL+KeansLEVWqoB7Tsxls6PbmCuxwgnNLTYIMWdoGVFlqwGmTpMhUrddXndy2tabU21vw==@kvack.org X-Gm-Message-State: APuU4Z99YgIh+wICyvYddnu0m2jGD0QWO1dXjPP9MVxsN9qf+k4UK8nr NTcTZrtrj55nZqEXbgs0b+ixIGYEA1eVjfrbEKlbcqBZaHbE782rfjwhyLIFagD1gdU= X-Gm-Gg: AZFdTZeE9ENF/QnmCia6meBMgMShDMLKfBTZlMtGWA/Y228tLD2G+zr5C1ZoheHfEfY Ina3wnm9edvkirMT1lekj5SORlJr0xy7WMYYbXMtawWUtQIyY6WH93Jo9UBrdIXZNh4jd1CTrqX /AMm8Iu07Qz3n0iAiPrVMrgAy6M3eGykjW61dIPNyfBUkf4zH0hrkxqp/j7gw37jCcUs+BK+U7E AhqS+6rMZ4wbPH8yMRelQusSflbUZXeSvi6mDgxPi5CuOfD8g6WOe34h308GDVkqoMygEjOp/bR +K91b3HHTAGTT+5xmAr6kFXorw/sd/pvLQLidtFMPlMWaUbvW3eQdX2c+f3jlZ3VcBu0uCG3O6A MB+ytlJrMllQLRgZ4lkLHKAeoS+ROPU2b0AhI6EZqp7420NRE/035YRrvvJHSzymkV8ZlEPKFIg utHroCc0fSkDZ8XFAmfDTgnpplt7YY/3LBjs8uctbskVwMwwT0699/V1XOtlu07ooyRIRAA4jhB QAc6ABVlPXy6cOWVh48rSYRQVW8MW2RBWssc2FL/7k0Dnlv2yRp+7t613jyMEBdbfRLiS9NOc/Y CWycW8cpSYDbPmyYvUu9u2243vcI5aNqKQblVeB9eA== X-Received: by 2002:a05:6000:454f:b0:4b7:6dcb:e909 with SMTP id ffacd0b85a97d-4d1e8dbd24emr40606f8f.8.1796330546994; Thu, 03 Dec 2026 12:42:26 -0800 (PST) Received: from localhost (109-81-27-207.rct.o2.cz. [109.81.27.207]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4d16e0b0c9bsm1396027f8f.3.2026.12.03.12.42.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2026 12:42:26 -0800 (PST) Date: Thu, 3 Dec 2026 21:42:24 +0100 From: Michal Hocko To: "Paul E. McKenney" Cc: "Lorenzo Stoakes (ARM)" , David Hildenbrand , Andrew Morton , David Rientjes , Ben Gardon , Johannes Weiner , linux-mm@kvack.org, LKML , Chris Mason Subject: Re: [PATCH v2] mm, oom: add rcu_barrier before hiding victim from the oom killer Message-ID: References: <20261202095450.296675-10-mhocko@kernel.org> <20261202212147.379270-1-mhocko@kernel.org> <71c575f6-60e6-48cf-9673-2727458733f4@paulmck-laptop> X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <71c575f6-60e6-48cf-9673-2727458733f4@paulmck-laptop> X-Rspamd-Queue-Id: B066720009 X-Stat-Signature: xkchh3554w6rhc7jpgndbgtwjccmsn8m X-Rspam-User: X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Rspamd-Server: rspam06 X-HE-Tag: 1796330548-482888 X-HE-Meta: U2FsdGVkX19LNAnA4AbwkF8FNNmfywWpeCM/QocYZc8Bz8Be7C91rebLHPS9VK7IbILOhXEW5GRKUuPBOKolNXrV8QuQ/8JRuE/vN9bAvphFuid60CqfbpO6pBsyFiXM7de6ji7/1/QQf4NuJ4UB9YMpyRR2OQUQhBLyGatHfsgU7adKDhXrAcFDFdxap8MXoHADiYWZw4SfCwWhoIKkXjBdJrBBaZ5gB28fN+hyXHDOqp3NF1oPHHuA0D7ev9PI8RmnLgaie2ZKgSHXVU257M1iln8Kf8OMPmd4PBQ99262Qta62ae5ls7JEg6OJHAMH7mCuuiwgF6ikGNv6hHFQEkoM+epIZbJFlsX7iH1BWEFisHxXgvfVw7DKfDdBzVUV7SMW8hSH4gt96Tm/XvRg5p8CIgSkCL2LR3hc4muouGqD0NEaH2aDhjVSQwNXPecpxGuV5YRHneoT6d0A1+nLNO6/NJQ4Q4eahtdLbDNMN3PeIp0l5BLerz2A8Z/wz6QVJn5XrpZjJJ8NttYhAk20POTyFGv0DWQgpkgq8ZwMPetYEOe78ymvRfnd7xj7yneIv1TSJqPICn1vdrtSvFRdufuOFUbFGiv6l4o9GruYNrFdml7TtWAtaY8Ij3F8KTguxi5/7rzRQxsgkKB9t63s8Q7NOyMxUFzENqtc6WMFJcUc89K4LISP89XNa2uXvkW7h7SP6SxSJivfOguwfwUmzwZGCdpwO639Dx+FVzLJfaH8iJhxTll92KNp0U0GiiUGJyh4fLfh9o7eNBQOEtIHkRfhfwoqiVCDuT5UbT9GerO0mCoi4nxzidf9IZadX2rC2tgeV1xWMWt/k4SP1eBmD3OtnxRkc9pdTOiRRcaSphN5uQkhmOwAD9i5T6V2MpSKME6CzY5I1aqYzd9uQIIxUkyYe7YksC3bUm54RshUQAT5hDvPIv7jpRCNQLrLLg4ctaVIUdOwAwZ1R/Sewx e7iLs2s5 XODOIpjDqX4Ry67jN89LjPUvgD4TFE7q793Fg4u58RsEUqPPW58p+zDuxuoPWV75qFf3FA9wvtqztvXsuc0/2Z5nX8AYFO/D/kxE+xJrMPT55205FkJz6vIhQ6hdSuXTaBWrKU/oF+AU9zxmyGsW9zjCqw+X9KdNA5bfBZ40hu+7zn3r0rDsay7nJRvJ4Gjwa3sz9CVYIZsBZ0VT/ctuMNhzYBCmXIjkfKkDcSdwU+uV6zq6e/NuPOSIlwZRu0JQXLwrxPoF1SsIVfy0BWSi3EI+/aFga3UoRumQauGUnGUWiZ3fbbp67aj4H6KtXUg0peR0zrKBfAkLyfCWfZjkxw+J/ML+kTfcOcp+xn/ny/53+xfg+fAueDkSKEdE0hRQSxggZ1Wdx6aQqO8pJgxadESo/AsYf4C69pnNCaIrcRTcr7GMec2bvhTtGD8ToQJqFUxRdvv2nUEXzbIIfJXHHKXSB1LGUyLaubm8QILTyMgWcplPnmcdBpL8e91DEMdafYdBVeQg6P/dthhSXolKT7hU6wqeF11+NnSipPw3RvRsJrYeYrZphxoSplSERmgn4/rDNabRrcVd6Xs/QJvhLcOHe2hZQGJkYMJ5feGU2LWzGN4B2JKpVnFp3KMOBzkOHA0jf Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On Thu 03-12-26 12:02:00, Paul E. McKenney wrote: > On Thu, Dec 03, 2026 at 07:11:39PM +0100, Michal Hocko wrote: > > On Thu 03-12-26 09:39:53, Paul E. McKenney wrote: > > [...] > > > > And this is a super sensitive point - will this always result in forward > > > > progress? Could it be significantly delayed? > > > > > > Normal grace period latencies tend to be in the tens or hundreds of > > > milliseconds. And RCU CPU stall warnings happen when a given grace period > > > extends for more than 21 *seconds*, so long RCU grace periods can happen. > > > On the other hand, grace periods this long are (and should be) treated > > > as bugs. > > > > Yes, I guess it is expected that this can take a long time. And this > > particular patch adds it to two places: > > - exit_mmap for an oom_victim > > - oom_reaper > > > > The former is dying and if that takes longer while it is guaranteed to > > release its own memory from page tables which are freed through RCU then > > this is good. We do not even need a guarantee of a fwd progress here. > > > > The latter is more sensitive as it needs the guarantee of fwd progress. > > Although it doesn't hold any locks explicitly it ensures that the > > currently selected oom victims will be torn down - either through them > > exiting or remotely through the reaper. In either case they are declared > > MMF_OOM_SKIP in the end. > > If that takes longer then still not anything really earth shattering as > > long as this cannot block for unbound amount of time. > > OK, good to know! > > > > > Are there any lock dependencies that could be problematic? > > > > > > Given that you are asking this, I am assuming that if this rcu_barrier() > > > gets stuck, reclaim also gets stuck. > > > > > > You are not allowed to acquire sleeplocks in RCU callback functions, > > > and you are not allowed to hold spinlocks across an rcu_barrier(), so > > > at a high level, no. > > > > Thanks for the confirmation. That was my understanding. > > > > > One theoretical problem would be if RCU allocated > > > memory while doing a grace period, and the call to rcu_barrier() blocked > > > the grace period that its callback functions were in turn waiting on. > > > And there might be something like this that could happen when a CPU > > > was coming online for the very first time, especially if that CPU was > > > a rcu_nocbs CPU, which needs kthreads to be created. > > > > > > No locks involved, but self-deadlock nevertheless. > > > > Could you clarify a bit please? So this would be possible only during > > early boot while hitting OOM because RCU internals would be blocked on > > the memory allocation which cannot be resolved? > > Also when bringing a CPU online during runtime, potentially. There are > some oddball configurations that bring up only some of the CPUs initially, > and bring up the rest later. One way to do this is to have qemu and > the kernel have different ideas about the number of CPUs that exist. > > And yes, my concern is that RCU grace periods are blocked on reclaim > while reclaim blocks on an RCU grace period. But maybe this code is > guaranteed to run in its own kthreads or similar? Yes, oom_reaper itself is running in a dedicated kernel thread. Is that sufficient? I thought we could have an indirect dependency chain RCU grace period oom_reaper oom_victim allocates memory [blocked] looping in reclaim rcu_barrier(); [blocked] MMF_OOM_SKIP > Either way, I freely confess that I have not traced out an actual > failure scenario. > > > > So maybe make that rcu_barrier() execute asynchronously? > > > > Well the thing is that we need to use it to order MMF_OOM_SKIP setting > > in the oom_reaper case. > > OK, that would rule out asynchrony. ;-) > > > > And/or do a > > > synchronize_rcu_expedited(), also asynchronously? > > > > As this is mostly a best effort to ensure a lot of memory is not sitting > > to be freed in rcu callbacks then I would much rather just drop the > > rcu_barrier from oom_reap_task. > > The main advantage of doing an rcu_barrier() would be in kernels built > with CONFIG_RCU_LAZY=y, in which case rcu_barrier() would "motivate" > lazy callbacks, potentially large numbers of them. > > On the other hand, RCU does a shrinker_register() in that case, so > maybe those lazy callbacks are already covered. That only involves k[v]free_rcu ones right? So for example page tables wouldn't fall into that category. -- Michal Hocko SUSE Labs