Received: by 10.213.65.68 with SMTP id h4csp1011316imn; Tue, 27 Mar 2018 12:59:00 -0700 (PDT) X-Google-Smtp-Source: AIpwx49qW3crPaNpGHWhzkInTSKgPFo0cIQJjkf2VGxmgfvdc8JS7UydJ78kak3uyzFiU59yWdGm X-Received: by 10.99.47.4 with SMTP id v4mr487495pgv.42.1522180739955; Tue, 27 Mar 2018 12:58:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522180739; cv=none; d=google.com; s=arc-20160816; b=S7fsF+zqsrhG6oEy2vLuHPje+Niaqvv3185aYql9fZ+7aftDnwUdE24ydzX/+Qk8zi /S8fACfkvSaVGH61hY6/Oon9ogQM/nxNpA/GAopTsbS3wbtx/CDQDPG+qMZYeIWIZesJ OmarEyrOHEMQeOw82+KSSC+KXEUzq1+dXwZZi3cVs0POoilgN1B92mP2z51HC1+hcEnE LuONQu56TrpBaLIBffnnWcRXjfEHXDD11N6vFWM9l260ELxniIQfvt5LIYRRxQQU0jnc NjCMcAuFrC5lCHJlhou0p34PgEzGSkwt4+guI2uDzqh0nFCpgpQ7Pks4p7LZkQ4eG/zh ZOyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=tYNsRNtPUN4nZ887zhK8WP+2J9K4F9Uyv7yymqAbUbA=; b=HndwbPPcdJdvZ6FtvRGRogk1x6LIVAsoQ4Sr3w3OpUS4JOc/8Er3R6f03Q8kpb2KXh bwv7P6Bzm66s5dv362qJbJRBxtzPhtJ618JTDCzQT3AABxv1pP2N6zcnuEA97zQMxMF+ R3uGSKhSdS3KOS4GpVErbFA+ieQaB0gEuQbO6g08sgutsOvowOr3vZFWvUjep5E/v4Kk mmoszyd24ZmK6OqhRYoejJlyWV947ehB+/FIAtnKh++frMyENJOI0zSRGBA1Fp2K9h54 eHrVJ4jpFWpsH6PHUTygNkwMm4IaxrP753KbhzYTt2uMbcMcPBpAKEOolrxrs2sZUh+H ckQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=jefpZgj/; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 24si1459993pfo.327.2018.03.27.12.58.42; Tue, 27 Mar 2018 12:58:59 -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=fail header.i=@gmail.com header.s=20161025 header.b=jefpZgj/; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751748AbeC0T4p (ORCPT + 99 others); Tue, 27 Mar 2018 15:56:45 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:55999 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751008AbeC0T4n (ORCPT ); Tue, 27 Mar 2018 15:56:43 -0400 Received: by mail-wm0-f68.google.com with SMTP id b127so76418wmf.5 for ; Tue, 27 Mar 2018 12:56:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=tYNsRNtPUN4nZ887zhK8WP+2J9K4F9Uyv7yymqAbUbA=; b=jefpZgj/DF+EZ5gPUtLyt9dEIYp+bKdGblqMJDyATd2I83KKTNz4mKZiUVNJcOwvaK mQ6D1HnYlL9VMVse8cYutyACqi/PwBp5LjilReroXq27HDLFMOGNY+c1LD2Bz78V6G1d Mba6JV94PkLhvJVPi2ejyA6K7vXdst0fAb6/JbK9pEUR5ASzOd1KMDMmBDd9n2T32iwN bdO8P2iXeJ9/G97XC3UWoTxHP8Qs/mazJQaKQCb1L3ZOC0Y+JGSLo/1rZ/TIxg9SEnLU KSpacusCJlYhstU8kljj5KntjSQAx3I9wyjwcYM3PL1OyKAapyrWfHX5aa850JGxXyLL oxQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=tYNsRNtPUN4nZ887zhK8WP+2J9K4F9Uyv7yymqAbUbA=; b=dt1DHMbHfd26JJOS0gcU3UqccsiyIcEAQhpjTwgqDqqGYVGsMk9m1WcDYFn/5vZsJq +mJ/gcutZOMi22ztEv5qESFn8+k8tkBGzIcXxzNEbpFTibLoEKx2mjVJyHFI+fRB+Egv 0doIEUUDbV8iAK7G+hFo3abijdzmxzOAOb+HEuQx3TpG1593PR3bqmy6+7f4tWFW54ZG BVNoKzuB24LhHbxdKdRCtnusjJKm582/ed484ALd9Y8r8OZ8TEuDPLJ0Jb9ZH3fQq9Ao RM+uOqzQvmcSGTZwu/7yrC2bZWMH46AAw9F+dmnkRPXqEaqAYRmQivGHpeAVSEFaP2mo K+/w== X-Gm-Message-State: AElRT7HmwE9Zsltwq6wYNDIgRucfTUWAOCAUbwbIpo6ypOGVcxWN26Nn CAiL+yV0Rfqh+a0tPnZhgnFEmA== X-Received: by 10.28.10.83 with SMTP id 80mr476788wmk.70.1522180601947; Tue, 27 Mar 2018 12:56:41 -0700 (PDT) Received: from gmail.com (2E8B0CD5.catv.pool.telekom.hu. [46.139.12.213]) by smtp.gmail.com with ESMTPSA id m129sm2272621wma.16.2018.03.27.12.56.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 27 Mar 2018 12:56:41 -0700 (PDT) Date: Tue, 27 Mar 2018 21:56:39 +0200 From: Ingo Molnar To: Waiman Long Cc: Ingo Molnar , Peter Zijlstra , linux-kernel@vger.kernel.org, Thomas Gleixner Subject: Re: [PATCH v2] locking/rwsem: Add DEBUG_RWSEMS to look for lock/unlock mismatches Message-ID: <20180327195639.7pkqb47wcgr6jgoy@gmail.com> References: <1522091848-18426-1-git-send-email-longman@redhat.com> <20180327060655.25zjgqlgbfsp6b3p@gmail.com> <72b8a73c-bfc0-5884-199d-349ee3311802@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <72b8a73c-bfc0-5884-199d-349ee3311802@redhat.com> User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Waiman Long wrote: > On 03/27/2018 02:06 AM, Ingo Molnar wrote: > > * Waiman Long wrote: > > > >> For a rwsem, locking can either be exclusive or shared. The corresponding > >> exclusive or shared unlock must be used. Otherwise, the protected data > >> structures may get corrupted or the lock may be in an inconsistent state. > >> > >> In order to detect such anomaly, a new configuration option DEBUG_RWSEMS > >> is added which can be enabled to look for such mismatches and print > >> warnings that that happens. > >> diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug > >> index 64155e3..0958192 100644 > >> --- a/lib/Kconfig.debug > >> +++ b/lib/Kconfig.debug > >> @@ -1075,6 +1075,13 @@ config DEBUG_WW_MUTEX_SLOWPATH > >> even a debug kernel. If you are a driver writer, enable it. If > >> you are a distro, do not. > >> > >> +config DEBUG_RWSEMS > >> + bool "RW Semaphore debugging: basic checks" > >> + depends on DEBUG_KERNEL && RWSEM_SPIN_ON_OWNER > >> + help > >> + This feature allows mismatched rw semaphore locks and unlocks > >> + to be detected and reported. > >> + > > Makes sense - but this should also be integrated into the rest of lock debugging > > Kconfig hierarchy similar to DEBUG_MUTEXES: i.e. DEBUG_LOCK_ALLOC, PROVE_LOCKING, > > etc. should select this new lock debugging option as well. > > > > People generally are not supposed to know and configure the finer details, > > CONFIG_LOCK_DEBUGGING=y is a one-stop-shop in this regard. > > I can add a patch to rework lock debugging configuration code. Do you > want to hide the individual config options but still allow them to be > enabled manually? Alternatively we can also just add a master lock > debugging option to select them all. They should work like mutex debugging: it's auto-selected by PROVE_LOCKING, but can be enabled individually as well if PROVE_LOCKING is disabled. Thanks, Ingo