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 0E921C0015E for ; Wed, 19 Jul 2023 09:05:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7D132280041; Wed, 19 Jul 2023 05:05:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 75CD628003D; Wed, 19 Jul 2023 05:05:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5FB98280041; Wed, 19 Jul 2023 05:05:26 -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 4D54328003D for ; Wed, 19 Jul 2023 05:05:26 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 1EEBF160150 for ; Wed, 19 Jul 2023 09:05:26 +0000 (UTC) X-FDA: 81027777852.23.35E27D1 Received: from outbound-smtp55.blacknight.com (outbound-smtp55.blacknight.com [46.22.136.239]) by imf12.hostedemail.com (Postfix) with ESMTP id BE3EE4001B for ; Wed, 19 Jul 2023 09:05:23 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf12.hostedemail.com: domain of mgorman@techsingularity.net designates 46.22.136.239 as permitted sender) smtp.mailfrom=mgorman@techsingularity.net ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689757524; 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; bh=246qRSzuAfmDgOGPdNYT0SfvLMVG4MK6lZRxorhwZ4M=; b=2TihQ4tmPGG1apigT7aN5a94zaUbZm7b0zRbzpR2w9ags54v0gQPLaQxB4uyCfyqa14nmb ZG/e4XTtl1qMS5wNhe3nBB8mq7PzdjgRDp/EKZlvfy5Rs735QysXKDfmnyqf/KLjsnSzwc BdytG3LAHdh+aJ84zX8ThPbdydq6Cds= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf12.hostedemail.com: domain of mgorman@techsingularity.net designates 46.22.136.239 as permitted sender) smtp.mailfrom=mgorman@techsingularity.net ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689757524; a=rsa-sha256; cv=none; b=tVOnYgmKOLuMqqnBKDW6s0S1i4yEfYK1jOFM5c2PIpzU97Wgbg4NTg2/BNgtmeFPic34mS vqBjYuyHEzgyFiuMNROJoi13UI9x5ZTHtBeSvn4ofqUx8z8oC5I+LuOQwPwiKyAyJDmLta Y+Y16ct3iHIrXbubBLDPbbH9JmuywwU= Received: from mail.blacknight.com (pemlinmail02.blacknight.ie [81.17.254.11]) by outbound-smtp55.blacknight.com (Postfix) with ESMTPS id 911A1FAC35 for ; Wed, 19 Jul 2023 10:05:21 +0100 (IST) Received: (qmail 3286 invoked from network); 19 Jul 2023 09:05:21 -0000 Received: from unknown (HELO techsingularity.net) (mgorman@techsingularity.net@[84.203.20.191]) by 81.17.254.9 with ESMTPSA (AES256-SHA encrypted, authenticated); 19 Jul 2023 09:05:21 -0000 Date: Wed, 19 Jul 2023 10:05:18 +0100 From: Mel Gorman To: "Huang, Ying" Cc: Michal Hocko , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Arjan Van De Ven , Andrew Morton , Vlastimil Babka , David Hildenbrand , Johannes Weiner , Dave Hansen , Pavel Tatashin , Matthew Wilcox Subject: Re: [RFC 2/2] mm: alloc/free depth based PCP high auto-tuning Message-ID: <20230719090518.67g7hascnfcly6hk@techsingularity.net> References: <20230710065325.290366-3-ying.huang@intel.com> <20230712090526.thk2l7sbdcdsllfi@techsingularity.net> <871qhcdwa1.fsf@yhuang6-desk2.ccr.corp.intel.com> <20230714140710.5xbesq6xguhcbyvi@techsingularity.net> <87pm4qdhk4.fsf@yhuang6-desk2.ccr.corp.intel.com> <20230717135017.7ro76lsaninbazvf@techsingularity.net> <87lefeca2z.fsf@yhuang6-desk2.ccr.corp.intel.com> <20230718123428.jcy4avtjg3rhuh7i@techsingularity.net> <87mszsbfx7.fsf@yhuang6-desk2.ccr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <87mszsbfx7.fsf@yhuang6-desk2.ccr.corp.intel.com> X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: BE3EE4001B X-Stat-Signature: 1z54pqhtr44q8p6nw4if4uzssq9xu94a X-HE-Tag: 1689757523-641473 X-HE-Meta: U2FsdGVkX1+vXddDkxB7UwFdXWkR3ziReDYUDrNTq6stI30pMevjtB7Dq47FZIfHJ05BpfBTHwYljIoYy3E/CvxDIR5ehVCitEhG/npPjByFBTuUFC7YsZrnhCsFeGWWiaUmfFAGJzRVNJEABDAuSoRgyTE0FQZyyh1yB2nw4GuXij2s4Z83+Z5tCihEuEZYX/M84H1ZQu0Kk+XIKT9D2E73zthirCSTtbnGefobEdG6V96XJNzb5rrvRw9WNNLy71P9YzR50DQdAzZ0A0BWIjUQDflNCn5NQ8CH7ZYvQ1n3r2jhyrBfMSQFpFQBspBcokHhwzB5MGtq2JAYbSR5YS8R6WgE+aRESCZTeHhyhKpiOCkldTE3ZRxQPzIpORUS4glsaLKShgNqY8/TFiFX3mAgZnsvgMtbUCFG3kN3ID3XNblN4bakb/bDz3ON0bszonE70AMoXZj/Up8ctG1zX3Cg+GLR5yM320zntZyDXE9nmqRCRpqISZ2sc/5YfSiFaa1Zu2QNp7oPRj00/Dt9tXXgZ6QWs/Zq2SCC1t+PcStW/duGVPI9Y9TLWPlJVojR01cpmXBMykt7UFFnx1dzGRtMW1/z6KGhgeCr6Jtqe0qyGxMssY4EEKdBCasaBYAZBiTO4UPi7Yk4UqEZF6MC/+0zQ20v+RLUaJ9104XMdMD9E4wpgIIBD0PrrltCrsQfkjAOd4ZyF9F+KlKZ6fPTIlL1mGnfrm7r7t+kO/umJYhUKzrpI6MMK+05+n18gEaQygspw7C26EUkW95zn2068+tPAgNUr6nADVs7oIHFQipyPqxTW8CDkAln9i9+rJR8iS6zOezxDlwe10HqM+tiTzvmjGSSCoKmP7/6QzPUqGKd7FZOapAXX1oCUAL1xrgTq5aZW7rAewxTY2nWUIEoE1+9KR12cr8slXhzwZ7IFdhrewjvStdFvN0riKIuh41CNDnOrtPOuGo84EvOFlJ eHfYGHHi HUDPkmK/MBLMuQPuoiCtZD8MobI63i8YDapZhWDVMPHhj+7sFfE0Gk5Dxvu9sLV05Q1UrdNuAxfVXFTOMmUGmAxgyhs7//Smk6ZXsGEdAqTKophYyb6uzr5PYayogfqsdR8BlgHzW2+PYB9JoaJXKSiHiMON92Sebm9+J+3SXPLHm+3sb/O2Ehtujz0d+Iy24WY9FVjehfNzfT5rm62TnLnG2VyFFT+AaXYz3vNaKTCYsKSgCOdx+UlSxHb1ukMIkWT7HMOwlXpnEHGc= 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 Wed, Jul 19, 2023 at 01:59:00PM +0800, Huang, Ying wrote: > > The big remaaining corner case to watch out for is where the sum > > of the boosted pcp->high exceeds the low watermark. If that should ever > > happen then potentially a premature OOM happens because the watermarks > > are fine so no reclaim is active but no pages are available. It may even > > be the case that the sum of pcp->high should not exceed *min* as that > > corner case means that processes may prematurely enter direct reclaim > > (not as bad as OOM but still bad). > > Sorry, I don't understand this. When pages are moved from buddy to PCP, > zone NR_FREE_PAGES will be decreased in rmqueue_bulk(). That is, pages > in PCP will be counted as used instead of free. And, in > zone_watermark_ok*() and zone_watermark_fast(), zone NR_FREE_PAGES is > used to check watermark. So, if my understanding were correct, if the > number of pages in PCP is larger than low/min watermark, we can still > trigger reclaim. Whether is my understanding correct? > You're right, I didn't check the timing of the accounting and all that occurred to me was "the timing of when watermarks trigger kswapd or direct reclaim may change as a result of PCP adaptive resizing". Even though I got the timing wrong, the shape of the problem just changes. I suspect that excessively large PCP high relative to the watermarks may mean that reclaim happens prematurely if too many pages are pinned by PCP pages as the zone free pages approaches the watermark. While disabling the adaptive resizing during reclaim will limit the worst of the problem, it may still be the case that kswapd is woken early simply because there are enough CPUs pinning pages in PCP lists. Similarly, depending on the size of pcp->high and the gap between the watermarks, it's possible for direct reclaim to happen prematurely. I could still be wrong because I'm not thinking the problem through fully, examining the code or thinking about the implementation. It's simply worth keeping in mind the impact elevated PCP high values has on the timing of watermarks failing. If it's complex enough, it may be necessary to have a separate patch dealing with the impact of elevated pcp->high on watermarks. -- Mel Gorman SUSE Labs