Received: by 10.223.176.5 with SMTP id f5csp2023846wra; Wed, 31 Jan 2018 15:26:10 -0800 (PST) X-Google-Smtp-Source: AH8x224Y0ickoweagTjjukJjvlE2OuhMpuV7F9kRvQW2G0W+bCWEFF/P+nV6b2z2iLiCKEcU9034 X-Received: by 2002:a17:902:6f08:: with SMTP id w8-v6mr29810943plk.155.1517441170472; Wed, 31 Jan 2018 15:26:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517441170; cv=none; d=google.com; s=arc-20160816; b=dU2HVkbjLOYm0UHx9C3AKXHiUCbGwgjQGB3+eleLzMpIvhbzd3HeGKDsviaLPgFH+D ibYmFJT4C6q7RLGLXvIEiNOve8Gx+mPr469u8XbNlc3zWdGHs0OBcG/Pbvn15mEAQVGG XDiuDchEcStTQ7kY1RQXwWOECK9ilKGoOksswWGz64+u//UhWj21JCtkgPh9Hi/X8UnV muiSgPW/wtRqjB3nqLIVDtZ2gpesQQpTPGB3dMI0mSQSszQD8SxaXT87u5qf92KNpIQO 6Bqq76szHPQUCLrG4P+8GHgONvmcHYAcfX8t0DfAk5T/S3J07CLBxlVeYVxOc/a9t+yM Q1UA== 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:dkim-signature:arc-authentication-results; bh=U4HFNk2Dj6dUqF2fv4EZJHgjaFBL8vrTXpliwM87dhs=; b=i/y6YTVrrvWfa2HNXAqKraXGQgQvKNTkOMnZUfA04HFPU7sqCx34qJUgNSoFdwIKA8 SF+7/J/OGkZo53oW11G4bGjig7fU3dxcea1ik6aqEvta8WP0S1uFLNKiJAzY3M9skS9U QLI65ydwENrWLdw2WQogpHpS0UL1mDB9KRCrsybnaHvBBXlcpkPfLIKChU+H5AhhF6QP naoZdoXPQDBgDISS6FY5lqa6+aGMJpmq2f7WmdV9Iqc7ZaHbVsP8CfVqZpyNfrMnaYUh luJGgjFWnedxqJdfs8InYVe7jg9OwtBOsQo9Wy1bsTGj4Kmrx+pJzzUHiW0VARJupn2H tD6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=ZdPKAvZ5; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a89-v6si386134pla.524.2018.01.31.15.25.55; Wed, 31 Jan 2018 15:26:10 -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; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=ZdPKAvZ5; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754395AbeAaXFu (ORCPT + 99 others); Wed, 31 Jan 2018 18:05:50 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:60126 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754417AbeAaXFo (ORCPT ); Wed, 31 Jan 2018 18:05:44 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w0VMpfFX130436; Wed, 31 Jan 2018 23:04:36 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2017-10-26; bh=U4HFNk2Dj6dUqF2fv4EZJHgjaFBL8vrTXpliwM87dhs=; b=ZdPKAvZ50cRU3aog6mDhOyvAEj3J2scCf1s1P/PRmErZNR7Cxq0jt4DEovksD3g8Dnby aXWUTEZELWjm5ES7vOSPy4CooiYpnk6muN7S/1Wiz5hP+tUXAMM86ttWsiloyeHJoRiB RRX0B5ENKtBqQDktOC9xcWks5eaPrIWs12Fkp/j77jqR03lCWaIUer8Kuot/ZCYfOkJm Lg+GbNxXpf4EfyF4ykTqNPfwdT0nGsHXveYHW0tWyJuSLFom1WGvDpOsz1LrL4QXE/62 BsFzhwNufWG3S+k30RxnLEHxtk3DpQ/trMxM23ir4FnxapEmaSIk3zvTfR2qavhqrLZ4 jQ== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2120.oracle.com with ESMTP id 2fuf632mx0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 31 Jan 2018 23:04:36 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w0VN4ZoE021167 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 31 Jan 2018 23:04:35 GMT Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w0VN4ZsK019218; Wed, 31 Jan 2018 23:04:35 GMT Received: from parnassus.us.oracle.com (/10.39.213.30) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 31 Jan 2018 15:04:35 -0800 From: daniel.m.jordan@oracle.com To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: aaron.lu@intel.com, ak@linux.intel.com, akpm@linux-foundation.org, Dave.Dice@oracle.com, dave@stgolabs.net, khandual@linux.vnet.ibm.com, ldufour@linux.vnet.ibm.com, mgorman@suse.de, mhocko@kernel.org, pasha.tatashin@oracle.com, steven.sistare@oracle.com, yossi.lev@oracle.com Subject: [RFC PATCH v1 12/13] mm: split up release_pages into non-sentinel and sentinel passes Date: Wed, 31 Jan 2018 18:04:12 -0500 Message-Id: <20180131230413.27653-13-daniel.m.jordan@oracle.com> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180131230413.27653-1-daniel.m.jordan@oracle.com> References: <20180131230413.27653-1-daniel.m.jordan@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8791 signatures=668659 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1801310283 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org A common case in release_pages is for the 'pages' list to be in roughly the same order as they are in their LRU. With LRU batch locking, when a sentinel page is removed, an adjacent non-sentinel page must be promoted to a sentinel page to follow the locking scheme. So we can get behavior where nearly every page in the 'pages' array is treated as a sentinel page, hurting the scalability of this approach. To address this, split up release_pages into non-sentinel and sentinel passes so that the non-sentinel pages can be locked with an LRU batch lock before the sentinel pages are removed. For the prototype, just use a bitmap and a temporary outer loop to implement this. Performance numbers from a single microbenchmark at this point in the series are included in the next patch. Signed-off-by: Daniel Jordan --- mm/swap.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/mm/swap.c b/mm/swap.c index fae766e035a4..a302224293ad 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -731,6 +731,7 @@ void lru_add_drain_all(void) put_online_cpus(); } +#define LRU_BITMAP_SIZE 512 /** * release_pages - batched put_page() * @pages: array of pages to release @@ -742,16 +743,32 @@ void lru_add_drain_all(void) */ void release_pages(struct page **pages, int nr) { - int i; + int h, i; LIST_HEAD(pages_to_free); struct pglist_data *locked_pgdat = NULL; spinlock_t *locked_lru_batch = NULL; struct lruvec *lruvec; unsigned long uninitialized_var(flags); + DECLARE_BITMAP(lru_bitmap, LRU_BITMAP_SIZE); + + VM_BUG_ON(nr > LRU_BITMAP_SIZE); + bitmap_zero(lru_bitmap, nr); + + for (h = 0; h < 2; h++) { for (i = 0; i < nr; i++) { struct page *page = pages[i]; + if (h == 0) { + if (PageLRU(page) && page->lru_sentinel) { + bitmap_set(lru_bitmap, i, 1); + continue; + } + } else { + if (!test_bit(i, lru_bitmap)) + continue; + } + if (is_huge_zero_page(page)) continue; @@ -798,6 +815,7 @@ void release_pages(struct page **pages, int nr) list_add(&page->lru, &pages_to_free); } + } if (locked_lru_batch) { lru_batch_unlock(NULL, &locked_lru_batch, &locked_pgdat, &flags); -- 2.16.1