Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4612569iob; Sun, 8 May 2022 19:12:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz0uk/67YmSQUpFQt97XJIoJilL2b5WL95IGdxPa5lv0LcUrMW8zyl1MWjHvn79r8QU5wdS X-Received: by 2002:a05:6a00:16c5:b0:505:c572:7c2a with SMTP id l5-20020a056a0016c500b00505c5727c2amr13627510pfc.46.1652062365390; Sun, 08 May 2022 19:12:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652062365; cv=none; d=google.com; s=arc-20160816; b=Lzyh9lraaJx5OugJ17k++6Hfv2Igg97mgy+Ixy2/QA0kPranpwD4QKdMELBsr/kTxd O/db3q+KbpsnPesYiSTa7be9+YR2G/44t2K2vl1koc54SUMKVbOEeHnO1aNq5GQk12xI Wye9INl2Zk6UKetFf0SdDml26hTuHqx6uoe07oA5k4udM0a4Dh2G/i8KjUlretdnr0EZ wYUl7+Lg7ylFMOTFgv1yij50SIMweY68tsiA6yJRpj+IFmGOXh++0Z/qVWh7b6QEB3EM SCd3WBS2ODzbMHIYrQiPqJve2NFg1CZ5hcqHjJopatACHNc3lGPJk5LCmJK/N3zLFvm2 EDfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=hdZNeAaqEJQoqK70xLpJ0ojgn5dKOvqcZ1AMqHsIgi0=; b=akB+F9NrhnTNTjEhUFYit++Lhjq74/M2jsj4J1mZaz1dntlcN2hQW445N6y4EpvrCw ft5L6avoLZAkg8b5DWe2zgFz/tEU1fNCovjoazxKBhJnBxvYI/Oy2GtFKdrCgA4qr2+z l28D3bGa8R2OwfLoZdYMaPv9NQg32ZxgD8ORsexN96C2p0UWF/1fpWyqZDxzVOXGtXXi 4NDr2HH2ppLjmRCjDJBoqJj06MV83mX/3tCCuktjMP0QkQHlStuwf8z0w8v5prp6JWIb vBLiPM/sHplbO3nnoQUhIAdtO+Xc33KNgDPOaK04O8MMM1kQdHMWZlwIDUgyz85wQELj 4Tiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=JX20wX8S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id c13-20020a170903234d00b00156b46e2407si11345857plh.471.2022.05.08.19.12.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 May 2022 19:12:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=JX20wX8S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3F39F50B3C; Sun, 8 May 2022 19:12:39 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1390217AbiEFIoi (ORCPT + 99 others); Fri, 6 May 2022 04:44:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1390216AbiEFIoh (ORCPT ); Fri, 6 May 2022 04:44:37 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5DD9D5B3D7 for ; Fri, 6 May 2022 01:40:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1651826452; x=1683362452; h=message-id:subject:from:to:cc:date:in-reply-to: references:mime-version:content-transfer-encoding; bh=wrGPP0wdU1m8YDsOqid/12IF8MjBkyBNkqejD+7ex4M=; b=JX20wX8SW4g/kiRdBvE6V/IRWD1LolkYnV552eKIyjORbvK/ThBT2I/U MKKCg2Y6EIvoaTpfnOLLpcnewS6NAehhTVNFQ96RNOxOSJyP606o9RfTN Ma6iu+TDWzNc7Vh/mHSxIbSQaSB+Yv5Kjbl/hDYLOBYPEVbP8JbesvsnH IUH9rr/PyxFHVe6NvCJ5H/mkOKkDY1z39igyUVCJyoKrH1elbaQLQ8f8D 5NzpvCzsqkAZgQmjYa1EYVFXUJgkR080DLZOEr3Kgxw1gLtlHdu1uuiTu kdjO6QPoxHRxyNNve1ZElwosoCdeAt4XHZ0fwmQ7m9upqf5CR2eySbHIY A==; X-IronPort-AV: E=McAfee;i="6400,9594,10338"; a="331384953" X-IronPort-AV: E=Sophos;i="5.91,203,1647327600"; d="scan'208";a="331384953" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 May 2022 01:40:51 -0700 X-IronPort-AV: E=Sophos;i="5.91,203,1647327600"; d="scan'208";a="695068117" Received: from fulaizha-mobl1.ccr.corp.intel.com ([10.254.213.163]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 May 2022 01:40:47 -0700 Message-ID: Subject: Re: [mm/page_alloc] f26b3fa046: netperf.Throughput_Mbps -18.0% regression From: "ying.huang@intel.com" To: Aaron Lu , Mel Gorman Cc: kernel test robot , Linus Torvalds , Vlastimil Babka , Dave Hansen , Jesper Dangaard Brouer , Michal Hocko , Andrew Morton , LKML , lkp@lists.01.org, lkp@intel.com, feng.tang@intel.com, zhengjun.xing@linux.intel.com, fengwei.yin@intel.com Date: Fri, 06 May 2022 16:40:45 +0800 In-Reply-To: References: <20220420013526.GB14333@xsang-OptiPlex-9020> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.38.3-1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Fri, 2022-04-29 at 19:29 +0800, Aaron Lu wrote: > Hi Mel, > > On Wed, Apr 20, 2022 at 09:35:26AM +0800, kernel test robot wrote: > > > > (please be noted we reported > > "[mm/page_alloc] 39907a939a: netperf.Throughput_Mbps -18.1% regression" > > on > > https://lore.kernel.org/all/20220228155733.GF1643@xsang-OptiPlex-9020/ > > while the commit is on branch. > > now we still observe similar regression when it's on mainline, and we also > > observe a 13.2% improvement on another netperf subtest. > > so report again for information) > > > > Greeting, > > > > FYI, we noticed a -18.0% regression of netperf.Throughput_Mbps due to commit: > > > > > > commit: f26b3fa046116a7dedcaafe30083402113941451 ("mm/page_alloc: limit number of high-order pages on PCP during bulk free") > > https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git master > > > > So what this commit did is: if a CPU is always doing free(pcp->free_factor > 0) IMHO, this means the consumer and producer are running on different CPUs. > and if the being freed high-order page's order is <= PAGE_ALLOC_COSTLY_ORDER, > then do not use PCP but directly free the page directly to buddy. > > The rationale as explained in the commit's changelog is: > " > Netperf running on localhost exhibits this pattern and while it does not > matter for some machines, it does matter for others with smaller caches > where cache misses cause problems due to reduced page reuse. Pages > freed directly to the buddy list may be reused quickly while still cache > hot where as storing on the PCP lists may be cold by the time > free_pcppages_bulk() is called. > " > > This regression occurred on a machine that has large caches so this > optimization brings no value to it but only overhead(skipped PCP), I > guess this is the reason why there is a regression. Per my understanding, not only the cache size is larger, but also the L2 cache (1MB) is per-core on this machine. So if the consumer and producer are running on different cores, the cache-hot page may cause more core-to-core cache transfer. This may hurt performance too. > I have also tested this case on a small machine: a skylake desktop and > this commit shows improvement: > 8b10b465d0e1: "netperf.Throughput_Mbps": 72288.76, > f26b3fa04611: "netperf.Throughput_Mbps": 90784.4, +25.6% > > So this means those directly freed pages get reused by allocator side > and that brings performance improvement for machines with smaller cache. Per my understanding, the L2 cache on this desktop machine is shared among cores. > I wonder if we should still use PCP a little bit under the above said > condition, for the purpose of: > 1 reduced overhead in the free path for machines with large cache; > 2 still keeps the benefit of reused pages for machines with smaller cache. > > For this reason, I tested increasing nr_pcp_high() from returning 0 to > either returning pcp->batch or (pcp->batch << 2): > machine\nr_pcp_high() ret: pcp->high 0 pcp->batch (pcp->batch << 2) > skylake desktop: 72288 90784 92219 91528 > icelake 2sockets: 120956 99177 98251 116108 > > note nr_pcp_high() returns pcp->high is the behaviour of this commit's > parent, returns 0 is the behaviour of this commit. > > The result shows, if we effectively use a PCP high as (pcp->batch << 2) > for the described condition, then this workload's performance on > small machine can remain while the regression on large machines can be > greately reduced(from -18% to -4%). > Can we use cache size and topology information directly? > Best Regards, Huang, Ying [snip]