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 E6F9AC6FD1F for ; Wed, 22 Mar 2023 10:03:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 809C56B0075; Wed, 22 Mar 2023 06:03:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7BA186B007B; Wed, 22 Mar 2023 06:03:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 683016B007D; Wed, 22 Mar 2023 06:03:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 556646B0075 for ; Wed, 22 Mar 2023 06:03:51 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 22879140443 for ; Wed, 22 Mar 2023 10:03:51 +0000 (UTC) X-FDA: 80596097862.26.A16A6CF Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf11.hostedemail.com (Postfix) with ESMTP id 36AD740020 for ; Wed, 22 Mar 2023 10:03:48 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=Evl84Jii; spf=pass (imf11.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=1679479429; 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=2MLTpDoYnLV5dF3NCYU327C0XL13UyAq3sNf1Gle6b8=; b=PMlDkIeD8CCox+/C5AmCPs/1w3Y05eghEcN+1EdxFxjTZvtCHUv2Cado6jEpBKwYknvrZd JMm3ZOqZTSIXeDqr1aNRRDSdans7ga73QKKmi/39iwKO6Smp1aRlgohYE6IGC42xVM2oaz Jy5aNnlcdkJZEC/vPbT5WwsYXJbKgX0= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=Evl84Jii; spf=pass (imf11.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=1679479429; a=rsa-sha256; cv=none; b=iGYfsNpQMjv+C5yM0qcZ3kigC2lrIL+MELkFmgBSRNUmeG205nJsutT3auFWv4wPNCspFP DHECpHSRCVZKrZDkPwF/GUIt7HD3R95xjN+ihouP/SAKzs2+391cKpQrHiVw4bqpu36qCV KTr+m9cAS2rRUws/wYxpe53OyG2M7cg= 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 D7C153399A; Wed, 22 Mar 2023 10:03:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1679479427; 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=2MLTpDoYnLV5dF3NCYU327C0XL13UyAq3sNf1Gle6b8=; b=Evl84Jii4HGa0Ifhe7gJbp2u2F2WV1Utfwi7n6ACtiWkwMPUgbuKWTl2AQ1GE3ZQFX0CME 8d5wMMmcmAsRdSe2ohqlG6lMPYlAspsUtdmTcDscph5GngssyE98ECFSahGILxV++pjcoZ 1tRg+sNtZihsdjODCmpHr6kyyDZhSI0= 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 B3F1613416; Wed, 22 Mar 2023 10:03:47 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id ZsqpKYPSGmSUBAAAMHmgww (envelope-from ); Wed, 22 Mar 2023 10:03:47 +0000 Date: Wed, 22 Mar 2023 11:03:47 +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: X-Stat-Signature: 17j3oyhwdk3ek87nege4ficbyqrqwf9k X-Rspam-User: X-Rspamd-Queue-Id: 36AD740020 X-Rspamd-Server: rspam06 X-HE-Tag: 1679479428-337780 X-HE-Meta: U2FsdGVkX1+HgkHFdmhBDclFWQ/BVr1+eVbk0zhKvDGQI+dME/gA6zWLSMtcTs2dssnD3a1B5lMYQp2GtXIHZCvI9H7l8gXzpBCsp1YFLEpgQezzYFFquM58/Uk/bWlcL5YMmpCB0MreWVbBj72W36qFXiGS+CqNz9dap1/2h2G+/EXq9oswAsYkruj4bAcdWBpYUsSnn4D4MPgDDuuATwsdb2izpF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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:32:15, Marcelo Tosatti wrote: > 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). This is a fair point and I would just add it to the changelog for the future reference. -- Michal Hocko SUSE Labs