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 86789C3DA49 for ; Tue, 23 Jul 2024 07:30:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D81B36B0099; Tue, 23 Jul 2024 03:30:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D31C96B009E; Tue, 23 Jul 2024 03:30:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B84316B00A2; Tue, 23 Jul 2024 03:30:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 98D046B0099 for ; Tue, 23 Jul 2024 03:30:32 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 0D4BF121D28 for ; Tue, 23 Jul 2024 07:30:32 +0000 (UTC) X-FDA: 82370194704.05.BDBA637 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by imf26.hostedemail.com (Postfix) with ESMTP id 9292C14001B for ; Tue, 23 Jul 2024 07:30:29 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=tp0Zvpek; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=VItdnO17; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=bcgkBsQ8; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=4Hd4G4DE; spf=pass (imf26.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721719784; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=fG4EbjWGNqFXRR6ZQnIuAvzoJK16ltpj5WMaolGqCe8=; b=d886Hq8NziP89xX9+ECcW7ex68NtS1IoctPkYpUxhp1EPs4a2dEB7yx7NUrXJ4EzbQOShS OO9z79TuliWuRhkR22UQoLA/A5r5J6/Ee/nP7u0R6HSLIu6tIWBWSiuwOH/gcTrNDHagyZ Y+CuyOyP/ZSX2frxKOFPqFtIvgS0uGU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721719784; a=rsa-sha256; cv=none; b=ZN7YXrhGded4qb7ll6g91BkkFt+W9J/hmIX+p1SLWLXRrAr83cgZ78GTnkZiGQn4C7+q5g OOaG+oHDfNfqbc2zm8ojgajDSQwOMkpKATFGE5aJ6SUZ8UPdEcCB8qqJr3/WXVBxjdS47C +BePxNdbvD4dTG3Imh0R+XVhtkgDHFw= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=tp0Zvpek; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=VItdnO17; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=bcgkBsQ8; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=4Hd4G4DE; spf=pass (imf26.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id EC53B21AB3; Tue, 23 Jul 2024 07:30:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1721719828; h=from:from:reply-to: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:autocrypt:autocrypt; bh=fG4EbjWGNqFXRR6ZQnIuAvzoJK16ltpj5WMaolGqCe8=; b=tp0ZvpekPuBQx0xah3rl6Eme61oaWDJ0sfC9n9j4fkq2u7gyIrSnPchrao6iUtAl6fpS2i VW2vYmKWYbvBeDrmRB0ktSjymSIOl8QvFWpCuvegYL4aXr5nh/8yzkDGjVCjK0Pl37Ngx8 WCSpqWL3HgnLjzrKTBD/umL9e2E73ic= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1721719828; h=from:from:reply-to: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:autocrypt:autocrypt; bh=fG4EbjWGNqFXRR6ZQnIuAvzoJK16ltpj5WMaolGqCe8=; b=VItdnO17LdABIMZ3ZPbJ81uFQi/g7vWX/nyvCl7z2HFMUZqRRWeO2aN1K8w4fC8q+h06L8 whFYuNyX6dcAiVCg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1721719827; h=from:from:reply-to: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:autocrypt:autocrypt; bh=fG4EbjWGNqFXRR6ZQnIuAvzoJK16ltpj5WMaolGqCe8=; b=bcgkBsQ8DJTrLtQVisPsaX4tm7wkC9154CMg9wWh0sbw/zQeJ2jPPD6Fzyel9iBVmnmS2J NZ4rLO/cDCHGpEHRqPEWf1vYXFjakLGq0QuV/R3bBoPjNxgO4Z+IKh/EamEsjDWNtDwMlo y5eq17ncatR8x0pDbs9cT99JsR75TO4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1721719827; h=from:from:reply-to: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:autocrypt:autocrypt; bh=fG4EbjWGNqFXRR6ZQnIuAvzoJK16ltpj5WMaolGqCe8=; b=4Hd4G4DE9LfCBaaoJbxC7zXaTJLMNa1Qbta/DBQ7AsHpo84y+p1Im33hX7Av0PoAXzN++P p4Ep8KfUxKwFpSDQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id CECDF13874; Tue, 23 Jul 2024 07:30:27 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id dVV7MRNcn2ZlVgAAD6G6ig (envelope-from ); Tue, 23 Jul 2024 07:30:27 +0000 Message-ID: <564ff8e4-42c9-4a00-8799-eaa1bef9c338@suse.cz> Date: Tue, 23 Jul 2024 09:30:27 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] mm: Fix endless reclaim on machines with unaccepted memory. Content-Language: en-US To: "Kirill A. Shutemov" , Michal Hocko Cc: Andrew Morton , "Borislav Petkov (AMD)" , Mel Gorman , Tom Lendacky , Mike Rapoport , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Jianxiong Gao , stable@vger.kernel.org References: <20240716130013.1997325-1-kirill.shutemov@linux.intel.com> From: Vlastimil Babka Autocrypt: addr=vbabka@suse.cz; keydata= xsFNBFZdmxYBEADsw/SiUSjB0dM+vSh95UkgcHjzEVB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y7PpqaODbYv727Dvm5eX64HCyyAH0s6sOCyGF5/p eIhrOn24oBf67KtdAN3H9JoFNUVTYJc1VJU3R1JtVdgwEdr+NEciEfYl0O19VpLE/PZxP4wX PWnhf5WjdoNI1Xec+RcJ5p/pSel0jnvBX8L2cmniYnmI883NhtGZsEWj++wyKiS4NranDFlA HdDM3b4lUth1pTtABKQ1YuTvehj7EfoWD3bv9kuGZGPrAeFNiHPdOT7DaXKeHpW9homgtBxj 8aX/UkSvEGJKUEbFL9cVa5tzyialGkSiZJNkWgeHe+jEcfRT6pJZOJidSCdzvJpbdJmm+eED w9XOLH1IIWh7RURU7G1iOfEfmImFeC3cbbS73LQEFGe1urxvIH5K/7vX+FkNcr9ujwWuPE9b 1C2o4i/yZPLXIVy387EjA6GZMqvQUFuSTs/GeBcv0NjIQi8867H3uLjz+mQy63fAitsDwLmR EP+ylKVEKb0Q2A== In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 9292C14001B X-Stat-Signature: r711tnru9bnta9iwwfiru4ztppkieat8 X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1721719829-750797 X-HE-Meta: U2FsdGVkX1960YnS78lq4LOv6mHvFsZYlRc8d+7unWfgVFh1qQyMfsGI8qKn8TdPeP6zy6kFC2PpqQ+SF/z93Eso4GH2vG8sfXaQ+R5j7Qxs7mWCM3WV4wVQy+MssZmH4zBJZbvlChzmUYuAd7+y9+OA3++E4oVAd8bx7awMmDru17k1yvLDR3y0L4A/1Elty7d6rzH/5UsDJIGEdJsdypziNl5gTSePSDIsuiZnMBRLlIchKNcuCJL6u6TtGv3eCd9twZSGASlOuD3Br1rWXoHM1XncLHzGlsoyyMNjRILt+qirhJJr9LnqKQxlzwyZ2/hIHUldX8n2S72xRGyDaoX0Oq0FcwqAaebcc78V2ZNXMpoJfky0RfCtmACQ44YODacksRTAXn8596o3O5AqoEISpBJ8Rsg5aGFG8JpN5NE1EYlcEeXuZ2k1Of/X9U/1YnpoGK3F4ZgAbThBDiZlxA2tZq0HbSHFq2+H5otloKvfZEZ43b8p9ks/B/Ry4h6TS2dXl9zrZVEYcGThpGnme3C4VX81stunKqXSsmrjMBK6njlnXEbwlFt9Bl1UfXchdABYng2WHOoP3zSZuxxzmZqZbM0JAHrec8qoVZxmgOJ9IE6+RNcshVL0QJmZbju2cBd12vZau3qH2Boo52ohFgb4LePhaLCzbAVN4Dg1J2mztPcQzBdboHU6J6GmwHZMLrHbBdMvKC5R5B5UHzmx0ocQbhlmsJsSDLhChQNN70ftUo8dtY1eLDzF74NqHo+kHdguzJHH5DtCfDVnWdPL/MdlBoBKb0DiR94byRPzVDd4LDG+Jduj8LrVACtB4KFXFlQHN3CFE78ecmjVXvpBU+yFzz7Lr5lZz2XM3KHvLM1PaAyTAJGR13lTDTR/KsiLt93H+/CQyN6SMHTFnDprCouw1ZmnsmL7xLGspeQ813Uh11ZQIDzVz0uIA6XF6kQTlY4kiWfWO7PJXOBZaVX p6KAH7cL P4N9twR/sCfqcOgLj2EM6sbOl3F6BnMhUkgAh+XM0NnFDG9Y8odlwhGRd9K6AdM6TmmYUWAfXjVb17Eu99q2Au2X9oRPe5IF9ZN+0pJ6XAGld0hOlNKhpJoWa9o2EANm2Z7bwbR65xbMATThx36Z8lfcv0kLKfEiF0wef1oPwV2XaT09YyG5y+X4UPmsrWgv3ba7rSlsj9/4c4EII2RF81ZoV5s8zFPD0ie8SX6qa9R0PsfBghi2Wo4geEaIp2GLSvfIippq2CftzosY= 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: List-Subscribe: List-Unsubscribe: On 7/22/24 4:07 PM, Kirill A. Shutemov wrote: > On Wed, Jul 17, 2024 at 02:06:46PM +0200, Michal Hocko wrote: >> Please try to investigate this further. The patch as is looks rather >> questionable to me TBH. Spilling unaccepted memory into the reclaim >> seems like something we should avoid if possible as this is something > > Okay, I believe I have a better understanding of the situation: > > - __alloc_pages_bulk() takes pages from the free list without accepting > more memory. This can cause number of free pages to fall below the > watermark. > > This issue can be resolved by accepting more memory in > __alloc_pages_bulk() if the watermark check fails. > > The problem is not only related to unallocated memory. I think the > deferred page initialization mechanism could result in premature OOM if > __alloc_pages_bulk() allocates pages faster than deferred page > initialization can add them to the free lists. However, this scenario is > unlikely. > > - There is nothing that compels the kernel to accept more memory after the > watermarks have been calculated in __setup_per_zone_wmarks(). This can > put us under the watermark. > > This issue can be resolved by accepting memory up to the watermark after > the watermarks have been initialized. > > - Once kswapd is started, it will begin spinning if we are below the > watermark and there is no memory that can be reclaimed. Once the above > problems are fixed, the issue will be resolved. > > - The kernel needs to accept memory up to the PROMO watermark. This will > prevent unaccepted memory from interfering with NUMA balancing. So do we still assume all memory is eventually accepted and it's just a initialization phase thing? And the only reason we don't do everything in a kthread like the deferred struct page init, is to spread out some potential contention on the host side? If yes, do we need NUMA balancing even to be already active during that phase? > The patch below addresses the issues I listed earlier. It is not yet ready > for application. Please see the issues listed below. > > Andrew, please drop the current patch. > > There are a few more things I am worried about: > > - The current get_page_from_freelist() and patched __alloc_pages_bulk() > only try to accept memory if the requested (alloc_flags & ALLOC_WMARK_MASK) > watermark check fails. For example, if a requested allocation with > ALLOC_WMARK_MIN is called, we will not try to accept more memory, which > could potentially put us under the high/promo watermark and cause the > following kswapd start to get us into an endless loop. > > Do we want to make memory acceptance in these paths independent of > alloc_flags? Hm ALLOC_WMARK_MIN will proceed, but with a watermark below the low watermark will still wake up kswapd, right? Isn't that another scenario where kswapd can start spinning? > - __isolate_free_page() removes a page from the free list without > accepting new memory. The function is called with the zone lock taken. > It is bad idea to accept memory while holding the zone lock, but > the alternative of pushing the accept to the caller is not much better. > > I have not observed any issues caused by __isolate_free_page() in > practice, but there is no reason why it couldn't potentially cause > problems. > > - The function take_pages_off_buddy() also removes pages from the free > list without accepting new memory. Unlike the function > __isolate_free_page(), it is called without the zone lock being held, so > we can accept memory there. I believe we should do so. > > I understand why adding unaccepted memory handling into the reclaim path > is questionable. However, it may be the best way to handle cases like > __isolate_free_page() and possibly others in the future that directly take > memory from free lists. Yes seems it might be not that bad solution, otherwise it could be hopeless whack-a-mole to prevent all corner cases where reclaim can be triggered without accepting memory first. Although just removing the lazy accept mode would be much more appealing solution than this :) > Any thoughts? Wonder if deferred struct page init has many of the same problems, i.e. with __isolate_free_page() and take_pages_off_buddy(), and if not, why? > I am still new to reclaim code and may be overlooking something > significant. Please correct any misconceptions you see. > > diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h > index c11b7cde81ef..5e0bdfbe2f1f 100644 > --- a/include/linux/mmzone.h > +++ b/include/linux/mmzone.h > @@ -667,6 +667,7 @@ enum zone_watermarks { > #define min_wmark_pages(z) (z->_watermark[WMARK_MIN] + z->watermark_boost) > #define low_wmark_pages(z) (z->_watermark[WMARK_LOW] + z->watermark_boost) > #define high_wmark_pages(z) (z->_watermark[WMARK_HIGH] + z->watermark_boost) > +#define promo_wmark_pages(z) (z->_watermark[WMARK_PROMO] + z->watermark_boost) > #define wmark_pages(z, i) (z->_watermark[i] + z->watermark_boost) > > /* > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index c62805dbd608..d537c633c6e9 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -1748,7 +1748,7 @@ static bool pgdat_free_space_enough(struct pglist_data *pgdat) > continue; > > if (zone_watermark_ok(zone, 0, > - wmark_pages(zone, WMARK_PROMO) + enough_wmark, > + promo_wmark_pages(zone) + enough_wmark, > ZONE_MOVABLE, 0)) > return true; > } > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index 14d39f34d336..b744743d14a2 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -4462,6 +4462,22 @@ unsigned long __alloc_pages_bulk(gfp_t gfp, int preferred_nid, > alloc_flags, gfp)) { > break; > } > + > + if (has_unaccepted_memory()) { > + if (try_to_accept_memory(zone, 0)) > + break; > + } > + > +#ifdef CONFIG_DEFERRED_STRUCT_PAGE_INIT > + /* > + * Watermark failed for this zone, but see if we can > + * grow this zone if it contains deferred pages. > + */ > + if (deferred_pages_enabled()) { > + if (_deferred_grow_zone(zone, 0)) > + break; > + } > +#endif > } > > /* > @@ -5899,6 +5915,9 @@ static void __setup_per_zone_wmarks(void) > zone->_watermark[WMARK_PROMO] = high_wmark_pages(zone) + tmp; > > spin_unlock_irqrestore(&zone->lock, flags); > + > + if (managed_zone(zone)) > + try_to_accept_memory(zone, 0); > } > > /* update totalreserve_pages */ > @@ -6866,8 +6885,8 @@ static bool try_to_accept_memory(struct zone *zone, unsigned int order) > long to_accept; > int ret = false; > > - /* How much to accept to get to high watermark? */ > - to_accept = high_wmark_pages(zone) - > + /* How much to accept to get to promo watermark? */ > + to_accept = wmark_pages(zone, WMARK_PROMO) - > (zone_page_state(zone, NR_FREE_PAGES) - > __zone_watermark_unusable_free(zone, order, 0)); > > diff --git a/mm/vmscan.c b/mm/vmscan.c > index 3ef654addd44..d20242e36904 100644 > --- a/mm/vmscan.c > +++ b/mm/vmscan.c > @@ -6607,7 +6607,7 @@ static bool pgdat_balanced(pg_data_t *pgdat, int order, int highest_zoneidx) > continue; > > if (sysctl_numa_balancing_mode & NUMA_BALANCING_MEMORY_TIERING) > - mark = wmark_pages(zone, WMARK_PROMO); > + mark = promo_wmark_pages(zone); > else > mark = high_wmark_pages(zone); > if (zone_watermark_ok_safe(zone, order, mark, highest_zoneidx))