From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed1-f46.google.com (mail-ed1-f46.google.com [209.85.208.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 035FD232459 for ; Tue, 14 Jan 2025 16:46:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736873204; cv=none; b=RE7vsUe665XM75M+UqyN0HE7gtl1v+5ns0mfoDquATe5F+zd551+zyVfovKRFjYez9o2NHp5dlkMlWy1hmeUCneW9HXS68RT09NCGoPoBEzAb6YjbBAIl3F7XYszvwNZ4Dqk1XuIQxxmrXDGlTcfl9ACrX+8qH5/bM1qMLMsPpg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736873204; c=relaxed/simple; bh=Od7cT+6OePddRARsQyMIKh3g3Dy5MlIPURlz6c/4yws=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=CZIKC9I7hRETLkXB6TPEA3ng1CLSs7qe5mPUzjTwmY+9YWRnNJA0JGyVSmsufprfXl9I4H3qWEPl6Vu6PzmxPoO2X/L7GrrLsoyzFYYtXywKSvJBDwtjIwgL5+BYRN3CjBgw7P5PjjQ/8dEJO3toMBVxF+ldZhANTS3oY64Abck= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=AaFvgzsg; arc=none smtp.client-ip=209.85.208.46 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) header.d=suse.com header.i=@suse.com header.b="AaFvgzsg" Received: by mail-ed1-f46.google.com with SMTP id 4fb4d7f45d1cf-5d9f0a6ad83so3098722a12.2 for ; Tue, 14 Jan 2025 08:46:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1736873200; x=1737478000; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=a2BHjXvqFbc3tWWjsYaH/7UzCgd7nB1pFhFnKUVV49g=; b=AaFvgzsgO52JwxRFfGf0OoxAX0tcUchVDR8u3DrG0uaiArS9DucM4pa4WoKreL3TU3 vUGvOL7Ik6T9dQ0OsCZ3y0wXbndSlZD2KcQMRqr8AtoeVlMJNhId1ufj1T+ZUZz7RH1U nG57kP0xH2PuwxyqVKGlyj+/q4ZOHjgs3nflYIRIlOOcWw693gL2E26SJgcilPU+OtPc lWQ1NfmV7ANQcO0Ok/KqYrYOXap43n4wLfCYSEyUKywSQxN6NNClBIIMAdNtj3+qu2H3 3DHFevne620xB6ZbDk++Lixc896MyCmt/w/JzVas9Qjkf60lAWF6ZmwZKSd6rPgd86Wo eiwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736873200; x=1737478000; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=a2BHjXvqFbc3tWWjsYaH/7UzCgd7nB1pFhFnKUVV49g=; b=ZjUP1Qw/G8XuKLH6Kqou9snyc/Fmof42cR6xPzwIoTRMTIspSUYIJ0fbeN4EVcDE0n x2huzDAh7SErESpWAqo4oUoYh+rSTvXaDiiSdQbZiIKbAhjo8OqK6TT6v6p8LP8TJU89 jGIX1uS3cm4U8QX/t4gRBnoeUZ6NBA+6ia3PWwqDBClnFvfeSrE1bzDTE5ths0BLs/sC 8tlZ9Cz8PYGaxRd+kovRliTKzCwwh/hLCBfyd6ETuq/yGXvjb33ndnRih4l5TbMQUnBR h0MXQepL87Q7Rol2j1pIsJYJtrwvLBgIQvBwwMrEpTrjX7anpEbcGSEaQSCHJ0V/n82W lh8Q== X-Forwarded-Encrypted: i=1; AJvYcCUqQCghxMyL8xdsWeKJjF77Livs+XIme/ET6unAxL31Ffafc3FReT3gxqWRkJttPJpWacbmGunKtNTF78s=@vger.kernel.org X-Gm-Message-State: AOJu0YwxPNvSywcHtdKJ+nKyzWx77nIY8/RT48SDrKoUYTdeN9P4o+Ie 5gRActnw0QQWMtR3MObWnnK9oJk+2TlN7DJADG14fDpxVdu02snsGRp9Pk65RFY= X-Gm-Gg: ASbGnctdmvg1Lwp4AG9DvioF4u9urMoKplGLIXDFKrAexz8kYfNVmRvvmOs8QZfHwvv O9Vl8ZU3Rilmc4p+4mD6HiJoQTIEEcF8j5UwnS72o9o0lUQS7oUH3itwdAaECRwA1ORfacYLISb 1MUTGXC/xqGriSyd/K96sVLeTA3Yh67PR+jOE793lrF9AmJJHBDD0psjCIulhZ40TiVI4y7tGGS 7Tfujv1/ibnSpLq9PmLlOQPqzjIcQiRoaaXMNniGQj99aqyUFQQNjyTF77jwICWiJ/LZQ== X-Google-Smtp-Source: AGHT+IHPbTGhIrcMN7gSIY4GR5omZuGW4NRVR+gBuMJJgCqPbIEcYAZVtpjD8uuNUx3jv0VoINP82A== X-Received: by 2002:a05:6402:50c9:b0:5d9:a61:e7c9 with SMTP id 4fb4d7f45d1cf-5d972e1bf6fmr24029174a12.20.1736873198702; Tue, 14 Jan 2025 08:46:38 -0800 (PST) Received: from localhost (109-81-90-202.rct.o2.cz. [109.81.90.202]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5d98fe8f68csm6433022a12.0.2025.01.14.08.46.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 08:46:38 -0800 (PST) Date: Tue, 14 Jan 2025 17:46:37 +0100 From: Michal Hocko To: Johannes Weiner Cc: Yosry Ahmed , Rik van Riel , Balbir Singh , Roman Gushchin , hakeel Butt , Muchun Song , Andrew Morton , cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@meta.com, Nhat Pham Subject: Re: [PATCH v2] memcg: allow exiting tasks to write back data to swap Message-ID: References: <20241212115754.38f798b3@fangorn> <20241212183012.GB1026@cmpxchg.org> <20250114160955.GA1115056@cmpxchg.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250114160955.GA1115056@cmpxchg.org> On Tue 14-01-25 11:09:55, Johannes Weiner wrote: > Hi, > > On Mon, Dec 16, 2024 at 04:39:12PM +0100, Michal Hocko wrote: > > On Thu 12-12-24 13:30:12, Johannes Weiner wrote: [...] > > > If we return -ENOMEM to an OOM victim in a fault, the fault handler > > > will re-trigger OOM, which will find the existing OOM victim and do > > > nothing, then restart the fault. > > > > IIRC the task will handle the pending SIGKILL if the #PF fails. If the > > charge happens from the exit path then we rely on ENOMEM returned from > > gup as a signal to back off. Do we have any caller that keeps retrying > > on ENOMEM? > > We managed to extract a stack trace of the livelocked task: > > obj_cgroup_may_swap > zswap_store > swap_writepage > shrink_folio_list > shrink_lruvec > shrink_node > do_try_to_free_pages > try_to_free_mem_cgroup_pages OK, so this is the reclaim path and it fails due to reasons you mention below. This will retry several times until it hits mem_cgroup_oom which will bail in mem_cgroup_out_of_memory because of task_is_dying (returns true) and retry the charge + reclaim (as the oom killer hasn't done anything) with passed_oom = true this time and eventually got to nomem path and returns ENOMEM. This should propaged -ENOMEM down the path > charge_memcg > mem_cgroup_swapin_charge_folio > __read_swap_cache_async > swapin_readahead > do_swap_page > handle_mm_fault > do_user_addr_fault > exc_page_fault > asm_exc_page_fault > __get_user All the way here and return the failure to futex_cleanup which doesn't retry __get_user on the failure AFAICS (exit_robust_list). But I might be missing something, it's been quite some time since I've looked into futex code. > futex_cleanup > fuxtex_exit_release > do_exit > do_group_exit > get_signal > arch_do_signal_or_restart > exit_to_user_mode_prepare > syscall_exit_to_user_mode > do_syscall > entry_SYSCALL_64 > syscall > > Both memory.max and memory.zswap.max are hit. I don't see how this > could ever make forward progress - the futex fault will retry until it > succeeds. I must be missing something but I do not see the retry, could you point me where this is happening please? -- Michal Hocko SUSE Labs