Received: by 10.213.65.68 with SMTP id h4csp1043520imn; Tue, 27 Mar 2018 13:38:58 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+I3RtEju/nYvnissEtKgvK7BSuWM0/yplAxtJ/Zhyf/srO2G6/HPQ0SEOUF3e8geAXDUDy X-Received: by 10.99.97.20 with SMTP id v20mr545552pgb.214.1522183138772; Tue, 27 Mar 2018 13:38:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522183138; cv=none; d=google.com; s=arc-20160816; b=ehc9pAs/yd85v0vfPu1Z6ZVI6YXLRRk7G3hIQbWRc3N+f0U8GaIPYA0NdfxnKrSM00 y18Swkk7d9rdAiYUBo3ZLNyb0N+tpxcVvxEZuTBrkwxbtkWoSHRjtVCm15Qt8z6mcg8P JDmzJPZRFCFuuetGDyWMZVNskRFbF/nKMRBEKOPvCvU9AeU+LgGwCNK9vX/XZQwq5l/V hOjROppVcUxIkQkjAKikhA36ZoWJbEBTE59lRTKTPXufm/3SIncFNLX7NrfHhBFD6pcY e5eL7yjSUgiDeQzklAS6SHZfpFA6RySTdx4crXgfUs74fFe7VG9R31t+l7QDa8FB75jm ZKyg== 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=ysX+jRvi5THakAHYXuEwbOZuq24IQPcmcdMUQ43GM9Y=; b=xkZqW4Ftr5Ajjjj0063ORUikrDeu+Lz2RvcUeGTOJU4ahEkFimG37Pq6dL6GlwgXm+ 9fiX8+VjCeIXWkMaWUPmz2qotntmD9of93wElWkCp/2TwcO6n64vNmtuMfX8brekqASR TezKwpOJBOFJuqC6J5rYMUFpCBmgXTd384+9aAklNgZVVEM6jP4z9g23FH/DvkW0+ANv ZD5d+qFPy7MM9BGyLlryHP1jHwPj5RhQAIo10MMvTBfaTG4mu+XwpREr4DEjC763eCvJ ZRWyebSGISGQ6ANVQ6oS2xEwLAZQDR9LXQV9zqpo0kuxPyHrYXW9SOkL0A5vpItNNS+R NtGA== 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 j9si1476426pfh.200.2018.03.27.13.38.43; Tue, 27 Mar 2018 13:38:58 -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 S1752004AbeC0Uhh (ORCPT + 99 others); Tue, 27 Mar 2018 16:37:37 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:34754 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751207AbeC0Uhf (ORCPT ); Tue, 27 Mar 2018 16:37:35 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 75A7781902B3; Tue, 27 Mar 2018 20:37:35 +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 3318C215CDB5; Tue, 27 Mar 2018 20:37:34 +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> <72b8a73c-bfc0-5884-199d-349ee3311802@redhat.com> <20180327195639.7pkqb47wcgr6jgoy@gmail.com> From: Waiman Long Organization: Red Hat Message-ID: <529e4373-754e-307c-6dc2-a605a05826de@redhat.com> Date: Tue, 27 Mar 2018 16:37:34 -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: <20180327195639.7pkqb47wcgr6jgoy@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Tue, 27 Mar 2018 20:37:35 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Tue, 27 Mar 2018 20:37:35 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.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 03:56 PM, Ingo Molnar wrote: > * 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. Got it. Thanks, Longman