From patchwork Thu Nov 21 16:28:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 13882135 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 1435AD78788 for ; Thu, 21 Nov 2024 16:28:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3B4766B0088; Thu, 21 Nov 2024 11:28:34 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3637A6B0089; Thu, 21 Nov 2024 11:28:34 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1DD246B008A; Thu, 21 Nov 2024 11:28:34 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 006986B0088 for ; Thu, 21 Nov 2024 11:28:33 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id A610BADFD1 for ; Thu, 21 Nov 2024 16:28:33 +0000 (UTC) X-FDA: 82810633668.10.AB1E19A Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by imf19.hostedemail.com (Postfix) with ESMTP id 7C1D01A0006 for ; Thu, 21 Nov 2024 16:27:25 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=0LAmIRo4; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf19.hostedemail.com: domain of 3rl8_ZwYKCKsdfcPYMRZZRWP.NZXWTYfi-XXVgLNV.ZcR@flex--surenb.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3rl8_ZwYKCKsdfcPYMRZZRWP.NZXWTYfi-XXVgLNV.ZcR@flex--surenb.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1732206444; a=rsa-sha256; cv=none; b=dEjwATT2fw4lJ2+hQCYmIxbMVahAdj3Ow1UIBCUGG+eyZzotHdBOcuXhwGoohQ8TgxYgqm M0AdZCk0McdxS9gjZHbNlOrRh2GS6BwLeirZH+dugphlZZ++lc2M5GT4fn/HQOIRkojpCr LY+vZGSwqimsJftKkkvxYOvo94M6Hb8= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=0LAmIRo4; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf19.hostedemail.com: domain of 3rl8_ZwYKCKsdfcPYMRZZRWP.NZXWTYfi-XXVgLNV.ZcR@flex--surenb.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3rl8_ZwYKCKsdfcPYMRZZRWP.NZXWTYfi-XXVgLNV.ZcR@flex--surenb.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1732206444; 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=BJ8UTjZk7jir+LycT80EIvFwdpwWL3Ztdnpnjs747EY=; b=3Pm5dPYrumVua+I2OiUbWuE6TlRu9+DVBY2ibynaFIBZnGUJmF05i8KI5Y+HT8e8d9iYgO sogNeahUv6HIZNKPO4Z1eEouRx5iIVfvpqhh6fwkWNiYk7V/5kp83PnOpb911eYTQ31eNC xiYRa8DkstRmVBdJNKT4e/IFODDljr0= Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e38902a3200so1761144276.2 for ; Thu, 21 Nov 2024 08:28:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1732206511; x=1732811311; darn=kvack.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=BJ8UTjZk7jir+LycT80EIvFwdpwWL3Ztdnpnjs747EY=; b=0LAmIRo4f79jgyLATiZs+krQmQIVFNAWE+xEJZ4DCfRs5ftVn1Q1bZscTn7SlmW95K n+L5efriiz7SV+KSigDhbAObDYeT9eTMNZ3G0PAS9rM4NRYA94ESR3b1c78GpjJ7m34P QgL69875mrfSxah9bKjWUNlTT4LvwBkNTnYUTMk4E24k60bDIpJjLcIhqw+m4PiE+zrW st+LmUUxyMJ0n6ptd25FrgjMGY4atOcFAri3Aqh47au62SWrDKKWpwZsGeywGxdBn8HV CKR7CPQywGx0VZHgPtglINQ+nrPZO6wll4pyPciNmzHeB+4Dda5L75I2gFsyJIQr5cn6 Otkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732206511; x=1732811311; 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=BJ8UTjZk7jir+LycT80EIvFwdpwWL3Ztdnpnjs747EY=; b=f087Zk0kHAFOxOmzFvY7ubyuxrBIC0/2rFcjBfkJ+NSOb9E8fMf7jrs+drHf3pAXeo +X5OXviv7xT7as82xUJk0wsmfXT2q5vASrDQB2WBHscJoGbr7trhb2IM7aVv1mJiIcDH lA7IOiAZ8vRUHS7TYSR18RatW3E43YKamP3fy9NYBLTO8ZOzYXjmMdEqFNuJl1gOIV8j Rw4v+2t6iqyvsQxDtze2xKO5HnAViuKoJrwErxc1Uw2HHmKyDefnj74f7VOD37X9R++C HwLZ63yOopIhK0BmEyYDJ5r+feoedM0tdM+4HicYb1rK6uoyhLqlifkk+mrq7UmK3CGU OZ0w== X-Forwarded-Encrypted: i=1; AJvYcCVfOYAcSGk2Pb6OOaSa6FNYckdBWoMjnu9P71gYU+Dz7aEeH3HFJP+GeI582KMRICksjvQhrGcdSg==@kvack.org X-Gm-Message-State: AOJu0Yw8XJNIQxL9D/HCf68cL4qhp/swp1IhuFR4U2Ed1tkhV+MH7i3P mUjFGb211H0ksytleUWc6HN6Gq/z9y6e4P3Lg/FKhQGHhWITTYwxss3ujrBaGdXCQq7FsRrpRvH rSA== X-Google-Smtp-Source: AGHT+IEiWQTUWgLiCmkwi9eVp67gN+iglBj6XKTbng/qFRBIlXjEnuyDXqw9cHcVPHq3FWFlD33DHj9qCN0= X-Received: from surenb-desktop.mtv.corp.google.com ([2a00:79e0:2e3f:8:ab6:ec44:b69c:2388]) (user=surenb job=sendgmr) by 2002:a25:8811:0:b0:e25:6701:410b with SMTP id 3f1490d57ef6-e38cb5f7069mr34619276.5.1732206510848; Thu, 21 Nov 2024 08:28:30 -0800 (PST) Date: Thu, 21 Nov 2024 08:28:25 -0800 In-Reply-To: <20241121162826.987947-1-surenb@google.com> Mime-Version: 1.0 References: <20241121162826.987947-1-surenb@google.com> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog Message-ID: <20241121162826.987947-2-surenb@google.com> Subject: [PATCH v2 2/3] mm: convert mm_lock_seq to a proper seqcount From: Suren Baghdasaryan To: akpm@linux-foundation.org Cc: peterz@infradead.org, andrii@kernel.org, jannh@google.com, Liam.Howlett@oracle.com, lorenzo.stoakes@oracle.com, vbabka@suse.cz, mhocko@kernel.org, shakeel.butt@linux.dev, hannes@cmpxchg.org, david@redhat.com, willy@infradead.org, brauner@kernel.org, oleg@redhat.com, arnd@arndb.de, richard.weiyang@gmail.com, zhangpeng.00@bytedance.com, linmiaohe@huawei.com, viro@zeniv.linux.org.uk, hca@linux.ibm.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, surenb@google.com X-Rspam-User: X-Rspamd-Queue-Id: 7C1D01A0006 X-Rspamd-Server: rspam01 X-Stat-Signature: kmtbmmyhe6qs4myg6yruz7rqobz97u85 X-HE-Tag: 1732206445-506006 X-HE-Meta: U2FsdGVkX1/YJLoe8l4M7sls6YwQkN2QP7PX26ReQQTV4ml2tNKoIrt7wIO0ZzAc3o3QioDU8aMhgYoce9Ks2YRPxAdCrN6rJSq+LBi51hMkjdYRaEHt0TRByeQ3LJLht9ObU1gdTTULWU0T5kY+fWVWiB966in0STCQh/JTUVYG7svu80kWs3P9mB0ACIhCNPvQxA4m0CHrgX1ytAzeH1PLJFh85vfEL7Iv2o6+fYY8mcMSX9xqIDitX/HoYdJIB6ua16AnQAJvCmxbpnRfiWf2Z1WaUxAL/ArNi+flz6K1H7KdX2sNghalpcfOSXpVF6YiCPcy4xFxs9bTqhcih6minw55cB0rxGDlz04BUy9rsWnAtUbs04xJu+oSLmgDbHljgQ9zGIEUv/ZuCO/Zkjwef5DSkJ+gNo43W2lFdT7jHm9cFcGnEAn9YlM65RTZTLR2O6kOW4G5j2HAY7ArH2MnFSzhVg5zAnl05oJiUaD416Fkz13lACC/VH4Q//YgApAgRVuce0NNAsIMr2l2rWLlQ1lGYtWPls7n5+ZBALW5fuTydcsqEo22Slx1Za3A/I9Sez9aJ4375XXG715QmOjv3tTVxLRgf1YTBYu+qH75cu7Jl7Vm598obhHwOKTFr38vPSrDyLxdH5c1SEO37Fb4K2gaNR8yIq+/BzPZ2s3S+vUALGag63FVND2iIFvx65Q0o/1F7SYrum213iJ3DiOWYc/JAIwmMQ34V7SozwicCNyfzarFl358thaP1AlOmBieEWkRY1MfI8FHS99ahyYAMQCoVYNzEhp8IrWDrcYoJ0YZE10j+TLKHj1W5kQUcKK5TZB6YcGDfL3VqZM5L1UHXoEwICWUar9aeUOMLVsYzD/r9Nu0FvW5/ThXXuHrBSrp4OxY8SXO8NznEr7qAEjE/58oJImy36dGOuYAI3Z7bYtMro1favsC7zIsgWADShx94cW9POd1tGOihdM mQ4cZOWD aAF5L5rIm4lJp4XRkcNvL+yB1R3bR+ZO3/NFLw8+u6uSut3HxRBM7T/5teRehd17BOQ7yr/2ifAluUD67SflPwRm/EV4vl0KrAhKuIBrs2xhKjxIAihWntPJGbCPKu3M1OHWzqJ9sYKVd72J4g5h+o6lj0uxFbncJTzDUOiXvhnv2S/gyAcC3TjteZEiS31TqK1j2dt2FjUQludc6oOoGBGlG0vk6uE8bOCW03u3AD7hjnOJbPuHNZDiQQH7Yb9Aennl2vZQ1eP/DKpWXvPVx9zl++Ge/D14BlBVg5TWVab0/5CmR9eiTYFMeEYe8E8vKwXhb46Ad7VePAFxIObG6bfocsJqz0CuJmzsG/VDVwpQnWZ+G90JvhwWEpVLawdoU01wB09D3Xg/A10dd8Fc8pWKMj8v00llYQq1l+0rs9cudoT0ojxSsQobXLcyUOO/OKvSnX05vgTwtfLJj35DzfTptch0Anxpi5X9OCRv/JtifYqTNLn3WEYRbZP3X8/Nkez8jXxI0U56qcMBjTqk1DVxB7R1FoTqhkUt1B+Ecqm6r/a10elLQRZG3+ecGXYydslP/Br1lXr69jbPhmiFCMepQF4sanZyM6oeIJi5xxNgt+oIGIqcp+jaPJ+H6Bg2p0hLGuFj+oTYNG8sMro2CNs3H69luSKpaWQXwzOB78coM0XChgu35FejFVXd5fGL7dzKasL7gR7QI33+TcupWHs6wHFBBifJmZQLtg5nj5aUrgjo= 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: List-Subscribe: List-Unsubscribe: Convert mm_lock_seq to be seqcount_t and change all mmap_write_lock variants to increment it, in-line with the usual seqcount usage pattern. This lets us check whether the mmap_lock is write-locked by checking mm_lock_seq.sequence counter (odd=locked, even=unlocked). This will be used when implementing mmap_lock speculation functions. As a result vm_lock_seq is also change to be unsigned to match the type of mm_lock_seq.sequence. Suggested-by: Peter Zijlstra Signed-off-by: Suren Baghdasaryan Reviewed-by: Liam R. Howlett --- Changes since v1 [1] - Added ASSERT_EXCLUSIVE_WRITER() instead of a comment in vma_end_write_all, per Peter Zijlstra [1] https://lore.kernel.org/all/20241024205231.1944747-1-surenb@google.com/ include/linux/mm.h | 12 +++---- include/linux/mm_types.h | 7 ++-- include/linux/mmap_lock.h | 55 +++++++++++++++++++++----------- kernel/fork.c | 5 +-- mm/init-mm.c | 2 +- tools/testing/vma/vma.c | 4 +-- tools/testing/vma/vma_internal.h | 4 +-- 7 files changed, 53 insertions(+), 36 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index feb5c8021bef..e6de22738ee1 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -710,7 +710,7 @@ static inline bool vma_start_read(struct vm_area_struct *vma) * we don't rely on for anything - the mm_lock_seq read against which we * need ordering is below. */ - if (READ_ONCE(vma->vm_lock_seq) == READ_ONCE(vma->vm_mm->mm_lock_seq)) + if (READ_ONCE(vma->vm_lock_seq) == READ_ONCE(vma->vm_mm->mm_lock_seq.sequence)) return false; if (unlikely(down_read_trylock(&vma->vm_lock->lock) == 0)) @@ -727,7 +727,7 @@ static inline bool vma_start_read(struct vm_area_struct *vma) * after it has been unlocked. * This pairs with RELEASE semantics in vma_end_write_all(). */ - if (unlikely(vma->vm_lock_seq == smp_load_acquire(&vma->vm_mm->mm_lock_seq))) { + if (unlikely(vma->vm_lock_seq == raw_read_seqcount(&vma->vm_mm->mm_lock_seq))) { up_read(&vma->vm_lock->lock); return false; } @@ -742,7 +742,7 @@ static inline void vma_end_read(struct vm_area_struct *vma) } /* WARNING! Can only be used if mmap_lock is expected to be write-locked */ -static bool __is_vma_write_locked(struct vm_area_struct *vma, int *mm_lock_seq) +static bool __is_vma_write_locked(struct vm_area_struct *vma, unsigned int *mm_lock_seq) { mmap_assert_write_locked(vma->vm_mm); @@ -750,7 +750,7 @@ static bool __is_vma_write_locked(struct vm_area_struct *vma, int *mm_lock_seq) * current task is holding mmap_write_lock, both vma->vm_lock_seq and * mm->mm_lock_seq can't be concurrently modified. */ - *mm_lock_seq = vma->vm_mm->mm_lock_seq; + *mm_lock_seq = vma->vm_mm->mm_lock_seq.sequence; return (vma->vm_lock_seq == *mm_lock_seq); } @@ -761,7 +761,7 @@ static bool __is_vma_write_locked(struct vm_area_struct *vma, int *mm_lock_seq) */ static inline void vma_start_write(struct vm_area_struct *vma) { - int mm_lock_seq; + unsigned int mm_lock_seq; if (__is_vma_write_locked(vma, &mm_lock_seq)) return; @@ -779,7 +779,7 @@ static inline void vma_start_write(struct vm_area_struct *vma) static inline void vma_assert_write_locked(struct vm_area_struct *vma) { - int mm_lock_seq; + unsigned int mm_lock_seq; VM_BUG_ON_VMA(!__is_vma_write_locked(vma, &mm_lock_seq), vma); } diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index 381d22eba088..ac72888a54b8 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -715,7 +715,7 @@ struct vm_area_struct { * counter reuse can only lead to occasional unnecessary use of the * slowpath. */ - int vm_lock_seq; + unsigned int vm_lock_seq; /* Unstable RCU readers are allowed to read this. */ struct vma_lock *vm_lock; #endif @@ -909,6 +909,9 @@ struct mm_struct { * Roughly speaking, incrementing the sequence number is * equivalent to releasing locks on VMAs; reading the sequence * number can be part of taking a read lock on a VMA. + * Incremented every time mmap_lock is write-locked/unlocked. + * Initialized to 0, therefore odd values indicate mmap_lock + * is write-locked and even values that it's released. * * Can be modified under write mmap_lock using RELEASE * semantics. @@ -917,7 +920,7 @@ struct mm_struct { * Can be read with ACQUIRE semantics if not holding write * mmap_lock. */ - int mm_lock_seq; + seqcount_t mm_lock_seq; #endif diff --git a/include/linux/mmap_lock.h b/include/linux/mmap_lock.h index de9dc20b01ba..083b7fa2588e 100644 --- a/include/linux/mmap_lock.h +++ b/include/linux/mmap_lock.h @@ -71,39 +71,38 @@ static inline void mmap_assert_write_locked(const struct mm_struct *mm) } #ifdef CONFIG_PER_VMA_LOCK -/* - * Drop all currently-held per-VMA locks. - * This is called from the mmap_lock implementation directly before releasing - * a write-locked mmap_lock (or downgrading it to read-locked). - * This should normally NOT be called manually from other places. - * If you want to call this manually anyway, keep in mind that this will release - * *all* VMA write locks, including ones from further up the stack. - */ -static inline void vma_end_write_all(struct mm_struct *mm) +static inline void mm_lock_seqcount_init(struct mm_struct *mm) { - mmap_assert_write_locked(mm); - /* - * Nobody can concurrently modify mm->mm_lock_seq due to exclusive - * mmap_lock being held. - * We need RELEASE semantics here to ensure that preceding stores into - * the VMA take effect before we unlock it with this store. - * Pairs with ACQUIRE semantics in vma_start_read(). - */ - smp_store_release(&mm->mm_lock_seq, mm->mm_lock_seq + 1); + seqcount_init(&mm->mm_lock_seq); +} + +static inline void mm_lock_seqcount_begin(struct mm_struct *mm) +{ + do_raw_write_seqcount_begin(&mm->mm_lock_seq); +} + +static inline void mm_lock_seqcount_end(struct mm_struct *mm) +{ + do_raw_write_seqcount_end(&mm->mm_lock_seq); } + #else -static inline void vma_end_write_all(struct mm_struct *mm) {} +static inline void mm_lock_seqcount_init(struct mm_struct *mm) {} +static inline void mm_lock_seqcount_begin(struct mm_struct *mm) {} +static inline void mm_lock_seqcount_end(struct mm_struct *mm) {} #endif static inline void mmap_init_lock(struct mm_struct *mm) { init_rwsem(&mm->mmap_lock); + mm_lock_seqcount_init(mm); } static inline void mmap_write_lock(struct mm_struct *mm) { __mmap_lock_trace_start_locking(mm, true); down_write(&mm->mmap_lock); + mm_lock_seqcount_begin(mm); __mmap_lock_trace_acquire_returned(mm, true, true); } @@ -111,6 +110,7 @@ static inline void mmap_write_lock_nested(struct mm_struct *mm, int subclass) { __mmap_lock_trace_start_locking(mm, true); down_write_nested(&mm->mmap_lock, subclass); + mm_lock_seqcount_begin(mm); __mmap_lock_trace_acquire_returned(mm, true, true); } @@ -120,10 +120,27 @@ static inline int mmap_write_lock_killable(struct mm_struct *mm) __mmap_lock_trace_start_locking(mm, true); ret = down_write_killable(&mm->mmap_lock); + if (!ret) + mm_lock_seqcount_begin(mm); __mmap_lock_trace_acquire_returned(mm, true, ret == 0); return ret; } +/* + * Drop all currently-held per-VMA locks. + * This is called from the mmap_lock implementation directly before releasing + * a write-locked mmap_lock (or downgrading it to read-locked). + * This should normally NOT be called manually from other places. + * If you want to call this manually anyway, keep in mind that this will release + * *all* VMA write locks, including ones from further up the stack. + */ +static inline void vma_end_write_all(struct mm_struct *mm) +{ + mmap_assert_write_locked(mm); + ASSERT_EXCLUSIVE_WRITER(mm->mm_lock_seq); + mm_lock_seqcount_end(mm); +} + static inline void mmap_write_unlock(struct mm_struct *mm) { __mmap_lock_trace_released(mm, true); diff --git a/kernel/fork.c b/kernel/fork.c index e58d27c05788..8cd36645b9fc 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -449,7 +449,7 @@ static bool vma_lock_alloc(struct vm_area_struct *vma) return false; init_rwsem(&vma->vm_lock->lock); - vma->vm_lock_seq = -1; + vma->vm_lock_seq = UINT_MAX; return true; } @@ -1262,9 +1262,6 @@ static struct mm_struct *mm_init(struct mm_struct *mm, struct task_struct *p, seqcount_init(&mm->write_protect_seq); mmap_init_lock(mm); INIT_LIST_HEAD(&mm->mmlist); -#ifdef CONFIG_PER_VMA_LOCK - mm->mm_lock_seq = 0; -#endif mm_pgtables_bytes_init(mm); mm->map_count = 0; mm->locked_vm = 0; diff --git a/mm/init-mm.c b/mm/init-mm.c index 24c809379274..6af3ad675930 100644 --- a/mm/init-mm.c +++ b/mm/init-mm.c @@ -40,7 +40,7 @@ struct mm_struct init_mm = { .arg_lock = __SPIN_LOCK_UNLOCKED(init_mm.arg_lock), .mmlist = LIST_HEAD_INIT(init_mm.mmlist), #ifdef CONFIG_PER_VMA_LOCK - .mm_lock_seq = 0, + .mm_lock_seq = SEQCNT_ZERO(init_mm.mm_lock_seq), #endif .user_ns = &init_user_ns, .cpu_bitmap = CPU_BITS_NONE, diff --git a/tools/testing/vma/vma.c b/tools/testing/vma/vma.c index b33b47342d41..9074aaced9c5 100644 --- a/tools/testing/vma/vma.c +++ b/tools/testing/vma/vma.c @@ -87,7 +87,7 @@ static struct vm_area_struct *alloc_and_link_vma(struct mm_struct *mm, * begun. Linking to the tree will have caused this to be incremented, * which means we will get a false positive otherwise. */ - vma->vm_lock_seq = -1; + vma->vm_lock_seq = UINT_MAX; return vma; } @@ -212,7 +212,7 @@ static bool vma_write_started(struct vm_area_struct *vma) int seq = vma->vm_lock_seq; /* We reset after each check. */ - vma->vm_lock_seq = -1; + vma->vm_lock_seq = UINT_MAX; /* The vma_start_write() stub simply increments this value. */ return seq > -1; diff --git a/tools/testing/vma/vma_internal.h b/tools/testing/vma/vma_internal.h index c5b9da034511..4007ec580f85 100644 --- a/tools/testing/vma/vma_internal.h +++ b/tools/testing/vma/vma_internal.h @@ -231,7 +231,7 @@ struct vm_area_struct { * counter reuse can only lead to occasional unnecessary use of the * slowpath. */ - int vm_lock_seq; + unsigned int vm_lock_seq; struct vma_lock *vm_lock; #endif @@ -406,7 +406,7 @@ static inline bool vma_lock_alloc(struct vm_area_struct *vma) return false; init_rwsem(&vma->vm_lock->lock); - vma->vm_lock_seq = -1; + vma->vm_lock_seq = UINT_MAX; return true; }