From patchwork Mon Oct 17 21:13:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Waiman Long X-Patchwork-Id: 239 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1652878wrs; Mon, 17 Oct 2022 14:39:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM68cD3OB3ukJRwKTE/PrFWuIvkVofpXvgsEy2XJM3afHW4jeC+XhZ4uXf6WKhMdc0IpsXR1 X-Received: by 2002:a17:907:2cf7:b0:78d:c7fc:29ff with SMTP id hz23-20020a1709072cf700b0078dc7fc29ffmr10554975ejc.748.1666042799604; Mon, 17 Oct 2022 14:39:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666042799; cv=none; d=google.com; s=arc-20160816; b=Zy0tqfE771wrQ+86oPXQw9KSg0bGyKtz/T41AKq+cmaBmbjhxYjSSVXY8yWOHbuW4/ 1hJmL5pvJs915v+S+nb1TMZt5ZtaCHde1aXQ4x9JpzA7QKlW4J2xPe1F6OQDEV6QewFm E4fa6nXr/fQKFby/ZxPQDRHVWraHiC2o/bpAMea9QE/uQwD/QKFJsBrInyu+riZ2J84t +GhuFdZYmi69n625IJeQVSBSFik6W5RhRMT19MCWfykdz+q1sL2har3Ym1L0EsKQDZ4R 3m7ilcbVW8Pb00tvFgKACfTu7yymDjVX5A6Oj4n4wPJfusPRbYUiO+5c6xAh2+OfjBfq smgQ== 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=OFj+fpTcybhy1EO/TBp6S/h5BFRJbIkWDHIGTag8Fxc=; b=wcyhQRUarHPEEfyIBO0+LnK6ATsvz/MqGn6/WDbbqNripOkN7xjPeXRGn+k70hccjf pcJQf+CpUl1q93E3cnVSpMW31KzRl9NtQJ8NHMIesvlJC61uqmI0bJv5ODJYn96/aKwa bOEpo6TAXvmqnYNLoIpjdb6DabtvAXoD+E8b/EQLr2R6fAm1zhsQdBTaJxpwnhpvnV/I VdqlR3o/O3sdgehjkg9/lx2NGRBuHC347+FHCh9akSgQWlt1URKoOaLg4nJtYaTc8/4e FO4zwFgPSDX3ac9P3xlUrXo12BtxGh8ozHpcwgZINVVlpZoaJAwQZ4u8JcRAEPR8+/D0 uwYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=L7sgrU+X; 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 dv2-20020a170906b80200b0078d2848bca9si8518770ejb.704.2022.10.17.14.39.34; Mon, 17 Oct 2022 14:39:59 -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=L7sgrU+X; 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 S229707AbiJQVOt (ORCPT + 99 others); Mon, 17 Oct 2022 17:14:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230123AbiJQVOp (ORCPT ); Mon, 17 Oct 2022 17:14:45 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 554C0183A4 for ; Mon, 17 Oct 2022 14:14:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666041281; 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=OFj+fpTcybhy1EO/TBp6S/h5BFRJbIkWDHIGTag8Fxc=; b=L7sgrU+XMrreS7mtCcR58rg6ajkEwiO2tK4Pz17MTQdMN40yqUWLmyjeVyyetxMQL0rqih bzN+WgdMoYOrUYjVBhquCuu/Kk9P5pTEqWujIDw2yyf6hZom5YtaQfREFHSy18ctyf80Ij NrGZbNGmtFqJoXeACn+l1HFUo7/INPY= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-589-65OJOv85O4-RjKwZGFgZLg-1; Mon, 17 Oct 2022 17:14:36 -0400 X-MC-Unique: 65OJOv85O4-RjKwZGFgZLg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C619486F12E; Mon, 17 Oct 2022 21:14:35 +0000 (UTC) Received: from llong.com (unknown [10.22.33.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id E2DD440C206B; Mon, 17 Oct 2022 21:14:34 +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 v3 0/5] lockinig/rwsem: Fix rwsem bugs & enable true lock handoff Date: Mon, 17 Oct 2022 17:13:51 -0400 Message-Id: <20221017211356.333862-1-longman@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Spam-Status: No, score=-2.4 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?1746972494517157755?= X-GMAIL-MSGID: =?utf-8?q?1746972494517157755?= v3: - Make a minor cleanup to patch 1. - Add 3 more patches to implement true lock handoff. v2: - Add an additional patch to limit the # of first waiter optimistic spinning in the writer slowpath. 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(-)