Received: by 10.223.176.5 with SMTP id f5csp2045704wra; Wed, 31 Jan 2018 15:53:23 -0800 (PST) X-Google-Smtp-Source: AH8x227z1DJ0jzc5sLy85htkb2TcjPeGYa+oWIB2OBwPBb4gMUONGeBpwtjXeTupDLhIez2obdEU X-Received: by 10.99.108.7 with SMTP id h7mr27377856pgc.292.1517442803218; Wed, 31 Jan 2018 15:53:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517442803; cv=none; d=google.com; s=arc-20160816; b=iGwWLfPRXNbGAHTLFHCRVDjmVKc27nc4BsoE3lhYkmqyWB1BmCO/Y6Wl//62QboAkW 1bTEy0vjHyYM0DEsb62HaKd3HSwOghIi63bqHL4lugHLGJsMyrYTzvFOY88khS6fMUv6 0IdjsivN8Jcfk/Fb4psi48YoWoi7mYLh6PI6l88ju7jBpjLJ1UUwucGsMeotCC8W7/3f +qPhwu3wkTJI9FceXV918JRceyNL9poMe3EexST8M9Iezeq+rtCvzEKzimsquGOFgHlX NG/wnGS7iXCHsvfmJeE0JGKfuKrAlFC5kHkFCGiEN7kqqlW6qG4Q1ScBN83nXdeoxVe2 BUwQ== 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=EpiJ0kNY/9Z0xza+VZ4qMooUvmES7vVwGrA3Rm6eU38=; b=NG0oZxIbNYE3bqGDV46BieHZa6HdXjMfjAdCFjY/C5EFOA5MEmEV4BbcHFaYp/l7a4 FsKinY0+8/EnH1uunb7dQCKJFF2XRUqVIyaZli6m/HeSSu4dr6U/4FTjytkj+nvEiKCM 3ZWMRyF+p8oBJDVzidS009JeXVLC1Ky9JASIncDiEdCrXEGEt/wt9qPqGkEX10nVVe/9 rEwyYGaCHBRuzpMZ+6l965WB6XZtckJnICQnEXZe4ZVhxW4WVxecTM3xnL7qXMSRRrM+ iHi7hcbs+nXuYVSLtAIyXuDlanbDKzsWyBzt0zfjZrWCQ4LopJ5DM6OQQJP68iaOC56M HMnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=ph7jeDUk; 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 z34-v6si440305plh.45.2018.01.31.15.53.09; Wed, 31 Jan 2018 15:53:23 -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=ph7jeDUk; 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 S1755917AbeAaXPA (ORCPT + 99 others); Wed, 31 Jan 2018 18:15:00 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:51796 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754258AbeAaXEh (ORCPT ); Wed, 31 Jan 2018 18:04:37 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w0VMpu8l107823; Wed, 31 Jan 2018 23:04:29 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=EpiJ0kNY/9Z0xza+VZ4qMooUvmES7vVwGrA3Rm6eU38=; b=ph7jeDUk+b+wk2smk1q9BRRWI5Hrd/yqQjU8uBmu93zLXdq+XvywcK0IlN3k4wGj0bpg N3FERU6HLKG0RILKAbq71hLZIdZmq9VBCyo1tNzWYX2Zv/XP0IolGfOmpN2lTTt7vZ2G Ic4BD9a7pvQWmEJ1xgXX21bmRJ2DzAWhwN7eQQYJLQRcACUsWNhCkhsAYzanBAWGbCo0 YaFfE/LsZ5bqUXAfxoIcnS8cHI4RX3bCoKGUsdIep9gSlfB7J2RuL24046OGaiw7Jrih HRJYwNkRf+Y1DFDcHLeqAhbd5FBG/4LW4rMlz8/6OSPr1SvNvxsb4Q03ub2a6A4jHDyQ Dg== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2130.oracle.com with ESMTP id 2fuc8kkh2y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 31 Jan 2018 23:04:29 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w0VN4T6p011851 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 31 Jan 2018 23:04:29 GMT Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w0VN4SKA022106; Wed, 31 Jan 2018 23:04:28 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:28 -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 06/13] mm: add lru_[un]lock_all APIs Date: Wed, 31 Jan 2018 18:04:06 -0500 Message-Id: <20180131230413.27653-7-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=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=958 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 Add heavy locking API's for the few cases that a thread needs exclusive access to an LRU list. This locks lru_lock as well as every lock in lru_batch_locks. This API will be used often at first, in scaffolding code, to ease the transition from using lru_lock to the batch locking scheme. Later it will be rarely needed. Signed-off-by: Daniel Jordan --- include/linux/mm_inline.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/include/linux/mm_inline.h b/include/linux/mm_inline.h index ec8b966a1c76..1f1657c75b1b 100644 --- a/include/linux/mm_inline.h +++ b/include/linux/mm_inline.h @@ -178,6 +178,38 @@ static __always_inline void move_page_to_lru_list_tail(struct page *page, __add_page_to_lru_list_tail(page, lruvec, lru); } +static __always_inline void lru_lock_all(struct pglist_data *pgdat, + unsigned long *flags) +{ + size_t i; + + if (flags) + local_irq_save(*flags); + else + local_irq_disable(); + + for (i = 0; i < NUM_LRU_BATCH_LOCKS; ++i) + spin_lock(&pgdat->lru_batch_locks[i].lock); + + spin_lock(&pgdat->lru_lock); +} + +static __always_inline void lru_unlock_all(struct pglist_data *pgdat, + unsigned long *flags) +{ + int i; + + spin_unlock(&pgdat->lru_lock); + + for (i = NUM_LRU_BATCH_LOCKS - 1; i >= 0; --i) + spin_unlock(&pgdat->lru_batch_locks[i].lock); + + if (flags) + local_irq_restore(*flags); + else + local_irq_enable(); +} + /** * page_lru_base_type - which LRU list type should a page be on? * @page: the page to test -- 2.16.1