Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5701128rwd; Wed, 24 May 2023 05:47:33 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6ULQzvTRNUtYlOgW3ELp3Md4Di6tcJmBUoMDoK3TousGye9Cc+fmLvEq541jhCuXadNNfd X-Received: by 2002:a05:6a21:339f:b0:10b:3b4d:8c16 with SMTP id yy31-20020a056a21339f00b0010b3b4d8c16mr13036532pzb.38.1684932453313; Wed, 24 May 2023 05:47:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684932453; cv=none; d=google.com; s=arc-20160816; b=VkM2NFkD+YCYmt/7Ce/9o3xzlUbztWC0MF14AL0AmeCC/Wp4eNLMJDvhb0zmxQiTx+ 7xFW8IZhiBlmqBfrr9Jf+Wwd/ZMqaAHAnlfKw2ZNO6Pvbg3hu+J1Xhbo43H4UWtkcUOr xSjsceLL69NvpbHxOdy2Um3eBfTpYk8CTO4zozgS91kj2l9t4A7jwQ0SlybvFJdSxqjk vLI4VTUaFPU+E8gs7vqH3iw9TQSGGwJ4L6wV4XLICTq207zknt3OTR/flACu4csU2b79 ODnqywP7WMP7xqFZAu1IiyZHfpDXBKl+C5Jsu8g773hWitkqpuIV2XXbszpwcIIy17FI 5q5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=AiiMIvYGdbIRGL9zQDfeMCY6Hk4lfNGeYEXmOzeLdh0=; b=jM/hAQJzOM1qnfniEPbk9HsGtV6o/h2bVUf9YDmfmz7p94NlxfzryFdEyRPboS6w6G y5UtT1bmoyPuiauMrDeqfGiCgY5XuHBAsjWpjypkRFErCV5Q91M+XDgdJMojsnsx+paD Fg+wuCvtqoZ+VU8BcE16P7daCx57r0vPJQdRqgNnpveE4fZfoReahPymIoqwczPMViEm mK6bNx5KCsdfDzg8Bq3URmBx9wKOcqceIREXoHtuUBlZF+qiDJ+jJkcinQArbvitXPH2 SNtY6RPpj4swjT+P/tYPJS7+8TUMj1KfG+jiGJmgP0QgYdr3/+JJWOGMusy5Cu2r+iyO fK2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=eDp4Qudo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r184-20020a632bc1000000b0052cad187979si8544055pgr.147.2023.05.24.05.47.20; Wed, 24 May 2023 05:47:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=eDp4Qudo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232199AbjEXMez (ORCPT + 99 others); Wed, 24 May 2023 08:34:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233886AbjEXMex (ORCPT ); Wed, 24 May 2023 08:34:53 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C36721A6 for ; Wed, 24 May 2023 05:34:40 -0700 (PDT) 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-out2.suse.de (Postfix) with ESMTPS id 6AD231F8BF; Wed, 24 May 2023 12:34:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1684931679; 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=AiiMIvYGdbIRGL9zQDfeMCY6Hk4lfNGeYEXmOzeLdh0=; b=eDp4QudooCjdxpuWCFiomINeR63fpz11H/DfOnUwO7iR8RKbLClzPI9G1HSlFw/4jQUlLw U6y+szIJ3lKAPBGQBgvx4Amf9OQVgnABQBWTeI2fWxlZR93ByrtsD7q73sSG+GzkdVa8Sk n09CF444KiotVDN91YA0flskmKbWnIE= 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 41FD313425; Wed, 24 May 2023 12:34:39 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id t7NMDV8EbmQeawAAMHmgww (envelope-from ); Wed, 24 May 2023 12:34:39 +0000 Date: Wed, 24 May 2023 14:34:38 +0200 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 v8 01/13] vmstat: allow_direct_reclaim should use zone_page_state_snapshot Message-ID: References: <20230515180015.016409657@redhat.com> <20230515180138.442505633@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230515180138.442505633@redhat.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon 15-05-23 15:00:16, 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. I have asked this patch to contain a note about testing done for future reference IIRC. You have said that the above scenario is not easy to reproduce and therefore not much of testing has been done but this is a valuable information on its own. > Suggested-by: Michal Hocko > Signed-off-by: Marcelo Tosatti I have also acked the patch. So let me repeat Acked-by: Michal Hocko Btw. the patch should be routed separately as it is a potential fix. > > --- > > Index: linux-vmstat-remote/mm/vmscan.c > =================================================================== > --- linux-vmstat-remote.orig/mm/vmscan.c > +++ linux-vmstat-remote/mm/vmscan.c > @@ -6886,7 +6886,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