Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp5638459rwp; Mon, 17 Jul 2023 07:19:51 -0700 (PDT) X-Google-Smtp-Source: APBJJlGLaMrwrylPlp+hRIHWajsJnH6puZI7ta3GcZzDGphW0b3+9a0j2SUovGmRztKFl1KHonOs X-Received: by 2002:a17:902:8ec6:b0:1b8:847d:973a with SMTP id x6-20020a1709028ec600b001b8847d973amr10572969plo.46.1689603590891; Mon, 17 Jul 2023 07:19:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689603590; cv=none; d=google.com; s=arc-20160816; b=ocSJ54oM2BLWCwr42UqfNGKgrq4iDVC2z6M5UMf+0/8FPHAr4qWfZC1oX29jsA7LZP 0yiYAwYQua60LPud5Mle9N2l7f4SlI0arYZQ5qZgk2tjtVQZtSBKE6zFvzdYMaYhLNww IZgLA3bNWNClKFby5hbnDP5VjY3C6/lAknu8gjpJhcyOm7tnPp4CBDiB0pgRHrXOh2nu 13vW56d363wAngJLjn8lk3C0pNyFMJCd5wuSXgnRq3joRiSfD7lcChC4vnzRZK8M29D9 lsLFDSvP2L4pt+LeDTI1Ru43swzhw8qygxmAE0hVm3Y3Xdu+HdrAKux+gVJOXkHGPOVg RYDQ== 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=T1flYcIcKkoL6Q2cNqLqqCQC7gfFf+ToSrC/tA6Jplk=; fh=JOEvKw9NcG31fWAmRC6CLJS1txpNfvmn25hzKmt6oZk=; b=h+XebHLCWoWV9nOkpXBWGv1IbYApv9m5rPlYUEwgJrlKPPDP1YXQNiTwmGBRzv1I6F 0zTQEMyOVNJ43ykkKJNasQg0Io9ICvW+W+/aahenjHZvwaJT3+Fd1dfL8KjeHdeKN7yE jpeSb63g6KkqAPvpGZhlSg71a3+ClONbZtoPOco2q+jpG3hOrmc5bi63+KfCsMBHXN5/ liz4wcnvNJk1pRXlG4qXz/gJ7vBvJxZmLZpSAA5Hur0iV5Jp7yqY5uc6IE7iJ1/rrQE/ tnOWjYjr+XxOUqbzmwthvcDvABwewadsRRQeTvVTmRvy71U3stOqCNgxXDRYV+FBIKqn s+hA== 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 kw3-20020a170902f90300b001b8a591d5b9si11589005plb.133.2023.07.17.07.19.38; Mon, 17 Jul 2023 07:19:50 -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 S230295AbjGQNuY (ORCPT + 99 others); Mon, 17 Jul 2023 09:50:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229541AbjGQNuX (ORCPT ); Mon, 17 Jul 2023 09:50:23 -0400 Received: from outbound-smtp28.blacknight.com (outbound-smtp28.blacknight.com [81.17.249.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D66CD94 for ; Mon, 17 Jul 2023 06:50:20 -0700 (PDT) Received: from mail.blacknight.com (pemlinmail01.blacknight.ie [81.17.254.10]) by outbound-smtp28.blacknight.com (Postfix) with ESMTPS id 2E04BCCB70 for ; Mon, 17 Jul 2023 14:50:19 +0100 (IST) Received: (qmail 650 invoked from network); 17 Jul 2023 13:50:19 -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); 17 Jul 2023 13:50:18 -0000 Date: Mon, 17 Jul 2023 14:50:17 +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: <20230717135017.7ro76lsaninbazvf@techsingularity.net> References: <20230710065325.290366-1-ying.huang@intel.com> <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> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <87pm4qdhk4.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 Mon, Jul 17, 2023 at 05:16:11PM +0800, Huang, Ying wrote: > Mel Gorman writes: > > > Batch should have a much lower maximum than high because it's a deferred cost > > that gets assigned to an arbitrary task. The worst case is where a process > > that is a light user of the allocator incurs the full cost of a refill/drain. > > > > Again, intuitively this may be PID Control problem for the "Mix" case > > to estimate the size of high required to minimise drains/allocs as each > > drain/alloc is potentially a lock contention. The catchall for corner > > cases would be to decay high from vmstat context based on pcp->expires. The > > decay would prevent the "high" being pinned at an artifically high value > > without any zone lock contention for prolonged periods of time and also > > mitigate worst-case due to state being per-cpu. The downside is that "high" > > would also oscillate for a continuous steady allocation pattern as the PID > > control might pick an ideal value suitable for a long period of time with > > the "decay" disrupting that ideal value. > > Maybe we can track the minimal value of pcp->count. If it's small > enough recently, we can avoid to decay pcp->high. Because the pages in > PCP are used for allocations instead of idle. Implement as a separate patch. I suspect this type of heuristic will be very benchmark specific and the complexity may not be worth it in the general case. > > Another question is as follows. > > For example, on CPU A, a large number of pages are freed, and we > maximize batch and high. So, a large number of pages are put in PCP. > Then, the possible situations may be, > > a) a large number of pages are allocated on CPU A after some time > b) a large number of pages are allocated on another CPU B > > For a), we want the pages are kept in PCP of CPU A as long as possible. > For b), we want the pages are kept in PCP of CPU A as short as possible. > I think that we need to balance between them. What is the reasonable > time to keep pages in PCP without many allocations? > This would be a case where you're relying on vmstat to drain the PCP after a period of time as it is a corner case. You cannot reasonably detect the pattern on two separate per-cpu lists without either inspecting remote CPU state or maintaining global state. Either would incur cache miss penalties that probably cost more than the heuristic saves. -- Mel Gorman SUSE Labs