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 C0E25C7618A for ; Mon, 20 Mar 2023 18:21:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3E4B06B0078; Mon, 20 Mar 2023 14:21:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3953F6B007D; Mon, 20 Mar 2023 14:21:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 25CF36B007E; Mon, 20 Mar 2023 14:21:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 120716B0078 for ; Mon, 20 Mar 2023 14:21:09 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id D93C940624 for ; Mon, 20 Mar 2023 18:21:08 +0000 (UTC) X-FDA: 80590093416.12.D41A901 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf06.hostedemail.com (Postfix) with ESMTP id D1C3A180007 for ; Mon, 20 Mar 2023 18:21:06 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=tL+1vY6K; spf=pass (imf06.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.28 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1679336467; 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=tvdbxllJgu2dqqiuZgfiKsVLc6kJGymLv0RE9T2++/A=; b=MBChEgKwcsgQ7N9CcdXk53PSqNw7ArETq3NVYOykv6HJv6NRHGVu4rs/2aFOmzuMAwzBrU 3JqSXgo3yK/2jLDmgDRqvKmDMarzEAxYHol6G4UFPLBVvr6kPJGGmHpF+VnxfSWxdxY03s 44NJlAZ6GV3dRx/mmj8rRF4xdos3oE8= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=tL+1vY6K; spf=pass (imf06.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.28 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1679336467; a=rsa-sha256; cv=none; b=b4ZH+ozyP/5431s7odGmkaPsSqSuQBiqJH4/q00VKvbNuis/k3NGXsgtSI0KR2jqkTxF6e Vzyh5Br9SSfPJxImivcgCal+e0YYnqIFP081tEe6M47aPYIslvbhOORYISbHQE7FGAr3G0 Ms2idAhSyQKWEWNkO6I7tS2mRZ9GoEM= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 4AC2021AB5; Mon, 20 Mar 2023 18:21:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1679336465; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=tvdbxllJgu2dqqiuZgfiKsVLc6kJGymLv0RE9T2++/A=; b=tL+1vY6K+qBHzZGuT5l11aWn8w82TXl7YrNDkuxjrlswA2ybLxyBEPPKT1YfiPIwQeAJLd Fqd3auVZzPRsm4VTiozhp+zbkDajZnrLFpMe8oLa6JqxvXi6dnLh6zSJqfvSWebtY8pM7I m1VC5zNG7Kf+NNW8neqI00FEFigKoeo= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 1F13B13416; Mon, 20 Mar 2023 18:21:05 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id oVeBBRGkGGRTJgAAMHmgww (envelope-from ); Mon, 20 Mar 2023 18:21:05 +0000 Date: Mon, 20 Mar 2023 19:21:04 +0100 From: Michal Hocko To: Marcelo Tosatti Cc: Christoph Lameter , Aaron Tomlin , Frederic Weisbecker , Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Russell King , Huacai Chen , Heiko Carstens , x86@kernel.org, Vlastimil Babka Subject: Re: [PATCH v7 01/13] vmstat: allow_direct_reclaim should use zone_page_state_snapshot Message-ID: References: <20230320180332.102837832@redhat.com> <20230320180745.556821285@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230320180745.556821285@redhat.com> X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: D1C3A180007 X-Stat-Signature: pfyq8szqc4dijff9mzbrpczooz7p59ts X-HE-Tag: 1679336466-341534 X-HE-Meta: U2FsdGVkX18rnMA93A0bTdPOzdNX9cJ4FwruN+/0xYLbVaICAHFP84IHUFIewfJm528RvcQsoRfk/9XCXLS0MoSn8nJKglL1erCt/LBVbkf1lI9P3U+uxtAJFlDwPSShrV6EPiFDTmSEZy0YmqqiaRrPFCld78Z7Ow2Bec/aLVM+BPl4UzvJA2HJlU3YydS45sT/E84zKh3gXfKiNF+yZQ9bB9Wy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KuMbBoR9m/8a+A== 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: On Mon 20-03-23 15:03:33, Marcelo Tosatti wrote: > A customer provided evidence indicating that a process > was stalled in direct reclaim: > > - The process was trapped in throttle_direct_reclaim(). > The function wait_event_killable() was called to wait condition > allow_direct_reclaim(pgdat) for current node to be true. > The allow_direct_reclaim(pgdat) examined the number of free pages > on the node by zone_page_state() which just returns value in > zone->vm_stat[NR_FREE_PAGES]. > > - On node #1, zone->vm_stat[NR_FREE_PAGES] was 0. > However, the freelist on this node was not empty. > > - This inconsistent of vmstat value was caused by percpu vmstat on > nohz_full cpus. Every increment/decrement of vmstat is performed > on percpu vmstat counter at first, then pooled diffs are cumulated > to the zone's vmstat counter in timely manner. However, on nohz_full > cpus (in case of this customer's system, 48 of 52 cpus) these pooled > diffs were not cumulated once the cpu had no event on it so that > the cpu started sleeping infinitely. > I checked percpu vmstat and found there were total 69 counts not > cumulated to the zone's vmstat counter yet. > > - In this situation, kswapd did not help the trapped process. > In pgdat_balanced(), zone_wakermark_ok_safe() examined the number > of free pages on the node by zone_page_state_snapshot() which > checks pending counts on percpu vmstat. > Therefore kswapd could know there were 69 free pages correctly. > Since zone->_watermark = {8, 20, 32}, kswapd did not work because > 69 was greater than 32 as high watermark. > > Change allow_direct_reclaim to use zone_page_state_snapshot, which > allows a more precise version of the vmstat counters to be used. > > allow_direct_reclaim will only be called from try_to_free_pages, > which is not a hot path. Have you managed to test this patch to confirm it addresses the above issue? It should but better double check that. > Suggested-by: Michal Hocko > Signed-off-by: Marcelo Tosatti The patch makes sense regardless but a note about testing should be added. Acked-by: Michal Hocko > > --- > > Index: linux-vmstat-remote/mm/vmscan.c > =================================================================== > --- linux-vmstat-remote.orig/mm/vmscan.c > +++ linux-vmstat-remote/mm/vmscan.c > @@ -6861,7 +6861,7 @@ static bool allow_direct_reclaim(pg_data > continue; > > pfmemalloc_reserve += min_wmark_pages(zone); > - free_pages += zone_page_state(zone, NR_FREE_PAGES); > + free_pages += zone_page_state_snapshot(zone, NR_FREE_PAGES); > } > > /* If there are no reserves (unexpected config) then do not throttle */ > -- Michal Hocko SUSE Labs