Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp5328628rwp; Mon, 17 Jul 2023 02:00:50 -0700 (PDT) X-Google-Smtp-Source: APBJJlGlQqBDlRTcKzeC8cimgeSsERBByWTHDAVD0Z110THkKun+Iaxv0nk+wMyUpDlR0zU/sDzZ X-Received: by 2002:aa7:c40e:0:b0:51d:f589:9c7a with SMTP id j14-20020aa7c40e000000b0051df5899c7amr10359074edq.17.1689584450407; Mon, 17 Jul 2023 02:00:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689584450; cv=none; d=google.com; s=arc-20160816; b=AO3ycHbvvDrbwPi3lwNSEg4cBh/cHL7V9iH0EE9D9VP8KkYyQ3orvMAxeQYvyZA5n8 yyDeOXXxGSwRqYFf4Bg1GiONsJQSDFNv0i1TBCiqOXxMUrdTKpayqKORk6NLsyLaoGIl aZT61YO7REy8hFXhxmXcOD/wqjO+ahFtzDToIDE9ZbAz/L+PUJPlhWGsJKE5qkUc0DYm fXk7EMEPtKdkSz5Mf2tE2aPSltdUmJYoj5CmHuOhva2XgeBnL77Pq/DvF7+Oh59X2Ewi DmfgyqYwBlLiFJc5ITkG4Et3BRPAqbyukNbBf0d6+9RbenMulayoZIzqorFZFEVaolD7 2MzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:in-reply-to :date:references:subject:cc:to:from:dkim-signature; bh=2o4373jD05NVNFJ4F9qrKxo5v5H39cUYqM490ipjKzU=; fh=zEuFmelXQ7J1hrvTH39Vq+P9peWGN5Ay5ZkFI8b53H4=; b=RFN3ESvn7/yPKN0QhnOvHuH9Azry5aJDiKs5jQu/Xqa+PdhajqUzMdT10nURNSykCF UtN3Bwpv+vpSREXVjkmeDcpEBoPQNkEt468NTm7Ly0/ffOhMBsRkFhsLUZ4dt216Cp+2 VMluy3qkeMXCuZyJoOqKro6oWpF3dL29bHvhKHNX1VFqfR+GBrfL/38yu3V7sf822hAt kCq0a2u2NTFjhN41CG75MITLr4QwugMEAGrj0RjOpyKdWxTUrc4hhWimV4W0pSH3zxZC rbApdHPPhwP6aRTskCfl/swrdeQU8GxD0O190xc7rKBT1b25nqs/9BWBtdyCV3qhlK5V 2hqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=OGkMIitM; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r15-20020aa7d14f000000b0051ff0798770si8161399edo.633.2023.07.17.02.00.26; Mon, 17 Jul 2023 02:00: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; dkim=pass header.i=@intel.com header.s=Intel header.b=OGkMIitM; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229796AbjGQIVA (ORCPT + 99 others); Mon, 17 Jul 2023 04:21:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229496AbjGQIU7 (ORCPT ); Mon, 17 Jul 2023 04:20:59 -0400 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6ADC2130 for ; Mon, 17 Jul 2023 01:20:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689582058; x=1721118058; h=from:to:cc:subject:references:date:in-reply-to: message-id:mime-version; bh=EXOX2k9VFsuPowKXuZz03YoTvqXpHZ/inazra+32p+s=; b=OGkMIitMlRKlLyb8/V7J2m3jEj5SBzk58JZBbyFI6hGvDEBtZtbsdSzO D0gwgAh28rLDlEkbQ13wBh9G/Y81bDouZaYAHbWbMMu908fiqDvfPiouo VFf5H2x+L7+JAQnXO0dcWe8hUu/lcgNpTU9x/YuIG5/pgWnt0ycuscwK4 HKfq49U0ahYayN14QhiqjUL59oogwYqTt574hgR6f1HqEdmhTfTga7jDT 9OJFHy8eRAbsZqsYHEjRaVQAOgZVzpEQoL+PuvXQn7fZLl6UN8s0Qkif0 FyCUrmur5E59ThdX2IR3noelp2/Tn4nSRtBzwYrsuDrYrSOdtW5UPTKc3 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10773"; a="364748643" X-IronPort-AV: E=Sophos;i="6.01,211,1684825200"; d="scan'208";a="364748643" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2023 01:20:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10773"; a="758322066" X-IronPort-AV: E=Sophos;i="6.01,211,1684825200"; d="scan'208";a="758322066" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.238.208.55]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2023 01:20:54 -0700 From: "Huang, Ying" To: Michal Hocko Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Arjan Van De Ven , Andrew Morton , Mel Gorman , Vlastimil Babka , David Hildenbrand , Johannes Weiner , Dave Hansen , Pavel Tatashin , Matthew Wilcox Subject: Re: [RFC 1/2] mm: add framework for PCP high auto-tuning References: <20230710065325.290366-1-ying.huang@intel.com> <20230710065325.290366-2-ying.huang@intel.com> <87edldefnt.fsf@yhuang6-desk2.ccr.corp.intel.com> Date: Mon, 17 Jul 2023 16:19:12 +0800 In-Reply-To: (Michal Hocko's message of "Fri, 14 Jul 2023 10:59:19 +0200") Message-ID: <87wmyzc5mn.fsf@yhuang6-desk2.ccr.corp.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=ascii X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,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 Michal Hocko writes: > On Wed 12-07-23 15:45:58, Huang, Ying wrote: >> Michal Hocko writes: >> >> > On Mon 10-07-23 14:53:24, Huang Ying wrote: >> >> The page allocation performance requirements of different workloads >> >> are usually different. So, we often need to tune PCP (per-CPU >> >> pageset) high to optimize the workload page allocation performance. >> >> Now, we have a system wide sysctl knob (percpu_pagelist_high_fraction) >> >> to tune PCP high by hand. But, it's hard to find out the best value >> >> by hand. And one global configuration may not work best for the >> >> different workloads that run on the same system. One solution to >> >> these issues is to tune PCP high of each CPU automatically. >> >> >> >> This patch adds the framework for PCP high auto-tuning. With it, >> >> pcp->high will be changed automatically by tuning algorithm at >> >> runtime. Its default value (pcp->high_def) is the original PCP high >> >> value calculated based on low watermark pages or >> >> percpu_pagelist_high_fraction sysctl knob. To avoid putting too many >> >> pages in PCP, the original limit of percpu_pagelist_high_fraction >> >> sysctl knob, MIN_PERCPU_PAGELIST_HIGH_FRACTION, is used to calculate >> >> the max PCP high value (pcp->high_max). >> > >> > It would have been very helpful to describe the basic entry points to >> > the auto-tuning. AFAICS the central place of the tuning is tune_pcp_high >> > which is called from the freeing path. Why? Is this really a good place >> > considering this is a hot path? What about the allocation path? Isn't >> > that a good spot to watch for the allocation demand? >> >> Yes. The main entry point to the auto-tuning is tune_pcp_high(). Which >> is called from the freeing path because pcp->high is only used by page >> freeing. It's possible to call it in allocation path instead. The >> drawback is that the pcp->high may be updated a little later in some >> situations. For example, if there are many page freeing but no page >> allocation for quite long time. But I don't think this is a serious >> problem. > > I consider it a serious flaw in the framework as it cannot cope with the > transition of the allocation pattern (e.g. increasing the allocation > pressure). Sorry, my previous words are misleading. What I really wanted to say is that the problem may be just theoretical. Anyway, I will try to avoid this problem in the future version. >> > Also this framework seems to be enabled by default. Is this really >> > desirable? What about workloads tuning the pcp batch size manually? >> > Shouldn't they override any auto-tuning? >> >> In the current implementation, the pcp->high will be tuned between >> original pcp high (default or tuned manually) and the max pcp high (via >> MIN_PERCPU_PAGELIST_HIGH_FRACTION). So the high value tuned manually is >> respected at some degree. >> >> So you think that it's better to disable auto-tuning if PCP high is >> tuned manually? > > Yes, I think this is a much safer option. For two reasons 1) it is less > surprising to setups which know what they are doing by configuring the > batching and 2) the auto-tuning needs a way to get disabled in case > there are pathological patterns in behavior. OK. Best Regards, Huang, Ying