Received: by 10.213.65.68 with SMTP id h4csp687215imn; Tue, 27 Mar 2018 07:01:46 -0700 (PDT) X-Google-Smtp-Source: AG47ELtRnCkg3l/k4HAGun2CfWmk3EZs5e2pX4cOrBHqmSMs2qfuAuoc2oznBGSzlMcHbqjkFF0g X-Received: by 10.99.127.75 with SMTP id p11mr30785761pgn.392.1522159306670; Tue, 27 Mar 2018 07:01:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522159306; cv=none; d=google.com; s=arc-20160816; b=z9DhVxTTWd8Kjnvdrh64PqYSbu2wHgoEGUmZDyK5IeQEaXAO9vZpI6VrtIjpi9bHpP /s32SngtL9u0XZyIViaP1ttH4aBmo15qukowMyhGwC3q/AadTRHDYXXF/d5G4p5PuAoo rkMjXf624bCu2qaKjDfiFYnmhHRLqIvQFnjWBweWMBzFZ99B4dryu4Lj4iyCorLfrDZc iTSGr6uHGKec93ZB1iLzJqq/nSitqQ9EyryyxdV68i4DOEN5xi+WPp7ROg/QspBB5gGB egmFGwDIUQegnov4jmOydLkuzpzy0bE4sKGCnj4GkZgaE9UL67Ip0bpKcsIM6hB1O7rj hJYw== 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 :arc-authentication-results; bh=0sp1yD+l2kKxSj4TCsojlLg/x8JUiod6z+Ab9PlEXQA=; b=Lq12sDmaRUm3rId8g8RCK/bFCi5rLZaDgXJECZyaUWIxka+t6XPUjeUGTar2lpPA2i 67rBlR70fdLUr8flr+b4CJ6TT4ztDUo0kQkQ0iSDP9Y6UInPc7kL+oTxlAtYV1Xvwcax n3fHPremD1Bzbb5br/3dpenVxmPCZzV99wE519q3RlaM2fmptvLbzKSzczk8TpkDVZ3i r+waN0/Q2d/Bvi8CXKWB1YCcFRmInbYZ+NAjsnxcnr63zcPk0/G+G+RVIBU2nWAQCbAU Zzn0xoE1RURdAfbq7NNy9dLoYAf5v3lbgx3YYrvMCRSFEmBuOEQqNRCgH1odnpGVR2PI yNrg== 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 c27si930416pgn.223.2018.03.27.07.01.30; Tue, 27 Mar 2018 07:01:46 -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 S1752947AbeC0N74 convert rfc822-to-8bit (ORCPT + 99 others); Tue, 27 Mar 2018 09:59:56 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:48804 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752775AbeC0N7y (ORCPT ); Tue, 27 Mar 2018 09:59:54 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 04C8A8182D1D; Tue, 27 Mar 2018 13:59:54 +0000 (UTC) Received: from llong.remote.csb (dhcp-17-164.bos.redhat.com [10.18.17.164]) by smtp.corp.redhat.com (Postfix) with ESMTP id B622910AF9C8; Tue, 27 Mar 2018 13:59:53 +0000 (UTC) Subject: Re: [PATCH v2] locking/rwsem: Add DEBUG_RWSEMS to look for lock/unlock mismatches To: Ingo Molnar Cc: Ingo Molnar , Peter Zijlstra , linux-kernel@vger.kernel.org, Thomas Gleixner References: <1522091848-18426-1-git-send-email-longman@redhat.com> <20180327060655.25zjgqlgbfsp6b3p@gmail.com> From: Waiman Long Organization: Red Hat Message-ID: <72b8a73c-bfc0-5884-199d-349ee3311802@redhat.com> Date: Tue, 27 Mar 2018 09:59:53 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 MIME-Version: 1.0 In-Reply-To: <20180327060655.25zjgqlgbfsp6b3p@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Content-Language: en-US X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Tue, 27 Mar 2018 13:59:54 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Tue, 27 Mar 2018 13:59:54 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'longman@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Cheers, Longman