Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4906314ybi; Mon, 3 Jun 2019 20:28:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqwXZ9mgXq+76kSkiMtthgS9/g+qmsM4mzFCgeU2tKwi9lTWlNaww0wuqVi9nV7FRkq1C+Nh X-Received: by 2002:a65:5203:: with SMTP id o3mr32531598pgp.379.1559618882982; Mon, 03 Jun 2019 20:28:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559618882; cv=none; d=google.com; s=arc-20160816; b=kKzelfxd2dCeAq/qnGzgJr531HWfwq4rwescPwoWyqg3lQk7qzo1kAvTsRmefo8eAy j8e60B0uUfLbex8RpeJnFJ4mcVfM27RDQAWIcjnLxl3ChPi+v2v2kHKZxe/mHsZ+2yAJ lHR0omlK5saQvR0R55ZPNRjwrTRn9W7LxKZYH6PqPNOp671aI/nZAmnXIrBCpV9sk9cQ ieCZKADFxi49ZLTGLB+lZE/WcSa2XVgIVjxD1/WOgopBz67dyp5EYEtK8LOUHDs6dSFi Un4xz3P5Y+pMgtDiGMkA+baqcIcP8+E7ZkzZbXVnolmRsRd7elPbT27rV01RVy5R3+xj CIZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=EAjnAQ0K1hwYMM9KoNoMU2lJGPs5nS56B44QDhx0hDo=; b=FqV/V58CjDLiyARKhqBWga6Pa0aFWT2DwU1MpvIWDjRx/+A/W8wZOQJyECSWGWo1Da swk/yUZdqghrE43ToSIqG1kHDNojShOWRh1RYky9TRI7+j8ix6OLAsA18P5xWxYHltsf lZvL98JMwlDszr1bLDaWLrLQ200LTZwu7fw0VvOscMIOj8x1yhVdRlYNjmf5osCppX/D D9uvv/zs3Zq/N3G4cDrhQN+xyc4m36und9GsnHq3OmLBiKY6ci+ar5EEZfbcBeMTf74w ykJb+UseS3O1NbrRIKeRN2GUrU86FKLGFiQitKZbk4DTQj9O0ycWa3HEihe5MudMnS+9 gqIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="lcst1qx/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b12si19391846pjw.17.2019.06.03.20.27.47; Mon, 03 Jun 2019 20:28:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="lcst1qx/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726343AbfFDD0m (ORCPT + 99 others); Mon, 3 Jun 2019 23:26:42 -0400 Received: from mail-qt1-f193.google.com ([209.85.160.193]:38274 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726076AbfFDD0m (ORCPT ); Mon, 3 Jun 2019 23:26:42 -0400 Received: by mail-qt1-f193.google.com with SMTP id l3so12135728qtj.5 for ; Mon, 03 Jun 2019 20:26:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=EAjnAQ0K1hwYMM9KoNoMU2lJGPs5nS56B44QDhx0hDo=; b=lcst1qx/GHdqNmKA5u4qCKjmdHycGvAGijuRlbh3ztn3J7LpyVsaugqFZCmbkCquOQ X2bn4P7pO4r9AsUbDUkhCCHmv/lu3RO5D4chblb12rGHWFNLJtQ+gP8e1QCcqpPZWmPW j5oSO+KtxAVIVj8LWjRBEdVyC5vGu1OPBoKOHnnFXAcZ8vvwIn6UG0DBiVKomyJG/Lz0 5rBKGdHftFs88QBitexyae3k1ZoFAspekrRpU3lPJrTNr5oy9hxRVJSwg5FWTOfMGpHj 6onv6LN/pvWrlKILtHdpE985wcuhAohzeTVe6a+OcBysWTffIjA3aMR5JT8kVjBYfRD4 9N5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=EAjnAQ0K1hwYMM9KoNoMU2lJGPs5nS56B44QDhx0hDo=; b=f27dF1OKODXuCVDCfsVkkSTEiGlBHl39atBbxbNcLtWVvVdOlcPebbvlTrAJ1L1FaA ceiSdAGtRdx1AWDvanfvP7IgZH2IgXBtDNuza+96jqjtV56S3u+iv4c2VTaR3QYr0I22 +QGNMSU6kmfOh3qnhWqVK/WmrdQJ5JinbJfaOwUTikL2GiMVBTTVBa4zU6yfKphWk1cs ykKO8gVi/swqfZcH/aiTqnQhVJM2buPEJKqSm27F9l1KjkSDAGtYiFcdjz6+VtkJFKTN a9F5egEK22ICK1cmet+LEqovNpvgz5d3bIiIbI+PFzNOSiooHdy6UQv0FjR6hxI2Hc0a u1Ig== X-Gm-Message-State: APjAAAXctqmbKcDFZhWq39eE7Yvvz3EUWkYzB+ReuJe0A7Rj9vfwEvW8 GySiwreLOdEzPMAhj32dG4vjSltiYsX9AoiTd5dvBdA6RdNZzWPd X-Received: by 2002:a0c:a066:: with SMTP id b93mr24420790qva.140.1559618801568; Mon, 03 Jun 2019 20:26:41 -0700 (PDT) MIME-Version: 1.0 References: <20190520205918.22251-1-longman@redhat.com> <20190520205918.22251-8-longman@redhat.com> In-Reply-To: From: Yuyang Du Date: Tue, 4 Jun 2019 11:26:30 +0800 Message-ID: Subject: Re: [PATCH v8 07/19] locking/rwsem: Implement lock handoff to prevent lock starvation To: Waiman Long Cc: Peter Zijlstra , Ingo Molnar , Will Deacon , Thomas Gleixner , Borislav Petkov , "H. Peter Anvin" , LKML , x86@kernel.org, Davidlohr Bueso , Linus Torvalds , Tim Chen , huang ying , Boqun Feng Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 4 Jun 2019 at 11:03, Yuyang Du wrote: > > Hi Waiman, > > On Tue, 21 May 2019 at 05:01, Waiman Long wrote: > > > > Because of writer lock stealing, it is possible that a constant > > stream of incoming writers will cause a waiting writer or reader to > > wait indefinitely leading to lock starvation. > > > > This patch implements a lock handoff mechanism to disable lock stealing > > and force lock handoff to the first waiter or waiters (for readers) > > in the queue after at least a 4ms waiting period unless it is a RT > > writer task which doesn't need to wait. The waiting period is used to > > avoid discouraging lock stealing too much to affect performance. > > I was working on a patchset to solve read-write lock deadlock > detection problem (https://lkml.org/lkml/2019/5/16/93). > > One of the mistakes in that work is that I considered the following > case as deadlock: Sorry everyone, but let me rephrase: One of the mistakes in that work is that I considered the following case as no deadlock: > > T1 T2 > -- -- > > down_read1 down_write2 > > down_write2 down_read1 > > So I was trying to understand what really went wrong and find the > problem is that if I understand correctly the current rwsem design > isn't showing real fairness but priority in favor of write locks, and > thus one of the bad effects is that read locks can be starved if write > locks keep coming. > > Luckily, I noticed you are revamping rwsem and seem to have thought > about it already. I am not crystal sure what is your work's > ramification on the above case, so hope that you can shed some light > and perhaps share your thoughts on this. > > Thanks, > Yuyang