From mboxrd@z Thu Jan 1 00:00:00 1970 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 8BEA2C61DA4 for ; Thu, 23 Feb 2023 20:34:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B70556B0073; Thu, 23 Feb 2023 15:34:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AF9A06B0074; Thu, 23 Feb 2023 15:34:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 974BA6B0075; Thu, 23 Feb 2023 15:34:27 -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 847696B0073 for ; Thu, 23 Feb 2023 15:34:27 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 20C36A056C for ; Thu, 23 Feb 2023 20:34:27 +0000 (UTC) X-FDA: 80499709374.12.A64C27A Received: from mail-yw1-f181.google.com (mail-yw1-f181.google.com [209.85.128.181]) by imf02.hostedemail.com (Postfix) with ESMTP id 6487E8000F for ; Thu, 23 Feb 2023 20:34:25 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=Bjdh4smk; spf=pass (imf02.hostedemail.com: domain of surenb@google.com designates 209.85.128.181 as permitted sender) smtp.mailfrom=surenb@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=1677184465; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=f5E7QcOom432WfEB2tmrrxUq3oMwXLGBGrJE5okH/nk=; b=35E6CFqnTIhpqvx8PD4/H0YwY8FmTvwFnlFChW5KbuGqFamKuA8LEWaYRCxod3bNuzc/Fs Ol2Yw1LIohbM6lF7xdh3hJMjHBA1inbyQF7Yub9ofvw3djYfK8lFSy+Au17AxygTVRzzNj DFDdM9RkEk7OhBAAmrK8qnMwL3hNW78= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=Bjdh4smk; spf=pass (imf02.hostedemail.com: domain of surenb@google.com designates 209.85.128.181 as permitted sender) smtp.mailfrom=surenb@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677184465; a=rsa-sha256; cv=none; b=7/f2nlaz0EXyl5tuHC68n+b2lTZDmhIkbBiUxfBKPVAgbsd4/YAEXSOwl7Kd3HpsraCSWN JPL5+R4oV2ZVXSZyBbs+D0U+u0u3gDcWRhu3u5DzCMtjY5n5KU4rLCDpdVCQnD8/I0/UI8 7Xf/XKIrqIgU3wviJl1+pQEwrMa5aIs= Received: by mail-yw1-f181.google.com with SMTP id 00721157ae682-536cd8f6034so192294447b3.10 for ; Thu, 23 Feb 2023 12:34:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=f5E7QcOom432WfEB2tmrrxUq3oMwXLGBGrJE5okH/nk=; b=Bjdh4smkRYXHxyJxf+ZPmX1mSDOmm08FE7XfZXgXnwbjIj0Tr92u5+3ShwG8tiACzc Pof9mljBUaqOQTUVIM1dPEXeIO1n+vfqVjaajcfSb8uDjDpKkcLttKpyU2C/2S7lm+mf q42lTgGSPo9zGGLJRWqST8W0nNri4Cxbg2MLkL5MQ6ukmU00c89ISaqbm900QLcuYhEk e1er6rludgb8W/NHr6xfiascVRAJzEMxgbqRxRdgHwX2szDjjBMtfu1HahnMjBS55yLo r4VLNPUnUIUZes9CuFCJgSxvTSuqgxT8D/GUbu3fifQqAgmc+BacynLKLTXkq8fdqCqW 2X6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=f5E7QcOom432WfEB2tmrrxUq3oMwXLGBGrJE5okH/nk=; b=4Tuw5uE6lu3Zoc+TdNPj716vGLpQ3cbJUukw2GYm3k2IpyUalhOPfeJRPWE+LrFN5b wlHLbRUG9ey7JwP4W0VCUrZykWUpfH9jzRNfqda19QI1qmJ+G2tDg1PE/v/Z3sC2jiVv sRmiYfk1mX6UMVriYF4Tda66jBPsZaxUKVJZ4dcRP0ijmq+pMK+04O0orjSBNbFpNWgI E6xuLUbicwdfDS/bxA7EZC5A1Rstqro6be7WVyReA5jy4J8CKfuqAXBY86jmDxnWfKPu GmVnUeyYnGFGLABFB5XgilJU5ZeZPOpRmtruJaH42eimOGuf0GvH8uGr3rgFoShfZUON 7q+A== X-Gm-Message-State: AO0yUKUaq9NjeDgqLXrVZW62BrCGk+GwunvDr6n+dGRaIWT+CjzrpQav pVcKnhuAvacjiO3xxikh7/COqmjXEm/oM4g8YvR2CQ== X-Google-Smtp-Source: AK7set9Te/5uWtt5zt1fQaHwXqFRJISgrOCqlFEddaHqmIZQDT7I+U9PTLYweByzGpk4rUIUZlowo03Z5xLHHDmLpLE= X-Received: by 2002:a5b:b07:0:b0:9fe:1493:8b8 with SMTP id z7-20020a5b0b07000000b009fe149308b8mr2417322ybp.6.1677184464289; Thu, 23 Feb 2023 12:34:24 -0800 (PST) MIME-Version: 1.0 References: <20230216051750.3125598-1-surenb@google.com> <20230216051750.3125598-25-surenb@google.com> <20230223200800.5cydej7s2ybafuaf@revolver> In-Reply-To: <20230223200800.5cydej7s2ybafuaf@revolver> From: Suren Baghdasaryan Date: Thu, 23 Feb 2023 12:34:13 -0800 Message-ID: Subject: Re: [PATCH v3 24/35] mm: introduce vma detached flag To: "Liam R. Howlett" , Suren Baghdasaryan , akpm@linux-foundation.org, michel@lespinasse.org, jglisse@google.com, mhocko@suse.com, vbabka@suse.cz, hannes@cmpxchg.org, mgorman@techsingularity.net, dave@stgolabs.net, willy@infradead.org, 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 Content-Type: text/plain; charset="UTF-8" X-Stat-Signature: ot46gnzpyfuoomwn3z534hmguisn849s X-Rspam-User: X-Rspamd-Queue-Id: 6487E8000F X-Rspamd-Server: rspam06 X-HE-Tag: 1677184465-863246 X-HE-Meta: U2FsdGVkX19Asve6VJsCPNtZmM3/gLSTjAbE4VYuAUmx/ynjFWeVDL2EcsCSP89wOqcTFQuVTmiBM0bK5PXL7Kgp+pfgMnRHIQ/KR5FBwbydcmuvO0ylz5ZVjQsAaZpokoyERlobkAO26UhI1qYdhKLQKrjseTg4yK0HUfv3XkGP1rbcACnY5IaoPGoUHeL8Vd4UKMsFDHRe8rM8J2LGymt3k9rfHsbRn9c+JdU0HKCoo66AYDsEjPj9TprVn9tqLPsIRwkESlXD8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, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Feb 23, 2023 at 12:08 PM Liam R. Howlett wrote: > > > Can we change this to active/inactive? I think there is potential for > reusing this functionality to even larger degrees and that name would > fit better and would still make sense in this context. > > ie: vma_mark_active() and vma_mark_inactive() ? Those names sound too generic (not obvious what active/inactive means), while detached/isolated I think is more clear and specific. Does not really make a huge difference to me but maybe you can come up with better naming that addresses my concern and meets your usecase? > > * Suren Baghdasaryan [230216 00:18]: > > Per-vma locking mechanism will search for VMA under RCU protection and > > then after locking it, has to ensure it was not removed from the VMA > > tree after we found it. To make this check efficient, introduce a > > vma->detached flag to mark VMAs which were removed from the VMA tree. > > > > Signed-off-by: Suren Baghdasaryan > > --- > > include/linux/mm.h | 11 +++++++++++ > > include/linux/mm_types.h | 3 +++ > > mm/mmap.c | 2 ++ > > 3 files changed, 16 insertions(+) > > > > diff --git a/include/linux/mm.h b/include/linux/mm.h > > index f4f702224ec5..3f98344f829c 100644 > > --- a/include/linux/mm.h > > +++ b/include/linux/mm.h > > @@ -693,6 +693,14 @@ static inline void vma_assert_write_locked(struct vm_area_struct *vma) > > VM_BUG_ON_VMA(vma->vm_lock_seq != READ_ONCE(vma->vm_mm->mm_lock_seq), vma); > > } > > > > +static inline void vma_mark_detached(struct vm_area_struct *vma, bool detached) > > +{ > > + /* When detaching vma should be write-locked */ > > + if (detached) > > + vma_assert_write_locked(vma); > > + vma->detached = detached; > > +} > > + > > #else /* CONFIG_PER_VMA_LOCK */ > > > > static inline void vma_init_lock(struct vm_area_struct *vma) {} > > @@ -701,6 +709,8 @@ static inline bool vma_start_read(struct vm_area_struct *vma) > > static inline void vma_end_read(struct vm_area_struct *vma) {} > > static inline void vma_start_write(struct vm_area_struct *vma) {} > > static inline void vma_assert_write_locked(struct vm_area_struct *vma) {} > > +static inline void vma_mark_detached(struct vm_area_struct *vma, > > + bool detached) {} > > > > #endif /* CONFIG_PER_VMA_LOCK */ > > > > @@ -712,6 +722,7 @@ static inline void vma_init(struct vm_area_struct *vma, struct mm_struct *mm) > > vma->vm_mm = mm; > > vma->vm_ops = &dummy_vm_ops; > > INIT_LIST_HEAD(&vma->anon_vma_chain); > > + vma_mark_detached(vma, false); > > vma_init_lock(vma); > > } > > > > diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h > > index e268723eaf44..939f4f5a1115 100644 > > --- a/include/linux/mm_types.h > > +++ b/include/linux/mm_types.h > > @@ -511,6 +511,9 @@ struct vm_area_struct { > > #ifdef CONFIG_PER_VMA_LOCK > > int vm_lock_seq; > > struct rw_semaphore lock; > > + > > + /* Flag to indicate areas detached from the mm->mm_mt tree */ > > + bool detached; > > #endif > > > > /* > > diff --git a/mm/mmap.c b/mm/mmap.c > > index 801608726be8..adf40177e68f 100644 > > --- a/mm/mmap.c > > +++ b/mm/mmap.c > > @@ -593,6 +593,7 @@ static inline void vma_complete(struct vma_prepare *vp, > > > > if (vp->remove) { > > again: > > + vma_mark_detached(vp->remove, true); > > if (vp->file) { > > uprobe_munmap(vp->remove, vp->remove->vm_start, > > vp->remove->vm_end); > > @@ -2267,6 +2268,7 @@ static inline int munmap_sidetree(struct vm_area_struct *vma, > > if (mas_store_gfp(mas_detach, vma, GFP_KERNEL)) > > return -ENOMEM; > > > > + vma_mark_detached(vma, true); > > if (vma->vm_flags & VM_LOCKED) > > vma->vm_mm->locked_vm -= vma_pages(vma); > > > > -- > > 2.39.1 > > > > -- > To unsubscribe from this group and stop receiving emails from it, send an email to kernel-team+unsubscribe@android.com. >