Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp24184pxb; Tue, 17 Nov 2020 19:08:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJyWfOk8Mb5Edxmk30Bfyj+njmXUpfnLuDYjXoobS+luLN9i7pCLAnlKNc2VZfdhR+4Qzu6W X-Received: by 2002:a17:906:fa98:: with SMTP id lt24mr1094310ejb.52.1605668921348; Tue, 17 Nov 2020 19:08:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605668921; cv=none; d=google.com; s=arc-20160816; b=F4guH4SZVMB1ZlYZ4u7RL/3dK0QnGXPB4F7yqEfed64PqIaLMd3mRAS8yLP6Z5diIL MK7FEYxifm9bBWruEVcHJMQ7VQHA6zOIGAiYOVM2QNzzVa9D8QgkAqrviJK525ZYqS2s OtK028WZBgWbaP+QHt3M3AsxaQCw8jAH7DLgom150Jl0FHS23FJTed/T6AUrO5ZWJaTO FzA25pz+xa5LBxm0uFcGyV4h6igALC0bXOAlXAH3t6+gDy3kpR0p0MkOUvZF7QrytJ1D 6aUucvZpCS9lYZuoqCD/Le5oAZetDIxQB5hYI5MiE9Oowrk9dYGYeTKmzoDOaIqFlKC/ 2yXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=1tHTZo0NWIQ6U/qkej3mS/LRGrC8hfvrmLswNc7GVTU=; b=HkW71KcK4pMsZptt3qLAoXJQ3+NQ3D41V0gKJdoecTGp085Id818Wc7pVT5o6x5yFc UJbvTLgKQ6QG8KY53KYT86HWPUI5yYleTEWzd+i9vsp+oeHIy9sA2Z1Ce7TfdjivuLgq Ek6oD9Ss7mQNIRhb6H5GS/EJ4BoeA/H7unMyS63c6ae+B3BmTitrOqU8CYRmg9WO78rq pmTpAktDQXt7BMfQM7gcaoGB4tsBFSSjpD9V6wq7jSbNV8ZpTStKdDqw/Uf9rWTH2DxH Vbu7G0u81kb38hfLsKiCONkAH2Aj8H6sBOX62rgU+p940hJu0MZODvsU6eFQ3yVCjOIR A/rA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bVcpEq5C; 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 sb10si15114479ejb.541.2020.11.17.19.08.19; Tue, 17 Nov 2020 19:08:41 -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=bVcpEq5C; 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 S1726980AbgKRDFF (ORCPT + 99 others); Tue, 17 Nov 2020 22:05:05 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:22673 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725613AbgKRDFE (ORCPT ); Tue, 17 Nov 2020 22:05:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605668703; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc; bh=1tHTZo0NWIQ6U/qkej3mS/LRGrC8hfvrmLswNc7GVTU=; b=bVcpEq5CumX18md6R37cs5tmcwDpFQjFW4806jHlJ39fQfB/3QJoB3f8vd+6CfgVj2+vk0 QhNlbpXpJYrt4lRspzeWmhqPQkXJiEof1+sOI856lpc3GwXpF9JHvcDIsTqSh27PO9US5y lhvNeA+2m0DW/agS9+pBFbckRqneOu0= 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-529-_YoaksjpNB2KnzEAWxd0aw-1; Tue, 17 Nov 2020 22:05:01 -0500 X-MC-Unique: _YoaksjpNB2KnzEAWxd0aw-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 B73346414C; Wed, 18 Nov 2020 03:04:59 +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 E36BF5C1A3; Wed, 18 Nov 2020 03:04:55 +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 0/5] locking/rwsem: Rework reader optimistic spinning Date: Tue, 17 Nov 2020 22:04:24 -0500 Message-Id: <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 A recent report of SAP certification failure caused by increased system time due to rwsem reader optimistic spinning led me to reexamine the code to see the pro and cons of doing it. This led me to discover a potential lock starvation scenario as explained in patch 2. That patch does reduce reader spinning to avoid this potential problem. Patches 3 and 4 are further optimizations of the current code. Then there is the issue of reader fragmentation that can potentially reduce performance in some heavy contention cases. Two different approaches are attempted: 1) further reduce reader optimistic spinning 2) disable reader spinning See the performance shown in patch 5. This patch series adopts the second approach by dropping reader spinning for now. We can discuss if this is the right move or we should try the alternative or just don't do anything further. Waiman Long (5): locking/rwsem: Pass the current atomic count to rwsem_down_read_slowpath() locking/rwsem: Prevent potential lock starvation locking/rwsem: Enable reader optimistic lock stealing locking/rwsem: Wake up all waiting readers if RWSEM_WAKE_READ_OWNED locking/rwsem: Remove reader optimistic spinning kernel/locking/lock_events_list.h | 6 +- kernel/locking/rwsem.c | 277 ++++++++---------------------- 2 files changed, 73 insertions(+), 210 deletions(-) -- 2.18.1