From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail115-24.sinamail.sina.com.cn (mail115-24.sinamail.sina.com.cn [218.30.115.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0347A201017 for ; Thu, 9 Jan 2025 10:36:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=218.30.115.24 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736418982; cv=none; b=ZrCDSwwwbT0apiB0T+sueTfV21hoco9BXu527fsoQ+fV2YoHkuB75AT0aU1alNfwpquJbdFppBHX+ppfOgFnZpc6E0tJfySBcSxJpiXPCR59qkbqRuhWNx4xVXPwjeFpTVF8peJ1pKaJvzPDZnCNLO6CUBbzjqeghwjQ5ClyjVE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736418982; c=relaxed/simple; bh=JYbqYGVZulOup1WYDVO640RbhlWUKo+mWX4S+hwwdCQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fFjySJY1iRqqJHxpJECxuFbZGA4z0LPlNuGGKOIoYQPs5MNT2ad/5yF7M+utnEhc48RpuCFbhNHEChObkSC8UGv398n2vpV/OlAcbZmu73WYnMPqc778Xpdc+WpmRCXOgyEvNmL4/jBn7zUM1gLkXMrSLQ4TbEb7P5qhYEt83f4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sina.com; spf=pass smtp.mailfrom=sina.com; arc=none smtp.client-ip=218.30.115.24 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sina.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sina.com X-SMAIL-HELO: localhost.localdomain Received: from unknown (HELO localhost.localdomain)([113.88.49.137]) by sina.com (10.185.250.22) with ESMTP id 677FA69C00005730; Thu, 9 Jan 2025 18:36:14 +0800 (CST) X-Sender: hdanton@sina.com X-Auth-ID: hdanton@sina.com Authentication-Results: sina.com; spf=none smtp.mailfrom=hdanton@sina.com; dkim=none header.i=none; dmarc=none action=none header.from=hdanton@sina.com X-SMAIL-MID: 3179197602762 X-SMAIL-UIID: 7A752A1180A04EDF9621790FA3977399-20250109-183614-1 From: Hillf Danton To: Suren Baghdasaryan Cc: peterz@infradead.org, lorenzo.stoakes@oracle.com, hannes@cmpxchg.org, hughd@google.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v8 11/16] mm: replace vm_lock and detached flag with a reference count Date: Thu, 9 Jan 2025 18:35:59 +0800 Message-ID: <20250109103602.1555-1-hdanton@sina.com> In-Reply-To: <20250109023025.2242447-12-surenb@google.com> References: <20250109023025.2242447-1-surenb@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit On Wed, 8 Jan 2025 18:30:20 -0800 Suren Baghdasaryan > + > +static inline void vma_refcount_put(struct vm_area_struct *vma) > +{ > + int oldcnt; > + > + if (!__refcount_dec_and_test(&vma->vm_refcnt, &oldcnt)) { > + rwsem_release(&vma->vmlock_dep_map, _RET_IP_); In up_read() rwsem is released reguardless wakeup, which is different than what is added here. Nit. > + > + if (is_vma_writer_only(oldcnt - 1)) > + rcuwait_wake_up(&vma->vm_mm->vma_writer_wait); > + } > +} ... > @@ -735,9 +773,10 @@ static inline bool vma_start_read(struct vm_area_struct *vma) > * This pairs with RELEASE semantics in vma_end_write_all(). > */ > if (unlikely(vma->vm_lock_seq == raw_read_seqcount(&vma->vm_mm->mm_lock_seq))) { > - up_read(&vma->vm_lock.lock); > + vma_refcount_put(vma); > return false; > } void up_read(struct rw_semaphore *sem) { rwsem_release(&sem->dep_map, _RET_IP_); __up_read(sem); }