From patchwork Mon Feb 24 20:30:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michel Lespinasse X-Patchwork-Id: 11401521 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 07D1514BC for ; Mon, 24 Feb 2020 20:31:55 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C927320675 for ; Mon, 24 Feb 2020 20:31:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Glj9B/Y7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C927320675 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B15FB6B00A3; Mon, 24 Feb 2020 15:31:48 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A9E3A6B00A5; Mon, 24 Feb 2020 15:31:48 -0500 (EST) 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 9687F6B00A6; Mon, 24 Feb 2020 15:31:48 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0082.hostedemail.com [216.40.44.82]) by kanga.kvack.org (Postfix) with ESMTP id 6FA326B00A3 for ; Mon, 24 Feb 2020 15:31:48 -0500 (EST) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 26F6A40C0 for ; Mon, 24 Feb 2020 20:31:48 +0000 (UTC) X-FDA: 76526166696.08.veil31_2cc4dc772be5e X-Spam-Summary: 2,0,0,1605ba4706f6ff6d,d41d8cd98f00b204,3sjjuxgykcgev9kjdmfnnfkd.bnlkhmtw-llju9bj.nqf@flex--walken.bounces.google.com,,RULES_HIT:41:152:355:379:541:800:960:973:988:989:1260:1277:1313:1314:1345:1359:1437:1516:1518:1535:1542:1593:1594:1711:1730:1747:1777:1792:2194:2199:2393:2553:2559:2562:2897:2901:3138:3139:3140:3141:3142:3152:3354:3865:3866:3867:3868:3870:3871:3872:3874:4250:4321:4605:5007:6117:6119:6120:6261:6653:7875:7903:9969:10004:10400:11026:11658:11914:12048:12296:12297:12438:12555:12895:12986:13138:13231:13255:14096:14097:14181:14659:14721:21080:21324:21433:21444:21451:21627:21939:21987:30003:30054:30079:30090,0,RBL:209.85.214.202:@flex--walken.bounces.google.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: veil31_2cc4dc772be5e X-Filterd-Recvd-Size: 5586 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) by imf16.hostedemail.com (Postfix) with ESMTP for ; Mon, 24 Feb 2020 20:31:47 +0000 (UTC) Received: by mail-pl1-f202.google.com with SMTP id bg1so5803898plb.3 for ; Mon, 24 Feb 2020 12:31:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=hQJJGIfKlPWJhXpFrBvZnFayUmsKuvDqJ26xz/hSLSQ=; b=Glj9B/Y7YNr21pwvtNdzXJRSXkVJeoFcNHteCV698Yv5xJvYDoMJKcfzMb4XoU52DN yxigyrKTVz8jHS7urDTJFc9PxmNXubZD4WW6qTkNfEDebkLY5B7x7UWhEjRdp10MITe5 eI0uC0inHO1x1Xk6QNJaqqNwBRhhkfR805CJN1GgleGiIeTyHy837t3MwPycv0N4b1Wh iyPf/KVdvUgL7OpR/CZ5BvzrItmpRuXOl/s9iAqaacQH7/uqTOY8kpw8t+hvtuTlTkDD x/nQJhgu4nfEnIXM5V43Ctmjx3NaSPFqpPoj0iUKtbwUnsS1lUUDGD6E7dPIJILPVT4J NToA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=hQJJGIfKlPWJhXpFrBvZnFayUmsKuvDqJ26xz/hSLSQ=; b=KgME2OJbqbjh/oYdmQww+kcJQAoYab7Jt4IVAK08ywaU18jstagIf41hwxGNQUaK1a 8xr7asvPmQfRQLGVDPQjk4tr1nCJ8i57iFuCdMYzHc99V84EqE/yq9UoqHd8bNZf7/Eo wiSmFRXIDh/6KBIba7d1YtDkmhxkI1Lg5EKHFEkRPRRh8yAOULPAj4/i1OkzJ4E7meYU 8qiGiXUMHayYuyuGbbG+0x/99tSEFW3RqRlIWVwgcq72yX+2xcRYYBFI5iQew/gyBwlR Q+vQjAjMeyfp84ZlieIEkijPNUs8fUeYqTs+GFXJ/DcoHBOwX+bB32MK0nEnGTY0Dws3 pwbg== X-Gm-Message-State: APjAAAW9FGt3DRnyIq1+w5TKdbz1iATQoxQuWOTgxiELTt6NbXBpwp1S P21XiMKr/CeksbrUzZDZf8clRlx1HBk= X-Google-Smtp-Source: APXvYqxD3h+beDo9kHF4/QLU/da7YhklCHehR0CWfzHl0+E1/psedGpl+sAOl/EfDuyAIn6m+RIE8hPkuZ0= X-Received: by 2002:a63:7a1a:: with SMTP id v26mr10677760pgc.152.1582576306483; Mon, 24 Feb 2020 12:31:46 -0800 (PST) Date: Mon, 24 Feb 2020 12:30:52 -0800 In-Reply-To: <20200224203057.162467-1-walken@google.com> Message-Id: <20200224203057.162467-20-walken@google.com> Mime-Version: 1.0 References: <20200224203057.162467-1-walken@google.com> X-Mailer: git-send-email 2.25.0.265.gbab2e86ba0-goog Subject: [RFC PATCH 19/24] mm: add field to annotate vm_operations that support range locking From: Michel Lespinasse To: Peter Zijlstra , Andrew Morton , Laurent Dufour , Vlastimil Babka , Matthew Wilcox , "Liam R . Howlett" , Jerome Glisse , Davidlohr Bueso , David Rientjes Cc: linux-mm , Michel Lespinasse 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: Add a fine_grained field to struct vm_operations_struct, and set it in the filesystems we have converted to support range locking. Signed-off-by: Michel Lespinasse --- fs/ext4/file.c | 1 + include/linux/mm.h | 16 ++++++++++++++++ mm/filemap.c | 1 + mm/shmem.c | 1 + 4 files changed, 19 insertions(+) diff --git fs/ext4/file.c fs/ext4/file.c index 6a7293a5cda2..8167fc7cc6ca 100644 --- fs/ext4/file.c +++ fs/ext4/file.c @@ -626,6 +626,7 @@ static const struct vm_operations_struct ext4_file_vm_ops = { .fault = ext4_filemap_fault, .map_pages = filemap_map_pages, .page_mkwrite = ext4_page_mkwrite, + .fine_grained = true, }; static int ext4_file_mmap(struct file *file, struct vm_area_struct *vma) diff --git include/linux/mm.h include/linux/mm.h index 43b7121ae005..28b6af200214 100644 --- include/linux/mm.h +++ include/linux/mm.h @@ -526,6 +526,22 @@ struct vm_operations_struct { */ struct page *(*find_special_page)(struct vm_area_struct *vma, unsigned long addr); + + /* + * fine_grained indicates that the vm_operations support + * fine grained mm locking. + * - The methods may be called with a fine grained range lock + * covering a PMD sized region around the fault address; + * - The range lock does not protect against concurrent access + * to per-mmmm structures, so an appropriate lock must be used + * for such cases + * (such as mm_vma_lock() for accessing the vma rbtree); + * - if dropping mmap_sem, the vmf->range must be used + * to release the specific locked range only; + * - vmf->vma only holds a copy of the original vma. + * Any persistent vma updates must first look up the actual vma. + */ + bool fine_grained; }; static inline void vma_init(struct vm_area_struct *vma, struct mm_struct *mm) diff --git mm/filemap.c mm/filemap.c index 7827de7b356c..c9f95ca5737c 100644 --- mm/filemap.c +++ mm/filemap.c @@ -2699,6 +2699,7 @@ const struct vm_operations_struct generic_file_vm_ops = { .fault = filemap_fault, .map_pages = filemap_map_pages, .page_mkwrite = filemap_page_mkwrite, + .fine_grained = true, }; /* This is used for a general mmap of a disk file */ diff --git mm/shmem.c mm/shmem.c index 8793e8cc1a48..32ec4ad05df5 100644 --- mm/shmem.c +++ mm/shmem.c @@ -3865,6 +3865,7 @@ static const struct vm_operations_struct shmem_vm_ops = { .set_policy = shmem_set_policy, .get_policy = shmem_get_policy, #endif + .fine_grained = true, }; int shmem_init_fs_context(struct fs_context *fc)