From patchwork Mon Feb 27 17:36:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 13153976 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 38708C64ED6 for ; Mon, 27 Feb 2023 17:37:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C5B1E6B008A; Mon, 27 Feb 2023 12:37:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B95456B0092; Mon, 27 Feb 2023 12:37:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A352A6B0093; Mon, 27 Feb 2023 12:37:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 95E576B008A for ; Mon, 27 Feb 2023 12:37:10 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 69E4E140B01 for ; Mon, 27 Feb 2023 17:37:10 +0000 (UTC) X-FDA: 80513777820.19.FEAF4AB Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) by imf12.hostedemail.com (Postfix) with ESMTP id ACCDF40023 for ; Mon, 27 Feb 2023 17:37:08 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=XBhlBuuW; spf=pass (imf12.hostedemail.com: domain of 3Q-r8YwYKCDIgifSbPUccUZS.QcaZWbil-aaYjOQY.cfU@flex--surenb.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3Q-r8YwYKCDIgifSbPUccUZS.QcaZWbil-aaYjOQY.cfU@flex--surenb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1677519428; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=I212iwzKiM4RAh4/x5atSdllFVTlqkGJNP08f3JbnWQ=; b=R/IwkxRpbpX2L3L2tyMs9Vsu8TfQg63i+O9mVSmm7i9h0nFDZR6H2wrH3UAB5sbHgbVOks SbcBRGwl0ki+RwvOS+ym46vc9m4TQNIvta/eeJU6T5ovy92GOEB4bSGp38rPJSV2GdSXIw vfeK4o5gUyYWg4xVlL2S1Q8I2JLhYDs= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=XBhlBuuW; spf=pass (imf12.hostedemail.com: domain of 3Q-r8YwYKCDIgifSbPUccUZS.QcaZWbil-aaYjOQY.cfU@flex--surenb.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3Q-r8YwYKCDIgifSbPUccUZS.QcaZWbil-aaYjOQY.cfU@flex--surenb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677519428; a=rsa-sha256; cv=none; b=0lPq25YniqNQYLw1tNNeMACqCqoXJVZ8YMkge9WQ41mVr7doLHET6lYWPGkyIsZx3HXs0e kid3Gh4Ieke+K+wwQfRK8uP4ecz6DQ0ohvN0XOYgLj6b1k/qduNli/537NiikCuWzjDrLX 5e8dNUW+qlhhXISXW917OU40zAJ2JFI= Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-536d63d17dbso154505707b3.22 for ; Mon, 27 Feb 2023 09:37:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=I212iwzKiM4RAh4/x5atSdllFVTlqkGJNP08f3JbnWQ=; b=XBhlBuuWfB0rAIGd6hmSTNeCzmJSeNc8sCljBThxSUCF4xl/MSw7wD8HJnBQqXsjUJ 57kJQANXg6fNdWd8Pt4eiSrUjDCyUw1I4L84NqCzMgqp7jq/T8VmsbuNmrFrLa4O4XYU GqAQJ+b6Oca+hy9pxgzol0kd/HIC9ER2wtl/KEZHOhFYwY8HxJnljLvK30eOyvBMk653 HhqyRDcfvr4BXt/19NWrR6/WQesJSjC/tN0jtggmEFB14E/QwVd/f4szWEolKHRDFF2I b8hGsHDba//nCM47ED9hrsor6X6kCcWnUTvy8GzRTm8e9DVF7x8YXaJ1E8nG+/bnJf9E 7yEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=I212iwzKiM4RAh4/x5atSdllFVTlqkGJNP08f3JbnWQ=; b=wFQA6wHPvYFcQOzC2xuzKo3CZ6x+gSAdxcp6EGKIRpTPx8bw1dbFd2IOgGQpn1JYf3 mst9GFZrRvmREFI6Oww25d+Xy07LvMWWTg45Ima2B6ODnH2rK9XzewvE69gwnL3j/Nhz PJIo5zehvFUZM7I76qXormA0zl0S22AAC8XLZqH9nTTcGhxhMwlKAeS5cdfofUbmiTZ1 pEwiBkVus09dEOKd6vd6FcWZkOB9RpyBo54dR4up8/vQE+81oTkN9HUV8H698mZWTRzv tWg+zv8M9PaUuoRu725jEXJQ0RxdY9Op1nKXvQ/Su+wWaIS1lEuGY0LqRuIPmLTtv3R5 A/GA== X-Gm-Message-State: AO0yUKUN53d26EhEYuxL8Pat0Go5h4d4Nn1Jx1f7FSi/i+7zpnDIo9bk SM0oawL1unFQP8bw5ELdRd2bb3h7fzk= X-Google-Smtp-Source: AK7set92Gr75A5uaM9VLoSN3m2+g8CdJzSD2poMBi0hZE65OwRnSrd/3zaVdEb4P76h2ChlMWirB5h4UQZs= X-Received: from surenb-desktop.mtv.corp.google.com ([2620:15c:211:200:e1f6:21d1:eead:3897]) (user=surenb job=sendgmr) by 2002:a5b:a4b:0:b0:a06:5ef5:3a82 with SMTP id z11-20020a5b0a4b000000b00a065ef53a82mr7473143ybq.5.1677519427726; Mon, 27 Feb 2023 09:37:07 -0800 (PST) Date: Mon, 27 Feb 2023 09:36:12 -0800 In-Reply-To: <20230227173632.3292573-1-surenb@google.com> Mime-Version: 1.0 References: <20230227173632.3292573-1-surenb@google.com> X-Mailer: git-send-email 2.39.2.722.g9855ee24e9-goog Message-ID: <20230227173632.3292573-14-surenb@google.com> Subject: [PATCH v4 13/33] mm: mark VMA as being written when changing vm_flags From: Suren Baghdasaryan To: akpm@linux-foundation.org Cc: michel@lespinasse.org, jglisse@google.com, mhocko@suse.com, vbabka@suse.cz, hannes@cmpxchg.org, mgorman@techsingularity.net, dave@stgolabs.net, willy@infradead.org, liam.howlett@oracle.com, peterz@infradead.org, ldufour@linux.ibm.com, paulmck@kernel.org, mingo@redhat.com, will@kernel.org, luto@kernel.org, songliubraving@fb.com, peterx@redhat.com, david@redhat.com, dhowells@redhat.com, hughd@google.com, bigeasy@linutronix.de, kent.overstreet@linux.dev, punit.agrawal@bytedance.com, lstoakes@gmail.com, peterjung1337@gmail.com, rientjes@google.com, chriscli@google.com, axelrasmussen@google.com, joelaf@google.com, minchan@google.com, rppt@kernel.org, jannh@google.com, shakeelb@google.com, tatashin@google.com, edumazet@google.com, gthelen@google.com, gurua@google.com, arjunroy@google.com, soheil@google.com, leewalsh@google.com, posk@google.com, michalechner92@googlemail.com, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, x86@kernel.org, linux-kernel@vger.kernel.org, kernel-team@android.com, Suren Baghdasaryan X-Rspamd-Server: rspam07 X-Rspamd-Que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4OJ rEAkF3UdoBxtZFRMci1gJIyarBLZaFP3zbU0mBaiTvBbiLRzcwAUTsNAuMdrsWHUpttHL7VJnk3htf3tVxLUloR/zfIvNObprwddHcSdnwCBCTEES7pyZYoM/gRbNXGBH0/VGzWMe86sHWL5Pmc8wdz9zrpgL69IrnDDw++ZbZoYsAJo+dW2b0mdAXyZizf3N3GvPSAYeblr0joFyFMAh6/T6lIQn6MZFHOudAdgXx5LCtFd4a0zun4jWcZsPWuwYPsJWeFOOcUUadMU029WPM4eR/HxcOlhzqcy56qG0tSdMbhpX++g72Fo7pioS9dUODIyqhxUbDsqKhd8w8m29gYMz5WHv1TqoYcxY+lReO/i9wPtxMLI7nD2oxa4ySwjY3ICRzjtDxum90ptFcRQpwlcaetdJwQrDBlDrFJdGbaSldcYyF7nigRo/Vw0KPmvaMhugzJWICHFJtBl0hhFWGE52p6mvFAErB3VAQxCkZ7Dsn0wQpksVLnYnz3DVgvy8ipVvGxTpgA8eC0iqSNcMo8tTK0vHAb2FRrsOLRZif9rIgBz364e5DurMyuEYUUgOdcXZC5p+Eu78QuuH3D/ixdXH3PXZt351P2qsurU/iGM06NE0MurkF2P6oCFU2wLSwUEA5zLiK84n31jd/2Isw9u0IHlPsQYQbwT5bryD7XACkks= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000028, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Updates to vm_flags have to be done with VMA marked as being written for preventing concurrent page faults or other modifications. Signed-off-by: Suren Baghdasaryan --- include/linux/mm.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index bbad5d4fa81b..3d5e8666892d 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -726,28 +726,28 @@ static inline void vm_flags_init(struct vm_area_struct *vma, static inline void vm_flags_reset(struct vm_area_struct *vma, vm_flags_t flags) { - mmap_assert_write_locked(vma->vm_mm); + vma_start_write(vma); vm_flags_init(vma, flags); } static inline void vm_flags_reset_once(struct vm_area_struct *vma, vm_flags_t flags) { - mmap_assert_write_locked(vma->vm_mm); + vma_start_write(vma); WRITE_ONCE(ACCESS_PRIVATE(vma, __vm_flags), flags); } static inline void vm_flags_set(struct vm_area_struct *vma, vm_flags_t flags) { - mmap_assert_write_locked(vma->vm_mm); + vma_start_write(vma); ACCESS_PRIVATE(vma, __vm_flags) |= flags; } static inline void vm_flags_clear(struct vm_area_struct *vma, vm_flags_t flags) { - mmap_assert_write_locked(vma->vm_mm); + vma_start_write(vma); ACCESS_PRIVATE(vma, __vm_flags) &= ~flags; } @@ -768,7 +768,7 @@ static inline void __vm_flags_mod(struct vm_area_struct *vma, static inline void vm_flags_mod(struct vm_area_struct *vma, vm_flags_t set, vm_flags_t clear) { - mmap_assert_write_locked(vma->vm_mm); + vma_start_write(vma); __vm_flags_mod(vma, set, clear); }