From patchwork Mon Jan 9 20:53:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 13094303 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 AAB8CC54EBD for ; Mon, 9 Jan 2023 20:55:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 48EAE900004; Mon, 9 Jan 2023 15:55:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 43E7D900002; Mon, 9 Jan 2023 15:55:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3066E900004; Mon, 9 Jan 2023 15:55:16 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 1DA83900002 for ; Mon, 9 Jan 2023 15:55:16 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id F0AEEAB133 for ; Mon, 9 Jan 2023 20:55:15 +0000 (UTC) X-FDA: 80336465790.28.92C6F0E Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by imf06.hostedemail.com (Postfix) with ESMTP id 50A16180007 for ; Mon, 9 Jan 2023 20:55:14 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=C0RC5qgB; spf=pass (imf06.hostedemail.com: domain of 3MX-8YwYKCEY02zmvjowwotm.kwutqv25-uus3iks.wzo@flex--surenb.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3MX-8YwYKCEY02zmvjowwotm.kwutqv25-uus3iks.wzo@flex--surenb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673297714; a=rsa-sha256; cv=none; b=IYcLkIT+BT78T0SZABdHVN8EbMLksNXsxiX4GASqyVN2gx/JB+0N/lcjJBsdZQVaJeAe4n G3FGs9FTn9W7ZNx0uesYvz7TN5F5Rg7u2gsZORxEKX6uqdKw0TDzPN7ho24x6m7K7S806G J2GyTNyGd50kgkD+ngJOMfFX3D7nLQw= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=C0RC5qgB; spf=pass (imf06.hostedemail.com: domain of 3MX-8YwYKCEY02zmvjowwotm.kwutqv25-uus3iks.wzo@flex--surenb.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3MX-8YwYKCEY02zmvjowwotm.kwutqv25-uus3iks.wzo@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=1673297714; 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=JqE4Jv/Ie7jJyt+ylXoJ6xWWNYJ7mAmWvaygaHhGgmA=; b=4sNE5bxT6xmZBUK9aNMQlc72TJTBSG9uLtZJhiidFiKh1xZRpl24MK6UtJREHil5kLW2bj J+e7mSz595r98+09MCTH2q18Luh6UTn+FJ6aemyD2Q7jiAl61DUOzmElWzd8WVAmX/P8Sx 7LAnuBEl9jxLU+i/CRmZRHwPzrPPV6E= Received: by mail-yb1-f201.google.com with SMTP id z17-20020a25e311000000b00719e04e59e1so10334040ybd.10 for ; Mon, 09 Jan 2023 12:55:14 -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=JqE4Jv/Ie7jJyt+ylXoJ6xWWNYJ7mAmWvaygaHhGgmA=; b=C0RC5qgBD/V26736LQT1/agfFQE3oawoBsVodaZr+HfHKR+SKXSkxzHnqRRZUQyjCF /VKZZZ+vJ6kaEdIfo26R2t3ZnpRNnactrnv5DhopT9zYmpMMrFjwmeMN0NuvQGOG9Ma5 xgohCqYaIMlqK/c6f2BeWoXmU7iZ4/9gccjpi+n1Vpya+2P9xxgUSOybhe5uijKT6IMh I/M50QEDZcxaCjlrD2td9ExwPf2mPPj9P3UPSnAgQR/cCy9DPbczOjnWTPsq0XpCcdbi g/lQrqmdlC6kTELYjuH3lVXIdNQlERXCKK1DKiV3+4JsEhkwrKU78EAKu+F90rDI8Z8t c6mg== 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=JqE4Jv/Ie7jJyt+ylXoJ6xWWNYJ7mAmWvaygaHhGgmA=; b=hrR21YQk+WRJ0X9B3kQXrySMPO8UGPZJgz0bHNXg3hnCBsQzZIGsKvD4ZAQTTBmM6y Il+H2wdFJpANTbJtBaOL2tzbSqjeTLxWG7PMa0MWUhc2DATeLA4g0KIJir07REwfvA41 nYZ8DglFjN8sNSCcpqTSsuopYKUqvvTeu+q821lpo4Rusorw+QzKsIDZhNAHNWm5MVNn MCtNn3CmxlRu3iBqkZqdrjJ5e+ZHzcrNbSYWwFia3GL6HHcx+nXRh/KtDmlMyzxNc0fU Gucd8mX5lLIIhv9ZJbr0xQ2g7B9m9XSeSRF+A74+sOvfQlV74xWNvY9djV+ly4GJ8q8i EauQ== X-Gm-Message-State: AFqh2kqZ5OuXwPaB5icBCn2g6RNLIlLfLhZTBD0+vn41Dv0bTMaAc15/ N9BvLAxryoApAOZrno2t441lFy1ZtBs= X-Google-Smtp-Source: AMrXdXsVSd5Wz07hI5hxUAzF2wzs/BFzwaLObvOXI24uMhgcUHGkQCCTKMo/jOVrGruw6pJEAc/B3Pke/WM= X-Received: from surenb-desktop.mtv.corp.google.com ([2620:15c:211:200:9393:6f7a:d410:55ca]) (user=surenb job=sendgmr) by 2002:a0d:dbce:0:b0:4ad:7104:1f63 with SMTP id d197-20020a0ddbce000000b004ad71041f63mr3427748ywe.49.1673297713421; Mon, 09 Jan 2023 12:55:13 -0800 (PST) Date: Mon, 9 Jan 2023 12:53:32 -0800 In-Reply-To: <20230109205336.3665937-1-surenb@google.com> Mime-Version: 1.0 References: <20230109205336.3665937-1-surenb@google.com> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog Message-ID: <20230109205336.3665937-38-surenb@google.com> Subject: [PATCH 37/41] mm: introduce mod_vm_flags_nolock 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, laurent.dufour@fr.ibm.com, paulmck@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, axelrasmussen@google.com, joelaf@google.com, minchan@google.com, jannh@google.com, shakeelb@google.com, tatashin@google.com, edumazet@google.com, gthelen@google.com, gurua@google.com, arjunroy@google.com, soheil@google.com, hughlynch@google.com, leewalsh@google.com, posk@google.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, surenb@google.com X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 50A16180007 X-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mhVK6MC2i5vkY92LjR8Lcnd7+x17eAKruvxW6JOh+/El8YgLXryRz+YljEf+7SaRLOzduX+Zi19Sy1Lb9lq6ZI1oIKHR48SukKHC39Pe50GnJa2TMUVk+hjstJrDibz4BXVRLxsTUD+Vnf80z0fKQ3vHtASQ8kVb0ef6A0CgSlnB00RKItZXuAKbHJVodAPegKUd1Vd0Kp1WAbjZTslVU2ZokgSz21KENvYA6/3h5V4GSE1dTkmpnugvisTOlCscfqQLajgda6++Iz1uuHHYc9Z8bxOX9U2hVRRI0CUiip55W8aMR7poqRgtncCwmRFdNn3gt9/cEqJ99kNyNjSlOsh9eF6wd9KY38iQlds4+k7Wry2SbGTsSPCjjVNpRU1o5R8+dE9mBI0dTGn X-Bogosity: Ham, tests=bogofilter, spamicity=0.000023, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: In cases when VMA flags are modified after VMA was isolated and mmap_lock was downgraded, flags modifications do not require per-VMA locking and an attempt to lock the VMA would result in an assertion because mmap write lock is not held. Introduce mod_vm_flags_nolock to be used in such situation. Signed-off-by: Suren Baghdasaryan --- include/linux/mm.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/linux/mm.h b/include/linux/mm.h index 2e3be1d45371..7d436a5027cc 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -743,6 +743,14 @@ void clear_vm_flags(struct vm_area_struct *vma, unsigned long flags) vma->vm_flags &= ~flags; } +static inline +void mod_vm_flags_nolock(struct vm_area_struct *vma, + unsigned long set, unsigned long clear) +{ + vma->vm_flags |= set; + vma->vm_flags &= ~clear; +} + static inline void mod_vm_flags(struct vm_area_struct *vma, unsigned long set, unsigned long clear)