Message ID | 20240213031656.1375951-4-longman@redhat.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-62902-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp302738dyb; Mon, 12 Feb 2024 19:18:42 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUFpDWUG7XUnRQkS7Yyz6e+/NkXiF7lsgGfgI4tk7F5diQyy0iq8vrJN8uEmBNwkHDJj+7JF58tdhmhXuY7HPFVX8L9WA== X-Google-Smtp-Source: AGHT+IFOcs7GJhO3yIM4SHhO/lccFxwcaEasN9+qxwv6USS/CbjOdrKPiyo2XDx+ZODh+iiWbKID X-Received: by 2002:a05:6402:22d0:b0:561:f601:e621 with SMTP id dm16-20020a05640222d000b00561f601e621mr280055edb.12.1707794322661; Mon, 12 Feb 2024 19:18:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707794322; cv=pass; d=google.com; s=arc-20160816; b=lQqZC7zGkpBdnQTifhcIkP1HGxHGIi1LWw6wgImzJlsx366V9EREVX4QOSubk1skTp iYkYpvBft9K7QfJwT0Ql/0CTgZq3Pf0Unlr579pGb+pARpc8Olk/UIbFrall/Motm1bs qJdI3ZiZ6KzClfvkQDU4wVvHQsHhLcc17lnMBPlQeUmpBzH2AmdX/V3Ss1NzCt60I6tn Wc1J/7z4LrbiNOt51UiwpcxSGNN+vpcJc9GV34VH7SPKWpWhdenKzRn2XU9833yfVDpf kXBYeqIQsPyLN4uNCPwag5hI1p5izFEub2/v9Z6/hT529XUd6uLbSRAroAjgRojHCt+4 xjuA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=X+mW6S3E9PxzlJ59KYM6a9lo9aW4LQzFCn0v6EM+0/M=; fh=suPy89/IXdjqM6u10BB3IsFflVBlubcB9VAOtErBbQk=; b=i0GVEI5rSs/kBnb2gPHsKUH3kYG0DAhPJIr2YlipAziWa2i4Px1YzA78qRPieOAixc kscvP0nOuw+hoH4m8zFeEgVOzR0B2WYSnWUvn7fIuOXf6wrvN3Ka1+fwFL5bs4IB6MXN P/3+XxVXQHd3vxwxtXnKR4+++xqm1HSNlkPPH8xUOfxzC43qQadVEH4Y37mDG0qBnGTF 9ynNgkM6Jvu/FpSs8kYiw5RrVGG3VMYzpjnu1UVi54j0o83YIAHGnuPfdztnaQCw8cr9 q5ek6cclDOVc5n3PCb6M0eib7NDZgxub4GE6fskHqq+lr3m5mz98ZgW6GlvF1OrnK6bQ nwKQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=O0yr4g1C; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-62902-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62902-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Forwarded-Encrypted: i=2; AJvYcCV2mmCGvk1+uU3As7mvST/pbqHQhCeXpTv/O06wIE8aYXpTWCGNqXQYXb9JigtCJTGQWL2p7TTuXSTqJdVdDKvtOLnh7Q== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id i9-20020a056402054900b005601034b5e1si3464014edx.478.2024.02.12.19.18.42 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 19:18:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-62902-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=O0yr4g1C; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-62902-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62902-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 47AF41F233F4 for <ouuuleilei@gmail.com>; Tue, 13 Feb 2024 03:18:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 43FD711721; Tue, 13 Feb 2024 03:17:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="O0yr4g1C" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 1F264AD4B for <linux-kernel@vger.kernel.org>; Tue, 13 Feb 2024 03:17:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707794238; cv=none; b=SAxH0k2vbauNqyPds1GbOOgV0/RH0FNBXaTU2SlAsWLdkENV6He8MIF/2zhDe9s1JuCjfGEexzYq78lHxP4ai5LD7rMMTtvnJ2jv5KdC6nNrHgEbNpQwFpqRv3I4mBbSoUwohcspFFqxHK4ge64b6nSUy5VHE3oK0OnrswVf+EE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707794238; c=relaxed/simple; bh=MANijGulv75x4C4ug9+yfGSrwL6bUaWQqE7f9b4Kc/k=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=a/WYNMlMDscydc5bPs0ygMSofiHoBkhdlCjKHUzQec9ONZOnyQMx/PG4sqbyCOaiKGA7N4ME3HQ17OG15n2zB7zZFPky75s/MsEg899RSDmNG0+nM+F1heYBVLI+PcMaQ4uQsfDujMIcSR9ZyXvQ8q+rwql1svtA+X6HVydgcnA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=O0yr4g1C; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707794235; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=X+mW6S3E9PxzlJ59KYM6a9lo9aW4LQzFCn0v6EM+0/M=; b=O0yr4g1Cc/HbKi184Bvb9E2ZhMF+HGOqMl9XDz8a2dSHx/SH1d6SOeFNEl1mWSM4/e4HAD LS7nVBckVw/Sxpg3YK1FN5sv89/DHu6JxW4UqX9RHcOiuoZtxu8UxDCkulzhHn5BWEXzly vRdEeotpUD/MiXLkP9ABBuiNJnXkRFw= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-240-vH9Kdgq5OdyB4buqj1ei4A-1; Mon, 12 Feb 2024 22:17:11 -0500 X-MC-Unique: vH9Kdgq5OdyB4buqj1ei4A-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 958DA3C02744; Tue, 13 Feb 2024 03:17:10 +0000 (UTC) Received: from llong.com (unknown [10.22.33.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id EB8A6AC17; Tue, 13 Feb 2024 03:17:09 +0000 (UTC) From: Waiman Long <longman@redhat.com> To: Peter Zijlstra <peterz@infradead.org>, Ingo Molnar <mingo@redhat.com>, Will Deacon <will@kernel.org>, Boqun Feng <boqun.feng@gmail.com>, Andrew Morton <akpm@linux-foundation.org> Cc: linux-kernel@vger.kernel.org, George Stark <gnstark@salutedevices.com>, Waiman Long <longman@redhat.com> Subject: [PATCH 3/4] locking/rwsem: Clarify that RWSEM_READER_OWNED is just a hint Date: Mon, 12 Feb 2024 22:16:55 -0500 Message-Id: <20240213031656.1375951-4-longman@redhat.com> In-Reply-To: <20240213031656.1375951-1-longman@redhat.com> References: <20240213031656.1375951-1-longman@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790752139764421573 X-GMAIL-MSGID: 1790752139764421573 |
Series |
locking: Some locking code cleanups
|
|
Commit Message
Waiman Long
Feb. 13, 2024, 3:16 a.m. UTC
Clarify in the comments that the RWSEM_READER_OWNED bit in the owner
field is just a hint, not an authoritative state of the rwsem.
Signed-off-by: Waiman Long <longman@redhat.com>
---
kernel/locking/rwsem.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
Comments
On Mon, Feb 12, 2024 at 10:16:55PM -0500, Waiman Long wrote: > Clarify in the comments that the RWSEM_READER_OWNED bit in the owner > field is just a hint, not an authoritative state of the rwsem. > > Signed-off-by: Waiman Long <longman@redhat.com> Reviewed-by: Boqun Feng <boqun.feng@gmail.com> Regards, Boqun > --- > kernel/locking/rwsem.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/kernel/locking/rwsem.c b/kernel/locking/rwsem.c > index 2340b6d90ec6..c6d17aee4209 100644 > --- a/kernel/locking/rwsem.c > +++ b/kernel/locking/rwsem.c > @@ -35,7 +35,7 @@ > /* > * The least significant 2 bits of the owner value has the following > * meanings when set. > - * - Bit 0: RWSEM_READER_OWNED - The rwsem is owned by readers > + * - Bit 0: RWSEM_READER_OWNED - rwsem may be owned by readers (just a hint) > * - Bit 1: RWSEM_NONSPINNABLE - Cannot spin on a reader-owned lock > * > * When the rwsem is reader-owned and a spinning writer has timed out, > @@ -1002,8 +1002,8 @@ rwsem_down_read_slowpath(struct rw_semaphore *sem, long count, unsigned int stat > > /* > * To prevent a constant stream of readers from starving a sleeping > - * waiter, don't attempt optimistic lock stealing if the lock is > - * currently owned by readers. > + * writer, don't attempt optimistic lock stealing if the lock is > + * very likely owned by readers. > */ > if ((atomic_long_read(&sem->owner) & RWSEM_READER_OWNED) && > (rcnt > 1) && !(count & RWSEM_WRITER_LOCKED)) > -- > 2.39.3 >
diff --git a/kernel/locking/rwsem.c b/kernel/locking/rwsem.c index 2340b6d90ec6..c6d17aee4209 100644 --- a/kernel/locking/rwsem.c +++ b/kernel/locking/rwsem.c @@ -35,7 +35,7 @@ /* * The least significant 2 bits of the owner value has the following * meanings when set. - * - Bit 0: RWSEM_READER_OWNED - The rwsem is owned by readers + * - Bit 0: RWSEM_READER_OWNED - rwsem may be owned by readers (just a hint) * - Bit 1: RWSEM_NONSPINNABLE - Cannot spin on a reader-owned lock * * When the rwsem is reader-owned and a spinning writer has timed out, @@ -1002,8 +1002,8 @@ rwsem_down_read_slowpath(struct rw_semaphore *sem, long count, unsigned int stat /* * To prevent a constant stream of readers from starving a sleeping - * waiter, don't attempt optimistic lock stealing if the lock is - * currently owned by readers. + * writer, don't attempt optimistic lock stealing if the lock is + * very likely owned by readers. */ if ((atomic_long_read(&sem->owner) & RWSEM_READER_OWNED) && (rcnt > 1) && !(count & RWSEM_WRITER_LOCKED))