Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp24415pxb; Tue, 17 Nov 2020 19:09:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJysU3yMBl6zgyje5yuxlUPdU5qYMPgKbRglluIx09GZIpoY+yETQNs3IVC1sgUmwzY6OZ8Q X-Received: by 2002:aa7:c3cc:: with SMTP id l12mr18075038edr.304.1605668946898; Tue, 17 Nov 2020 19:09:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605668946; cv=none; d=google.com; s=arc-20160816; b=Hav6BRzfZNidJmHmW7OGKqECk3QBGJcwYe/CC5o8wEniem2hYiLKqPtfqJ4iYZLTZ+ HaNJ5iTvtgmJZJg0f9TeZJRzlD/hvT/sW6hDODfxBqSdinmtz+rRyNLsYbla9bdjvy/7 i08eS2TjkKxrHnRkbko8JFdFsc1zKY8pyeDCswifNGDbevUQinPqwhjqCRTYGLoCc7gO ayoc7UPg52xD2jMolCwx6imKo87iXK2RqMHVbfjCDo+ZFt21RiejrAVnU8rWCCBJf06w 7Aw1YaS1Z9xEO7ocMojIU/DsBcKQLkodCpo60XNRcFb9KPV0AFyoAOvIhk/LFZ1aUnt6 9pgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=BC+R55JrBQj8lQ/l07npoVOBAJzecs7/KqVicWEiAKY=; b=nA/afyzyAZnpjlKG4LMLZHi0vFI7zC+rlDPIFZGhFznjJioic3Q37cFwnzONqBFxTY DGiStAqXr037i2hhJ9V9xj2OPsc036qY60xqlPSxLH7gTMxGrhmVAXL4vzHl3Gf0Ykp5 v7chJpslq9MWW4+LbS3+cIgi7Plh/5YmvVD6urX3Mx+jizhYnhC+B5PH9oG9xvtGWlft y9xwi8GqNXtv/1jwXQ65/qmEelVjl1fnDOmSUkBnfibe1VC4A0kbKI9v/MF18k4i7VXl njAqQ4KEqQOJYeHq9oiApJCneT62jUkGnSfMJ6F/cJP4R2Mh2jApNcHa44ITOWT/OObt R8NA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gq95q7eO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l17si15631080eds.580.2020.11.17.19.08.44; Tue, 17 Nov 2020 19:09:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gq95q7eO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727377AbgKRDFP (ORCPT + 99 others); Tue, 17 Nov 2020 22:05:15 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:37043 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726342AbgKRDFH (ORCPT ); Tue, 17 Nov 2020 22:05:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605668706; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:in-reply-to:in-reply-to:references:references; bh=BC+R55JrBQj8lQ/l07npoVOBAJzecs7/KqVicWEiAKY=; b=gq95q7eOWxP4oiNikWEpnC52UeSWOjaJ43enkPTRs/Yv56jZPV4kUnp/FcqbZMaQPnaeTm DL7tbPX/18QIpT5TrwKaWsO9XFxC9wIuW51grv6Z2v2D8jF+jR3cYobxUCeC47A67loDTA fV6QQPus+eGE4wcvXKOCvSFUrBN14Ho= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-21-iDUFYabPP7OL5bRpJunDnA-1; Tue, 17 Nov 2020 22:05:04 -0500 X-MC-Unique: iDUFYabPP7OL5bRpJunDnA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 28CF36414C; Wed, 18 Nov 2020 03:05:03 +0000 (UTC) Received: from llong.com (ovpn-113-17.rdu2.redhat.com [10.10.113.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6D8C05C1A3; Wed, 18 Nov 2020 03:05:02 +0000 (UTC) From: Waiman Long To: Peter Zijlstra , Ingo Molnar , Will Deacon Cc: linux-kernel@vger.kernel.org, Davidlohr Bueso , Phil Auld , Waiman Long Subject: [PATCH 4/5] locking/rwsem: Wake up all waiting readers if RWSEM_WAKE_READ_OWNED Date: Tue, 17 Nov 2020 22:04:28 -0500 Message-Id: <20201118030429.23017-5-longman@redhat.com> In-Reply-To: <20201118030429.23017-1-longman@redhat.com> References: <20201118030429.23017-1-longman@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The rwsem wakeup logic has been modified by commit d3681e269fff ("locking/rwsem: Wake up almost all readers in wait queue") to wake up all readers in the wait queue if the first waiter is a reader. In the case of RWSEM_WAKE_READ_OWNED, not all readers can be woken up if the first waiter happens to be a writer. Complete the logic by waking up all readers even for this case. Signed-off-by: Waiman Long --- kernel/locking/rwsem.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/kernel/locking/rwsem.c b/kernel/locking/rwsem.c index 930dd4af3639..23654e3950b5 100644 --- a/kernel/locking/rwsem.c +++ b/kernel/locking/rwsem.c @@ -426,7 +426,12 @@ static void rwsem_mark_wake(struct rw_semaphore *sem, lockevent_inc(rwsem_wake_writer); } - return; + /* + * If rwsem has already been owned by reader, wake up other + * readers in the wait queue even if first one is a writer. + */ + if (wake_type != RWSEM_WAKE_READ_OWNED) + return; } /* @@ -1052,8 +1057,7 @@ rwsem_down_read_slowpath(struct rw_semaphore *sem, int state, long count) if (rwsem_optimistic_spin(sem, false)) { /* rwsem_optimistic_spin() implies ACQUIRE on success */ /* - * Wake up other readers in the wait list if the front - * waiter is a reader. + * Wake up other readers in the wait queue. */ wake_readers: if ((atomic_long_read(&sem->count) & RWSEM_FLAG_WAITERS)) { -- 2.18.1