Received: by 10.223.176.5 with SMTP id f5csp1986616wra; Sun, 4 Feb 2018 17:29:46 -0800 (PST) X-Google-Smtp-Source: AH8x225tTIDtd5Klfuv0VFFWztggq5UJEPkh8sTCwneFR+AxfNfRWZg8H/VkhgoBSeGLtjkxFJjf X-Received: by 2002:a17:902:b608:: with SMTP id b8-v6mr22366644pls.404.1517794186843; Sun, 04 Feb 2018 17:29:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517794186; cv=none; d=google.com; s=arc-20160816; b=eGcaAQFn6jRM8cUVhoYxSfT1KToPQWn9VMw3Sod+hHDsd14WqXUxbZed7cORMXI4aT S3lWge/njGHZ4XMpHhApz9+/vpkS6fIN2qGS6cPp+MYuJZuF1YWsuVtPgql97uaw3ih2 rxqWRJpxE3BF2o3iW2qtSnA4pgqXgZ3AXKvb1qPzpu49cvqoIFNOHbOBRinBMu5jWWZ2 phKTWsshSMVUVWDH6E1bSc5PWvE9qquj2F+HZ6ghH3geAVOxdHTlOJdDxymxWzx7NDlj xJWeDn99Wd5V+FBPCUpF5KOHzugob64afgG21qmTPA8xkYARdYaI6YnU4AVMPo/40f2G GG7A== 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=ZCCK4Q7e02E7JLso6fQUo4ihc1WdNVI8zeHBAfjZctQ=; b=QmTWhuCKR53vAbT6g1QT+JGdL76vSeCK0zHJsq0K1dTAItYG6YcYqJaj2do6jELOMe /peJIkpfbyd56pqn7a67Ugyv7EWx1sInzASApVU7IE+ml/RTUVxSvr458sGqq40R7R17 hRvzNsXjOVtJdFasG4Gfj39tKr/NJ6ioHFRrTzv1ujlKzgwf8VY9fSxdovias5zKSLLP K2cqLLefsrtCHog0ii9oRsJ9F1qD7MlAMWLxx0rRMq7LlrZP6kHVZv7XiTMsgpxbFXZ9 DtxERADWhnHwfU4T3CbrUacyHP1EWBEurTEbWW3LfNWkcVJ+xSfJAi9i4rBKLrcVDLe/ u6hw== 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 e9-v6si3990362pln.634.2018.02.04.17.29.32; Sun, 04 Feb 2018 17:29:46 -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 S1752767AbeBEB3M (ORCPT + 99 others); Sun, 4 Feb 2018 20:29:12 -0500 Received: from mx2.suse.de ([195.135.220.15]:43456 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752536AbeBEB2D (ORCPT ); Sun, 4 Feb 2018 20:28:03 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id BC7DDADD3; Mon, 5 Feb 2018 01:27:59 +0000 (UTC) From: Davidlohr Bueso To: akpm@linux-foundation.org, mingo@kernel.org Cc: peterz@infradead.org, ldufour@linux.vnet.ibm.com, jack@suse.cz, mhocko@kernel.org, kirill.shutemov@linux.intel.com, mawilcox@microsoft.com, mgorman@techsingularity.net, dave@stgolabs.net, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Davidlohr Bueso Subject: [PATCH 08/64] mm: teach lock_page_or_retry() about range locking Date: Mon, 5 Feb 2018 02:26:58 +0100 Message-Id: <20180205012754.23615-9-dbueso@wotan.suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180205012754.23615-1-dbueso@wotan.suse.de> References: <20180205012754.23615-1-dbueso@wotan.suse.de> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Davidlohr Bueso The mmap_sem locking rules for lock_page_or_retry() depends on the page being locked upon return, and can get funky. As such we need to teach the function about mmrange, which is passed on via vm_fault. Signed-off-by: Davidlohr Bueso --- include/linux/pagemap.h | 7 ++++--- mm/filemap.c | 5 +++-- mm/memory.c | 3 ++- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 34ce3ebf97d5..e41a734efbe0 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -464,7 +464,7 @@ static inline pgoff_t linear_page_index(struct vm_area_struct *vma, extern void __lock_page(struct page *page); extern int __lock_page_killable(struct page *page); extern int __lock_page_or_retry(struct page *page, struct mm_struct *mm, - unsigned int flags); + unsigned int flags, struct range_lock *mmrange); extern void unlock_page(struct page *page); static inline int trylock_page(struct page *page) @@ -504,10 +504,11 @@ static inline int lock_page_killable(struct page *page) * __lock_page_or_retry(). */ static inline int lock_page_or_retry(struct page *page, struct mm_struct *mm, - unsigned int flags) + unsigned int flags, + struct range_lock *mmrange) { might_sleep(); - return trylock_page(page) || __lock_page_or_retry(page, mm, flags); + return trylock_page(page) || __lock_page_or_retry(page, mm, flags, mmrange); } /* diff --git a/mm/filemap.c b/mm/filemap.c index 693f62212a59..6124ede79a4d 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1293,7 +1293,7 @@ EXPORT_SYMBOL_GPL(__lock_page_killable); * with the page locked and the mmap_sem unperturbed. */ int __lock_page_or_retry(struct page *page, struct mm_struct *mm, - unsigned int flags) + unsigned int flags, struct range_lock *mmrange) { if (flags & FAULT_FLAG_ALLOW_RETRY) { /* @@ -2529,7 +2529,8 @@ int filemap_fault(struct vm_fault *vmf) goto no_cached_page; } - if (!lock_page_or_retry(page, vmf->vma->vm_mm, vmf->flags)) { + if (!lock_page_or_retry(page, vmf->vma->vm_mm, vmf->flags, + vmf->lockrange)) { put_page(page); return ret | VM_FAULT_RETRY; } diff --git a/mm/memory.c b/mm/memory.c index 2d087b0e174d..5adcdc7dee80 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -2986,7 +2986,8 @@ int do_swap_page(struct vm_fault *vmf) goto out_release; } - locked = lock_page_or_retry(page, vma->vm_mm, vmf->flags); + locked = lock_page_or_retry(page, vma->vm_mm, vmf->flags, + vmf->lockrange); delayacct_clear_flag(DELAYACCT_PF_SWAPIN); if (!locked) { -- 2.13.6