From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B94CA232459; Tue, 14 Jan 2025 16:51:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=96.67.55.147 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736873525; cv=none; b=VX1EB0RIqSIi8oljwBupJatfv2LXqdD2M0+chqUauN/iCFHgv79cisCK3fZg8gz3dht3bRqRdOgM5B5cwMcCuFZ1hbBRWSjMehD3MjeP5W/IfDojMO6vGJ0Y0jxsa5/r8ONFLlJyVO3QgJX1v+eDyCfe9nobPSYo2WQUguxiCOo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736873525; c=relaxed/simple; bh=LaPqHP4/NpZcpi7UsYIE/Yi5+Nyg0noYYqkJ+PH3r2k=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=HYb/PH2vrA5ypBtapXyLe0Q1J64dowwsr8odSWvU4FSbxtaS44kzhB4dUUBImIaDLG/jEgkbuT6rDrmiYmgTfEbWN0X/IyCaXS4EfmF9f/0wyjGtRg9xWrqQ18NRG2iuKZtKXdV0JPYH5rAEGy5Wx9+QP7gMLpHPbmpOEp+BEP0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=surriel.com; spf=pass smtp.mailfrom=shelob.surriel.com; arc=none smtp.client-ip=96.67.55.147 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=surriel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=shelob.surriel.com Received: from fangorn.home.surriel.com ([10.0.13.7]) by shelob.surriel.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.97.1) (envelope-from ) id 1tXk8M-000000008UK-1uCf; Tue, 14 Jan 2025 11:51:18 -0500 Message-ID: Subject: Re: [PATCH v2] memcg: allow exiting tasks to write back data to swap From: Rik van Riel To: Michal Hocko , Johannes Weiner Cc: Yosry Ahmed , 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 Date: Tue, 14 Jan 2025 11:51:18 -0500 In-Reply-To: References: <20241212115754.38f798b3@fangorn> <20241212183012.GB1026@cmpxchg.org> <20250114160955.GA1115056@cmpxchg.org> Autocrypt: addr=riel@surriel.com; prefer-encrypt=mutual; keydata=mQENBFIt3aUBCADCK0LicyCYyMa0E1lodCDUBf6G+6C5UXKG1jEYwQu49cc/gUBTTk33A eo2hjn4JinVaPF3zfZprnKMEGGv4dHvEOCPWiNhlz5RtqH3SKJllq2dpeMS9RqbMvDA36rlJIIo47 Z/nl6IA8MDhSqyqdnTY8z7LnQHqq16jAqwo7Ll9qALXz4yG1ZdSCmo80VPetBZZPw7WMjo+1hByv/ lvdFnLfiQ52tayuuC1r9x2qZ/SYWd2M4p/f5CLmvG9UcnkbYFsKWz8bwOBWKg1PQcaYHLx06sHGdY dIDaeVvkIfMFwAprSo5EFU+aes2VB2ZjugOTbkkW2aPSWTRsBhPHhV6dABEBAAG0HlJpayB2YW4gU mllbCA8cmllbEByZWRoYXQuY29tPokBHwQwAQIACQUCW5LcVgIdIAAKCRDOed6ShMTeg05SB/986o gEgdq4byrtaBQKFg5LWfd8e+h+QzLOg/T8mSS3dJzFXe5JBOfvYg7Bj47xXi9I5sM+I9Lu9+1XVb/ r2rGJrU1DwA09TnmyFtK76bgMF0sBEh1ECILYNQTEIemzNFwOWLZZlEhZFRJsZyX+mtEp/WQIygHV WjwuP69VJw+fPQvLOGn4j8W9QXuvhha7u1QJ7mYx4dLG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w== Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.54.1 (3.54.1-1.fc41) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Sender: riel@surriel.com On Tue, 2025-01-14 at 17:46 +0100, Michal Hocko wrote: > On Tue 14-01-25 11:09:55, Johannes Weiner wrote: >=20 > >=20 > > We managed to extract a stack trace of the livelocked task: > >=20 > > 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 >=20 > 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 =3D true this time and eventually got to > nomem > path and returns ENOMEM. This should propaged -ENOMEM down the path >=20 > > 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 >=20 > 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. Can you explain how -ENOMEM would get propagated down past the page fault handler? This isn't get_user_pages(), which can just pass -ENOMEM on to the caller. If there is code to pass -ENOMEM on past the page fault exception handler, I have not been able to find it. How does this work? >=20 > > 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 > >=20 > > 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. >=20 > I must be missing something but I do not see the retry, could you > point > me where this is happening please? >=20 --=20 All Rights Reversed.