Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp7926220rwp; Wed, 19 Jul 2023 02:27:57 -0700 (PDT) X-Google-Smtp-Source: APBJJlHh5XVPB1Ixb+R3Pse6UPdT7wSj7m4thHBa0Hc9BVvSxV++R1/vs7j4g4GiWo3DYzDZnRgx X-Received: by 2002:a05:620a:b93:b0:767:3c4c:9f1a with SMTP id k19-20020a05620a0b9300b007673c4c9f1amr2114155qkh.27.1689758877303; Wed, 19 Jul 2023 02:27:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689758877; cv=none; d=google.com; s=arc-20160816; b=eYntwfddypxg+lHDyoav/QNG9c0Yb8p57UxaKFGBbburK5pETNeoDec/Jrf2/ub+4Q LD56PEoxg2Bi62Gl5/WqSgDJoITzUHlvPwm8ATeHCFf260pIyIq0TiioCUj62zZ3nZue 8Jcok9B12eWtF5lYqmQGOvCikBXfb+OEZ4OrPPCj1oAPXKZBqzwJYOj00AG6hODMzzdF ljN+Al/1r/DoZytUXVYhnj3USbd8OkjPRF2EdClxvgv0pB9krSAHBhqOm3Al2rEBac/+ 6SjtRt2dmkws2LG7h2tG5EjG4YC4seS0BzhVqVX7FOY6fnYPAStBWvNS2562c0jliCvH zTkw== 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; bh=246qRSzuAfmDgOGPdNYT0SfvLMVG4MK6lZRxorhwZ4M=; fh=JOEvKw9NcG31fWAmRC6CLJS1txpNfvmn25hzKmt6oZk=; b=ifMWvjwK66IHvg4eJsjkv4fmFe5TuIPNLK3cQw31XQ4PlbkdxIQJr2Fh157iqItLTR 5oOp1B//8iduwnfNEiS8e1U1thPPZHXktm8ST9FewI3WX3sfB3iCLRECcZGwts1sk93p tu/fG1vSHpQMQhu7HJg16znXL9V6XW+SisGlnbxiZYD0Jr3R93iUU+IlxoVgVLVY+xEv lhr/OwNFkBc4pYUl5v14ZK13dUEX28YZ9W8VftKVkLXgpRT0qa44Z292TiU1S/+alvvm U/a66O0lZsH9QBkHwXRiC/tNl+7Fx7ScHecDA5l+pCgKJhmHhf9Oqn1IBAXHys4O/eTp OjaA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ls4-20020a17090b350400b002632bfd62b9si1116468pjb.185.2023.07.19.02.27.45; Wed, 19 Jul 2023 02:27:57 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229660AbjGSJGi (ORCPT + 99 others); Wed, 19 Jul 2023 05:06:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229626AbjGSJGg (ORCPT ); Wed, 19 Jul 2023 05:06:36 -0400 Received: from outbound-smtp06.blacknight.com (outbound-smtp06.blacknight.com [81.17.249.39]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE4DF2136 for ; Wed, 19 Jul 2023 02:06:07 -0700 (PDT) Received: from mail.blacknight.com (pemlinmail02.blacknight.ie [81.17.254.11]) by outbound-smtp06.blacknight.com (Postfix) with ESMTPS id 8E15EC2B5B 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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,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 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