From patchwork Tue Sep 11 00:59:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Jordan X-Patchwork-Id: 10594959 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BA41E6CB for ; Tue, 11 Sep 2018 01:00:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A8E5E29010 for ; Tue, 11 Sep 2018 01:00:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 992B42901E; Tue, 11 Sep 2018 01:00:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2D7D329010 for ; Tue, 11 Sep 2018 01:00:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6E40E8E0008; Mon, 10 Sep 2018 21:00:13 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 694008E0001; Mon, 10 Sep 2018 21:00:13 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 55D508E0008; Mon, 10 Sep 2018 21:00:13 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-it0-f69.google.com (mail-it0-f69.google.com [209.85.214.69]) by kanga.kvack.org (Postfix) with ESMTP id 2CDE58E0001 for ; Mon, 10 Sep 2018 21:00:13 -0400 (EDT) Received: by mail-it0-f69.google.com with SMTP id u195-v6so6059445ith.2 for ; Mon, 10 Sep 2018 18:00:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=GIGrhLpkq/UwRHuhh/oLny6MvSnAXVnSlsgDHYSyP4U=; b=pCpYEBu0VOQL8dY4bZW7krsksZIhlgP/37pfxn7GzP3mlHIdtzqzvRmGq386KrpjyW WqH47aMD81h5cVQuoTVFlL/Jb+sbMlsQw0wTk1wgloNV58g2/ssSJr2Oc6r0hhM+oKgQ Wm+4D28N+LrQF8DB01FsubYT8XQ88aUgdvOtmbi4Fkx+d/7be3xqjZIWHKgj1ID+X568 DXVHKCxEQoTEFyMe71s05qCmc83fXa9SIsgHS8veExJhzCWwyp8WgmCaIroLZphXcllF 46JIlytdd8KPXHz7GGXk0DQIojzsoxmLYRDKj49CHJqs4E19YH+WTlGmUSHC+u3UFkYC owwA== X-Gm-Message-State: APzg51Cc6u/AHWWWaNNOf258swOX/nxY8sNwrBIiBoHN61+mcNyhIa+m KncVGQ484NvFn8ijKDDN4yDQkQZbgYlBXtGTja2AvxhcwzwYWj7Yg7z9t8hSN/cXFpWtn3Rs6tW bJ6mQUT1qgWQI7yLOrAVbvhipSWj0fKuJSu58PCx1fBzuH7BFbrH3013NroGnLmjuOw== X-Received: by 2002:a6b:24a:: with SMTP id 71-v6mr18504118ioc.191.1536627612916; Mon, 10 Sep 2018 18:00:12 -0700 (PDT) X-Google-Smtp-Source: ANB0VdY0rIFuu7bRR7NEK2gYmvCi7WHh00BTY82yBfbYZeXr9Lez4HORam5k2ApxYGSB6Gzuu4jw X-Received: by 2002:a6b:24a:: with SMTP id 71-v6mr18504087ioc.191.1536627612253; Mon, 10 Sep 2018 18:00:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536627612; cv=none; d=google.com; s=arc-20160816; b=RgOmwHDjqX2jSpqRQvhfxvIxq5bl0agYsoEmvBRHK6UdKLyfGbYR3dyU64Q7yP2TU1 L5EFvDm5YMZf4MK+ElpDyQcFmM8+rpjE/uKkJdsj6e2x4BObK/Eof8ksckYE4GtZUhiQ UcbXE/kTq7GMlGB1D0os5vFeB5Q7ozCMZ0R23pRICnNsY4FCrpzpEY32FEKZdqWMzSQN fXqmAngnRSi15gcD1sIhnrXjopohc5hLo+2YwGJYWxCJHeg8Gey/CvK2sQiSXXOYErHa YGGL4mkDgIPmpDLBKLcRne3+gfOs1lkDjMiwjTTltzaOFnkuf6bLyL7s+4N5apynIRVK u2Gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=GIGrhLpkq/UwRHuhh/oLny6MvSnAXVnSlsgDHYSyP4U=; b=slib4aGzhJj/bhO88B5mJMKJZji1mtwTPnS9x05OAf2xTx9zb49d832XBU1i+2XN5k Fud2kEWw2dTKRBTTv5r+NQ+ZafcbNuohFU+nL4KSJtwmfq1lFaprDxSd0cudG5edwvdV WBovJhUWcex/PXci9UaGadJ2cMNYfAje9t+4aZ6DTsmyUYYWYmNFXgNy4UQjMHdLZMf9 KwJTCwMTnJvVS94i2dKD8wRR/y7ubKOj4WyrFeUcDvQ5+GVZXDKyEkixn6I1dtAmYLI6 8WdMLxKHj8W/hE0TNUi7Q75r3gFHTI9TJBVM2Ho4PSyA912YRFGG9V5rWntvUN4kzwEp +loQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=3OI9XnRy; spf=pass (google.com: domain of daniel.m.jordan@oracle.com designates 141.146.126.78 as permitted sender) smtp.mailfrom=daniel.m.jordan@oracle.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from aserp2120.oracle.com (aserp2120.oracle.com. [141.146.126.78]) by mx.google.com with ESMTPS id o186-v6si10518420ith.83.2018.09.10.18.00.11 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Sep 2018 18:00:12 -0700 (PDT) Received-SPF: pass (google.com: domain of daniel.m.jordan@oracle.com designates 141.146.126.78 as permitted sender) client-ip=141.146.126.78; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=3OI9XnRy; spf=pass (google.com: domain of daniel.m.jordan@oracle.com designates 141.146.126.78 as permitted sender) smtp.mailfrom=daniel.m.jordan@oracle.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com 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 w8B103Rl100843; Tue, 11 Sep 2018 01:00:03 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-2018-07-02; bh=GIGrhLpkq/UwRHuhh/oLny6MvSnAXVnSlsgDHYSyP4U=; b=3OI9XnRydeGejeV8QwnfkqjVjJlEVTTMlsrePEqSQOp4Y9+cOHcgzFBVUPLTe7hH4VG8 de/MXWq1vMnQphx5FIDoOT4uZACs36ca8V1BVUnHkeMMNa3XwmVGXdTm0fl+uyO0nfNg He8/OjcPsPrUB0WIUZZ1f8ImYmmUv+wzyUBW7Dv3tRNEFLL+wwEJ20ujHgCATBJ9I53F mnzO7Z/KcdCSHNxoSwnBezQ7Eg/GfHI/OP+aA+M5DEUESD6TqwxBevbtVAq9C6dl5nJU Qkm34sbCV3bwoRuStRnX/I3qZSMzMh8fPlTctpw9vzGKzeLRuuj60WW1ictvvwTA04hv Ug== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2120.oracle.com with ESMTP id 2mc6cph2dv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Sep 2018 01:00:03 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w8B0xvuJ012610 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Sep 2018 00:59:58 GMT Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w8B0xvqe026769; Tue, 11 Sep 2018 00:59:57 GMT Received: from localhost.localdomain (/73.143.71.164) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 10 Sep 2018 17:59:57 -0700 From: Daniel Jordan To: linux-mm@kvack.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org Cc: aaron.lu@intel.com, ak@linux.intel.com, akpm@linux-foundation.org, dave.dice@oracle.com, dave.hansen@linux.intel.com, hannes@cmpxchg.org, levyossi@icloud.com, ldufour@linux.vnet.ibm.com, mgorman@techsingularity.net, mhocko@kernel.org, Pavel.Tatashin@microsoft.com, steven.sistare@oracle.com, tim.c.chen@intel.com, vdavydov.dev@gmail.com, ying.huang@intel.com Subject: [RFC PATCH v2 5/8] mm: enable concurrent LRU removals Date: Mon, 10 Sep 2018 20:59:46 -0400 Message-Id: <20180911005949.5635-2-daniel.m.jordan@oracle.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180911004240.4758-1-daniel.m.jordan@oracle.com> References: <20180911004240.4758-1-daniel.m.jordan@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9012 signatures=668708 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=928 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1809110009 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP The previous patch used the concurrent algorithm serially to see that it was stable for one task. Now in release_pages, take lru_lock as reader instead of writer to allow concurrent removals from one or more LRUs. Suggested-by: Yosef Lev Signed-off-by: Daniel Jordan --- mm/swap.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/mm/swap.c b/mm/swap.c index 613b841bd208..b1030eb7f459 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -737,8 +737,8 @@ void release_pages(struct page **pages, int nr) * same pgdat. The lock is held only if pgdat != NULL. */ if (locked_pgdat && ++lock_batch == SWAP_CLUSTER_MAX) { - write_unlock_irqrestore(&locked_pgdat->lru_lock, - flags); + read_unlock_irqrestore(&locked_pgdat->lru_lock, + flags); locked_pgdat = NULL; } @@ -748,9 +748,8 @@ void release_pages(struct page **pages, int nr) /* Device public page can not be huge page */ if (is_device_public_page(page)) { if (locked_pgdat) { - write_unlock_irqrestore( - &locked_pgdat->lru_lock, - flags); + read_unlock_irqrestore(&locked_pgdat->lru_lock, + flags); locked_pgdat = NULL; } put_zone_device_private_or_public_page(page); @@ -763,9 +762,8 @@ void release_pages(struct page **pages, int nr) if (PageCompound(page)) { if (locked_pgdat) { - write_unlock_irqrestore( - &locked_pgdat->lru_lock, - flags); + read_unlock_irqrestore(&locked_pgdat->lru_lock, + flags); locked_pgdat = NULL; } __put_compound_page(page); @@ -776,14 +774,14 @@ void release_pages(struct page **pages, int nr) struct pglist_data *pgdat = page_pgdat(page); if (pgdat != locked_pgdat) { - if (locked_pgdat) { - write_unlock_irqrestore( - &locked_pgdat->lru_lock, flags); - } + if (locked_pgdat) + read_unlock_irqrestore( + &locked_pgdat->lru_lock, + flags); lock_batch = 0; locked_pgdat = pgdat; - write_lock_irqsave(&locked_pgdat->lru_lock, - flags); + read_lock_irqsave(&locked_pgdat->lru_lock, + flags); } lruvec = mem_cgroup_page_lruvec(page, locked_pgdat); @@ -800,7 +798,7 @@ void release_pages(struct page **pages, int nr) list_add(&page->lru, &pages_to_free); } if (locked_pgdat) - write_unlock_irqrestore(&locked_pgdat->lru_lock, flags); + read_unlock_irqrestore(&locked_pgdat->lru_lock, flags); mem_cgroup_uncharge_list(&pages_to_free); free_unref_page_list(&pages_to_free);