Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2819093rdb; Mon, 12 Feb 2024 19:18:22 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU8P7BmvTctPaqvee3D8J8wU8UeF38xNT2HZ6Dno6ejKfCSjKSNmuwIUYOW094sr3rL0d/8bYY85JndLAaPAwm28DDcza4UmqL2e/vQGQ== X-Google-Smtp-Source: AGHT+IHCve+3gIdCJWlVaff0scM3UTBDK03XG73nyJAj0pmolUgFNohn6/hcEYLZQbFrodxVGgT4 X-Received: by 2002:a17:902:e80b:b0:1db:28ae:5cef with SMTP id u11-20020a170902e80b00b001db28ae5cefmr3027085plg.11.1707794302108; Mon, 12 Feb 2024 19:18:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707794302; cv=pass; d=google.com; s=arc-20160816; b=ZKmV4mlyYOp5UZMgYAM96d3L8vKVq/BPN3JTVZigAcoFvunrwmK3nbqBswDIpSJwBB e/IV+AkdajQyP3tyVKX6Fk+azhExLLOaAQFF34mFLQHPTjPWNx4KC44Gvs5sqN9+nXV2 lYAdFFeml+wQ8XfEy75+3vAbsz+znofZTZ1nsFEB/vr/HJPrgDULyF6H5EC5s5iQDrO9 T+hIcLXh+zUJrYuzJ/HOeajuBMR9vqrz3d5V628yJO50WtAhTmpshQ3hmlaDS7heYGky g5zMB2iPNWK5nkFC9DwSXUreK/qEQLxmB8kZmlewDOI6v2ZDFce8Lm09FMhBp6oNkugz zJIw== 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=50mCEo50b4gHd8g8t+zbE/vIV/zQy4rlg3hscgXO/AI=; b=RxaFDNEKaFEjPp9pv88Kl2FAzTjdbRNYuC1iVqwmFar4hktMxojs0MzXRNheNOKjwh Iq0Okywt1D8JeZjqzo7qwSz2j0H9+CArpEHWrYlgt75nwQWI2fqyEeobRYvO2Uq+Ctvv HL5uv/r4G5sFUZx8b0JHR4Z1aAhlcEKRwLQmpCfReBovPITvvKzAHgnavHksQvYgv2In ujjJjlp3tuFMOJj83eJAebbj0H1/mBCCRQ/+v7dA9Cpfy6dgl5rw5V/5gzPZzqTitPe1 641cvqgfZuUR7zs3imzceXXEGrsqJxih3FcOmFHqY1kybd1Te1Y4QpMLR3+qsKgVSnUc TVqA==; 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-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62902-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Forwarded-Encrypted: i=2; AJvYcCWFLCiD5ZgEfhT/QkSS2Bh7RaZZ4dfxI4Z0FddXDFjMHbqSMJ9HWBvcfcRTwIh23EAGcPiKmZaTR6QerKne5Ke84t9VKtcPxGRLFj+zVw== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id j16-20020a170903025000b001d91df66e39si1295570plh.210.2024.02.12.19.18.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 19:18:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-62902-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; 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-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62902-linux.lists.archive=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id BEE812857F2 for ; Tue, 13 Feb 2024 03:18:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 70FDB10A23; Tue, 13 Feb 2024 03:17:19 +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 ; 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 To: Peter Zijlstra , Ingo Molnar , Will Deacon , Boqun Feng , Andrew Morton Cc: linux-kernel@vger.kernel.org, George Stark , Waiman Long 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: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 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 --- 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