From patchwork Wed Feb 28 12:53:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 207848 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp3323800dyb; Wed, 28 Feb 2024 04:54:18 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUEoq/Nr9B6qiGtccs6tXn8YR5HOzSaBNBaX0dl8FivWOZ1+7eSIRqynIJelB1cRBsW+YK2Gzv9rIWEAp4gr/omuv9RGA== X-Google-Smtp-Source: AGHT+IHIdBWzg0Lblhq50ZWUnfuZtpVuqEJobafgdwgUBWXBPjj7NJpfz4bzovFLbduDqHWBBTzk X-Received: by 2002:a05:622a:d6:b0:42e:b4a3:a4b1 with SMTP id p22-20020a05622a00d600b0042eb4a3a4b1mr246738qtw.35.1709124858091; Wed, 28 Feb 2024 04:54:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709124858; cv=pass; d=google.com; s=arc-20160816; b=VxcF50L7m8FdG//+4cykTMTLDpPjyOCrk3vkaMMJ8QmjH5Aot9ZpSaliDZi0iqPxx8 lP2NwKYRce1iV8u5Th1kgHZtD8JtNDOG7Wfog10yrSm3zLhUv1h1itf+Jze66SwaSVLc zXhHGYHzC3gWZSnPrZJwgLibQlos9rWgVoKSYdgRoKJ0e/bUaqu403EKPtNXpxQNKmKK 5BP5YET/Y+jCZnAl4aWpoUjf4o+BV5fkaTxVsw9NQxvOjfljTgOR+33pKd9OksrTIheQ 5i6N1Ab2Mn8RcUHyf55LCUSB6mxaRuKXmVwDLS68xSOX+BRjBmN7PYHTWkz5ijxIid98 5+Mg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:precedence:robot-unsubscribe:robot-id :message-id:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:in-reply-to:cc:subject:to:reply-to:sender :from:dkim-signature:dkim-signature:date; bh=IGMCpIi1CngzONyyqp5nSMzJJWqhw0WiBeW2EkwS0Rc=; fh=Lf2ys8B8adCSgbeQ6sCsOsgkPFRdsgLwbTH2Fa2dGSU=; b=ngqSW1sEwjckk0ZHV3g8SE2ZzwmKJItg8/9x0rW0uhasl5kDWGeNa1Z9Z1DzaC7rYk qHXOwz8W1e9WTAm+y/nBLypeGfKOLlHB6tr3IXJQktJr4PiKv9cuOc4GEEW59NHeY2oK wd+3yQ/rE0bCMtqm0UYq8wSUVLmiOx0k50W0TS8x0FLUYKPaJVpCNS+3VzNF474q2RMK N6tslPtIjTzEEZYWWnE1b22U3xEBUFqqb8arY8TYegPfF5xUUHGjU7VDwIFC6vAGVgBm t6uK8gztjie64lKELWxnns7c89CX0VaU2q5rNc9Mmm43JkaH2cawqyQr9zH3AaedCIRM q2XQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=0llgFHOV; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-85040-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85040-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id k26-20020ac8475a000000b0042cc56cc1b8si9150062qtp.193.2024.02.28.04.54.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 04:54:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85040-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=0llgFHOV; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-85040-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85040-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id CF46E1C22A98 for ; Wed, 28 Feb 2024 12:54:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 03A6014F98F; Wed, 28 Feb 2024 12:53:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="0llgFHOV"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="HrzdkMJ2" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 C34AC1487D7; Wed, 28 Feb 2024 12:53:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709124806; cv=none; b=WeeTgnT0MAiNxur6+bHv1Xcd+Vq+Se1pCvNDMDDy+wfTWpQveYonqIn5OSjtjldRLHlNzUtYKmYP+WqAW4wKkN2LZ2NpZqe4Htw+//gtBg12v3YCpo34/cCZF6TaRY1HhgYB+/9goDeO1Bpd45x2VwesplBw81ndxwNM3SwvQb0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709124806; c=relaxed/simple; bh=qllb9BunC54GClJH3gNc/f+b7ajqvH2CC3VhxcSMK7U=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=JTjQhidr8Zw0CCs07SxxeVdpFOW1wQBxtIXKfbKOsLvbe2HGP7TWGRjgiDV7BZI9dlMAdfjZJhMfEYxchhs7IaCORIv+XJuRIDVCnJuUZV1qUlPVd1z2yWW4SuhdhJDA1Tb+5fhWY25WjcQ7jKlQMbnYMRmkNRAuXAWoUimrJ/c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=0llgFHOV; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=HrzdkMJ2; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Date: Wed, 28 Feb 2024 12:53:21 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1709124802; h=from:from:sender:sender:reply-to: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IGMCpIi1CngzONyyqp5nSMzJJWqhw0WiBeW2EkwS0Rc=; b=0llgFHOVBDZse+shVKjZSSREH5DX+LW+nrjz7Al1K6aW1egTf7npBRtb4fxn1hKUJ001a4 yQr0NWSbADnPk2fZuBiGjm9NP5RjC8yx3Rx4DILQaFJnpu1bXRUYRU6/r2IV1c4hrSMpNq II5t+66AGzXLWFyxqgHz7zI6oorOGVKMH4GBDRETxSlLhw50eNOp7Ai9yppyC+E6PbzGxs XAMdR1vVuZp4k3ARWQa0znFoBV8TCzW7waBQ2Vk77vGe4SUf+jQ4BIf8j/U3+4xOvGcR8V iVBR/0S4DUgctY3H1b1+mY9eB4zj73492OStCff9u6GWMPCnyGAICZLybT7o7w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1709124802; h=from:from:sender:sender:reply-to: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IGMCpIi1CngzONyyqp5nSMzJJWqhw0WiBeW2EkwS0Rc=; b=HrzdkMJ2+ipuguPz8CPi0/I1ewUzeKhkHpaNp9GP5qpqXJw3lidi7UCEG45fZwmD82pmav S/nqWoHmHvoU6zBg== From: "tip-bot2 for Waiman Long" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: locking/core] locking/rwsem: Clarify that RWSEM_READER_OWNED is just a hint Cc: Waiman Long , Ingo Molnar , Boqun Feng , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20240222150540.79981-4-longman@redhat.com> References: <20240222150540.79981-4-longman@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <170912480198.398.8722869596829490134.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791612234891600623 X-GMAIL-MSGID: 1792147307303288185 The following commit has been merged into the locking/core branch of tip: Commit-ID: d566c78659eccf085f905fd266fc461de92eaa8f Gitweb: https://git.kernel.org/tip/d566c78659eccf085f905fd266fc461de92eaa8f Author: Waiman Long AuthorDate: Thu, 22 Feb 2024 10:05:39 -05:00 Committer: Ingo Molnar CommitterDate: Wed, 28 Feb 2024 13:08:38 +01:00 locking/rwsem: Clarify that RWSEM_READER_OWNED is just a hint 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 Signed-off-by: Ingo Molnar Reviewed-by: Boqun Feng Link: https://lore.kernel.org/r/20240222150540.79981-4-longman@redhat.com --- 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 2340b6d..c6d17ae 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))