Received: by 10.223.185.116 with SMTP id b49csp7462558wrg; Thu, 1 Mar 2018 06:02:55 -0800 (PST) X-Google-Smtp-Source: AG47ELubQMUJmn4mKcQZgy4IPZKm3LvzBKhcpMswnyb2LlEsHkW3mV3XxWiDMGIIWm0S1DO++sjM X-Received: by 10.101.69.75 with SMTP id x11mr1641185pgr.69.1519912975396; Thu, 01 Mar 2018 06:02:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519912975; cv=none; d=google.com; s=arc-20160816; b=yWzDtBd51oSUjSYJBCC5PUoojxNuugHRLzGCdNBu69VufPLEGjESqNX0/ucajj917V Ve1C9YLdUmprqC0eGOMOfXZQFVsXD7Bf9FSUOwRN2jLZhB6T6DTSxQ66qZnYHuhdYr5b 4Defe/YG0sKaYkySdfI/9lKCakQ+IqnXKEu+4eP2j4NmwjPeIqrTfH4kPsT9LchJLwVZ ajbtsR8dbsOLWQ4jtQFcgX5ePFyvxYDOpJi77Rg4VoF3GMKi5nza9Ch6dlAOm5Butt7H zdLuWVepq2geHBUCwUtVAPQSaMlffixpYFPA7iChsN9pTw2bux3CHlWFL1ckuaWMcXJ9 EN9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=8JHkRe/PV/Fimnwj2V71Mqx6IgxFGEcvhVN9fFoP7iM=; b=N3zbT1lIM3kcJrVpaAJNQQ5zfgiKmSAdZBfSd3riRJyjGPAjibdoJx9QawogKEo1Uz Ct07gNe89s3WqzIgKdk93yu3Y1sGOd+cQh+N0lvVcnC1CrDLnqVYRgN0jHBSuaNrVZoa lJAIoMNVQY9D45nljtxlskG9PmCZuEydWWTHzlBeJqBVlaH8OIJEwAYw+JT7Xm/p61jH oLbixMloidX9ZHfxFlGf2+xM/u5RGKsdw9bkviWQBAr99yR8314ymY1uZOrX2yXRFpoE bOuS4FagEhd0HhzMuzyOe9/kpvrUsHPKH2BtD6G8lo+zPO8sTtIWH7xyPLqOsm5mibln BI7A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a80si3039478pfa.315.2018.03.01.06.02.37; Thu, 01 Mar 2018 06:02:55 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1031038AbeCAOAw (ORCPT + 99 others); Thu, 1 Mar 2018 09:00:52 -0500 Received: from mx2.suse.de ([195.135.220.15]:60648 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031003AbeCAOAu (ORCPT ); Thu, 1 Mar 2018 09:00:50 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 05371AC76; Thu, 1 Mar 2018 14:00:49 +0000 (UTC) Date: Thu, 1 Mar 2018 15:00:44 +0100 From: Michal Hocko To: Aaron Lu Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton , Huang Ying , Dave Hansen , Kemi Wang , Tim Chen , Andi Kleen , Vlastimil Babka , Mel Gorman , Matthew Wilcox , David Rientjes Subject: Re: [PATCH v4 3/3] mm/free_pcppages_bulk: prefetch buddy while not holding lock Message-ID: <20180301140044.GK15057@dhcp22.suse.cz> References: <20180301062845.26038-1-aaron.lu@intel.com> <20180301062845.26038-4-aaron.lu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180301062845.26038-4-aaron.lu@intel.com> User-Agent: Mutt/1.9.3 (2018-01-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 01-03-18 14:28:45, Aaron Lu wrote: > When a page is freed back to the global pool, its buddy will be checked > to see if it's possible to do a merge. This requires accessing buddy's > page structure and that access could take a long time if it's cache cold. > > This patch adds a prefetch to the to-be-freed page's buddy outside of > zone->lock in hope of accessing buddy's page structure later under > zone->lock will be faster. Since we *always* do buddy merging and check > an order-0 page's buddy to try to merge it when it goes into the main > allocator, the cacheline will always come in, i.e. the prefetched data > will never be unused. > > In the meantime, there are two concerns: > 1 the prefetch could potentially evict existing cachelines, especially > for L1D cache since it is not huge; > 2 there is some additional instruction overhead, namely calculating > buddy pfn twice. > > For 1, it's hard to say, this microbenchmark though shows good result but > the actual benefit of this patch will be workload/CPU dependant; > For 2, since the calculation is a XOR on two local variables, it's expected > in many cases that cycles spent will be offset by reduced memory latency > later. This is especially true for NUMA machines where multiple CPUs are > contending on zone->lock and the most time consuming part under zone->lock > is the wait of 'struct page' cacheline of the to-be-freed pages and their > buddies. > > Test with will-it-scale/page_fault1 full load: > > kernel Broadwell(2S) Skylake(2S) Broadwell(4S) Skylake(4S) > v4.16-rc2+ 9034215 7971818 13667135 15677465 > patch2/3 9536374 +5.6% 8314710 +4.3% 14070408 +3.0% 16675866 +6.4% > this patch 10338868 +8.4% 8544477 +2.8% 14839808 +5.5% 17155464 +2.9% > Note: this patch's performance improvement percent is against patch2/3. I am really surprised that this has such a big impact. Is this a win on other architectures as well? > [changelog stole from Dave Hansen and Mel Gorman's comments] > https://lkml.org/lkml/2018/1/24/551 Please use http://lkml.kernel.org/r/ for references because lkml.org is quite unstable. It would be http://lkml.kernel.org/r/148a42d8-8306-2f2f-7f7c-86bc118f8ccd@intel.com here. -- Michal Hocko SUSE Labs