Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp2727060pxb; Mon, 31 Jan 2022 03:02:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJybfZB6c2uROlP14XgEZ2A8+6gDxkToPukl/F6toZS7ssv+stA3VyQfZTP5v6qMf58YG0+m X-Received: by 2002:a17:907:8a20:: with SMTP id sc32mr16656800ejc.346.1643626950174; Mon, 31 Jan 2022 03:02:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643626950; cv=none; d=google.com; s=arc-20160816; b=grkUX5uqVrnWX2roiv151/M7rg9UqNYGjuhsYjMEkzuYGXtIBF0zrL7T1BOFgUMuYT pMH+X8imZlDB3ltrXIIClkg0999bEyZkYaTDJ7QcZX3O+GKAom+h4cZtGLLclM8RoZh6 5sXtIuxwqKoJ8F1BYhSXEywkF287DE24DdPULu1tbPfBkrmWU4daLal4R4Bz3E6Wsuew w/qoPbFZxXAVkqyj2J6GwweEDuWFOzxgFNJ1voy5xZyC+3F2iIhl3XtygkbjcFJkgOQR 0vtKW8Ss9skEIgffEowiEizA43YKngPeXUM/7dx7eX8lsPvnr61AtQuOIkXMWAqwdX1Q rp9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=hCAjH/3pJlWdfRDX/fRs7omFq2p1vEsDo9ifolTeLag=; b=XphiO8vHJ/4ysrSyZwcYi1HYS2xE6qVl/2cDHvPj3nT2I50xPBKvh4DgLAmuEgfnkC k61Co7VLJNkl0KVUDI2gqgWN90s/b6W7yGOB1Wn9dT1v93lVXFE+m5I1WKEEKGzxH4Jp 1GnJKVPRdJABt9xsjtDwq1hN1I/5kpYUdHpgYpk7vKn9pnnUvzlXxLll3pBqyaPLiGBp vTkGle9ZKbVu1Jo3mKkQ4yiZ7vU5iF1pzzhPLRx/5Ua/r9OrUZlrsDrwApF6+0Vc6Kxi qtWDLLMe46/N+EtGj5U04lvv6q0OO5ZK7Fqzzlc6BIIHOmNFAZ1qQhP6ZsDU+1g9KJXz gs5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (no key) header.i=@lespinasse.org; dkim=pass (test mode) header.i=@lespinasse.org header.s=srv-52-rsa header.b=6rMpX8Xr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lespinasse.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b5si2392860edx.330.2022.01.31.03.01.58; Mon, 31 Jan 2022 03:02:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=neutral (no key) header.i=@lespinasse.org; dkim=pass (test mode) header.i=@lespinasse.org header.s=srv-52-rsa header.b=6rMpX8Xr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lespinasse.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348768AbiA1NTJ (ORCPT + 99 others); Fri, 28 Jan 2022 08:19:09 -0500 Received: from server.lespinasse.org ([63.205.204.226]:47913 "EHLO server.lespinasse.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244259AbiA1NTI (ORCPT ); Fri, 28 Jan 2022 08:19:08 -0500 X-Greylist: delayed 540 seconds by postgrey-1.27 at vger.kernel.org; Fri, 28 Jan 2022 08:19:08 EST DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=lespinasse.org; i=@lespinasse.org; q=dns/txt; s=srv-52-ed; t=1643375407; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : from; bh=hCAjH/3pJlWdfRDX/fRs7omFq2p1vEsDo9ifolTeLag=; b=HD0KmvGGgLZfvgB0K6C7PZ2rjWPZ8D6sLYkWyssN+ArRq1kjZzSZeXmySfGfqBn5e2UgD l7WYntcAlUF3hoDCg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lespinasse.org; i=@lespinasse.org; q=dns/txt; s=srv-52-rsa; t=1643375407; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : from; bh=hCAjH/3pJlWdfRDX/fRs7omFq2p1vEsDo9ifolTeLag=; b=6rMpX8XrXHJaYfiULXAeV9/onNQ2iau6A3/0eyy0Ajx9IBierM3eTmEDSZnryrm8u8vOK zRgYb2OlZ0xmYkay8H2Xw2P+q2ZqxT2iT6wKbvP0K486GTNCDKkrTJygUZM364JXX6Vjs2q Sj5/WUtqMpz1J4KFYhCAaIV/fkttQSKOWpRLZOnJ79QT2k6Ku2COSOGbnNa3iiyrwgXzQsV kv9V8h3LE4zesq4+lw/VV+nCZWv0cnxN6kivDSKZXxm/93k+qVR/ZM7uBvrRtO6q9l4xqRw M1zrnzijpM7EP0TFMtLPZo8xECv1M1Odjsbe1Q5Tlo60BCX6L/rSKHLUwDGg== Received: from zeus.lespinasse.org (zeus.lespinasse.org [IPv6:fd00::150:0]) by server.lespinasse.org (Postfix) with ESMTPS id 08D59160969; Fri, 28 Jan 2022 05:10:07 -0800 (PST) Received: by zeus.lespinasse.org (Postfix, from userid 1000) id E1C6320476; Fri, 28 Jan 2022 05:10:06 -0800 (PST) From: Michel Lespinasse To: Linux-MM , linux-kernel@vger.kernel.org, Andrew Morton Cc: kernel-team@fb.com, Laurent Dufour , Jerome Glisse , Peter Zijlstra , Michal Hocko , Vlastimil Babka , Davidlohr Bueso , Matthew Wilcox , Liam Howlett , Rik van Riel , Paul McKenney , Song Liu , Suren Baghdasaryan , Minchan Kim , Joel Fernandes , David Rientjes , Axel Rasmussen , Andy Lutomirski , Michel Lespinasse Subject: [PATCH v2 12/35] mm: separate mmap locked assertion from find_vma Date: Fri, 28 Jan 2022 05:09:43 -0800 Message-Id: <20220128131006.67712-13-michel@lespinasse.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220128131006.67712-1-michel@lespinasse.org> References: <20220128131006.67712-1-michel@lespinasse.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This adds a new __find_vma() function, which implements find_vma minus the mmap_assert_locked() assertion. find_vma() is then implemented as an inline wrapper around __find_vma(). Signed-off-by: Michel Lespinasse --- drivers/gpu/drm/i915/i915_gpu_error.c | 4 ++-- include/linux/mm.h | 9 ++++++++- mm/mmap.c | 5 ++--- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c b/drivers/gpu/drm/i915/i915_gpu_error.c index 5ae812d60abe..94ab71a9b493 100644 --- a/drivers/gpu/drm/i915/i915_gpu_error.c +++ b/drivers/gpu/drm/i915/i915_gpu_error.c @@ -515,7 +515,7 @@ static void error_print_context(struct drm_i915_error_state_buf *m, } static struct i915_vma_coredump * -__find_vma(struct i915_vma_coredump *vma, const char *name) +__i915_find_vma(struct i915_vma_coredump *vma, const char *name) { while (vma) { if (strcmp(vma->name, name) == 0) @@ -529,7 +529,7 @@ __find_vma(struct i915_vma_coredump *vma, const char *name) static struct i915_vma_coredump * find_batch(const struct intel_engine_coredump *ee) { - return __find_vma(ee->vma, "batch"); + return __i915_find_vma(ee->vma, "batch"); } static void error_print_engine(struct drm_i915_error_state_buf *m, diff --git a/include/linux/mm.h b/include/linux/mm.h index 4600dbb98cef..6f7712179503 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2751,10 +2751,17 @@ extern int expand_upwards(struct vm_area_struct *vma, unsigned long address); #endif /* Look up the first VMA which satisfies addr < vm_end, NULL if none. */ -extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long addr); +extern struct vm_area_struct * __find_vma(struct mm_struct * mm, unsigned long addr); extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr, struct vm_area_struct **pprev); +static inline +struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr) +{ + mmap_assert_locked(mm); + return __find_vma(mm, addr); +} + /** * find_vma_intersection() - Look up the first VMA which intersects the interval * @mm: The process address space. diff --git a/mm/mmap.c b/mm/mmap.c index 1e8fdb0b51ed..b09a2c875507 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2276,12 +2276,11 @@ get_unmapped_area(struct file *file, unsigned long addr, unsigned long len, EXPORT_SYMBOL(get_unmapped_area); /* Look up the first VMA which satisfies addr < vm_end, NULL if none. */ -struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr) +struct vm_area_struct *__find_vma(struct mm_struct *mm, unsigned long addr) { struct rb_node *rb_node; struct vm_area_struct *vma; - mmap_assert_locked(mm); /* Check the cache first. */ vma = vmacache_find(mm, addr); if (likely(vma)) @@ -2308,7 +2307,7 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr) return vma; } -EXPORT_SYMBOL(find_vma); +EXPORT_SYMBOL(__find_vma); /* * Same as find_vma, but also return a pointer to the previous VMA in *pprev. -- 2.20.1