From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.45 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796330549; b=UrJun7BcWHOE4lSbsf49PgZRuE0a2+Sm5bZOZyQlne76ZlYweZT7FLJQnLxYnqiYJbSF WqvAKbKEEVdN2esoLmu2eyx+6dD2fGq3/PW4Se2c4lH8q8QNhJGzQ4nWmUHDzu9cltsla SS5gitgJ7PdIORs0670whxlWqD0ft9sg434uzTTMW+8XdKcBvyl1qBEGrHewDebGLnHnk bssc6QQrmAKEwdVQ9jH3dghO0kC93w8c/MJOsMWf+OB9Fy5gVi46uGz2tkNov/bYvY9iv Z36ABQFbZvhZnoKZaY1X/Ne9Qmj6axF1WGqNRU0I4g7fZvwRG3YSoy7XzdNcYYyLFnA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796330549; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; bh=X178MMx1A1q7ptdUp1IR+RVfrsGqn2FZZ8eu0SAC3nE=; b=QVTITOcRp7wTPkYadjhAlLZQyaeye2lY51ZdzceHiiLysdkXIaTQxjn5tNcIX+Oa7acZ Q+xuch4Ka59SMcs4NTj9kzKKu2/8Zm8xDYSt+OWWavdVEYU4dYAYNX3HvBsySKJW0zHb6 JNntIFA3hNQKHAllb84JNaR1jakkJj3OZg9yGoh6i8W9VHEgfucxwCHW9sqVpWlXnU9ay U8vGFu7SUR86S/QTaLrTPslcihXoz3gmxVvteSlbSU1JlfMBVroRck6058PrPWxl7q4XC qfe2XOuhX3DSjEjdjFKqXDTaoyYrL/CNzzjkq7AL++iRYatnNXCN+0tKnN2n1NO5x5A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass header.d=suse.com header.i=@suse.com header.a=rsa-sha256 header.s=google header.b=NVoifTB9; arc=none smtp.remote-ip=209.85.221.45 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B9871606A32D for ; Thu, 3 Dec 2026 20:42:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B9871606A32D Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=suse.com header.i=@suse.com header.a=rsa-sha256 header.s=google header.b=NVoifTB9 Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-4a5024b3c28so820808f8f.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=vger.kernel.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=NVoifTB9Z7E9aOO6kXTrqhm670XSNFFTRNh2KD/z5mJSKudjBnnFxeLh37uyuXsrcU Fw3RJgUX7q0q2LntAXxgvRKt3Qm4Be4acrpVt1mBGSJUrv3O7RnsdtIFt63AeEcrHQ2S akpKNAxAcAD49BkmgCi/7arrDC0GElOWTw9TLMFWqLjHd8lKY+j/dP/CQeP4B1fM/pAZ IRLE+qeod4RIN/Bt6s4v1wVFGpiLEHyZQp/hMdJlhPs5uU74zrcqCU7t3JkMcSVkspS/ /e+jwjWGW1qLaQ6OiXkO+DWF4/BWfRPr2wf/PxWnrtmdsXE8FJsNbkLzppamS40g9+le 2vVA== 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=MHusffBU+sS8WBT+N9+puq2Fzb/qOCW2W8jCRYXBX4YtrCPdkdbGAx9fIsWhJyW7Sh wH7KD6UCIuiXxplHWXzfzehj/mGtcQSyyFHdQmusafjNWrvp6F15m6M76lZfL8z61kiN V56XSHl8rsTo60s9+qD4RDkhKSFIgPETj6/NiKYVg2ExzxeKpmNlJs1FXMKiu3t6ABwk MuGFQGAuc9gH6bWwqH1ekutRHCkUvkTAEpdZLX4sOcmUpk38L8Czwl/ALTSlQ90Z63r9 9rQG/pHIbxuPYqjLsdoIzPvATCmMuSTwuywARatE45/Acfj+49sVLuitI7Naf4hM4Woh PqrA== X-Forwarded-Encrypted: i=1; AL+hErEPkIeVcoFQjp96TVw0KCFJ/TUzydbgc3R0vtraKDUM92I8JoAPnfuF8/7z2mJxzk+dTLvdhP58uzNPh08=@vger.kernel.org X-Gm-Message-State: APuU4Z9pQZ+WdoB3AnCg2Q69H0vnr6oQGdbhlM684f5H0LJptGivxxVa HUbcZ9C1Qff/dDL65m+dbggYUSb1XWq4Z7BbNDYkW+CCNHhT9v4NHzub6pf0d539lSk= X-Gm-Gg: AZFdTZcn7R/5is6pZfOHStdRMcKSfimnyOIiwdXg++fJhNpBZITU3VU3Lwa9iSHCeFg eifR64vIflV8nqOVYsCAbqA0KTT5nRm9x02tWBo02+82odNiRPXuu1083RqxgiZPsOsj/OdEZqF aBgkdtoIHqbuKzODQMU8obj5cDP+Jibng0kd4L0dLPjfiWiI1Jhrpc2uy1wpe/6zMLKqmRsGCP5 1OVKO0iS2ppu6QQ4rs+TU5rOIR2LTSGQhr6hIo5WpkZtL1kfGJkLkiEa5RXqmEd7iAzv50uJIxB 7k1ffyb6ZtNQvHRDO5+e1FHggvMuRdjXxWh/KYtdoIWtYq9JJRBIu0Ql5k2eu/k8FZujS9AyW6+ +uAft8VMALffSjUl9raSl5SWdUiQLFpv5dfI29rRiYXE1XYClMeW/mlH0NhklhqVWIdwodduGNm kcgJzB282lXzP8ADH6y6mN6WwDJEgarEl+q5kcq1Ver5mU6DMQNudLGNJMYyTipqi6l1SMwRDFp w5RA0nWSkgXnAsfxGFFWQFS516DnX1HpgIVXmRulYGtklZhZGZrW9/b8/mEfNLoNf0LBmUyvUJQ B499ueHwTqbraxLbMSxlymZ3VcPfFVfT+6WeR2NLKQ== 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-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <71c575f6-60e6-48cf-9673-2727458733f4@paulmck-laptop> 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