Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5416225ybi; Tue, 4 Jun 2019 06:24:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqw6zjBUs7BD1soppGSay5fqI+ll/fYXUF8zqqf8Pi5REIZztZoXeHBvjOIxtN8H/HRRh8iI X-Received: by 2002:a17:90a:ac14:: with SMTP id o20mr9316782pjq.114.1559654696001; Tue, 04 Jun 2019 06:24:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559654695; cv=none; d=google.com; s=arc-20160816; b=fso0Uj4/QpMBVczu7BsL9d+rMWlRyqkdlPIBXmMP2U0AM3pkXc9ArrOf7RzxeRj1A1 buxeSyIZArkET1lcXfs1ruNXwywcfc//dHi15t4MGuHS8Ej0r0/7izgJebXCwFU8cvdc XMEYErhTQ3AFInernH82ODX9m2V69C8NvciOGB/r6IFfOYiClxQj+SM5pZqWyNwnSxmQ /labq3uenw19UtPbtV+QcaLyi41TJPUjvBQDVkKJ1L4dJ4ZhXaos4LUtrrVd2KAkQdcd ILX4HJprpq9+tBeY22boLSpaR8pq9uajpkfms9bLZqqoyl26o+XT5myN4bNBU/TCRfy8 e6sA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject; bh=cz7k22LKATPACEeKZ1QOqgf3Na7KhVmFSq9DJ4BZk+s=; b=sovj6CR3hQnrSTcMwAxJjhgwso+cexOA9NZWTma9PC/oLh6SNIZVr0sVt4fKdzqveP Tanb9xPq5XkQIw0RRZhP/OptXtoduNUA5NZDsdqd06RED3+xaFMG4Rg9I4N77fQ9aA98 UyTpJoMYgry0cmcF6ozQRKf/TetDfE37ziF5NLwsefyjRq2iMGM69h4KsIEj2nlrs12E //eO+HgHMTVJ7bWdeoNr78fqNPHJRsRVLBs2E5y7EHDzHOo5JPrDwrp7QniBaEv/EfVf toCLI06zh55zqc7rFUpDR/jbp2Rr1G0u3P6yK/hT+F4y30dfBpkTPO4vmtWh/7qxG2g1 UgRw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s5si22815999pgr.361.2019.06.04.06.24.38; Tue, 04 Jun 2019 06:24:55 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727648AbfFDNVn (ORCPT + 99 others); Tue, 4 Jun 2019 09:21:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59832 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727137AbfFDNVj (ORCPT ); Tue, 4 Jun 2019 09:21:39 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B6A4E356F5; Tue, 4 Jun 2019 13:21:23 +0000 (UTC) Received: from llong.remote.csb (dhcp-17-85.bos.redhat.com [10.18.17.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id D4C2B1001DD2; Tue, 4 Jun 2019 13:21:19 +0000 (UTC) Subject: Re: [PATCH v8 07/19] locking/rwsem: Implement lock handoff to prevent lock starvation To: Yuyang Du 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 References: <20190520205918.22251-1-longman@redhat.com> <20190520205918.22251-8-longman@redhat.com> From: Waiman Long Organization: Red Hat Message-ID: Date: Tue, 4 Jun 2019 09:21:19 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 04 Jun 2019 13:21:39 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/3/19 11:26 PM, Yuyang Du wrote: > 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 Yes, that combination shouldn't cause a deadlock. However, the lockdep code isn't able to recognize this case and so you may still see splat about possible deadlock scenario when lockdep checking is enabled. So the general advise is still to try to rearrange the lock ordering, if possible. >> 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. Lock starvation is certainly possible with the current rwsem code. Why don't try to apply the patch to see if it can remedy your problem? Cheers, Longman