Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp3309055imm; Sun, 1 Jul 2018 18:12:16 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIOVw3m43+3UrumTi11iI84gtep7aC6s9sXGrlhAALub6wXyDOr8M+ORg18rRiiXP1WHw+q X-Received: by 2002:a17:902:8d91:: with SMTP id v17-v6mr24110758plo.9.1530493936655; Sun, 01 Jul 2018 18:12:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530493936; cv=none; d=google.com; s=arc-20160816; b=QCeCrz158vZsne2qP6+oFvyUUq2jrgNLMsyCbfrEO72pGvGucJZgxmJxMOgMgLyxqv PRN9QJteplTPZ95Ju30M3yi2BnaLx8CQ5l8SVW6dvpB4fC0s2M42XGaMggnnrICCjooh 7cjYrNdzVihy/8ffX+2kis1xHwysAtSloixnSqSChLX08rk1blYuHW8dGWiHFh7OO7sm UUcMkViY3mjkrjyjr5o1tWfSPqR/Ju64oql6gXICgyrcxefK14HYxNmJYJogC5EX74HQ 3NZ1PloyCv32Iv69T91K2BeuyHZoMsM1mT+OPWq5ShKmM3TBYLomtC/G0E4R6ZaC9Rox URWA== 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=uQq7Rhh2IoBOG5dCp0+cMTRTysWrcwIj4JspKeAqpgw=; b=T911IFIjcKM+stuqrYT7+cwUZukFXtYkLjIC8HM3WCVziRtjw/NRmgOuwj3dpVqOlF r8jPY7qXxU3hKCef+std3s5Zu1ixqIuA3qLOYNbml7/mHo05gfFeRqkisqaYnSiDQL6G r+858AnLhl0CaTnMxgx7EuLB0I5beDjEp24c3gr7j5GgY0GGlMRwU4iJzhmIc294qstv fETpOLEJPxq0oO93cUqu9UOnHcNSQkVzDJBakcVlKdxZ8ieEHUvIuw2P097uZGkZ4TCR 5EjG8UYgHvCFuyVHojxp62duAu6BJtN47pzVR+Cc/CKZGtfTIbVm2Mv1f48Fqka6/Y1u x91A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=R7NKw7Mj; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e4-v6si14461348pfi.184.2018.07.01.18.12.02; Sun, 01 Jul 2018 18:12:16 -0700 (PDT) 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=@gmail.com header.s=20161025 header.b=R7NKw7Mj; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932396AbeGBA5y (ORCPT + 99 others); Sun, 1 Jul 2018 20:57:54 -0400 Received: from mail-oi0-f65.google.com ([209.85.218.65]:37300 "EHLO mail-oi0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932286AbeGBA5k (ORCPT ); Sun, 1 Jul 2018 20:57:40 -0400 Received: by mail-oi0-f65.google.com with SMTP id k81-v6so13349293oib.4; Sun, 01 Jul 2018 17:57:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=uQq7Rhh2IoBOG5dCp0+cMTRTysWrcwIj4JspKeAqpgw=; b=R7NKw7MjzwO2OAqPIqAKIb+0PZqdQgxMlT/+wbZ+5gPFLwCcqC9eAgg2KW5YgQT5nr 0rPcxMA9dA5mU+0Xds4payqHHKyaxEyjuOpNqGaNwyIbj+l+OFsHqL/aTnPzwLJaho1a /ZJvVa2SFD7o4pOnzI2EbaSEIuMfQrDSBkpBssZqRM3cUG8xQKjDChb3iHsVkrIpEB0j chJW3e+biapq1UMMntmhfjmG0zAvkiQ3BrrLx497Cy6Q4+9fdZRXVHHghj50apibuluT 7MmhPuFGnZo+uFsDFm/RmLU159Duko+IY1JXwPburS2vFn2TRyqr+wJDiFxfohXbX6Re jYWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=uQq7Rhh2IoBOG5dCp0+cMTRTysWrcwIj4JspKeAqpgw=; b=i+JjfL/yFQsk/pbaYZmlZEgACGF2fkjpEuIs+6IQGpftLJym86oV0swkO4FItz6mt/ Iscv5Kyyudg3TkdqSRFKr08bOtLxTjoGHiGNo2SVX8fDSmVFjiuTeKkG8PFb/pY+vgWt puS2HuResCnvUYPzbMuvnUg286UhL10Lr17LYKcNMcgFzC9lsVLUq3wlbFBTymyYsm/I ijy7EIWFVazJZGrir81cpqvEf/8BZXM/+YS261kLGobd2GijxXQT3jHUQ9ciLpS+4l9h 87XV2nNfqdon+X71GlWEKYue7xVE7CgnjQZKxT+FM84bhHA2opJEMeKwUXruDhiFDhE0 kkVw== X-Gm-Message-State: APt69E1gPQASOoA2j9+O+lILAx3K29t9eudvqE9AMfvu5HRq+CC2hk1L tsEY/IOw+VAnOIn0M6KKfmQ= X-Received: by 2002:aca:5c46:: with SMTP id q67-v6mr12867959oib.17.1530493060311; Sun, 01 Jul 2018 17:57:40 -0700 (PDT) Received: from sandstorm.nvidia.com ([2600:1700:43b0:3120:feaa:14ff:fe9e:34cb]) by smtp.gmail.com with ESMTPSA id v6-v6sm4111672oix.30.2018.07.01.17.57.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Jul 2018 17:57:39 -0700 (PDT) From: john.hubbard@gmail.com X-Google-Original-From: jhubbard@nvidia.com To: Matthew Wilcox , Michal Hocko , Christopher Lameter , Jason Gunthorpe , Dan Williams , Jan Kara Cc: linux-mm@kvack.org, LKML , linux-rdma , linux-fsdevel@vger.kernel.org, John Hubbard Subject: [PATCH v2 3/6] mm: introduce zone_gup_lock, for dma-pinned pages Date: Sun, 1 Jul 2018 17:56:51 -0700 Message-Id: <20180702005654.20369-4-jhubbard@nvidia.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180702005654.20369-1-jhubbard@nvidia.com> References: <20180702005654.20369-1-jhubbard@nvidia.com> X-NVConfidentiality: public Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: John Hubbard The page->dma_pinned_flags and _count fields require lock protection. A lock at approximately the granularity of the zone_lru_lock is called for, but adding to the locking contention of zone_lru_lock is undesirable, because that is a pre-existing hot spot. Fortunately, these new dma_pinned_* fields can use an independent lock, so this patch creates an entirely new lock, right next to the zone_lru_lock. Why "zone_gup_lock"? Most of the naming refers to "DMA-pinned pages", but "zone DMA lock" has other meanings already, so this is called zone_gup_lock instead. The "dma pinning" is a result of get_user_pages (gup) being called, so the name still helps explain its use. Signed-off-by: John Hubbard --- include/linux/mmzone.h | 7 +++++++ mm/page_alloc.c | 1 + 2 files changed, 8 insertions(+) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 32699b2dc52a..5b4ceef82657 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -662,6 +662,8 @@ typedef struct pglist_data { int kswapd_failures; /* Number of 'reclaimed == 0' runs */ + spinlock_t pinned_dma_lock; + #ifdef CONFIG_COMPACTION int kcompactd_max_order; enum zone_type kcompactd_classzone_idx; @@ -740,6 +742,11 @@ static inline spinlock_t *zone_lru_lock(struct zone *zone) return &zone->zone_pgdat->lru_lock; } +static inline spinlock_t *zone_gup_lock(struct zone *zone) +{ + return &zone->zone_pgdat->pinned_dma_lock; +} + static inline struct lruvec *node_lruvec(struct pglist_data *pgdat) { return &pgdat->lruvec; diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 1521100f1e63..9c493442b57c 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -6211,6 +6211,7 @@ static void __paginginit free_area_init_core(struct pglist_data *pgdat) int nid = pgdat->node_id; pgdat_resize_init(pgdat); + spin_lock_init(&pgdat->pinned_dma_lock); #ifdef CONFIG_NUMA_BALANCING spin_lock_init(&pgdat->numabalancing_migrate_lock); pgdat->numabalancing_migrate_nr_pages = 0; -- 2.18.0