Received: by 10.223.176.46 with SMTP id f43csp173410wra; Tue, 23 Jan 2018 18:31:24 -0800 (PST) X-Google-Smtp-Source: AH8x227RpnFTtxETw95x4CZ7XTBQJ2Q2eu9n4GJV4DBAcUUGx2oWL2DHhMB65Mo2BiVNgJdD5Rtl X-Received: by 10.98.161.16 with SMTP id b16mr11690867pff.34.1516761084567; Tue, 23 Jan 2018 18:31:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516761084; cv=none; d=google.com; s=arc-20160816; b=xuOfO5Rbb3UNcr7YgfkhxgooFXL+1vjwNFneuxu47EQZRQ+uI3KiBODXBqdELtIILz eVN5d7xPwqhnGo62dSIrOuv6gK4hwt+kdCjPerNpWYh1jXae2/ETYKE1A+0CmUB7eq8A KFpI8i75+Hi8kar4/kofbv2bI2eXL13qe2Be821DrjGwTbg0JOyPq6yN0cBKfGFpiAn1 zB6plMe1dD6+rzkuUBX+ZuzVN+G0FUC900SgcGx4nKxSxcJHFPKnRQSUSqNgV7oBNIBs RQcdCdPHV/AuUHPx3TD66591UvNyi8aRalxxjc1OV8bP7DTEeQTJmZnYmS9Vm5l73C3w AnXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=zxDQJi/jEDoce4HewYP13RrItgHK9zRdmhJxtsxNd9o=; b=CS1op7/dFPDcI157aaeRwMRnTI2DcFZ0IavQiHdgZ4/JJx7KO3/05MyxnZzZP4a7cn N12Yc6YLiTPRko/gb+uz3deyfVNNnhChfdAwPownlSggu24dXEg9bP/LnyTgd1bBbfSH p74maRA/znd2OFtGgPZVQQV4H22fE17suyR81q1jov8JZlUKDnYA1CR81gGLwie2Ymqs atFtzjd03Xde6+qu5gY2G+jajpEGyAViufVB/CfXmIjVFGi7TkxAn0eL3AK4fCKu8gBn YOq76ZQRwyjNqzi9L0JXhQgeYGxj3V/VK9bdsjWQotmqkwqFg1kzwJsZLoSh2bnbo0uC +dEA== 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 t203si15265113pgb.758.2018.01.23.18.31.10; Tue, 23 Jan 2018 18:31:24 -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 S1752246AbeAXCam (ORCPT + 99 others); Tue, 23 Jan 2018 21:30:42 -0500 Received: from mga01.intel.com ([192.55.52.88]:43977 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751937AbeAXCae (ORCPT ); Tue, 23 Jan 2018 21:30:34 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Jan 2018 18:30:33 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,404,1511856000"; d="scan'208";a="21846895" Received: from aaronlu.sh.intel.com ([10.239.159.135]) by orsmga003.jf.intel.com with ESMTP; 23 Jan 2018 18:30:30 -0800 From: Aaron Lu To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Andrew Morton , Huang Ying , Dave Hansen , Kemi Wang , Tim Chen , Andi Kleen , Michal Hocko , Vlastimil Babka , Mel Gorman Subject: [PATCH 2/2] free_pcppages_bulk: prefetch buddy while not holding lock Date: Wed, 24 Jan 2018 10:30:50 +0800 Message-Id: <20180124023050.20097-2-aaron.lu@intel.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180124023050.20097-1-aaron.lu@intel.com> References: <20180124023050.20097-1-aaron.lu@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Test with will-it-scale/page_fault1 full load: kernel Broadwell(2S) Skylake(2S) Broadwell(4S) Skylake(4S) v4.15-rc4 9037332 8000124 13642741 15728686 patch1/2 9608786 +6.3% 8368915 +4.6% 14042169 +2.9% 17433559 +10.8% this patch 10462292 +8.9% 8602889 +2.8% 14802073 +5.4% 17624575 +1.1% Note: this patch's performance improvement percent is against patch1/2. Suggested-by: Ying Huang Signed-off-by: Aaron Lu --- mm/page_alloc.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index a076f754dac1..9ef084d41708 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1140,6 +1140,9 @@ static void free_pcppages_bulk(struct zone *zone, int count, batch_free = count; do { + unsigned long pfn, buddy_pfn; + struct page *buddy; + page = list_last_entry(list, struct page, lru); /* must delete as __free_one_page list manipulates */ list_del(&page->lru); @@ -1148,6 +1151,16 @@ static void free_pcppages_bulk(struct zone *zone, int count, continue; list_add_tail(&page->lru, &head); + + /* + * We are going to put the page back to + * the global pool, prefetch its buddy to + * speed up later access under zone->lock. + */ + pfn = page_to_pfn(page); + buddy_pfn = __find_buddy_pfn(pfn, 0); + buddy = page + (buddy_pfn - pfn); + prefetch(buddy); } while (--count && --batch_free && !list_empty(list)); } -- 2.14.3