From patchwork Mon Oct 24 17:44:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Waiman Long X-Patchwork-Id: 607 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp617272wru; Mon, 24 Oct 2022 12:31:16 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5z4Xl6RbwYcyzkU1nktcewQeznggWq/yY2HltlTZqw2ONLkpS8SmeI1zdkzUl5EWYKOmFy X-Received: by 2002:a05:6402:268a:b0:45c:c38d:ed70 with SMTP id w10-20020a056402268a00b0045cc38ded70mr32085609edd.62.1666639875942; Mon, 24 Oct 2022 12:31:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666639875; cv=none; d=google.com; s=arc-20160816; b=ALPZfOMu9cqtzHoDOYINbiMMV3fAM/DnqfnzvA14++WQVCP2W2DbEE71x+d3kXarBl EdbuvZG9Pj6c7bJEuPKzNLnQySdfQ6mMN5Cv59vcrGduFqosPV0n0EEl61jDKI6tUL4s P+14wPoWyEwAdeMenbpq+6FTQd4yeghDwU99C0xmEPobN9aEK177cRFpxq2DL4g0VtoJ n6yvnS9RhzIo2LFzH8w2ZKCZFKylDEuNFA1YoE2hNuQHSIUTAGZNMO0il5RDBug9fcG0 oPYyRCeUBnGS6nPgBuGvy4Eb5iSaSG8RmienYa/Om4aMIDdqGJHNjy0NM5gvk1cGznd0 Cupw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=BKsIeHeTa8oYpszhjqyCKaOjh+pr8dDdDzbYGV4SIoQ=; b=cpRJcHl9TufWFuDZyEQTVUpe+JStOKBabOrPZddmT0pWN/iSbH1KL8ldl11HZAAi/1 K6noIzLhc4yBOskRR7/SKc1pm2a8ZC09vrEsZy44nOja6AzIs0+img2ijXvw4xP/Napt P2CWnMdIZ4QEAxrSnKI3m/Vp+lmpR/z+/ep3VhkZQNMFsNQwNIt4IPOHyzfNxL6McLze M3wi2jKWhC2X+/solgd1g2kBcUqDPV5QyuyWEVrSr6CF0a56ZlX0cpeC+2/gDI+fqjmH k3yCxFB+bGMJuSi7TkgiXZfoPGYMNvKMz+A8I+NDGPpDhPdRCFbmQdPQRsUVQCrLUa8K eIow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SsPZQ7g8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z3-20020a056402274300b0045cecdc1fbcsi802156edd.9.2022.10.24.12.30.50; Mon, 24 Oct 2022 12:31:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SsPZQ7g8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S233253AbiJXT2y (ORCPT + 99 others); Mon, 24 Oct 2022 15:28:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232408AbiJXT2W (ORCPT ); Mon, 24 Oct 2022 15:28:22 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C33997D1CB for ; Mon, 24 Oct 2022 11:00:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666634289; 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; bh=BKsIeHeTa8oYpszhjqyCKaOjh+pr8dDdDzbYGV4SIoQ=; b=SsPZQ7g8UDWrwxssM/GZHB2PjI/LmpN2Q9PeG8JRkvzOBCZa1JKj7kjwXmKbyf679Nmwpl QmMrNt5B39Ql1rzBtNxtqebU08aPjXo2nWSquWX0pg29T9alvenpXEYOlbD3c9jrgW61pm hf9CicA8FNCzEThre2IwI4hdo6KCaUs= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-270-6U8GaSwEOh6tl65uRXdbHw-1; Mon, 24 Oct 2022 13:44:50 -0400 X-MC-Unique: 6U8GaSwEOh6tl65uRXdbHw-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 38EB63C32C44; Mon, 24 Oct 2022 17:44:50 +0000 (UTC) Received: from llong.com (dhcp-17-153.bos.redhat.com [10.18.17.153]) by smtp.corp.redhat.com (Postfix) with ESMTP id 90A1E492B0A; Mon, 24 Oct 2022 17:44:49 +0000 (UTC) From: Waiman Long To: Peter Zijlstra , Ingo Molnar , Will Deacon , Boqun Feng Cc: linux-kernel@vger.kernel.org, john.p.donnelly@oracle.com, Hillf Danton , Mukesh Ojha , =?utf-8?b?VGluZzExIFdhbmcg546L5am3?= , Waiman Long Subject: [PATCH v4 0/5] lockinig/rwsem: Fix rwsem bugs & enable true lock handoff Date: Mon, 24 Oct 2022 13:44:13 -0400 Message-Id: <20221024174418.796468-1-longman@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747598574554579049?= X-GMAIL-MSGID: =?utf-8?q?1747598574554579049?= v4: - Update patch descriptions in patches 1 & 2 to make clear the live lock conditions that are being fixed by these patches. There is no code change from v3. v3: - Make a minor cleanup to patch 1. - Add 3 more patches to implement true lock handoff. It turns out the current waiter optimistic spinning code does not work that well if we have RT tasks in the mix. This patch series include two different fixes to resolve those issues. The last 3 patches modify the handoff code to implement true lock handoff similar to that of mutex. Waiman Long (5): locking/rwsem: Prevent non-first waiter from spinning in down_write() slowpath locking/rwsem: Limit # of null owner retries for handoff writer locking/rwsem: Change waiter->hanodff_set to a handoff_state enum locking/rwsem: Enable direct rwsem lock handoff locking/rwsem: Update handoff lock events tracking kernel/locking/lock_events_list.h | 6 +- kernel/locking/rwsem.c | 172 +++++++++++++++++++++++------- 2 files changed, 138 insertions(+), 40 deletions(-)