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 968D6C74A5B for ; Tue, 21 Mar 2023 12:58:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D73606B0075; Tue, 21 Mar 2023 08:58:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D21DE6B0078; Tue, 21 Mar 2023 08:58:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BC12B6B007D; Tue, 21 Mar 2023 08:58:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id A5D376B0075 for ; Tue, 21 Mar 2023 08:58:03 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 3B73D1610E9 for ; Tue, 21 Mar 2023 12:58:03 +0000 (UTC) X-FDA: 80592908046.20.7DCDF39 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf09.hostedemail.com (Postfix) with ESMTP id 5DA4D14001D for ; Tue, 21 Mar 2023 12:58:01 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=DP6WP1h5; spf=pass (imf09.hostedemail.com: domain of mtosatti@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=mtosatti@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1679403481; a=rsa-sha256; cv=none; b=mY+Qphv/HeQjt0vai3YIWsmpJwQwYVQTS9+LbEQYO11EDPuCqds7cDqiVD/SSRQXBuuL1j S9T9HPcL01jguzL0GX9aPxGw9pEOWaUJ3x+1J/Qm39VFdu4YdgCXkSPAX91Tv7UUGGcweH kVQQ3HUxqrknRMXzBAtdPlBXym4mth8= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=DP6WP1h5; spf=pass (imf09.hostedemail.com: domain of mtosatti@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=mtosatti@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1679403481; 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=q2xkYNfVT5T4eh3J0pm8IWrwrBm69x41pEfwfOVdgHA=; b=OHDQ+JygP7a3tlfp24CJVmsjq4eB1NZrvhL4fxEjPQDZ6h9OVhyF9bfozh3Xe5xah1qxwk qvaeW7br7ElfTQEskd4kwRViC/LLHbxiJV+v16kNxKOkaiwbuH6ROacQKQx9NKPV37W+Yc FJk6cGz3Fq/RHwaAAfRFleIgbwHYSVM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679403480; h=from:from:reply-to:subject:subject: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=q2xkYNfVT5T4eh3J0pm8IWrwrBm69x41pEfwfOVdgHA=; b=DP6WP1h5hBRcJ/Q9ESb3YTuHGwo71rjEeo3MCcLLHbLa/esC75HxKRNWjVidGUcHEj8Z9S xpDQnD2Q3uGwvzNLyc43X5ICYdHNdRjLMIntTxmZg88LuN4aqbGovWC4Qbg1NoFGdL6ONG BJ+WYCcToGGD9UASo4olxGUZmnbVrRE= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-64-8JpaL_WyOJuYFWsujIn_WA-1; Tue, 21 Mar 2023 08:57:55 -0400 X-MC-Unique: 8JpaL_WyOJuYFWsujIn_WA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9BBAE3C1712C; Tue, 21 Mar 2023 12:57:54 +0000 (UTC) Received: from tpad.localdomain (ovpn-112-2.gru2.redhat.com [10.97.112.2]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 65A66140E960; Tue, 21 Mar 2023 12:57:54 +0000 (UTC) Received: by tpad.localdomain (Postfix, from userid 1000) id 84184400E055D; Mon, 20 Mar 2023 15:32:15 -0300 (-03) Date: Mon, 20 Mar 2023 15:32:15 -0300 From: Marcelo Tosatti To: Michal Hocko 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: X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Rspam-User: X-Rspamd-Queue-Id: 5DA4D14001D X-Rspamd-Server: rspam01 X-Stat-Signature: g6t5hqejmcz8emj8cwc74g3a3soqdkdu X-HE-Tag: 1679403481-284364 X-HE-Meta: U2FsdGVkX19MmBJSiV3w+9qrQJoK5LMlXCdZubFI9qQnCJqVLeOWIHEF6Hi+ii9MrDO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s3QngGA5buWM4Spn0y1xZliaZkGRMJ+Vei8sLGdb5HaySFx/6+UBg5ixBa/77A2WrQF7FVQrCv7SRui4X2q/aWXiXBNDVmuj38/luBo6VcRdVhjn7kshbBllggAoeOsTzaWi1tqSEMaAFwPW8vRo6mTaZTZiqmndxGAkBMw== 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, Mar 20, 2023 at 07:21:04PM +0100, Michal Hocko wrote: > 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 Michal, The patch has not been tested in the original setup where the problem was found, however i don't think its easy to do that validation (checking with the reporter anyway). Perhaps one could find a synthetic reproducer. It is pretty easy to note that, on an isolated nohz_full CPU, the deferrable timer that is queued on it (timer which should queue vmstat_update on that CPU) does not execute for long periods. This makes the global stats stale (since per-CPU free pages can become stale for as long as the CPU has tick processing stopped). Which matches the data available. Thanks!