From patchwork Mon Nov 19 18:55:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Waiman Long X-Patchwork-Id: 10689303 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1D6B15A4 for ; Mon, 19 Nov 2018 18:56:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0F8012A453 for ; Mon, 19 Nov 2018 18:56:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 034A02A459; Mon, 19 Nov 2018 18:56:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 98F562A453 for ; Mon, 19 Nov 2018 18:56:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 816E06B1B88; Mon, 19 Nov 2018 13:56:53 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 7733A6B1B89; Mon, 19 Nov 2018 13:56:53 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 667E46B1B8A; Mon, 19 Nov 2018 13:56:53 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by kanga.kvack.org (Postfix) with ESMTP id 35CD56B1B88 for ; Mon, 19 Nov 2018 13:56:53 -0500 (EST) Received: by mail-qk1-f200.google.com with SMTP id j125so4413591qke.12 for ; Mon, 19 Nov 2018 10:56:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=JRoIINT4wLhq1H5JNDRgKPNpks/BWJgT7rRCeSI5Vhk=; b=A48WZblMXjPU7YVNKf1OsN72NkaPixMuBIduRecnUEFBdbtUZuJbB7mbKPR61fHZdy 8rixPT0Rqb0QL+GQxtOCkEBj62/hlQrQfny723Lr5aZPtTqtjblseTQLCc/WLu+H3rbF FACM7UCPAG+OejAj/TKvuygx4U2E13h3Mhl8jOupER8x644kNikmXREf9aoqpv3UrgEh GRTLoLRPX34dZAcUasBFDLtVjpZoAnXdcdvX4E+i6gFMYehR63gC992jQwv2b82JgP7J HkJlwST4lIjIifVt3GAR+Rl859kFR6QIGFaj0C/oSRdRaqzZVJ/LzwBcLC7OmUDZCWf3 /Jsw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: AGRZ1gJLRGYAUzeF0joBYLqIS8/u0jVXLwhM+S7SbXKEgTp7U1awCgLh wUJ4W0dUucVt6k59WeLxUqLTv83G1tWnfKYmE54dP9cSCqpMtZJwKD7S1k4Le0p1LbJvmshDJ8T Qy8PchTOi/8ADVNoww/liNNhIwF1LoogYNp3143lVP26Vrv85pxYAsPpFdrBygl9gRQ== X-Received: by 2002:a37:4f4e:: with SMTP id d75mr21629260qkb.257.1542653812987; Mon, 19 Nov 2018 10:56:52 -0800 (PST) X-Google-Smtp-Source: AJdET5c5ajv0GLxTaDm9jAm6F7UHTineQbsUYxrGUbY/+qh4cfHF1hAvJi+fH60DP2pjPQXtmOq/ X-Received: by 2002:a37:4f4e:: with SMTP id d75mr21629241qkb.257.1542653812380; Mon, 19 Nov 2018 10:56:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542653812; cv=none; d=google.com; s=arc-20160816; b=MW8ANSzh+RXVixqD0mYPoSh9L7zzbKSgm8GivEQvocNHufEGugFI/KvSkEo2IhoVjO grRMA9TEPtqu503WbGd5g6Pdnr3MRVczQQ1ibxuXYdNmIxSLXAIPnZ/GfXgfaMAis0+Z WIjI6+tUP6tjVFzCC5v1n1JBNG7K2gGXjfku2knT1joTQGyy19QrZMK+xzcRBR8Dymlr kEjPJZdyYE86s0KGo1UjFrBThjYe2YYYHq/FhJelZbxng/H2Y3TeTQzXZTcHjsqNUG7P MF4ON5qqXzoVnknOLKS2x8JBby+ZrZvvZOW+kdS3DSE/JNGJ44Z1lR76a6W+gJKfpB7v yLxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=JRoIINT4wLhq1H5JNDRgKPNpks/BWJgT7rRCeSI5Vhk=; b=MoBe/Rma3vatbsv64hEzE7oMt1oapa0vWb/X6CqfNqqEnTZhreDrTIsuPc6QuXB1za TK9KJpvMjJg96R879J2JsfrRCcPzf+mag/GoMfpxIStPoMMiXQ/fFBqrifydz24aD9s1 l89GB8mR/8Fp+RGDT2Z2SGWkbGtVST/zrGuhG0UdaibMEkp1c98YnpRMgePeND7utsTv k1l1Cnty0uNhpWr7aVF7pN3IYDKJ2XPUwbgk33Sqt7VBa8cRg2ggyq8srWIM7gxxipA0 LaYzfXIASoao4BmgHIYhgK8zPRSRWVYr4f7Hda41BSGfdilpkXhK4pXPHYRDynJ+78X6 b79A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id v40si4418652qtv.322.2018.11.19.10.56.52 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Nov 2018 10:56:52 -0800 (PST) Received-SPF: pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5EB8F30DDBC4; Mon, 19 Nov 2018 18:56:51 +0000 (UTC) Received: from llong.com (dhcp-17-55.bos.redhat.com [10.18.17.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id DB01E608F8; Mon, 19 Nov 2018 18:56:49 +0000 (UTC) From: Waiman Long To: Peter Zijlstra , Ingo Molnar , Will Deacon , Thomas Gleixner Cc: linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org, iommu@lists.linux-foundation.org, Petr Mladek , Sergey Senozhatsky , Andrey Ryabinin , Tejun Heo , Andrew Morton , Waiman Long Subject: [PATCH v2 01/17] locking/lockdep: Remove version from lock_class structure Date: Mon, 19 Nov 2018 13:55:10 -0500 Message-Id: <1542653726-5655-2-git-send-email-longman@redhat.com> In-Reply-To: <1542653726-5655-1-git-send-email-longman@redhat.com> References: <1542653726-5655-1-git-send-email-longman@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Mon, 19 Nov 2018 18:56:51 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP It turns out the version field in the lock_class structure isn't used anywhere. Just remove it. Signed-off-by: Waiman Long --- include/linux/lockdep.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h index 1fd82ff..c5335df 100644 --- a/include/linux/lockdep.h +++ b/include/linux/lockdep.h @@ -97,8 +97,6 @@ struct lock_class { * Generation counter, when doing certain classes of graph walking, * to ensure that we check one node only once: */ - unsigned int version; - int name_version; const char *name; From patchwork Mon Nov 19 18:55:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Waiman Long X-Patchwork-Id: 10689305 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A68D213AD for ; Mon, 19 Nov 2018 18:56:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9838A2A2F2 for ; Mon, 19 Nov 2018 18:56:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 88CCF2A457; Mon, 19 Nov 2018 18:56:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EC4432A2F2 for ; Mon, 19 Nov 2018 18:56:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 59FA76B1B8A; Mon, 19 Nov 2018 13:56:56 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 54EDC6B1B8D; Mon, 19 Nov 2018 13:56:56 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 467236B1B8E; Mon, 19 Nov 2018 13:56:56 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by kanga.kvack.org (Postfix) with ESMTP id 1D4C96B1B8A for ; Mon, 19 Nov 2018 13:56:56 -0500 (EST) Received: by mail-qk1-f200.google.com with SMTP id v64so10147732qka.5 for ; Mon, 19 Nov 2018 10:56:56 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=3f2kXbq7ok7E/qMIuI8uIAU15Mf4RLPeqbdYXouJSBg=; b=p6oK5aXBVcBFUqJgIYHLk08oeEQxmKFzE6A4ORhOYs1h805Ui2J+DWrdkF6DUTQV9q oM/MRWKHylS0GPQ55BroEwPbPfqNUycADJqeANpZZ3jejbw9tREpwvJPPEFccwWUMVW3 OlEoen+HPHwksVAvu3sIo6v3GHZdPiRwqBiGcP+L7VWLXeHJAWy3lBv0lQT3YYvolcJx 5Tpfsha3CkbCl/d9LI/I8hB/zwXMeo4HXDiDmNfVIFBraM5CGUgHRuYXZTtar3cEpccc PfxtaJQurzy+jp+FQVZIvrYlPtZwmRgyxgDjnv4xs5zDSIsAaZCdFFm42mAv7e1teGaF P9yA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: AGRZ1gIkjfpM8mSt/TF1IAunM3epcLAcXoX+5yiaG20ULOfmcXKDgr8p fCAWXjhzW6DxEHWVj0n9DCV9M/do73T0VALsxfsRM0a5Zrzkve352J36vcZ2GmkBz5yavXqAsm8 vg/5SFnTbvnoxvaEQpm0VhtoETYpDLEkb1ki3zvUUAoSQNsS12fwLU9oh9PY7NfKAew== X-Received: by 2002:ac8:6949:: with SMTP id n9mr22278257qtr.308.1542653815866; Mon, 19 Nov 2018 10:56:55 -0800 (PST) X-Google-Smtp-Source: AJdET5dxdusmmp22YkSF9r3et6OFJmsKOpirGkaGTji6DaMVEAfzswwj3/ulgADATR7SRgmhTaCv X-Received: by 2002:ac8:6949:: with SMTP id n9mr22278213qtr.308.1542653814651; Mon, 19 Nov 2018 10:56:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542653814; cv=none; d=google.com; s=arc-20160816; b=Gx5O/2bhdOrwc5QaBTs2B8YM2lyZil2FQau8/iy7DdVvBWbQohoYIDixRjV3MRTUIE XSdapFYaGv383Ieuh85XoRENYpy+Rk6/ZiMUFWLKcmYYW06ec/TTgRAh3o2qEI8APG58 rzxQPcne+/cUzBczX7+fLlcsWtZFApUYExsnglbS592rvwAaZOW3orTl01RirCRqVyrk Y8bUJghwbboq1R5My9a1mw0mtFzvGmqlv0pifEXg+SocwrKQGk81Gh3ggznLiZnVcwKT FZT2WFcPNpMlFRdS9XzD0SKuY3cQcLq7G3e48SKlKh69BMBmFqW8VUNzEXzXh4Lx5JqC oQMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=3f2kXbq7ok7E/qMIuI8uIAU15Mf4RLPeqbdYXouJSBg=; b=bF6ioyLLI3K/Ly7k8CBbhhtsAIAi5zc5xDu+tsfXnPLqaVMLCqCNAsQlK52OmisuGk 9HhcUnHnP+m0BlUipApXz0tPemKfEW4YBBDgApxekrwyHXrxhvHDN42h1sPqnMDh8PMF k4wDLH0bT5tcyomwn0gfw7QD+5aoTVyJBsl9ybfaDRZ2M6GMwRFigL3vHHRIDS5ucn2+ JHnpxh58CXCXF1YmLhgDzDzDV4bfOoEiIzCWL08rEBPUI0NjaneImmM/+zVo1ikF/9WO NZIJZycn2g7XwMhXHDcLsCnlNrAyDZUD2KDg7GzJmMh4KmkYDfRHx+8HYBA6W2qJUfN+ HlSQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id 190si957531qkk.28.2018.11.19.10.56.54 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Nov 2018 10:56:54 -0800 (PST) Received-SPF: pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4D11573A85; Mon, 19 Nov 2018 18:56:53 +0000 (UTC) Received: from llong.com (dhcp-17-55.bos.redhat.com [10.18.17.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 73CCE608E7; Mon, 19 Nov 2018 18:56:51 +0000 (UTC) From: Waiman Long To: Peter Zijlstra , Ingo Molnar , Will Deacon , Thomas Gleixner Cc: linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org, iommu@lists.linux-foundation.org, Petr Mladek , Sergey Senozhatsky , Andrey Ryabinin , Tejun Heo , Andrew Morton , Waiman Long Subject: [PATCH v2 02/17] locking/lockdep: Rework lockdep_set_novalidate_class() Date: Mon, 19 Nov 2018 13:55:11 -0500 Message-Id: <1542653726-5655-3-git-send-email-longman@redhat.com> In-Reply-To: <1542653726-5655-1-git-send-email-longman@redhat.com> References: <1542653726-5655-1-git-send-email-longman@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 19 Nov 2018 18:56:53 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP The current lockdep_set_novalidate_class() implementation is like a hack. It assigns a special class key for that lock and calls lockdep_init_map() twice. This patch changes the implementation to make it as a flag bit instead. This will allow other special locking class types to be defined and used in the lockdep code. A new "type" field is added to both the lockdep_map and lock_class structures. The new field can now be used to designate a lock and a class object as novalidate. The lockdep_set_novalidate_class() call, however, should be called only after lock initialization which calls lockdep_init_map(). For 64-bit architectures, the new type field won't increase the size of the lock_class structure. The lockdep_map structure won't change as well for 64-bit architectures with CONFIG_LOCK_STAT configured. Please note that lockdep_set_novalidate_class() should not be used at all unless there is overwhelming reason to do so. Hopefully we can retired it in the near future. Signed-off-by: Waiman Long --- include/linux/lockdep.h | 17 ++++++++++++++--- kernel/locking/lockdep.c | 14 +++++++------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h index c5335df..8fe5b4f 100644 --- a/include/linux/lockdep.h +++ b/include/linux/lockdep.h @@ -58,8 +58,6 @@ struct lock_class_key { struct lockdep_subclass_key subkeys[MAX_LOCKDEP_SUBCLASSES]; }; -extern struct lock_class_key __lockdep_no_validate__; - #define LOCKSTAT_POINTS 4 /* @@ -94,6 +92,11 @@ struct lock_class { struct list_head locks_after, locks_before; /* + * Lock class type flags + */ + unsigned int flags; + + /* * Generation counter, when doing certain classes of graph walking, * to ensure that we check one node only once: */ @@ -140,6 +143,12 @@ struct lock_class_stats { #endif /* + * Lockdep class type flags + * 1) LOCKDEP_FLAG_NOVALIDATE: No full validation, just simple checks. + */ +#define LOCKDEP_FLAG_NOVALIDATE (1 << 0) + +/* * Map the lock object (the lock instance) to the lock-class object. * This is embedded into specific lock instances: */ @@ -147,6 +156,7 @@ struct lockdep_map { struct lock_class_key *key; struct lock_class *class_cache[NR_LOCKDEP_CACHING_CLASSES]; const char *name; + unsigned int flags; #ifdef CONFIG_LOCK_STAT int cpu; unsigned long ip; @@ -294,7 +304,8 @@ extern void lockdep_init_map(struct lockdep_map *lock, const char *name, (lock)->dep_map.key, sub) #define lockdep_set_novalidate_class(lock) \ - lockdep_set_class_and_name(lock, &__lockdep_no_validate__, #lock) + do { (lock)->dep_map.flags |= LOCKDEP_FLAG_NOVALIDATE; } while (0) + /* * Compare locking classes */ diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index 1efada2..493b567 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -692,10 +692,11 @@ static int count_matching_names(struct lock_class *new_class) hlist_for_each_entry_rcu(class, hash_head, hash_entry) { if (class->key == key) { /* - * Huh! same key, different name? Did someone trample - * on some memory? We're most confused. + * Huh! same key, different name or flags? Did someone + * trample on some memory? We're most confused. */ - WARN_ON_ONCE(class->name != lock->name); + WARN_ON_ONCE((class->name != lock->name) || + (class->flags != lock->flags)); return class; } } @@ -788,6 +789,7 @@ static bool assign_lock_key(struct lockdep_map *lock) debug_atomic_inc(nr_unused_locks); class->key = key; class->name = lock->name; + class->flags = lock->flags; class->subclass = subclass; INIT_LIST_HEAD(&class->lock_entry); INIT_LIST_HEAD(&class->locks_before); @@ -3108,6 +3110,7 @@ static void __lockdep_init_map(struct lockdep_map *lock, const char *name, return; } + lock->flags = 0; lock->name = name; /* @@ -3152,9 +3155,6 @@ void lockdep_init_map(struct lockdep_map *lock, const char *name, } EXPORT_SYMBOL_GPL(lockdep_init_map); -struct lock_class_key __lockdep_no_validate__; -EXPORT_SYMBOL_GPL(__lockdep_no_validate__); - static int print_lock_nested_lock_not_held(struct task_struct *curr, struct held_lock *hlock, @@ -3215,7 +3215,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass, if (unlikely(!debug_locks)) return 0; - if (!prove_locking || lock->key == &__lockdep_no_validate__) + if (!prove_locking || (lock->flags & LOCKDEP_FLAG_NOVALIDATE)) check = 0; if (subclass < NR_LOCKDEP_CACHING_CLASSES) From patchwork Mon Nov 19 18:55:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Waiman Long X-Patchwork-Id: 10689307 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2960913AD for ; Mon, 19 Nov 2018 18:57:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1A6432A459 for ; Mon, 19 Nov 2018 18:57:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0EB842A467; Mon, 19 Nov 2018 18:57:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 181CC2A459 for ; Mon, 19 Nov 2018 18:57:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 94F6D6B1B8D; Mon, 19 Nov 2018 13:56:57 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8D52C6B1B8E; Mon, 19 Nov 2018 13:56:57 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 79B786B1B90; Mon, 19 Nov 2018 13:56:57 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by kanga.kvack.org (Postfix) with ESMTP id 52E3B6B1B8D for ; Mon, 19 Nov 2018 13:56:57 -0500 (EST) Received: by mail-qk1-f197.google.com with SMTP id v64so10147803qka.5 for ; Mon, 19 Nov 2018 10:56:57 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=tO4c/KM0bSn41nZdkVbqQD0yAeGBjW+OUEJgTkQdiZE=; b=Nlo5LJlrWWhrv6Wh5Z8BsdEjaS0XJNODSzKxEaChbwSH8IMY81pXud4BhQvzNymjI7 P2oPItdjBB4pxO3wnEvQ5ka1d/Ow1TGg3B3Uxv1dyFv1P6GdZaao36ufgkZI/yqdVMw0 3Z/us62eBz8VJ1Tfzd09zPnb/O8fYTfVG7948Q/MPhe8l/UrOXAWBS1hZQqouVN99KF0 re/vLS9KhpYaYssVECQFbPq0G6gexCULjlheV2IJLhDFSqAlEWCrV1XxyMWUQ2PR4dkt YYXEX+NgLsXEb+gItvAZR1H9IqSxg7Zo8MfQk5Tr+HqTzsQx4NWtJAVz9YgeCGYdZB7N Zg6Q== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: AGRZ1gJovVzdw8PgAIHt5D3ZO+jdWVTC9UQV0OHji7svdQaZThtb0lFW JrDl0AB9U8VaI/H+kk11rFk3i+QSB5Azbe2OFgAKkhQUHRwCxF6vMsks/C7gC1Khwbz4HFCcDBX DmnA1USp37tmZxx5wJGeSZtY2Y8pXuNJM5ysvRRS4qmehqfvB/OhS4Fy7ync000sv1g== X-Received: by 2002:ac8:3565:: with SMTP id z34mr22305252qtb.272.1542653817052; Mon, 19 Nov 2018 10:56:57 -0800 (PST) X-Google-Smtp-Source: AJdET5eOnJovZUhDqpEwkJdIjU+rtsBtvb0bn5Yp9RSMfXYZ5x/EbTt7YNi3kQbASabKQ0R/F937 X-Received: by 2002:ac8:3565:: with SMTP id z34mr22305198qtb.272.1542653816059; Mon, 19 Nov 2018 10:56:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542653816; cv=none; d=google.com; s=arc-20160816; b=sLF7GiRqgDeM1bs163hM+h3/F1fKuRZoeSvJqbB1PaybjtwDTPCASAQJcN2I2cwFLW AA3/hQvER2rhpA9QeLlE0l1O+hpKFyEHCMGQuAyGeXUQECuK2VyOypojq1P/j6WXT+co HwY+AQ5REhnMPg9dgabuFLGD/jk/7SXDkz60kO84CyFZ+6YNA1uNOtx67rRkVyDzWQa0 FkZXE71Y+vhdgOZDLDlGWGiUhDtLI1ZhyQMWIL0uCbehDidM03DMJRZ08Z0UvSJVkMgA +3HE877nTFLpHCH91vERa0+PYFNXGHTb9QDpmkRf+YLVRYcEUk+eurvi7fG87IQOl7ve fr/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=tO4c/KM0bSn41nZdkVbqQD0yAeGBjW+OUEJgTkQdiZE=; b=lskG5JXVogzbr8WumLf1KOziSS/srHtQ0jXbXylbS4FNx9Yar953BDzPxuTU/8KOB/ b3OVth/utndK8MS6C2M73Jvzu98M6DY6FrZgVXreH0iq8Tamb21CLr/MhIsqbrowDxL8 hua5dlceMwNpFPN4d0FnIPaOEz8xys6yfy3g6ssxRwEzljEXZbnnoa305IdukPf2cLN0 skaIPgNSRSAMyKOaZf1ORqXljbabmf6LdcICsmDzNtf0NKdeS5jFFcHbpYcZpwnNCVEF UIMs0sw0Mc3qXuRwF9oLJ2Tegw2wK20pduCTG1GJnQcB14jHDDS9Mh4/o90Tmu4ZvpDP uyag== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id h130si6929394qka.91.2018.11.19.10.56.55 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Nov 2018 10:56:56 -0800 (PST) Received-SPF: pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DC82A45CD3; Mon, 19 Nov 2018 18:56:54 +0000 (UTC) Received: from llong.com (dhcp-17-55.bos.redhat.com [10.18.17.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 63B7B608F8; Mon, 19 Nov 2018 18:56:53 +0000 (UTC) From: Waiman Long To: Peter Zijlstra , Ingo Molnar , Will Deacon , Thomas Gleixner Cc: linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org, iommu@lists.linux-foundation.org, Petr Mladek , Sergey Senozhatsky , Andrey Ryabinin , Tejun Heo , Andrew Morton , Waiman Long Subject: [PATCH v2 03/17] locking/lockdep: Add a new terminal lock type Date: Mon, 19 Nov 2018 13:55:12 -0500 Message-Id: <1542653726-5655-4-git-send-email-longman@redhat.com> In-Reply-To: <1542653726-5655-1-git-send-email-longman@redhat.com> References: <1542653726-5655-1-git-send-email-longman@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 19 Nov 2018 18:56:55 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP A terminal lock is a lock where further locking or unlocking on another lock is not allowed. IOW, no forward dependency is permitted. With such a restriction in place, we don't really need to do a full validation of the lock chain involving a terminal lock. Instead, we just check if there is any further locking or unlocking on another lock when a terminal lock is being held. Only spinlocks which are acquired by the _irq or _irqsave variants or in IRQ disabled context should be classified as terminal locks. By adding this new lock type, we can save entries in lock_chains[], chain_hlocks[], list_entries[] and stack_trace[]. By marking suitable locks as terminal, we reduce the chance of overflowing those tables allowing them to focus on locks that can have both forward and backward dependencies. Four bits are stolen from the pin_count of the held_lock structure to hold a new 4-bit flags field. The pin_count field is essentially a summation of 16-bit random cookie values. Removing 4 bits still allow the pin_count to accumulate up to almost 4096 of those cookie values. Signed-off-by: Waiman Long Signed-off-by: Peter Zijlstra (Intel) --- include/linux/lockdep.h | 29 ++++++++++++++++++++--- kernel/locking/lockdep.c | 47 ++++++++++++++++++++++++++++++++------ kernel/locking/lockdep_internals.h | 5 ++++ kernel/locking/lockdep_proc.c | 11 +++++++-- 4 files changed, 80 insertions(+), 12 deletions(-) diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h index 8fe5b4f..a146bca 100644 --- a/include/linux/lockdep.h +++ b/include/linux/lockdep.h @@ -144,9 +144,20 @@ struct lock_class_stats { /* * Lockdep class type flags + * * 1) LOCKDEP_FLAG_NOVALIDATE: No full validation, just simple checks. + * 2) LOCKDEP_FLAG_TERMINAL: This is a terminal lock where lock/unlock on + * another lock within its critical section is not allowed. + * + * Only the least significant 4 bits of the flags will be copied to the + * held_lock structure. */ -#define LOCKDEP_FLAG_NOVALIDATE (1 << 0) +#define LOCKDEP_FLAG_TERMINAL (1 << 0) +#define LOCKDEP_FLAG_NOVALIDATE (1 << 4) + +#define LOCKDEP_HLOCK_FLAGS_MASK 0x0f +#define LOCKDEP_NOCHECK_FLAGS (LOCKDEP_FLAG_NOVALIDATE |\ + LOCKDEP_FLAG_TERMINAL) /* * Map the lock object (the lock instance) to the lock-class object. @@ -263,7 +274,16 @@ struct held_lock { unsigned int check:1; /* see lock_acquire() comment */ unsigned int hardirqs_off:1; unsigned int references:12; /* 32 bits */ - unsigned int pin_count; + /* + * Four bits are stolen from pin_count for flags so as not to + * increase the size of the structure. The stolen bits may not + * be enough in the future as more flag bits are added. However, + * not all of them may need to be checked in the held_lock + * structure. We just have to make sure that the the relevant + * ones will be in the 4 least significant bits. + */ + unsigned int pin_count:28; + unsigned int flags:4; }; /* @@ -305,6 +325,8 @@ extern void lockdep_init_map(struct lockdep_map *lock, const char *name, #define lockdep_set_novalidate_class(lock) \ do { (lock)->dep_map.flags |= LOCKDEP_FLAG_NOVALIDATE; } while (0) +#define lockdep_set_terminal_class(lock) \ + do { (lock)->dep_map.flags |= LOCKDEP_FLAG_TERMINAL; } while (0) /* * Compare locking classes @@ -420,7 +442,8 @@ static inline void lockdep_on(void) do { (void)(key); } while (0) #define lockdep_set_subclass(lock, sub) do { } while (0) -#define lockdep_set_novalidate_class(lock) do { } while (0) +#define lockdep_set_novalidate_class(lock) do { } while (0) +#define lockdep_set_terminal_class(lock) do { } while (0) /* * We don't define lockdep_match_class() and lockdep_match_key() for !LOCKDEP diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index 493b567..40894c1 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -3020,6 +3020,11 @@ static inline int separate_irq_context(struct task_struct *curr, #endif /* defined(CONFIG_TRACE_IRQFLAGS) && defined(CONFIG_PROVE_LOCKING) */ +static int hlock_is_terminal(struct held_lock *hlock) +{ + return flags_is_terminal(hlock->flags); +} + /* * Mark a lock with a usage bit, and validate the state transition: */ @@ -3047,7 +3052,11 @@ static int mark_lock(struct task_struct *curr, struct held_lock *this, hlock_class(this)->usage_mask |= new_mask; - if (!save_trace(hlock_class(this)->usage_traces + new_bit)) + /* + * We don't need to save the stack trace for terminal locks. + */ + if (!hlock_is_terminal(this) && + !save_trace(hlock_class(this)->usage_traces + new_bit)) return 0; switch (new_bit) { @@ -3215,9 +3224,6 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass, if (unlikely(!debug_locks)) return 0; - if (!prove_locking || (lock->flags & LOCKDEP_FLAG_NOVALIDATE)) - check = 0; - if (subclass < NR_LOCKDEP_CACHING_CLASSES) class = lock->class_cache[subclass]; /* @@ -3229,6 +3235,9 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass, return 0; } + if (!prove_locking || (class->flags & LOCKDEP_NOCHECK_FLAGS)) + check = 0; + debug_class_ops_inc(class); if (very_verbose(class)) { @@ -3255,6 +3264,13 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass, if (depth) { hlock = curr->held_locks + depth - 1; + + /* + * Warn if the previous lock is a terminal lock. + */ + if (DEBUG_LOCKS_WARN_ON(hlock_is_terminal(hlock))) + return 0; + if (hlock->class_idx == class_idx && nest_lock) { if (hlock->references) { /* @@ -3294,6 +3310,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass, hlock->holdtime_stamp = lockstat_clock(); #endif hlock->pin_count = pin_count; + hlock->flags = class->flags & LOCKDEP_HLOCK_FLAGS_MASK; if (check && !mark_irqflags(curr, hlock)) return 0; @@ -3636,6 +3653,14 @@ static int __lock_downgrade(struct lockdep_map *lock, unsigned long ip) if (i == depth-1) return 1; + /* + * Unlock of an outer lock is not allowed while holding a terminal + * lock. + */ + hlock = curr->held_locks + depth - 1; + if (DEBUG_LOCKS_WARN_ON(hlock_is_terminal(hlock))) + return 0; + if (reacquire_held_locks(curr, depth, i + 1)) return 0; @@ -3688,7 +3713,7 @@ static struct pin_cookie __lock_pin_lock(struct lockdep_map *lock) /* * Grab 16bits of randomness; this is sufficient to not * be guessable and still allows some pin nesting in - * our u32 pin_count. + * our 28-bit pin_count. */ cookie.val = 1 + (prandom_u32() >> 16); hlock->pin_count += cookie.val; @@ -4013,7 +4038,7 @@ void lock_unpin_lock(struct lockdep_map *lock, struct pin_cookie cookie) } static void -__lock_acquired(struct lockdep_map *lock, unsigned long ip) +__lock_acquired(struct lockdep_map *lock, unsigned long ip, unsigned long flags) { struct task_struct *curr = current; struct held_lock *hlock; @@ -4039,6 +4064,13 @@ void lock_unpin_lock(struct lockdep_map *lock, struct pin_cookie cookie) if (hlock->instance != lock) return; + /* + * A terminal lock should only be used with IRQ disabled. + */ + if (DEBUG_LOCKS_WARN_ON(hlock_is_terminal(hlock) && + !irqs_disabled_flags(flags))) + return; + cpu = smp_processor_id(); if (hlock->waittime_stamp) { now = lockstat_clock(); @@ -4093,9 +4125,10 @@ void lock_acquired(struct lockdep_map *lock, unsigned long ip) return; raw_local_irq_save(flags); + check_flags(flags); current->lockdep_recursion = 1; - __lock_acquired(lock, ip); + __lock_acquired(lock, ip, flags); current->lockdep_recursion = 0; raw_local_irq_restore(flags); } diff --git a/kernel/locking/lockdep_internals.h b/kernel/locking/lockdep_internals.h index 88c847a..271fba8 100644 --- a/kernel/locking/lockdep_internals.h +++ b/kernel/locking/lockdep_internals.h @@ -212,3 +212,8 @@ static inline unsigned long debug_class_ops_read(struct lock_class *class) # define debug_atomic_read(ptr) 0 # define debug_class_ops_inc(ptr) do { } while (0) #endif + +static inline unsigned int flags_is_terminal(unsigned int flags) +{ + return flags & LOCKDEP_FLAG_TERMINAL; +} diff --git a/kernel/locking/lockdep_proc.c b/kernel/locking/lockdep_proc.c index 3d31f9b..37fbd41 100644 --- a/kernel/locking/lockdep_proc.c +++ b/kernel/locking/lockdep_proc.c @@ -78,7 +78,10 @@ static int l_show(struct seq_file *m, void *v) get_usage_chars(class, usage); seq_printf(m, " %s", usage); - seq_printf(m, ": "); + /* + * Print terminal lock status + */ + seq_printf(m, "%c: ", flags_is_terminal(class->flags) ? 'T' : ' '); print_name(m, class); seq_puts(m, "\n"); @@ -208,7 +211,7 @@ static int lockdep_stats_show(struct seq_file *m, void *v) nr_irq_read_safe = 0, nr_irq_read_unsafe = 0, nr_softirq_read_safe = 0, nr_softirq_read_unsafe = 0, nr_hardirq_read_safe = 0, nr_hardirq_read_unsafe = 0, - sum_forward_deps = 0; + nr_nocheck = 0, sum_forward_deps = 0; list_for_each_entry(class, &all_lock_classes, lock_entry) { @@ -240,6 +243,8 @@ static int lockdep_stats_show(struct seq_file *m, void *v) nr_hardirq_read_safe++; if (class->usage_mask & LOCKF_ENABLED_HARDIRQ_READ) nr_hardirq_read_unsafe++; + if (class->flags & LOCKDEP_NOCHECK_FLAGS) + nr_nocheck++; #ifdef CONFIG_PROVE_LOCKING sum_forward_deps += lockdep_count_forward_deps(class); @@ -318,6 +323,8 @@ static int lockdep_stats_show(struct seq_file *m, void *v) nr_uncategorized); seq_printf(m, " unused locks: %11lu\n", nr_unused); + seq_printf(m, " unchecked locks: %11lu\n", + nr_nocheck); seq_printf(m, " max locking depth: %11u\n", max_lockdep_depth); #ifdef CONFIG_PROVE_LOCKING From patchwork Mon Nov 19 18:55:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Waiman Long X-Patchwork-Id: 10689309 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F00DB5A4 for ; Mon, 19 Nov 2018 18:57:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E23022A470 for ; Mon, 19 Nov 2018 18:57:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D60BD2A46A; Mon, 19 Nov 2018 18:57:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5F2072A46C for ; Mon, 19 Nov 2018 18:57:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EF3466B1B90; Mon, 19 Nov 2018 13:56:58 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E561E6B1B92; Mon, 19 Nov 2018 13:56:58 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CCD996B1B93; Mon, 19 Nov 2018 13:56:58 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by kanga.kvack.org (Postfix) with ESMTP id 94F526B1B90 for ; Mon, 19 Nov 2018 13:56:58 -0500 (EST) Received: by mail-qk1-f197.google.com with SMTP id s70so71781123qks.4 for ; Mon, 19 Nov 2018 10:56:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=6XDZ2ln/gR3ohqeRdUDrEhPq3uOa3/v4RpHArz8esP0=; b=aSjCyc+G1hWEvHxnsPs6o5feMqfevadZkvK8G0NXmpM1/n3K9NCGjL3jpAjZfbAAm7 JsHQREjySrOB9GYlbFP3ylQZq7u4Ah0dORar+OXOuZsbKsE1LLyhfqXWnRK7EieCKiiq /1+DQ0MyrnNeIrMngir20J1JJFs8a/e8ExFRghtBTtEOOGlzXx9DKiu2qs2sCekA/8V+ evm5VEqPBMzRiDHMpWcgp0n1DBwuqqPD9zzVePUzXK65UE4YvM+al/8dsOY8w8R+ZwQ6 hPOTN4F/ygW3l0xBRFiEiB5h7ArYWkMyqJJaHVeVNUx3yEsrKZk5gubcydh7itZGCakB +daQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: AGRZ1gK+9psuayQ9+v8Az2zmKXQyCW4595/ucMCsyVDl0ffsQVSGcoTV 7bsxXiap5iP3chdFVGrGplGDcuyhuHmZO1kx9rWX1webh2IMHeQoJ7i0rmqOJ6GqpsdvMKM/N1F jK75daff3IWqUlgmf8Jk/Xt6QyqP45GPRjGxETxkK24tCyD9DoMgmQjMhInQjj/Tjcg== X-Received: by 2002:a37:18e5:: with SMTP id 98mr22261325qky.333.1542653818360; Mon, 19 Nov 2018 10:56:58 -0800 (PST) X-Google-Smtp-Source: AJdET5cQvXaasSNOrJjoTe4B4p+CPMH/RRfjONnXqBGIcVbDe7eagDjPgCaspy270mkgVkGrXHyA X-Received: by 2002:a37:18e5:: with SMTP id 98mr22261302qky.333.1542653817740; Mon, 19 Nov 2018 10:56:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542653817; cv=none; d=google.com; s=arc-20160816; b=P+rZgyhA2tsMzOxMvXVToucZw2/Hz0IygjouoJPwknkRZEEy1fVX7fzDAV/89/3PyZ 16PcNtc7decjNEpp0T93g6/mv3prqXpQNhfN+8jNzow1uTMh0+fZ429Wuk3Lr+4OEWxF u624fbNZ51NXzgc+0YtiWvLwbh7tuLTNLVB3IOpvAhUQiz9JjBh+gGmTqJoZyYx+q3mH EMUKjeybHC6J4HzBSzFcQ8xD3UJBPAP36+DGuODxFGNH3fDuSrWvVP5izbRveYyis6+k w00+CI5Lxq+gnEsMVIcgadrZdwtIcpdvMErvUUVWqCyX6sHjjhsH0vGUHkByn+aM12iJ loVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=6XDZ2ln/gR3ohqeRdUDrEhPq3uOa3/v4RpHArz8esP0=; b=orWcNmCKMe35Pj5TdraEKAjX1FcsmrZaARGV0CMd3K7WtD5e0mFA5B8N8aQPxiVGBt 48Z3cHA0CIseWQvNfOxuRGtFqxlQd1kiMfKZSGKh7txGCwZ0yQFWpPz7VBXvnPhmIwk8 FFmJtqUlBz7Gs0LeWnBY4ssZPubESkrvfahcAjX/XP1BqPJ2PWMpSVjY2MojFM5dZtHk Wtn5VXmAkVSViya8Y/3bm9doiw8iv44E2uz3WjmQoqOkCRDL1MBNJXBeLqnBhOzOjzvg /W25roVQhRtkDOBjRTMYRUSC+ebxj6ZdXDaFV6M34RLyp9B7elOGGzEXDJvnU8wzaLBf Ri5A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id m37si12246403qtc.111.2018.11.19.10.56.57 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Nov 2018 10:56:57 -0800 (PST) Received-SPF: pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 821D34E902; Mon, 19 Nov 2018 18:56:56 +0000 (UTC) Received: from llong.com (dhcp-17-55.bos.redhat.com [10.18.17.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0BF5E608E7; Mon, 19 Nov 2018 18:56:54 +0000 (UTC) From: Waiman Long To: Peter Zijlstra , Ingo Molnar , Will Deacon , Thomas Gleixner Cc: linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org, iommu@lists.linux-foundation.org, Petr Mladek , Sergey Senozhatsky , Andrey Ryabinin , Tejun Heo , Andrew Morton , Waiman Long Subject: [PATCH v2 04/17] locking/lockdep: Add DEFINE_TERMINAL_SPINLOCK() and related macros Date: Mon, 19 Nov 2018 13:55:13 -0500 Message-Id: <1542653726-5655-5-git-send-email-longman@redhat.com> In-Reply-To: <1542653726-5655-1-git-send-email-longman@redhat.com> References: <1542653726-5655-1-git-send-email-longman@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 19 Nov 2018 18:56:56 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Add new DEFINE_RAW_TERMINAL_SPINLOCK() and DEFINE_TERMINAL_SPINLOCK() macro to define a raw terminal spinlock and a terminal spinlock. Signed-off-by: Waiman Long --- include/linux/spinlock_types.h | 34 +++++++++++++++++++++++----------- kernel/printk/printk_safe.c | 2 +- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/include/linux/spinlock_types.h b/include/linux/spinlock_types.h index 24b4e6f..6a8086e 100644 --- a/include/linux/spinlock_types.h +++ b/include/linux/spinlock_types.h @@ -33,9 +33,10 @@ #define SPINLOCK_OWNER_INIT ((void *)-1L) #ifdef CONFIG_DEBUG_LOCK_ALLOC -# define SPIN_DEP_MAP_INIT(lockname) .dep_map = { .name = #lockname } +# define SPIN_DEP_MAP_INIT(lockname, f) .dep_map = { .name = #lockname, \ + .flags = f } #else -# define SPIN_DEP_MAP_INIT(lockname) +# define SPIN_DEP_MAP_INIT(lockname, f) #endif #ifdef CONFIG_DEBUG_SPINLOCK @@ -47,16 +48,22 @@ # define SPIN_DEBUG_INIT(lockname) #endif -#define __RAW_SPIN_LOCK_INITIALIZER(lockname) \ - { \ - .raw_lock = __ARCH_SPIN_LOCK_UNLOCKED, \ - SPIN_DEBUG_INIT(lockname) \ - SPIN_DEP_MAP_INIT(lockname) } +#define __RAW_SPIN_LOCK_INITIALIZER(lockname, f) \ + { \ + .raw_lock = __ARCH_SPIN_LOCK_UNLOCKED, \ + SPIN_DEBUG_INIT(lockname) \ + SPIN_DEP_MAP_INIT(lockname, f) } #define __RAW_SPIN_LOCK_UNLOCKED(lockname) \ - (raw_spinlock_t) __RAW_SPIN_LOCK_INITIALIZER(lockname) + (raw_spinlock_t) __RAW_SPIN_LOCK_INITIALIZER(lockname, 0) + +#define __RAW_TERMINAL_SPIN_LOCK_UNLOCKED(lockname) \ + (raw_spinlock_t) __RAW_SPIN_LOCK_INITIALIZER(lockname, \ + LOCKDEP_FLAG_TERMINAL) #define DEFINE_RAW_SPINLOCK(x) raw_spinlock_t x = __RAW_SPIN_LOCK_UNLOCKED(x) +#define DEFINE_RAW_TERMINAL_SPINLOCK(x) \ + raw_spinlock_t x = __RAW_TERMINAL_SPIN_LOCK_UNLOCKED(x) typedef struct spinlock { union { @@ -72,13 +79,18 @@ }; } spinlock_t; -#define __SPIN_LOCK_INITIALIZER(lockname) \ - { { .rlock = __RAW_SPIN_LOCK_INITIALIZER(lockname) } } +#define __SPIN_LOCK_INITIALIZER(lockname, f) \ + { { .rlock = __RAW_SPIN_LOCK_INITIALIZER(lockname, f) } } #define __SPIN_LOCK_UNLOCKED(lockname) \ - (spinlock_t ) __SPIN_LOCK_INITIALIZER(lockname) + (spinlock_t) __SPIN_LOCK_INITIALIZER(lockname, 0) + +#define __TERMINAL_SPIN_LOCK_UNLOCKED(lockname) \ + (spinlock_t) __SPIN_LOCK_INITIALIZER(lockname, LOCKDEP_FLAG_TERMINAL) #define DEFINE_SPINLOCK(x) spinlock_t x = __SPIN_LOCK_UNLOCKED(x) +#define DEFINE_TERMINAL_SPINLOCK(x) \ + spinlock_t x = __TERMINAL_SPIN_LOCK_UNLOCKED(x) #include diff --git a/kernel/printk/printk_safe.c b/kernel/printk/printk_safe.c index 0913b4d..8ff1033 100644 --- a/kernel/printk/printk_safe.c +++ b/kernel/printk/printk_safe.c @@ -192,7 +192,7 @@ static void report_message_lost(struct printk_safe_seq_buf *s) static void __printk_safe_flush(struct irq_work *work) { static raw_spinlock_t read_lock = - __RAW_SPIN_LOCK_INITIALIZER(read_lock); + __RAW_SPIN_LOCK_UNLOCKED(read_lock); struct printk_safe_seq_buf *s = container_of(work, struct printk_safe_seq_buf, work); unsigned long flags; From patchwork Mon Nov 19 18:55:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Waiman Long X-Patchwork-Id: 10689311 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2156C13AD for ; Mon, 19 Nov 2018 18:57:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0FC272A470 for ; Mon, 19 Nov 2018 18:57:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 036472A478; Mon, 19 Nov 2018 18:57:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A07AD2A470 for ; Mon, 19 Nov 2018 18:57:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 860D16B1B92; Mon, 19 Nov 2018 13:57:00 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 7E88F6B1BE8; Mon, 19 Nov 2018 13:57:00 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6D87F6B1BE9; Mon, 19 Nov 2018 13:57:00 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by kanga.kvack.org (Postfix) with ESMTP id 43D436B1B92 for ; Mon, 19 Nov 2018 13:57:00 -0500 (EST) Received: by mail-qk1-f200.google.com with SMTP id k66so71416494qkf.1 for ; Mon, 19 Nov 2018 10:57:00 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=H8VIsA4Ij3jks30GbEQG8DPgsV0wrakGHHdAzEZAbwQ=; b=QlLbgfia4VInB5V0hs/eQVB66XdNCYRPktaJwYb+h61S86DMtu0x2Em0gvQHqqxKGp ME64rcfCidEtPrRyOg6thVFXIL9WI9dTTLn70R3gQcWBeaIpfihj/uxDQV2O00Q0Btsu x1wABZUdMIHIpjsuF8HVsu6mOamDMkqvkx6oif/shGp5CNnDj8QsRStyNAI4pUwmKfyv gbF4/a6Av2zZ3lne2SlPxbXnZmDXzF0DLExOEnqwK32WYHViLuxzKDStraB7fRhz1koa JRZSeqiXyumefLxLO+prwWKkON+vrsXCCxPV8d4YYhZekEWxiSsy8/OuNlHlIoqG6mXt lvnQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: AGRZ1gIeR2HVKQk2CTH66fQaqr/1ZGy0VG1BVkl05xtki+c0jQk8NKMo Ll4XRxyz2MX6lndLiFZirJwo/fHqfLFlvegWKj1TtB3nbjFwO7bIspT1NUXC1t1HRxjz/1IltMP moxIUo4mI54GjrQXSK3/czkHWd+598n0tIey6J2LdaJBksYfS1CVmCRCJn3+64Ybhfg== X-Received: by 2002:a37:2704:: with SMTP id n4mr21419713qkn.349.1542653820021; Mon, 19 Nov 2018 10:57:00 -0800 (PST) X-Google-Smtp-Source: AJdET5cSphZ21geqcl40Oh+IE3IzoGi85AiGNse2wmtpB6xiqtM+au5l/dpEnYM5kG0eTF5hDB/2 X-Received: by 2002:a37:2704:: with SMTP id n4mr21419688qkn.349.1542653819452; Mon, 19 Nov 2018 10:56:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542653819; cv=none; d=google.com; s=arc-20160816; b=K+3zgAdZiPXoa6JfYteYungukbQfCxQF/+VY0Sw2K1J4G+pDyj9Gpt6+dELeQdEN+e ejLvTVY68twbUppj70iuA60gy30sWCklgTjK9MwUHzFC2XBHwb3QmcoQEGyzl5EHYhIq kAgDSSz/DFW3Vbpn2KEf9mMUCkoToe1NeN1Ucx8q6yas19eA+f8PFK/80qSkJU84nvuL gknEpt7fVWfDtYtlUeuVyIwaQn+UwuWMPBGIc8BBukNGep/0GdAp8Al58wtd2p8myNv1 B+7P9mIYAE05ET0oJ6sW0SlpPEuwkSwImLt+K9TQRhCtMRhAKPPZORl6M/AgS+dqMGjc fMAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=H8VIsA4Ij3jks30GbEQG8DPgsV0wrakGHHdAzEZAbwQ=; b=UXD1/UPP70Gw+qjSbvDaGRQ9ubBNH2tPD6xBJNpw5AjWM7iwSHmdSj5mzBTUsQRGL7 onPXRHEg+Xg+GSwacpdQaLiUD/2Sgpchh/zsA/qiFYtFgnOTTNjr4rBFxhp3oXEA7uMw +8RmQqF4XUax1oJObLL8P9dW37ByTh/N1YQ9aKOOy0ftXaQHURcj3JcjuhYA4hPjPZbi 8GjXxMC161dNjSc71pVJoUd/5DKnDB1HCbT2QZa/DYcsvlYXtdOKyupN92fNsMyZwb37 oWlUvUlDoNTshOeAW3pgms40NSpqABDkxg7hPTFxt68ciKBtqwLADGI5b1t28L8CaXT5 cNug== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id t22si474853qtq.46.2018.11.19.10.56.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Nov 2018 10:56:59 -0800 (PST) Received-SPF: pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2368B4E937; Mon, 19 Nov 2018 18:56:58 +0000 (UTC) Received: from llong.com (dhcp-17-55.bos.redhat.com [10.18.17.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9D00C6090B; Mon, 19 Nov 2018 18:56:56 +0000 (UTC) From: Waiman Long To: Peter Zijlstra , Ingo Molnar , Will Deacon , Thomas Gleixner Cc: linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org, iommu@lists.linux-foundation.org, Petr Mladek , Sergey Senozhatsky , Andrey Ryabinin , Tejun Heo , Andrew Morton , Waiman Long Subject: [PATCH v2 05/17] printk: Mark logbuf_lock & console_owner_lock as terminal locks Date: Mon, 19 Nov 2018 13:55:14 -0500 Message-Id: <1542653726-5655-6-git-send-email-longman@redhat.com> In-Reply-To: <1542653726-5655-1-git-send-email-longman@redhat.com> References: <1542653726-5655-1-git-send-email-longman@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 19 Nov 2018 18:56:58 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP By marking logbuf_lock and console_owner_lock as terminal locks, it reduces the performance overhead when those locks are used with lockdep enabled. Signed-off-by: Waiman Long --- kernel/printk/printk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 1b2a029..bdbbe31 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -367,7 +367,7 @@ __packed __aligned(4) * within the scheduler's rq lock. It must be released before calling * console_unlock() or anything else that might wake up a process. */ -DEFINE_RAW_SPINLOCK(logbuf_lock); +DEFINE_RAW_TERMINAL_SPINLOCK(logbuf_lock); /* * Helper macros to lock/unlock logbuf_lock and switch between @@ -1568,7 +1568,7 @@ int do_syslog(int type, char __user *buf, int len, int source) }; #endif -static DEFINE_RAW_SPINLOCK(console_owner_lock); +static DEFINE_RAW_TERMINAL_SPINLOCK(console_owner_lock); static struct task_struct *console_owner; static bool console_waiter; From patchwork Mon Nov 19 18:55:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Waiman Long X-Patchwork-Id: 10689313 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 71E0313AD for ; Mon, 19 Nov 2018 18:57:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 644352A47A for ; Mon, 19 Nov 2018 18:57:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 583F12A453; Mon, 19 Nov 2018 18:57:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F244D2A46A for ; Mon, 19 Nov 2018 18:57:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F17F26B1BE9; Mon, 19 Nov 2018 13:57:01 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id EC91A6B1BEA; Mon, 19 Nov 2018 13:57:01 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D6EE96B1BEB; Mon, 19 Nov 2018 13:57:01 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by kanga.kvack.org (Postfix) with ESMTP id A10756B1BE9 for ; Mon, 19 Nov 2018 13:57:01 -0500 (EST) Received: by mail-qk1-f198.google.com with SMTP id d196so71046734qkb.6 for ; Mon, 19 Nov 2018 10:57:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=WiW/qIP5xtsgvsYCncGrXAjAG3FpozQuBKj1j0D5XBM=; b=nkgdVt2FJfkxm78gBFObgFAuvZxEtqZJpZ26DU1LZsaC6TRte3s0+e0oEFuF8lSSqG firdbsTmdhfmLh/FNzutdx8P3B5Hr00PmEPvUjY1sCVmzQ4tA7krymmH48G+sSwni9oS pN0ZYAwdPckX/PBbWQi8vu8nB1zZUsQb25p5+0TplOxGTaMlKmy6xGisgf4/mauK+op6 I1wtIGZDuGTyNYNPupJhWTUP1QCgDPiZ9pzptQVC72NLMBy58Fvpoc9jN20skEwUQxRi cCAe43qTdgSHZj4hKrWFVCzVkz18UT7dDqw8MUwC3V0qscEewQAwbGm+ioJMMy4/5Nvu wSEw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: AGRZ1gLbTeJOX+vMunw76ZvQI+wTvtSJvty8IKDFxywjJ3jsy2oCeKom GIl9JUQKGicaB9VNIH58TVzVRdn1XJ/mcX/j/OdcuPnYHWZ6OjoH3NGrqx3+WtmrpAEFK7CajEi Iy8GcE6yWYjdEMsp+L384PY6b/w8jB7ulxminF78m0Tn5wtIrXe+AQZZOfCam0dTSqg== X-Received: by 2002:a37:116a:: with SMTP id b103mr20843473qkh.77.1542653821386; Mon, 19 Nov 2018 10:57:01 -0800 (PST) X-Google-Smtp-Source: AJdET5fbpk4ubLCwBj148HoXX3erOLPNxSbRGKDOwK/pGPqV3pLjwTh4AzhVIE7C22Rphr0yp4pN X-Received: by 2002:a37:116a:: with SMTP id b103mr20843447qkh.77.1542653820641; Mon, 19 Nov 2018 10:57:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542653820; cv=none; d=google.com; s=arc-20160816; b=ZvrOUygrWpI3FDuN2D6/ga/p2qyRKZSUiIC/F7+I8mMHU3M14CLBduMKsD/uC96dmP 2lFwewIOf5AfN2+zQGSIXikFLhfNqwxgTFAoA06vxeYz9Q5W7QuAHqig4jailL+NBjEu MoBVpaA+AHmSQdViu2JWQg1r8Fnd0S1Q3Us9tmf+GeAbXxgRAAEvhOd78o+AzRnqTIjW uv0DiXLI79G4pQ1lKm2rCyRRV7aV6tmY0FeVHHcaBY96cwxsKXlrUnKeqpn3J6aZ2jnl y50TV7VNKfvKp6BMi70fMlnCa6j44YPD+2JAbkRvLHPy1jYOO5TAsVRYze6+7igCjlJK WaiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=WiW/qIP5xtsgvsYCncGrXAjAG3FpozQuBKj1j0D5XBM=; b=y3KlkLVORtLwObUnibmMLdnBUNjRTpSKf2T1370IfzgnfMmK36abT9YIdmALk6DACM 5TWnd+IWiO5XCs07YkZkg4L6LTU3OaeNN/AggI7kglXSK4Lrdm37HlqluPhHIU5rAqQ9 1a1IBoAr9i6G/PEgwZz2HyKvXFQQf70a/c6FH+30nT+Tt1HxFQboieNrgPRuxp1myIxz goVG52wVk+cCDP1kzqCD5CjHUQksx4mgpFQzNP8KOFWs3ptEdHDdfQk08nE+iZSHsIAL CeMrvPsNZMdXr23xJ8IIlSJ+rkJhMfP7oJZ5ZRfGoAbmctifjrHC89cY/Nt1VXrQXlpX kCPQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id g24si6557809qvb.43.2018.11.19.10.57.00 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Nov 2018 10:57:00 -0800 (PST) Received-SPF: pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AA61D30842AC; Mon, 19 Nov 2018 18:56:59 +0000 (UTC) Received: from llong.com (dhcp-17-55.bos.redhat.com [10.18.17.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3446E6090A; Mon, 19 Nov 2018 18:56:58 +0000 (UTC) From: Waiman Long To: Peter Zijlstra , Ingo Molnar , Will Deacon , Thomas Gleixner Cc: linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org, iommu@lists.linux-foundation.org, Petr Mladek , Sergey Senozhatsky , Andrey Ryabinin , Tejun Heo , Andrew Morton , Waiman Long Subject: [PATCH v2 06/17] debugobjects: Mark pool_lock as a terminal lock Date: Mon, 19 Nov 2018 13:55:15 -0500 Message-Id: <1542653726-5655-7-git-send-email-longman@redhat.com> In-Reply-To: <1542653726-5655-1-git-send-email-longman@redhat.com> References: <1542653726-5655-1-git-send-email-longman@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Mon, 19 Nov 2018 18:56:59 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP By marking the internal pool_lock as a terminal lock, lockdep will be able to skip full validation to improve locking performance. Signed-off-by: Waiman Long --- lib/debugobjects.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/debugobjects.c b/lib/debugobjects.c index 70935ed..403dd95 100644 --- a/lib/debugobjects.c +++ b/lib/debugobjects.c @@ -39,7 +39,7 @@ struct debug_bucket { static struct debug_obj obj_static_pool[ODEBUG_POOL_SIZE] __initdata; -static DEFINE_RAW_SPINLOCK(pool_lock); +static DEFINE_RAW_TERMINAL_SPINLOCK(pool_lock); static HLIST_HEAD(obj_pool); static HLIST_HEAD(obj_to_free); From patchwork Mon Nov 19 18:55:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Waiman Long X-Patchwork-Id: 10689315 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BF8135A4 for ; Mon, 19 Nov 2018 18:57:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B16C92A465 for ; Mon, 19 Nov 2018 18:57:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A5D842A46A; Mon, 19 Nov 2018 18:57:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 043402A47A for ; Mon, 19 Nov 2018 18:57:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 022CB6B1BED; Mon, 19 Nov 2018 13:57:28 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id F127B6B1BEE; Mon, 19 Nov 2018 13:57:27 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E04B86B1BEF; Mon, 19 Nov 2018 13:57:27 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by kanga.kvack.org (Postfix) with ESMTP id B88396B1BED for ; Mon, 19 Nov 2018 13:57:27 -0500 (EST) Received: by mail-qk1-f200.google.com with SMTP id j125so4416233qke.12 for ; Mon, 19 Nov 2018 10:57:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=pBrzX19Dr5nbNXt+/L10z/X8TbXcySqhbwnGmi3C9/U=; b=IdqToAN+AWr0/7Gh0viLv9d8/Sy2eMc5m6N5t5EzMrlDJG5xjQAyf14HqdUwwJh3mX Ge440LODqxwEpCJfYAOHpLI0Q4gGaONsjA3sZDS7qsYPGkK9BPTwXQ5z7Re3VWKtUG6F Nat4Rc37EaZaKlDeAAnn9jkkujqh9uFnMqL3iHZYrnFOUbflUlTLYh0GlF/V2B2mGL4O EceHC1LHYKixI4k9zojUQJOB+6L3tJwQOs/+4/mUMnfQ+nRS3yOP7XQ+YJiYyEJ9ykG2 AJtpdrSlZQn+f9kwhx3/gkFbuFemE+Rc/n7XGcY3TPbF+bh6dxH3nQT4Nm/ITCLSCCkJ /2fA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: AGRZ1gJmVetXRG02CqVMpiEvvEQ8R4VXmUalZG8O/GrEyOkLx8nS9LQy kiLHnnOfx5NWUF4NlnG1J1SOGABapigdMMK3oAJRPRYEfrnpUfG0YvVwZoV8pKF50rxH3sP0xz4 /khv1q8RmmSod4ZhtshEWZBniqYhIJa6aesxBB6Zyyh6RW1e7AsF1h9g/dE7XJQRmtQ== X-Received: by 2002:a0c:9659:: with SMTP id 25mr22445449qvy.3.1542653847515; Mon, 19 Nov 2018 10:57:27 -0800 (PST) X-Google-Smtp-Source: AJdET5e0LO+ZFqMSNRsP6DLjO1Odi+jXWldbE+YkcHPDp4+D5dBpU+4xdH67LevG7rqbqHhELQ7m X-Received: by 2002:a0c:9659:: with SMTP id 25mr22445417qvy.3.1542653846766; Mon, 19 Nov 2018 10:57:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542653846; cv=none; d=google.com; s=arc-20160816; b=vtXjPzFeMjJ+wKb9hT+dGqAt9ijOyqPNpMwe+2Mpwx6fEcFKZwa/sO732Sfl1J2kFD 7P20UHmjkCghY2ZOgrCH4tfaxG7aclt8QCegF3+5xqmdhie/AYRC9kZm24OJpU6aJA/D irywuKMTiFYmiWweS3Z4PXjWdlEi81V0izhF84FdG9mUh9sxqZ8ipo6JCTIzSMoLX7R2 7gkyCKQjDW0nvOQY3S74rznEDqMLMIqxIRQuc6PwF6yT4aYOKlf+RfKJ42mcy7RG9PCK Ve7WmbP6/3AhXktrzz7giKkWUaUMRQ69i2bSZdYJXECEi1q5qiFslbXkbRfVOQ7OkYBC WA5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=pBrzX19Dr5nbNXt+/L10z/X8TbXcySqhbwnGmi3C9/U=; b=aYqVhcNla+0Pe2nE4SmMh8WJ38hZsYJ/InDdpZsHZ4igP5jkIsI5zRNzu3CYYrZWEP PQSC/v885d3vPztQZi/YECHWRIoC9csrNrfbY+vgqySEEK8uwaf/v7MphZSJkB2YEb14 XUbNuKxXbjG1F90qpnpzDampHJrH7zdbbxFiv6oRk7lsFc0XS+C5lcu1BJ/U+hDWv2VN absIPfyrdrNvQ7g8VtbDJUmPqvEv+E0eBB6u3ZxbFVRnUMWt5277Kf696y4IszaL+2cW dUWm6p6rkbeFm5bCwGoUPHsAumhzjFZKlVjr/7LgWXtH5SrzTOhsp2NiTVOHsx9Z61Lb TRZg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id a6si1312474qtj.202.2018.11.19.10.57.26 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Nov 2018 10:57:26 -0800 (PST) Received-SPF: pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 681C1394D52; Mon, 19 Nov 2018 18:57:25 +0000 (UTC) Received: from llong.com (dhcp-17-55.bos.redhat.com [10.18.17.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id C4E0160922; Mon, 19 Nov 2018 18:56:59 +0000 (UTC) From: Waiman Long To: Peter Zijlstra , Ingo Molnar , Will Deacon , Thomas Gleixner Cc: linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org, iommu@lists.linux-foundation.org, Petr Mladek , Sergey Senozhatsky , Andrey Ryabinin , Tejun Heo , Andrew Morton , Waiman Long Subject: [PATCH v2 07/17] debugobjects: Move printk out of db lock critical sections Date: Mon, 19 Nov 2018 13:55:16 -0500 Message-Id: <1542653726-5655-8-git-send-email-longman@redhat.com> In-Reply-To: <1542653726-5655-1-git-send-email-longman@redhat.com> References: <1542653726-5655-1-git-send-email-longman@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 19 Nov 2018 18:57:25 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP The db->lock is a raw spinlock and so the lock hold time is supposed to be short. This will not be the case when printk() is being involved in some of the critical sections. In order to avoid the long hold time, in case some messages need to be printed, the debug_object_is_on_stack() and debug_print_object() calls are now moved out of those critical sections. Signed-off-by: Waiman Long --- lib/debugobjects.c | 61 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 19 deletions(-) diff --git a/lib/debugobjects.c b/lib/debugobjects.c index 403dd95..4216d3d 100644 --- a/lib/debugobjects.c +++ b/lib/debugobjects.c @@ -376,6 +376,8 @@ static void debug_object_is_on_stack(void *addr, int onstack) struct debug_bucket *db; struct debug_obj *obj; unsigned long flags; + bool debug_printobj = false; + bool debug_chkstack = false; fill_pool(); @@ -392,7 +394,7 @@ static void debug_object_is_on_stack(void *addr, int onstack) debug_objects_oom(); return; } - debug_object_is_on_stack(addr, onstack); + debug_chkstack = true; } switch (obj->state) { @@ -403,20 +405,25 @@ static void debug_object_is_on_stack(void *addr, int onstack) break; case ODEBUG_STATE_ACTIVE: - debug_print_object(obj, "init"); state = obj->state; raw_spin_unlock_irqrestore(&db->lock, flags); + debug_print_object(obj, "init"); debug_object_fixup(descr->fixup_init, addr, state); return; case ODEBUG_STATE_DESTROYED: - debug_print_object(obj, "init"); + debug_printobj = true; break; default: break; } raw_spin_unlock_irqrestore(&db->lock, flags); + if (debug_chkstack) + debug_object_is_on_stack(addr, onstack); + if (debug_printobj) + debug_print_object(obj, "init"); + } /** @@ -474,6 +481,8 @@ int debug_object_activate(void *addr, struct debug_obj_descr *descr) obj = lookup_object(addr, db); if (obj) { + bool debug_printobj = false; + switch (obj->state) { case ODEBUG_STATE_INIT: case ODEBUG_STATE_INACTIVE: @@ -482,14 +491,14 @@ int debug_object_activate(void *addr, struct debug_obj_descr *descr) break; case ODEBUG_STATE_ACTIVE: - debug_print_object(obj, "activate"); state = obj->state; raw_spin_unlock_irqrestore(&db->lock, flags); + debug_print_object(obj, "activate"); ret = debug_object_fixup(descr->fixup_activate, addr, state); return ret ? 0 : -EINVAL; case ODEBUG_STATE_DESTROYED: - debug_print_object(obj, "activate"); + debug_printobj = true; ret = -EINVAL; break; default: @@ -497,10 +506,13 @@ int debug_object_activate(void *addr, struct debug_obj_descr *descr) break; } raw_spin_unlock_irqrestore(&db->lock, flags); + if (debug_printobj) + debug_print_object(obj, "activate"); return ret; } raw_spin_unlock_irqrestore(&db->lock, flags); + /* * We are here when a static object is activated. We * let the type specific code confirm whether this is @@ -532,6 +544,7 @@ void debug_object_deactivate(void *addr, struct debug_obj_descr *descr) struct debug_bucket *db; struct debug_obj *obj; unsigned long flags; + bool debug_printobj = false; if (!debug_objects_enabled) return; @@ -549,24 +562,27 @@ void debug_object_deactivate(void *addr, struct debug_obj_descr *descr) if (!obj->astate) obj->state = ODEBUG_STATE_INACTIVE; else - debug_print_object(obj, "deactivate"); + debug_printobj = true; break; case ODEBUG_STATE_DESTROYED: - debug_print_object(obj, "deactivate"); + debug_printobj = true; break; default: break; } - } else { + } + + raw_spin_unlock_irqrestore(&db->lock, flags); + if (!obj) { struct debug_obj o = { .object = addr, .state = ODEBUG_STATE_NOTAVAILABLE, .descr = descr }; debug_print_object(&o, "deactivate"); + } else if (debug_printobj) { + debug_print_object(obj, "deactivate"); } - - raw_spin_unlock_irqrestore(&db->lock, flags); } EXPORT_SYMBOL_GPL(debug_object_deactivate); @@ -581,6 +597,7 @@ void debug_object_destroy(void *addr, struct debug_obj_descr *descr) struct debug_bucket *db; struct debug_obj *obj; unsigned long flags; + bool debug_printobj = false; if (!debug_objects_enabled) return; @@ -600,20 +617,22 @@ void debug_object_destroy(void *addr, struct debug_obj_descr *descr) obj->state = ODEBUG_STATE_DESTROYED; break; case ODEBUG_STATE_ACTIVE: - debug_print_object(obj, "destroy"); state = obj->state; raw_spin_unlock_irqrestore(&db->lock, flags); + debug_print_object(obj, "destroy"); debug_object_fixup(descr->fixup_destroy, addr, state); return; case ODEBUG_STATE_DESTROYED: - debug_print_object(obj, "destroy"); + debug_printobj = true; break; default: break; } out_unlock: raw_spin_unlock_irqrestore(&db->lock, flags); + if (debug_printobj) + debug_print_object(obj, "destroy"); } EXPORT_SYMBOL_GPL(debug_object_destroy); @@ -642,9 +661,9 @@ void debug_object_free(void *addr, struct debug_obj_descr *descr) switch (obj->state) { case ODEBUG_STATE_ACTIVE: - debug_print_object(obj, "free"); state = obj->state; raw_spin_unlock_irqrestore(&db->lock, flags); + debug_print_object(obj, "free"); debug_object_fixup(descr->fixup_free, addr, state); return; default: @@ -717,6 +736,7 @@ void debug_object_assert_init(void *addr, struct debug_obj_descr *descr) struct debug_bucket *db; struct debug_obj *obj; unsigned long flags; + bool debug_printobj = false; if (!debug_objects_enabled) return; @@ -732,22 +752,25 @@ void debug_object_assert_init(void *addr, struct debug_obj_descr *descr) if (obj->astate == expect) obj->astate = next; else - debug_print_object(obj, "active_state"); + debug_printobj = true; break; default: - debug_print_object(obj, "active_state"); + debug_printobj = true; break; } - } else { + } + + raw_spin_unlock_irqrestore(&db->lock, flags); + if (!obj) { struct debug_obj o = { .object = addr, .state = ODEBUG_STATE_NOTAVAILABLE, .descr = descr }; debug_print_object(&o, "active_state"); + } else if (debug_printobj) { + debug_print_object(obj, "active_state"); } - - raw_spin_unlock_irqrestore(&db->lock, flags); } EXPORT_SYMBOL_GPL(debug_object_active_state); @@ -783,10 +806,10 @@ static void __debug_check_no_obj_freed(const void *address, unsigned long size) switch (obj->state) { case ODEBUG_STATE_ACTIVE: - debug_print_object(obj, "free"); descr = obj->descr; state = obj->state; raw_spin_unlock_irqrestore(&db->lock, flags); + debug_print_object(obj, "free"); debug_object_fixup(descr->fixup_free, (void *) oaddr, state); goto repeat; From patchwork Mon Nov 19 18:55:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Waiman Long X-Patchwork-Id: 10689317 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D1AB213AD for ; Mon, 19 Nov 2018 18:57:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C3EC82A46F for ; Mon, 19 Nov 2018 18:57:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AFD1F2A45B; Mon, 19 Nov 2018 18:57:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 28AFA2A46C for ; Mon, 19 Nov 2018 18:57:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4DC176B1BEE; Mon, 19 Nov 2018 13:57:37 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 48BDD6B1BEF; Mon, 19 Nov 2018 13:57:37 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3A3AF6B1BF0; Mon, 19 Nov 2018 13:57:37 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by kanga.kvack.org (Postfix) with ESMTP id 12C996B1BEE for ; Mon, 19 Nov 2018 13:57:37 -0500 (EST) Received: by mail-qk1-f199.google.com with SMTP id c84so71564028qkb.13 for ; Mon, 19 Nov 2018 10:57:37 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=80nYVpjORCReHIj2uz46o7n7SFyAOvH/JNuXPKW8n38=; b=i7zQTM1jclGzWV9u0Y9EhbTFlLtN4ghGVf4k2boW2D5FZdIrXeKTnje2L61HWzlakk bsQ7p0sfW9JTCF8pefgqYrz3Yj+0915vBwz2NMMhZhl7ku9RnIzDhBAcJ+n9qXlPWmKw AGsuKaYOdgbQlaUgyBlJYfg+4c3+taG2A9jJkdnUELNu3eBfGNxTtk+nEhnlPMMnOPpQ f6OQiwvyQU3u1L43UpDXBPkaamobJiOa5xo9EUhGzsHiRcF3SdgogL/GVYjs/pNDHUWj xOzIlDknegeL629gyCDW+NUDm8AjG/q1Une+FFF8ynywqIKs0nHiiJQLMzEenK20TW/M J5RA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: AGRZ1gKdmqCSHMsDzJ9S7O1/8TsxLpAr7HtcyZBSZP+D+KwwBPD4BYv7 bk7a2eTJ2C8X5qbqkv0qMhXUdinHuS4YJ8dVrPwfGLsycEyF+HNTACKQFcF9b+cre6ihs4hipId PtnYnnsG4k7MYSGNoFJzA0sqXmm0mFrXN3Q69jsMrvvA8zH8VtkuZCMZlB0U4UCIutg== X-Received: by 2002:ac8:3ae5:: with SMTP id x92mr22736007qte.370.1542653855506; Mon, 19 Nov 2018 10:57:35 -0800 (PST) X-Google-Smtp-Source: AJdET5e8Zk2f2Mhy8HNW2NBRi99RMV4kwqVirLg8IviVlViH5F6aqpeadiX0NDcWdRVCCOFT72PA X-Received: by 2002:ac8:3ae5:: with SMTP id x92mr22735976qte.370.1542653854771; Mon, 19 Nov 2018 10:57:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542653854; cv=none; d=google.com; s=arc-20160816; b=nz7mzhX/ogftxQMBC+kofEZ/hPSuGV4mLPC0iIBB2xXOElwkbmf8GvLb2pYqWfBIFQ OtXwaQ/mU/mJqMHMgerGfOQ104TWOYdNVIFGEFMJKwhSIwbcEYh+3sPO1venmNh0Aii5 MhyIi9nGSVCvOXY1vF/NJP6D2RXfzTWS9C1AuJEfZEgaMkFZB2kWAUJ1lwX/5i0i/UK8 YJ3QkrM7HBuZkoM3WcuPIt7BLxQg16JIbWoeRKxolLDXZRRXDz4k+UclGG2OQjbdhZhM xU9tfai8Xp2j9C0eUZEuaAJOG5XzM9zVed/mxAoXFU/z9bIvmEEFFCDIaRcOn0xRkCcM 2Qiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=80nYVpjORCReHIj2uz46o7n7SFyAOvH/JNuXPKW8n38=; b=ixIAtRsfVQ+6ITjWqqAQVFEip5MH/xKJOYy0lybSTQ1JipBiYdc3rLw8nkffSXHdJl y/64DjxTP9Mk+3IqZDA512g4/VSFbWohjamcxqlZFvITMLL+nj3tf+1qfXpm37IXom1o zniRAH1uK4pQbM5/3Cp2W+auJkOWIkGjo15dwh9ntKYrQ+WUiyvfr2mkV+mpXDzPIq8q Fhc2cS59lQG/35lJY0KBhPzvBlHaIaxd+ajNauLRR71YKEvnDTlkDj3BsM1f037lul7s mhnnsLkvyDkUKONEQ/cGO4stFVl+O2QhiYDrALwU1OsLdbh1qld3/AFURVmk+vUyS+8K 50+g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id f42si4122289qkh.191.2018.11.19.10.57.34 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Nov 2018 10:57:34 -0800 (PST) Received-SPF: pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C3BAC3154866; Mon, 19 Nov 2018 18:57:33 +0000 (UTC) Received: from llong.com (dhcp-17-55.bos.redhat.com [10.18.17.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7EFA4608E7; Mon, 19 Nov 2018 18:57:25 +0000 (UTC) From: Waiman Long To: Peter Zijlstra , Ingo Molnar , Will Deacon , Thomas Gleixner Cc: linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org, iommu@lists.linux-foundation.org, Petr Mladek , Sergey Senozhatsky , Andrey Ryabinin , Tejun Heo , Andrew Morton , Waiman Long Subject: [PATCH v2 08/17] locking/lockdep: Add support for nestable terminal locks Date: Mon, 19 Nov 2018 13:55:17 -0500 Message-Id: <1542653726-5655-9-git-send-email-longman@redhat.com> In-Reply-To: <1542653726-5655-1-git-send-email-longman@redhat.com> References: <1542653726-5655-1-git-send-email-longman@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Mon, 19 Nov 2018 18:57:33 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP There are use cases where we want to allow nesting of one terminal lock underneath another terminal-like lock. That new lock type is called nestable terminal lock which can optionally allow the acquisition of no more than one regular (non-nestable) terminal lock underneath it. Signed-off-by: Waiman Long --- include/linux/lockdep.h | 9 ++++++++- kernel/locking/lockdep.c | 15 +++++++++++++-- kernel/locking/lockdep_internals.h | 2 +- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h index a146bca..b9435fb 100644 --- a/include/linux/lockdep.h +++ b/include/linux/lockdep.h @@ -148,16 +148,20 @@ struct lock_class_stats { * 1) LOCKDEP_FLAG_NOVALIDATE: No full validation, just simple checks. * 2) LOCKDEP_FLAG_TERMINAL: This is a terminal lock where lock/unlock on * another lock within its critical section is not allowed. + * 3) LOCKDEP_FLAG_TERMINAL_NESTABLE: This is a terminal lock that can + * allow one more regular terminal lock to be nested underneath it. * * Only the least significant 4 bits of the flags will be copied to the * held_lock structure. */ #define LOCKDEP_FLAG_TERMINAL (1 << 0) +#define LOCKDEP_FLAG_TERMINAL_NESTABLE (1 << 1) #define LOCKDEP_FLAG_NOVALIDATE (1 << 4) #define LOCKDEP_HLOCK_FLAGS_MASK 0x0f #define LOCKDEP_NOCHECK_FLAGS (LOCKDEP_FLAG_NOVALIDATE |\ - LOCKDEP_FLAG_TERMINAL) + LOCKDEP_FLAG_TERMINAL |\ + LOCKDEP_FLAG_TERMINAL_NESTABLE) /* * Map the lock object (the lock instance) to the lock-class object. @@ -327,6 +331,8 @@ extern void lockdep_init_map(struct lockdep_map *lock, const char *name, do { (lock)->dep_map.flags |= LOCKDEP_FLAG_NOVALIDATE; } while (0) #define lockdep_set_terminal_class(lock) \ do { (lock)->dep_map.flags |= LOCKDEP_FLAG_TERMINAL; } while (0) +#define lockdep_set_terminal_nestable_class(lock) \ + do { (lock)->dep_map.flags |= LOCKDEP_FLAG_TERMINAL_NESTABLE; } while (0) /* * Compare locking classes @@ -444,6 +450,7 @@ static inline void lockdep_on(void) #define lockdep_set_novalidate_class(lock) do { } while (0) #define lockdep_set_terminal_class(lock) do { } while (0) +#define lockdep_set_terminal_nestable_class(lock) do { } while (0) /* * We don't define lockdep_match_class() and lockdep_match_key() for !LOCKDEP diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index 40894c1..5a853a6 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -3263,13 +3263,24 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass, class_idx = class - lock_classes + 1; if (depth) { + int prev_type; + hlock = curr->held_locks + depth - 1; /* - * Warn if the previous lock is a terminal lock. + * Warn if the previous lock is a terminal lock or the + * previous lock is a nestable terminal lock and the current + * one isn't a regular terminal lock. */ - if (DEBUG_LOCKS_WARN_ON(hlock_is_terminal(hlock))) + prev_type = hlock_is_terminal(hlock); + if (DEBUG_LOCKS_WARN_ON((prev_type == LOCKDEP_FLAG_TERMINAL) || + ((prev_type == LOCKDEP_FLAG_TERMINAL_NESTABLE) && + (flags_is_terminal(class->flags) != + LOCKDEP_FLAG_TERMINAL)))) { + pr_warn("Terminal lock error: prev lock = %s, curr lock = %s\n", + hlock->instance->name, class->name); return 0; + } if (hlock->class_idx == class_idx && nest_lock) { if (hlock->references) { diff --git a/kernel/locking/lockdep_internals.h b/kernel/locking/lockdep_internals.h index 271fba8..51fa141 100644 --- a/kernel/locking/lockdep_internals.h +++ b/kernel/locking/lockdep_internals.h @@ -215,5 +215,5 @@ static inline unsigned long debug_class_ops_read(struct lock_class *class) static inline unsigned int flags_is_terminal(unsigned int flags) { - return flags & LOCKDEP_FLAG_TERMINAL; + return flags & (LOCKDEP_FLAG_TERMINAL|LOCKDEP_FLAG_TERMINAL_NESTABLE); } From patchwork Mon Nov 19 18:55:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Waiman Long X-Patchwork-Id: 10689319 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DC2B713AD for ; Mon, 19 Nov 2018 18:57:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE6D82A46F for ; Mon, 19 Nov 2018 18:57:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C1FC32A470; Mon, 19 Nov 2018 18:57:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 694D52A479 for ; Mon, 19 Nov 2018 18:57:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A5CA66B1BEF; Mon, 19 Nov 2018 13:57:37 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A0A576B1BF0; Mon, 19 Nov 2018 13:57:37 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8F8FF6B1BF1; Mon, 19 Nov 2018 13:57:37 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by kanga.kvack.org (Postfix) with ESMTP id 6592A6B1BF0 for ; Mon, 19 Nov 2018 13:57:37 -0500 (EST) Received: by mail-qk1-f199.google.com with SMTP id j125so4417281qke.12 for ; Mon, 19 Nov 2018 10:57:37 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=Mibn5q7auVAfC91nUxucCjCODDH5pGKjJzAGifA4cIs=; b=SLXVuXlfvsDiKS5K5hEEqTSkIORqAWULC4ZGG+8inJMulPOY3ylL28Ejj0LQGw9rer Fi/wnjzlQSO66Prz98d+BoojR3vm5m2mpP0rha2bRitDYANnb4tkkbDci+NDMMNrkmjM RoAvoamis4TQCrnB4JbeRkl+bh5GORSQdDf4h+AHbtsg2zegiBLfL5ed+MIwpx7Qh1yO /3cupu9nIFcimnkqOVJxB5sDFy/EWEN3hBXTMjbKxt/63wf4CvhWvC7F8scYMgX6WEG4 T3GqETU+ohVyNDb7bZztvyhhWRUly/gS+sPCXX7k6yUJCa2VVA+MGJzXq2KS6j9T83dS yAuQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: AGRZ1gK/v7eVkp2s3YY9TDhXZI7fyy00mMMpFug+AviDznnp+n8WeXK7 CpJjMtnipqfbNen3+Fy8Pg3m12NTpaBSC0SrsvK6fqxayaTeVscE3Sdhhv6CNnTysFgJgpP7DrF IhriEysFw+KWNxGd4BTUxpI6xfsUSA8gd8pg+QMQWCpruG0+DE7QLjiHQ2oe5NBOO/w== X-Received: by 2002:a37:cf02:: with SMTP id e2mr21580497qkj.38.1542653857188; Mon, 19 Nov 2018 10:57:37 -0800 (PST) X-Google-Smtp-Source: AJdET5fJH6j4gdE3J6EN8OtKOJJEOZF07XV9bT7rOOfqe6ryNTd+IGcCoI46O679cJhQ/HBgZPJQ X-Received: by 2002:a37:cf02:: with SMTP id e2mr21580479qkj.38.1542653856472; Mon, 19 Nov 2018 10:57:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542653856; cv=none; d=google.com; s=arc-20160816; b=KeyzJ0xh7WGw6sDjzlQgJHzDUdKX+MN6qaq0UNhEzzzDES5oxC1w8n4isl7od9/Ehb 2032hLFKfjkDPI7zsffEsCwK55NdKduOWQRsWPkLwVeRGcgbruOqvHaAXEtxXeKVnXrr CyE3nQMY4WUw4WFJ8BEQ9xjUqzEmoIqp3mG6AffjdFyv8dCChYfRpQltgkQzJSd836T1 Rtp67i41DeItxIuiLIYQMxv+0SB6RX3UNBys/9fGEFSLQSv7h/Ewx8yQBXOe2caxitjb rLz73tu9SmtuRbxwAMqeth5f4yOoJhQtsK5pXRhg5HEywr5k2/Wgys23Jtr/qsijVd/2 YtBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=Mibn5q7auVAfC91nUxucCjCODDH5pGKjJzAGifA4cIs=; b=tR5M/8+tUV4cJ7tv2pb7hFkNFj2eaZCwe3YUhufJD3d9l7td9tg43IgoJNhQmJMPqi xiXPsPME49qAH5T63tk1Sz0Aftm2Kqf9b3812PiHwUMf39ReWkqrVos8swmxE7w+yjDI ohk4qNsvpIgsXkb+QG+10xnTAyHjJ4F0adWESIPZRvGMEdlrx6W9gXwmxXaYQ/7MSN+s PVkTvBvbqtcSuJgFgbfTcpuDM5ceaGtcsRV5DuqaOmHEl5tgPiJR2nvYmHun2gqYf7Pu NpMzSi/Qax2ixAiqMF7jeu+i7vnq0ccTurYyems5mVL4bhFVIzdvnP+H40y3k27QmO9A lSPA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id y36si130100qtd.218.2018.11.19.10.57.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Nov 2018 10:57:36 -0800 (PST) Received-SPF: pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 830AF3084033; Mon, 19 Nov 2018 18:57:35 +0000 (UTC) Received: from llong.com (dhcp-17-55.bos.redhat.com [10.18.17.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id DD3666090B; Mon, 19 Nov 2018 18:57:33 +0000 (UTC) From: Waiman Long To: Peter Zijlstra , Ingo Molnar , Will Deacon , Thomas Gleixner Cc: linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org, iommu@lists.linux-foundation.org, Petr Mladek , Sergey Senozhatsky , Andrey Ryabinin , Tejun Heo , Andrew Morton , Waiman Long Subject: [PATCH v2 09/17] debugobjects: Make object hash locks nestable terminal locks Date: Mon, 19 Nov 2018 13:55:18 -0500 Message-Id: <1542653726-5655-10-git-send-email-longman@redhat.com> In-Reply-To: <1542653726-5655-1-git-send-email-longman@redhat.com> References: <1542653726-5655-1-git-send-email-longman@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Mon, 19 Nov 2018 18:57:35 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP By making the object hash locks nestable terminal locks, we can avoid a bunch of unnecessary lockdep validations as well as saving space in the lockdep tables. Signed-off-by: Waiman Long --- lib/debugobjects.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/debugobjects.c b/lib/debugobjects.c index 4216d3d..c6f3967 100644 --- a/lib/debugobjects.c +++ b/lib/debugobjects.c @@ -1129,8 +1129,13 @@ void __init debug_objects_early_init(void) { int i; - for (i = 0; i < ODEBUG_HASH_SIZE; i++) + /* + * Make the obj_hash locks nestable terminal locks. + */ + for (i = 0; i < ODEBUG_HASH_SIZE; i++) { raw_spin_lock_init(&obj_hash[i].lock); + lockdep_set_terminal_nestable_class(&obj_hash[i].lock); + } for (i = 0; i < ODEBUG_POOL_SIZE; i++) hlist_add_head(&obj_static_pool[i].node, &obj_pool); From patchwork Mon Nov 19 18:55:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Waiman Long X-Patchwork-Id: 10689321 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2F7FD5A4 for ; Mon, 19 Nov 2018 18:57:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 223492A457 for ; Mon, 19 Nov 2018 18:57:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 165D22A469; Mon, 19 Nov 2018 18:57:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B81AB2A465 for ; Mon, 19 Nov 2018 18:57:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 52A836B1BF0; Mon, 19 Nov 2018 13:57:39 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4E2756B1BF1; Mon, 19 Nov 2018 13:57:39 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 330026B1BF2; Mon, 19 Nov 2018 13:57:39 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by kanga.kvack.org (Postfix) with ESMTP id 0BC9B6B1BF0 for ; Mon, 19 Nov 2018 13:57:39 -0500 (EST) Received: by mail-qk1-f199.google.com with SMTP id n68so70140530qkn.8 for ; Mon, 19 Nov 2018 10:57:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=okfj1MVMzbeAVQkSXdOtylbrtrPMSpu+PZx780Xlvgs=; b=SlhtJ4066BiUqN8N/t12GIPUnOvdJa382SOMBtv8PAwjG6Z0ERVJgNxWWKT4nkr/Y2 hAAqAbkn7wCQm67tc3jDftVj3/SOmijjtU9Vypm0f29+WfJwOxKCCI0uBYV66hnjqp7k XjoGQzKtIWv9fMVGd4b4oNX2FRrVTtRf8YoTA9k0lvx0BOvmsxFoC/n9mwKkP0voQ5l9 vV6oKGhtsISCL2FV9bFk8TM/tUd8n198qIxSZzRN3MqZdB7h1Uxhljex0FAo+LOh8sqr 3QA0Qa73ElYP9H01jgyQx3SANFTXv+/27WAAv/j1BLBAwmIDf8WB2/rt+SuKTM8toiwg ZOag== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: AGRZ1gJmXcZ6FMsOkjs00GnE+Ld3ixtLKjPdS0bkdhuhF/C4o1/MPKt0 AUshpxPj8ne0cG5n/bxkqcMYcko2o9I0Xkdv01tQFcaxLaRcBSbc4kMctqXOlnX9JRmY/gA3O/q hzz60t3DFwMPXhku7cBVhzDNn+umch115eoe07pZ9w9FH3bRUquMP7+qTnSZOEwSVNw== X-Received: by 2002:ac8:ecf:: with SMTP id w15mr9282409qti.359.1542653858826; Mon, 19 Nov 2018 10:57:38 -0800 (PST) X-Google-Smtp-Source: AJdET5fqUIqQ3KR/RFtWxJPrc6/KhyUcd4jng0gTLRiDfOEGaCkjETY019bDuG7T7j6CU0vYcQpM X-Received: by 2002:ac8:ecf:: with SMTP id w15mr9282392qti.359.1542653858190; Mon, 19 Nov 2018 10:57:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542653858; cv=none; d=google.com; s=arc-20160816; b=l5/Coq6hQ8ERY/bugA6nQRsoDte/n899mWyYKojibMtg1zUAA0ocAAcqkvRieBbcJD i1NeL7+c/jr6QhaYY67sRhpbxrRkPsHh7mJB7qSAnqGQmvqOcjgTlyxemfD3r746vn7M DScg0Tr/CD6MS8ZiD/zOw6TXZupd58ARjNWbJOMUD4mQeGP6VxEaKasEqVnQ8nK/OQKp tPyoDjM/aqx3guuZm3YcfY/gQN94F7y1xfJt+0R6mlAT0p+85hzL8CVNmUsGS9nhND0Z q1IL5AcS93c8+4oQ0eZbG1xcWOgeZUVMJ36iGzacoq0i0wQSH0nguyPJFpRvs7g7/ebl WAkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=okfj1MVMzbeAVQkSXdOtylbrtrPMSpu+PZx780Xlvgs=; b=pQIUdbHNYwmNsMOixG1OWj1ZAMR7ApLeCnE/fgsDSIpl+HBfkPUfKgaJwnk4/63o4l GW1xkEykXuz+ocorvSnJcvC3B27v6hH5MyMtsgROS4qXOQO9NoxWGo7xLd0KPxxYvOkE gDzWT5RVCMS5ytHAgd5IsQVRNbl2Z9x1jFvhJXBMGP3SrM+pwXSFuF9oiKC1gDwWwgip sjeRwwtCXqhbQpO6cYSBgAHC6qqdGnaabveEOM+bwKhtIhraeAtVK9w0rHO0cN/Xe/fM nPijXwscOdujs1cf4wvVmwgyrJZBqlihL1F5S6/I+kzy1X8JjVtXzqlcvh5s1XokmYXX 99/Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id w8si27002418qvn.137.2018.11.19.10.57.38 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Nov 2018 10:57:38 -0800 (PST) Received-SPF: pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 27E6FA403B; Mon, 19 Nov 2018 18:57:37 +0000 (UTC) Received: from llong.com (dhcp-17-55.bos.redhat.com [10.18.17.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8B59B18C51; Mon, 19 Nov 2018 18:57:35 +0000 (UTC) From: Waiman Long To: Peter Zijlstra , Ingo Molnar , Will Deacon , Thomas Gleixner Cc: linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org, iommu@lists.linux-foundation.org, Petr Mladek , Sergey Senozhatsky , Andrey Ryabinin , Tejun Heo , Andrew Morton , Waiman Long Subject: [PATCH v2 10/17] lib/stackdepot: Make depot_lock a terminal spinlock Date: Mon, 19 Nov 2018 13:55:19 -0500 Message-Id: <1542653726-5655-11-git-send-email-longman@redhat.com> In-Reply-To: <1542653726-5655-1-git-send-email-longman@redhat.com> References: <1542653726-5655-1-git-send-email-longman@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 19 Nov 2018 18:57:37 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP By defining depot_lock as a terminal spinlock, it reduces the lockdep overhead when this lock is being used. Signed-off-by: Waiman Long --- lib/stackdepot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/stackdepot.c b/lib/stackdepot.c index e513459..fb17888 100644 --- a/lib/stackdepot.c +++ b/lib/stackdepot.c @@ -78,7 +78,7 @@ struct stack_record { static int depot_index; static int next_slab_inited; static size_t depot_offset; -static DEFINE_SPINLOCK(depot_lock); +static DEFINE_TERMINAL_SPINLOCK(depot_lock); static bool init_stack_slab(void **prealloc) { From patchwork Mon Nov 19 18:55:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Waiman Long X-Patchwork-Id: 10689323 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A03F713AD for ; Mon, 19 Nov 2018 18:57:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8F9E82A46A for ; Mon, 19 Nov 2018 18:57:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 83BF02A470; Mon, 19 Nov 2018 18:57:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D40F2A46A for ; Mon, 19 Nov 2018 18:57:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 06EFE6B1BF1; Mon, 19 Nov 2018 13:57:41 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 01FB66B1BF2; Mon, 19 Nov 2018 13:57:40 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E7E5A6B1BF3; Mon, 19 Nov 2018 13:57:40 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by kanga.kvack.org (Postfix) with ESMTP id B502B6B1BF1 for ; Mon, 19 Nov 2018 13:57:40 -0500 (EST) Received: by mail-qk1-f197.google.com with SMTP id v64so10151021qka.5 for ; Mon, 19 Nov 2018 10:57:40 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=uY5ycgX/HkngIbFCmCg84ZdpAOa7T8I2cZvXNdRsYzg=; b=gZUMCShAEcBWrpCuULCv5NuDhDP1DXajymzA+REMMVtK0I5GPG0Qa7OAGm09cXtWt7 ocFrb0pWz0ztF6oiYp9Pp64VKZJ5tNDJgViZn/rJ2HK7rX6SQubSv+lmv+ik8Z5Fy6UU gvGwZOjk0hSleRe5OHL+BU7uqVAG/7cfUoo/MSrneSVKQKAfbLWcywXm+tyQnG3MjsWr +fk2MMranDGY6uBBwdDSiKkInikZ7PZfBzcVLIxMMUUxGbR7sn9C9gdYNIx3JsmZztxr 351C+ANvexyOo2xIGMZH3yrmZyApqvhdkThkxglV0XznMOiV7po4y4FOMsL0gYpcFt0j DWGA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: AGRZ1gII12v98PZn+mjF+5JdGgboOH1ERX8FWbjRg3M9fl3ihe4ovL10 1COH4y528SE2dCs3/YTe7fvD2cVa+fW3dnyVw3yg2TDDwpmKGZcz9lCqtZCvdd/ay6W7wgQoa2A ej48vzUWbaDz9iKjE9anWsLovCRfPTrN2M6YbvwkxjFoQkJPeP792yAft54u8UntzGQ== X-Received: by 2002:a0c:8a54:: with SMTP id 20mr22476810qvu.94.1542653860498; Mon, 19 Nov 2018 10:57:40 -0800 (PST) X-Google-Smtp-Source: AJdET5cGK+6emzn5Bxb9BfKLp6hogssdy+InuGgvfo2wPG0QssYjL3sLCm1yQoUK6Bll58vltGpW X-Received: by 2002:a0c:8a54:: with SMTP id 20mr22476776qvu.94.1542653859690; Mon, 19 Nov 2018 10:57:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542653859; cv=none; d=google.com; s=arc-20160816; b=OjvwnhEK+BVn5eNRE352PwmI9Yqzo0YBQfnlhFz1WLT5ZwZRgcXGEnuK3uthasLCkR YWujviz6S5vv7soRviqH5qgydyLNBLHxcR2jvKDueVFRUXCD/NsjyORIPf19CgjGbI30 ydoOrWU5U7waYlKphIHGgleLo//3GvTIvKAaCxEeLJUpCdv2TT8mwRITmfcyb/nibzlb 8BVU7pqllFTZmTJx8lQUp2SR+vD2uPaEvzzrKaCCxngmZr43Mq3aXC+jjcMGWMuAbcG/ 7O7rbz8nqoRFZBROunXmxt+RrRNWz5mgl63h547dqoDmeDYnz0fJ4DMiIwX8JffTO6Mm J6JQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=uY5ycgX/HkngIbFCmCg84ZdpAOa7T8I2cZvXNdRsYzg=; b=O9H4mh7tfg08uIaRizC/ywKewRrzy24J/V2Zor2TnQvPP/V6XuYV52nNSgIFbZHgz4 um8DevCo1IT9ePg0HoNTEYiNFn8oFtSD+9rEhCz0DrkuK7NkZiJWwpxcRQPqXfgpJgZr CFpGB7xSXHRKYPRW6w+qB/OvmMSgeH4qufpCaoRzFLIpJBvyP/Pu7M+uj07cbTAFiprH UUyDNPYplCYKGFZ+XFlrYAHdt/GEBLtyJJrKUtawFlp3JiZf9otJZqwks4VltG0G23Om 73wcz0HD+g9alIUSywTTd+AlPDUANFAWRARckZQ4tUj0cJHcqLoD3JMG3EJmZCTIVoly 0ybA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id d4si1166412qkf.87.2018.11.19.10.57.39 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Nov 2018 10:57:39 -0800 (PST) Received-SPF: pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9E56CCD25F; Mon, 19 Nov 2018 18:57:38 +0000 (UTC) Received: from llong.com (dhcp-17-55.bos.redhat.com [10.18.17.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 42C51608E7; Mon, 19 Nov 2018 18:57:37 +0000 (UTC) From: Waiman Long To: Peter Zijlstra , Ingo Molnar , Will Deacon , Thomas Gleixner Cc: linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org, iommu@lists.linux-foundation.org, Petr Mladek , Sergey Senozhatsky , Andrey Ryabinin , Tejun Heo , Andrew Morton , Waiman Long Subject: [PATCH v2 11/17] locking/rwsem: Mark rwsem.wait_lock as a terminal lock Date: Mon, 19 Nov 2018 13:55:20 -0500 Message-Id: <1542653726-5655-12-git-send-email-longman@redhat.com> In-Reply-To: <1542653726-5655-1-git-send-email-longman@redhat.com> References: <1542653726-5655-1-git-send-email-longman@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 19 Nov 2018 18:57:38 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP The wait_lock in a rwsem is always acquired with IRQ disabled. For the rwsem-xadd.c implementation, no other lock will be called while holding the wait_lock. So it satisfies the condition of being a terminal lock. By marking it as terminal, the lockdep overhead will be reduced. Signed-off-by: Waiman Long --- include/linux/rwsem.h | 11 ++++++++++- kernel/locking/rwsem-xadd.c | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/include/linux/rwsem.h b/include/linux/rwsem.h index 67dbb57..a2a2385 100644 --- a/include/linux/rwsem.h +++ b/include/linux/rwsem.h @@ -77,16 +77,25 @@ static inline int rwsem_is_locked(struct rw_semaphore *sem) # define __RWSEM_DEP_MAP_INIT(lockname) #endif +/* + * The wait_lock is marked as a terminal lock to reduce lockdep overhead + * when the rwsem-xadd.c is used. This is implied when + * CONFIG_RWSEM_SPIN_ON_OWNER is true. The rwsem-spinlock.c implementation + * allows calling wake_up_process() while holding the wait_lock. So it + * can't be marked as terminal in this case. + */ #ifdef CONFIG_RWSEM_SPIN_ON_OWNER #define __RWSEM_OPT_INIT(lockname) , .osq = OSQ_LOCK_UNLOCKED, .owner = NULL +#define __RWSEM_WAIT_LOCK_INIT(x) __RAW_TERMINAL_SPIN_LOCK_UNLOCKED(x) #else #define __RWSEM_OPT_INIT(lockname) +#define __RWSEM_WAIT_LOCK_INIT(x) __RAW_SPIN_LOCK_UNLOCKED(x) #endif #define __RWSEM_INITIALIZER(name) \ { __RWSEM_INIT_COUNT(name), \ .wait_list = LIST_HEAD_INIT((name).wait_list), \ - .wait_lock = __RAW_SPIN_LOCK_UNLOCKED(name.wait_lock) \ + .wait_lock = __RWSEM_WAIT_LOCK_INIT(name.wait_lock) \ __RWSEM_OPT_INIT(name) \ __RWSEM_DEP_MAP_INIT(name) } diff --git a/kernel/locking/rwsem-xadd.c b/kernel/locking/rwsem-xadd.c index 09b1800..3dbe593 100644 --- a/kernel/locking/rwsem-xadd.c +++ b/kernel/locking/rwsem-xadd.c @@ -85,6 +85,7 @@ void __init_rwsem(struct rw_semaphore *sem, const char *name, #endif atomic_long_set(&sem->count, RWSEM_UNLOCKED_VALUE); raw_spin_lock_init(&sem->wait_lock); + lockdep_set_terminal_class(&sem->wait_lock); INIT_LIST_HEAD(&sem->wait_list); #ifdef CONFIG_RWSEM_SPIN_ON_OWNER sem->owner = NULL; From patchwork Mon Nov 19 18:55:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Waiman Long X-Patchwork-Id: 10689325 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EF30A5A4 for ; Mon, 19 Nov 2018 18:57:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E19E92A2F2 for ; Mon, 19 Nov 2018 18:57:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CBB272A470; Mon, 19 Nov 2018 18:57:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7AA352A442 for ; Mon, 19 Nov 2018 18:57:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 922906B1BF2; Mon, 19 Nov 2018 13:57:42 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8D5CE6B1BF3; Mon, 19 Nov 2018 13:57:42 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7994A6B1BF4; Mon, 19 Nov 2018 13:57:42 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by kanga.kvack.org (Postfix) with ESMTP id 55B656B1BF2 for ; Mon, 19 Nov 2018 13:57:42 -0500 (EST) Received: by mail-qk1-f197.google.com with SMTP id z68so46724780qkb.14 for ; Mon, 19 Nov 2018 10:57:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=E+Ucu4Ad9hHS3vGoIXwWZmms3i3F/iQLn9fd6FpayKc=; b=nkhCp3anifYnR8X5a8K2zrOVyqpD7llQdcxqmkrio3aI+88pnaRSIrGLw8UlhZCOoE XFgV9vt7KZCbAncCYNVOAq7dLCHPjzBau0PV/c/Yw98yOqPbmfnJaTP55l5553OmucaC poinHnLn+bpH5/L0XOEcmDMc4h4kWNQnOH0wgqOmVD4AWHeUmC2/V271WKfL9ri2tV/g qZpwUgR3EtvD9JV2NaH+64SsBbj2FuC/rZsihZoY9MqlLauMho00EWN6ma5OFXPe0Cww JffreXzvmDwEgHUperczVrcA5aJDo9TwA210syTRar++wM/R5Zfmkf/2ZW96s3z8pJr8 aTuA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: AGRZ1gI+9Mxilf8JWHVmOjxBViHoXqUJMXOAepRt5Ax0Q+sE8cYGp68F xv3/dcKEi8SBNGS0x/Zx4EO9ykLYN/8q0nU8Va7HPhscZ5Qg//BOrw7Bwwo+EdUulh01MxRKup0 YxSrzMnxbhdtwZxytunbWwgbyIRcpXUC8RdTlP9gc1wjXEvH2XcxxC8WsqXNzIcxRvQ== X-Received: by 2002:ac8:31ed:: with SMTP id i42mr21763524qte.323.1542653862110; Mon, 19 Nov 2018 10:57:42 -0800 (PST) X-Google-Smtp-Source: AJdET5dJCq6xh7s3x+OON7Bk/66fxNpINo88wNDMybKRqC+ic0xmUGrmNPUvhgSKeaxy1Pt4b/Ue X-Received: by 2002:ac8:31ed:: with SMTP id i42mr21763488qte.323.1542653861073; Mon, 19 Nov 2018 10:57:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542653861; cv=none; d=google.com; s=arc-20160816; b=0vPGcu8WAjcVMi+N1sCMCk4oo6R8jcr8MEg+Lcq4R6UqqLmmv2kyKU8l1Ae+FNnsee iAQZpdzDi7CGlEw82sU82ryXxvGatii5Gz/AdPp9covnhLy81Zwp77sf27aosxDz0qQx zakwZXlB1/tmH354T0BqMYxc1uFocosXP3DpQxZX7Umdp1Nq532ZVQERI3VWKniDQw4P QFl0QGSyt/XKm7F5nwm9wrAnJ4dihhjvyK/L3hKcVleqJwOTHr23p5LpNGfq0/jm0Bd4 KFgAve8G8Xp3m0+vdYjix3d3UMSc51AEcjAso2sEeg2cIuzFOVLVSE/Ic5uPuwFyRq6K q4pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=E+Ucu4Ad9hHS3vGoIXwWZmms3i3F/iQLn9fd6FpayKc=; b=0s+DqevTI28oHfT6a25hBqDi0JH5Y+GdFl5RUpL6zbEK76KER66CUnQUn5QkYk8E7K rdGXGqmrMWj9OjiI2eOrvDKxiOASOCJBif3t3GNAN/f1aSMlWxw454dGEk7vbKABpLOx UbTJ5/fHrIkyasuoUN+pyFzHk7uuYlrQfsyypj1/PINN04tT8TA277CKnN1Z3LwLEuW/ MJSklCNr9t38aeCYScNVopbupg+kA0uJFDSRGmmCuJLxDDGhJEScz5mJ+7hR0sY16b0y lpg/UHLLahsFD/sJKB5ceRTjiiQ/11av4xGo9imgOgmuR5I5+2X4B0Sho8ntIxpciuZy ayVQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id i18si4050079qtq.201.2018.11.19.10.57.40 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Nov 2018 10:57:41 -0800 (PST) Received-SPF: pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2B2DF30026D5; Mon, 19 Nov 2018 18:57:40 +0000 (UTC) Received: from llong.com (dhcp-17-55.bos.redhat.com [10.18.17.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id B90B660922; Mon, 19 Nov 2018 18:57:38 +0000 (UTC) From: Waiman Long To: Peter Zijlstra , Ingo Molnar , Will Deacon , Thomas Gleixner Cc: linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org, iommu@lists.linux-foundation.org, Petr Mladek , Sergey Senozhatsky , Andrey Ryabinin , Tejun Heo , Andrew Morton , Waiman Long Subject: [PATCH v2 12/17] cgroup: Mark the rstat percpu lock as terminal Date: Mon, 19 Nov 2018 13:55:21 -0500 Message-Id: <1542653726-5655-13-git-send-email-longman@redhat.com> In-Reply-To: <1542653726-5655-1-git-send-email-longman@redhat.com> References: <1542653726-5655-1-git-send-email-longman@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Mon, 19 Nov 2018 18:57:40 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP By classifying the cgroup rstat percpu locks as terminal locks, it reduces the lockdep overhead when these locks are being used. Signed-off-by: Waiman Long --- kernel/cgroup/rstat.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/kernel/cgroup/rstat.c b/kernel/cgroup/rstat.c index d503d1a..47f7ffb 100644 --- a/kernel/cgroup/rstat.c +++ b/kernel/cgroup/rstat.c @@ -291,8 +291,13 @@ void __init cgroup_rstat_boot(void) { int cpu; - for_each_possible_cpu(cpu) - raw_spin_lock_init(per_cpu_ptr(&cgroup_rstat_cpu_lock, cpu)); + for_each_possible_cpu(cpu) { + raw_spinlock_t *cgroup_rstat_percpu_lock = + per_cpu_ptr(&cgroup_rstat_cpu_lock, cpu); + + raw_spin_lock_init(cgroup_rstat_percpu_lock); + lockdep_set_terminal_class(cgroup_rstat_percpu_lock); + } BUG_ON(cgroup_rstat_init(&cgrp_dfl_root.cgrp)); } From patchwork Mon Nov 19 18:55:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Waiman Long X-Patchwork-Id: 10689327 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C6DDA5A4 for ; Mon, 19 Nov 2018 18:57:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B9FD82A46C for ; Mon, 19 Nov 2018 18:57:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ADF872A479; Mon, 19 Nov 2018 18:57:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5612B2A46C for ; Mon, 19 Nov 2018 18:57:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E2E0C6B1BF3; Mon, 19 Nov 2018 13:57:43 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DB4B36B1BF4; Mon, 19 Nov 2018 13:57:43 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BBB186B1BF5; Mon, 19 Nov 2018 13:57:43 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by kanga.kvack.org (Postfix) with ESMTP id 955936B1BF3 for ; Mon, 19 Nov 2018 13:57:43 -0500 (EST) Received: by mail-qk1-f199.google.com with SMTP id c7so70780625qkg.16 for ; Mon, 19 Nov 2018 10:57:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=/AXVtKcmys+lbDgtDQa281BoRXMYSCg3AAu21s16z2c=; b=XpjiH0P3zJvH/3ffGu3jPYiRMVPM8kfTcAZ52+W/NksK1jTnmdKASZb0lm8D4Q5oIk TRA4SKPeh/RnNMyEx6V1P/wt6fPUaMib3dOrqOpRfOY2WZff8bJ+x+n1j+Hm65oylRRk Quiz2N1ZgYOJnmRrUuW/xxquFsz+nyk9J/y+vrrJZGJvcFhjbgR3jpNuEMgwRq8MSdod KXsTZJCRn8uBUTqTDyQdFi5nK7/6o4/Jya45e+BOOK95u77g8+hDnzVzohOl8W3+Tkz3 0qijdGlw34WkJsGW9BEt2vpMHS/B724x4jqaz78awTMvkzBBVcSvuNmS6IPBd13AblK7 67aQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: AGRZ1gIqjbV0BhPtQ1PcKRD0iOADjnFLneGC3nDLb/hpz+eaAXy64ocL y/DjXDO98t1JJWy+FPQlV+PeY4qFhwAOmBATLinRILWp0J2GEc2x/6T7o7IJ4J+FAbEB98sKPmP lGELXCHmLDVQaHvG2lbsxclz7btlH2NN7gWEZlmFG4woAYHEwghYxaX+2fVsZ1jg5+A== X-Received: by 2002:a0c:b02c:: with SMTP id k41mr21359657qvc.154.1542653863398; Mon, 19 Nov 2018 10:57:43 -0800 (PST) X-Google-Smtp-Source: AJdET5eZ63u239J+ufcEOpawG9DPssygGn5gyYDN96kDntD9jjY2oalcLBcHhUQBO9TqqTAVNn98 X-Received: by 2002:a0c:b02c:: with SMTP id k41mr21359635qvc.154.1542653862923; Mon, 19 Nov 2018 10:57:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542653862; cv=none; d=google.com; s=arc-20160816; b=SmaZn9EMcqO22rD5YyQ6KZACn2bmKBsnN1wzbfdnrI34wWoEm9feRZPNzd/bl3vYa+ MIBT8JkYo6LgoplZqWQo7sou/And918XUqr8Jx0Rcdn+fwtT2L99BLLXZkFeElTI+wfa wNubTwlJ/GAq5tjJNVyt1hF2iCGI28K9ig9aA4+YwwL/WWfl4Nse2YzKqSyjCIf1TG0l f2xZpzJ8JWboI4C1WU9eeOKLTJbD1ZInj6fhAka/zUZsOa2idFeyxo0kmHGorNiDpzgA mmvsNvFKHBYawgDg5Jjel7BtCRnWjyWDWBWKzsCxdhpTKY76SS+f+RJuMe4wQWwLckJq YL6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=/AXVtKcmys+lbDgtDQa281BoRXMYSCg3AAu21s16z2c=; b=fck+lYwPskHU/GXj6AtuT+TR9Upa/EYm6M3+6GTZTiJdYfqVUeS73Jn3+Jz86CHM9Z 2QKG+hEflpylGJvoDrYqWlv4nh/MV268F1sz7hl73mIRu9Fn6a0I7qmMgU/57F9tpX7H 0HE4UG2pyAd3rBuRBGybiWmgqR7t0nk4zPvzNFaBwi4rQAwfSa43jmkI/beyqzs5tcxR hBHyCmbNIsY6LJSK4k+7KS1hO2AXekcAL39g57n9TSjU3iqdtEAUE3tnM0Tjbt3gAt0q WiX2q04klw4mduGHeqUESpqUkD2JCnY0RI4eu7GB30/gIL4ATwWHTJYV3pGo7XwIFnif lt8w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id l49si2793755qvc.80.2018.11.19.10.57.42 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Nov 2018 10:57:42 -0800 (PST) Received-SPF: pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E9A188BD20; Mon, 19 Nov 2018 18:57:41 +0000 (UTC) Received: from llong.com (dhcp-17-55.bos.redhat.com [10.18.17.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4992A608E7; Mon, 19 Nov 2018 18:57:40 +0000 (UTC) From: Waiman Long To: Peter Zijlstra , Ingo Molnar , Will Deacon , Thomas Gleixner Cc: linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org, iommu@lists.linux-foundation.org, Petr Mladek , Sergey Senozhatsky , Andrey Ryabinin , Tejun Heo , Andrew Morton , Waiman Long Subject: [PATCH v2 13/17] mm/kasan: Make quarantine_lock a terminal lock Date: Mon, 19 Nov 2018 13:55:22 -0500 Message-Id: <1542653726-5655-14-git-send-email-longman@redhat.com> In-Reply-To: <1542653726-5655-1-git-send-email-longman@redhat.com> References: <1542653726-5655-1-git-send-email-longman@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 19 Nov 2018 18:57:42 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP By making quarantine_lock a terminal spinlock, it reduces the lockdep overhead when this lock is being used. Signed-off-by: Waiman Long --- mm/kasan/quarantine.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/kasan/quarantine.c b/mm/kasan/quarantine.c index b209dba..c9d36ab 100644 --- a/mm/kasan/quarantine.c +++ b/mm/kasan/quarantine.c @@ -103,7 +103,7 @@ static void qlist_move_all(struct qlist_head *from, struct qlist_head *to) static int quarantine_tail; /* Total size of all objects in global_quarantine across all batches. */ static unsigned long quarantine_size; -static DEFINE_RAW_SPINLOCK(quarantine_lock); +static DEFINE_RAW_TERMINAL_SPINLOCK(quarantine_lock); DEFINE_STATIC_SRCU(remove_cache_srcu); /* Maximum size of the global queue. */ From patchwork Mon Nov 19 18:55:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Waiman Long X-Patchwork-Id: 10689329 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CB7E414E2 for ; Mon, 19 Nov 2018 18:57:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BC24C2A465 for ; Mon, 19 Nov 2018 18:57:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AADB52A475; Mon, 19 Nov 2018 18:57:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 37CFB2A46D for ; Mon, 19 Nov 2018 18:57:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C0ACC6B1BF4; Mon, 19 Nov 2018 13:57:45 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B6C696B1BF5; Mon, 19 Nov 2018 13:57:45 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A09E96B1BF6; Mon, 19 Nov 2018 13:57:45 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by kanga.kvack.org (Postfix) with ESMTP id 7568C6B1BF4 for ; Mon, 19 Nov 2018 13:57:45 -0500 (EST) Received: by mail-qk1-f198.google.com with SMTP id y83so70181133qka.7 for ; Mon, 19 Nov 2018 10:57:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=gBoHeDukKRC914ZDMXFLqVWWJNRPsvA+oZ6Eqk+XrZ4=; b=bLoD9H37DJDkE09XiBR8xfqAbjfXE6xwVuOcVlprtXSlvXPLQnUvyXtnvReyXcysPA F6to+tDq9dnE7cP2yNcGqMqs/DfBJP2Jy7Mzmmk8+lOaVgpFIz1JTNGyAR/wZF0GFm7y BaJ1dyFlB4ZIE0tkwZzV+yYkdcSvnd7NDHI0sY48q7IDMFWWHgu1jOfZoGdLS+q5oMMo sO1FFfRaGVT/GFbbadhAzOXAM7pNkfISmzfDQgxmZv5DJ9utG5nywolEA9Z6vbItIoGH fWM3NzYjP20O9dKhNsWJr35GIDRlZhTDyMH3HEOrqJ7jku5ffbrLDjluIHXYs8JQUMQV jWvA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: AGRZ1gLLJKcYrK1riGElo6hihpUtyo6CD80tsSvm5Z+pHedakx7arFOI AyLMsfN+mOAciTzTXJ85DLHRGmDEUP73krDL7U69evhjaBoD5K7hRYVIdrRNMFaioxKzVTONl0b NApJ8VLTByhalYb7lwmTFbkxtM8xwqfmJotQx22f+Q+0b5nPgZ9ctv+zo0kAjklMk9g== X-Received: by 2002:a0c:e486:: with SMTP id n6mr23100718qvl.210.1542653865259; Mon, 19 Nov 2018 10:57:45 -0800 (PST) X-Google-Smtp-Source: AJdET5dLg48+WGT9fH4A1Mduv03H0oojaH/QKhS+5314XUtsbDSG1SxfLanqtqeHr8b/KJ9idml2 X-Received: by 2002:a0c:e486:: with SMTP id n6mr23100702qvl.210.1542653864496; Mon, 19 Nov 2018 10:57:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542653864; cv=none; d=google.com; s=arc-20160816; b=cA8eVjh6t/nlxe8uOwJWJDq+GnH7Sxr8/WI0erIZZEt5XbVG6e2R2tDFxtJrDwILTU gm7ud0g5B8v8JlH5ffrv0DGG+kScWWN4IEy6BPSwZvSq2Mq4XE3/YRcBLt5GMm/Q/bLx 3/vZV2OYH+DnbBlIJPKGuYytVPAAmN9fwfrPmIYfMWOYY1ZWhYrzjFQAKtbfJr3JWl08 hiLLXJ5XTdzHa5t3f2avfrx8HNvSiJt9L2Q92OmQjGgv/AdDahoWCfjq0kcGqGPQ8QV4 abQf9zF0/f3roD031uVhxUAwQbYeuamSpWjyBw7UxdCi0M4//hYLnZjJPADyllVV+1bI mCKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=gBoHeDukKRC914ZDMXFLqVWWJNRPsvA+oZ6Eqk+XrZ4=; b=lBdkVzg+77i82pkvKXbN00wiXXjFtUjXkYapg+0nyNOAGOB4yYpf7fIIaRNrhOjyzu gJjT7A5xTQUc8GDquEQq+TNPu9D+z24bG/R7hsRKTt0+yEfZNWsYUSnF02ydZgle1tSH uspkq8RJqM4XwDnixhF/uQM/Rdj0k75Vcvt+LKd7oZ4pGeppqRV6Wz1sUtYRNMgBnqgY yfX1hGWZbS9Xc0mh75R4RjMZ7VcGQ63CcVp+GWxUTNFz2rhlQfSYQOiYPzXtQmUnPEFQ Lh3IcMO/uuEkKCp38NyC09rKIcoi8x8OCUvf1C1pJn0CR791qAPNc0gO2sk0EIvbUY/o Q8jA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id 34si3350844qvq.116.2018.11.19.10.57.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Nov 2018 10:57:44 -0800 (PST) Received-SPF: pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9095C169739; Mon, 19 Nov 2018 18:57:43 +0000 (UTC) Received: from llong.com (dhcp-17-55.bos.redhat.com [10.18.17.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0051C6607F; Mon, 19 Nov 2018 18:57:41 +0000 (UTC) From: Waiman Long To: Peter Zijlstra , Ingo Molnar , Will Deacon , Thomas Gleixner Cc: linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org, iommu@lists.linux-foundation.org, Petr Mladek , Sergey Senozhatsky , Andrey Ryabinin , Tejun Heo , Andrew Morton , Waiman Long Subject: [PATCH v2 14/17] dma-debug: Mark free_entries_lock as terminal Date: Mon, 19 Nov 2018 13:55:23 -0500 Message-Id: <1542653726-5655-15-git-send-email-longman@redhat.com> In-Reply-To: <1542653726-5655-1-git-send-email-longman@redhat.com> References: <1542653726-5655-1-git-send-email-longman@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 19 Nov 2018 18:57:43 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP By making free_entries_lock a terminal spinlock, it reduces the lockdep overhead when this lock is used. Signed-off-by: Waiman Long --- kernel/dma/debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/dma/debug.c b/kernel/dma/debug.c index 231ca46..f891688 100644 --- a/kernel/dma/debug.c +++ b/kernel/dma/debug.c @@ -106,7 +106,7 @@ struct hash_bucket { /* List of pre-allocated dma_debug_entry's */ static LIST_HEAD(free_entries); /* Lock for the list above */ -static DEFINE_SPINLOCK(free_entries_lock); +static DEFINE_TERMINAL_SPINLOCK(free_entries_lock); /* Global disable flag - will be set in case of an error */ static bool global_disable __read_mostly; From patchwork Mon Nov 19 18:55:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Waiman Long X-Patchwork-Id: 10689331 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DD30E13AD for ; Mon, 19 Nov 2018 18:57:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CBF6B2A46E for ; Mon, 19 Nov 2018 18:57:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C04592A470; Mon, 19 Nov 2018 18:57:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 62C032A46F for ; Mon, 19 Nov 2018 18:57:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 751176B1BF5; Mon, 19 Nov 2018 13:57:47 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 6FCEF6B1BF6; Mon, 19 Nov 2018 13:57:47 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 614156B1BF7; Mon, 19 Nov 2018 13:57:47 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by kanga.kvack.org (Postfix) with ESMTP id 375AB6B1BF5 for ; Mon, 19 Nov 2018 13:57:47 -0500 (EST) Received: by mail-qk1-f199.google.com with SMTP id 67so70126732qkj.18 for ; Mon, 19 Nov 2018 10:57:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=Bxt3ARERLC5KVtx1tQ5C+kuJNMiNscHqVsmanCd8/14=; b=R98mCBPNJijf1AOjLWxNl9zJYYh8vMl6p5MkNm1Tx43dx2pxiwggLotLnAqRg0ThLd dCzhcsgLx6i1SfKxN258sNK+XGdGn2r4nJQXfri1XfcDmSVOBRabRZgD/3C8RaIC36oL lk+O35p3Io+1pukSUqOWXmvHRSmEeFqZ4sZmq6aEtHuR2HGq1sMH/rEpxxNCwJo9044m KRVuSzTDLPMzmbkNYDQsI7tlsckJxcPgcxKMslMR8lsdFg4O/ml5jEf1gAChjnlom27V p7a7LVxf0yNjNO4MXPUIJxwNZ8JHOlywY1ZfX1qrDw0BkKx8a/0+l0UWnOeU5ha1aBJq 58Tg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: AGRZ1gJflXdgpNj0fWvTCMzfsof95wMMWMPioQ2yKicNRAjmIZkAvUIt /o7dNypeBH77TCEjqXHGOdFd5MJpygZSwUb63uFej6WDJiWaYZfKA4nR1qd/5cdsvEnNFBcV/Aq rMvhvi8eEKzqPhzHMWs4OXExzCXT6/8mwsmxY91cEBYnjAvQDwrNGJHPPtqoeszQ9Cw== X-Received: by 2002:ae9:e311:: with SMTP id v17mr20785291qkf.193.1542653866999; Mon, 19 Nov 2018 10:57:46 -0800 (PST) X-Google-Smtp-Source: AJdET5ciiFu+AlpX9HkpUE0DzoWx8GuzHjX1ZQbFYsW36xKrvU+wr/ayyrBhf8g63MOIBogmN7kt X-Received: by 2002:ae9:e311:: with SMTP id v17mr20785267qkf.193.1542653866312; Mon, 19 Nov 2018 10:57:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542653866; cv=none; d=google.com; s=arc-20160816; b=RzBNnGHWRm7hEzY4KTvuWPq+HqapsaOJyAd2lXWD6SVlZkQqTRb4I7xi6Hn673N3EK JW44/PZN8Yz0dHqi2NA52z+3DxGeieSiQ8Y1kY+Vi6NK85pLSnf8Wis1YWfI1dxvnXB9 8MxQwLOj9nrO6fLX4IB+thjEZn6RBk2XJ8V9S0wOZyhRGt3qdvady0mOFBq+ie4ng2Oy AoxADmwo9b8IuvbIetcGMRbjZWUASXEg9GkCr5Z9+8rpfa2NUdw3OTFKu0uxk2tOTahy C4+TNiBiM5NeSDJxS1m0zsf9FqjO1s5Qn3GMXRqn65TZjZnuHbNolnA3Yr/Ovw8P0EVx jQQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=Bxt3ARERLC5KVtx1tQ5C+kuJNMiNscHqVsmanCd8/14=; b=Q1RSIYSlHm0lls71Oj9Ua3WHvKROzhbyWWX3W9KqLl7w+sYT9ndbWocewsTqPzcW5G thTPR9pj8R/hbepYkW8vbmU7rpra3etIVL32D8+3jVakZpTDecJry3SUeLT9Ou85DzFn J3+HihoNQy/TUNSINZNA0bwaqGrnmQxB7mt04T84TF+/GxB91uXL/pntqUnKTm+g5MJA lBatj1sc4ryYGhqvOjXHOMZhEBC0hAcrNxDFWhMicFmiGLGAwgSeIkyZrJOq/qWIgq/H fCkjbu0MhuWu5pnPPF197ecKfJmDzdvGfqHmItfgsNGnOAfeWcnwTYuG05K7AYVMa37i xvhA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id i5si1227992qtd.227.2018.11.19.10.57.46 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Nov 2018 10:57:46 -0800 (PST) Received-SPF: pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2DF227F3EC; Mon, 19 Nov 2018 18:57:45 +0000 (UTC) Received: from llong.com (dhcp-17-55.bos.redhat.com [10.18.17.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id AE661608E7; Mon, 19 Nov 2018 18:57:43 +0000 (UTC) From: Waiman Long To: Peter Zijlstra , Ingo Molnar , Will Deacon , Thomas Gleixner Cc: linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org, iommu@lists.linux-foundation.org, Petr Mladek , Sergey Senozhatsky , Andrey Ryabinin , Tejun Heo , Andrew Morton , Waiman Long Subject: [PATCH v2 15/17] kernfs: Mark kernfs_open_node_lock as terminal lock Date: Mon, 19 Nov 2018 13:55:24 -0500 Message-Id: <1542653726-5655-16-git-send-email-longman@redhat.com> In-Reply-To: <1542653726-5655-1-git-send-email-longman@redhat.com> References: <1542653726-5655-1-git-send-email-longman@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 19 Nov 2018 18:57:45 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP By making kernfs_open_node_lock a terminal spinlock, it reduces the lockdep overhead when this lock is used. Signed-off-by: Waiman Long --- fs/kernfs/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c index dbf5bc2..a86fe22 100644 --- a/fs/kernfs/file.c +++ b/fs/kernfs/file.c @@ -29,7 +29,7 @@ * kernfs_open_file. kernfs_open_files are chained at * kernfs_open_node->files, which is protected by kernfs_open_file_mutex. */ -static DEFINE_SPINLOCK(kernfs_open_node_lock); +static DEFINE_TERMINAL_SPINLOCK(kernfs_open_node_lock); static DEFINE_MUTEX(kernfs_open_file_mutex); struct kernfs_open_node { From patchwork Mon Nov 19 18:55:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Waiman Long X-Patchwork-Id: 10689333 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3F61213AD for ; Mon, 19 Nov 2018 18:57:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 31A1A2A446 for ; Mon, 19 Nov 2018 18:57:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 25A472A470; Mon, 19 Nov 2018 18:57:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BE08C2A465 for ; Mon, 19 Nov 2018 18:57:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D3C806B1BF7; Mon, 19 Nov 2018 13:57:48 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C0A0A6B1BF8; Mon, 19 Nov 2018 13:57:48 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A81886B1BF9; Mon, 19 Nov 2018 13:57:48 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by kanga.kvack.org (Postfix) with ESMTP id 811286B1BF7 for ; Mon, 19 Nov 2018 13:57:48 -0500 (EST) Received: by mail-qk1-f199.google.com with SMTP id f22so69981425qkm.11 for ; Mon, 19 Nov 2018 10:57:48 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=N+e4Z+AGez+DgdYjdKeTMuWLfGLvVoe5clNB4W8P3TE=; b=nRZ6VknJKZHfirLtJLbkGj0fgY5dtqpoBHHNdcL6W+LtScqtMSdMLggReBoR1OYc0R hFynmod2ISQot9cAtrZPVEfKZWw3aPvcmrdN0qIv2BwpbHrkcrtKn3FAtBsLBc7mweLi QbA+Uh67xMhoimN5/XgtysM+h8Z6HezVcCcpbF/+wnbFhWaodJokeHI9ORkcDGj6savE SlFAHzXdD9TaLDOyNzYyCs3wac82PdOJi1qTMQPxt8dZMyyYP7JTwuUYWQzK8fjtV94U /8PrIzx8jJuzaFs+mlM6YbsrxTlMHuMLv11DvKB2DEq5qSJnuoHqBs5u3WwK3JaYYJ6c f3Vw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: AGRZ1gKgbEP7oYp7GWc4nphhBhT6y77HosxoINfqfv+lznFI8pshPk7D m92STfmFhJJXcv1smaFLzlZ/CKsNkZKyTTIYOEdJt2UXrVWQW9KnOKQKVDRzJbt+bH6T7DEyKrU KKHcDgn/iLOoAmUKGSLlTRDhkFQ8eNVJYqI4Ij8jzEFBpT/cvUbqNwWks7GarXU2B0g== X-Received: by 2002:ac8:72c1:: with SMTP id o1mr22077717qtp.220.1542653868320; Mon, 19 Nov 2018 10:57:48 -0800 (PST) X-Google-Smtp-Source: AJdET5fTbMLvPpIPgPQNUtjQQiQjUq7Wo8T6T57sqm2mf5qoGy/EkQ/NZT0T5KIwlA91mVlKP+s5 X-Received: by 2002:ac8:72c1:: with SMTP id o1mr22077695qtp.220.1542653867870; Mon, 19 Nov 2018 10:57:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542653867; cv=none; d=google.com; s=arc-20160816; b=YIBVtNWFe6H4CwYkhHXcqsCmQ2XdD+QinuuJUu9GAYT78r2BCdjQSxMp9HXQdBeQ9Y u6HKAvznaCrY2yLl8zM/CxJg+eOEBvC2xETQm4DOYk5ningMFGN9yPQoOo5mOGZlgZJk QLzb3iXGuZyojc3ct51/yNDDitPtZgvk/dupUxeOQiIIVJmYOvgzcljVNz93fB9fAm4v AeBnw9QF5H9JFt38rgF8r+bxlNzSFaEjYPWU2Z6x31OXqN/8U8Q8Qb6weTr431BONABK iZzx6xGjQVQqlmRCb2G2T+scWNeGlCgX28iliGAz1ggKmXo6OzrN7CrtQux3Ll0Tvyrj Jjkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=N+e4Z+AGez+DgdYjdKeTMuWLfGLvVoe5clNB4W8P3TE=; b=W17ixOxNwoqNhy6MUm2B//SFf5ZR2pdNPwZnPKlKylrym31cE+pWUTxiBfYREFQ0X2 qJ88r15MVnwgVL3lrcohxn40eXZxwBbAyhy5tCHZrSdu9jfeuvFe2rVBtdvpMuogoQ/+ FNR9AikzIp4dSEeMXQPjyHS6nqIWp2otKOGwupLVBXsv8bAdlZCzNw2aCg+duIipbrd0 EfjHz2BbxLamK39p4SCId5ImDdYRgasowtdVzSW1fAs4/YHUU5IUvQXKN11wMgRMNiut Qx016eLtZy7xkpiE1yHNQXrd47cEkjF6UR99lAAJVjior4CQnjnbjkCMxR7GWqbcqLLU sNIg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id o127si7092133qkd.13.2018.11.19.10.57.47 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Nov 2018 10:57:47 -0800 (PST) Received-SPF: pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E2AED58E5A; Mon, 19 Nov 2018 18:57:46 +0000 (UTC) Received: from llong.com (dhcp-17-55.bos.redhat.com [10.18.17.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4B0726090A; Mon, 19 Nov 2018 18:57:45 +0000 (UTC) From: Waiman Long To: Peter Zijlstra , Ingo Molnar , Will Deacon , Thomas Gleixner Cc: linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org, iommu@lists.linux-foundation.org, Petr Mladek , Sergey Senozhatsky , Andrey Ryabinin , Tejun Heo , Andrew Morton , Waiman Long Subject: [PATCH v2 16/17] delay_acct: Mark task's delays->lock as terminal spinlock Date: Mon, 19 Nov 2018 13:55:25 -0500 Message-Id: <1542653726-5655-17-git-send-email-longman@redhat.com> In-Reply-To: <1542653726-5655-1-git-send-email-longman@redhat.com> References: <1542653726-5655-1-git-send-email-longman@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 19 Nov 2018 18:57:47 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP By making task's delays->lock a terminal spinlock, it reduces the lockdep overhead when this lock is used. Signed-off-by: Waiman Long --- kernel/delayacct.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/delayacct.c b/kernel/delayacct.c index 2a12b98..49dd8d3 100644 --- a/kernel/delayacct.c +++ b/kernel/delayacct.c @@ -43,8 +43,10 @@ void delayacct_init(void) void __delayacct_tsk_init(struct task_struct *tsk) { tsk->delays = kmem_cache_zalloc(delayacct_cache, GFP_KERNEL); - if (tsk->delays) + if (tsk->delays) { raw_spin_lock_init(&tsk->delays->lock); + lockdep_set_terminal_class(&tsk->delays->lock); + } } /* From patchwork Mon Nov 19 18:55:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Waiman Long X-Patchwork-Id: 10689335 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0E4745A4 for ; Mon, 19 Nov 2018 18:58:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F1D412A45B for ; Mon, 19 Nov 2018 18:58:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E5A7F2A470; Mon, 19 Nov 2018 18:58:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 586752A45B for ; Mon, 19 Nov 2018 18:58:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9BE216B1BF8; Mon, 19 Nov 2018 13:57:50 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 96D7E6B1BF9; Mon, 19 Nov 2018 13:57:50 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 838E06B1BFA; Mon, 19 Nov 2018 13:57:50 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by kanga.kvack.org (Postfix) with ESMTP id 56FB86B1BF8 for ; Mon, 19 Nov 2018 13:57:50 -0500 (EST) Received: by mail-qk1-f198.google.com with SMTP id v74so49180372qkb.21 for ; Mon, 19 Nov 2018 10:57:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=SI7tz9eZrMp1hrTBYCrMNckVSLrQLCvVme6CnCUGkhE=; b=FLdhm+lnwf2d6W0hboCGBi5Fp+Hvtn8D6rJNrTuCkJI9w28zdzQlp5Eb0ygoQ+o0Pf Jxjk3k5n2Zs7yY/DmahmTCs+72KjB7XYADQ6JZY2CO0kJPgqn7It78qK1ZxEb8StShR7 Bzqc4ojPJkDYZ1xKRkv8iO6kYK22QnOdsACVDvcjDhGwdFvyXiBvsdMix7Le84RwEcwb vB3O96meUplPKgqdhU5DOfkLmG1EvAIMF6775oowvF0NCYw+9FQhD3bcLynoP+tlwDt/ tHWENXjyTgmHQQUENa/RRGIQ6vOh5qVwsy/urHIpAC44GZN2YAcv4zQKpYPBkSNPU5ap Huag== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: AGRZ1gK0RN2sLj7rh7/JhjOMaAGhZtkkEEKZjkg8IoHrHJyFo3uJamPv U+PGMwjaipN1c2OXY1SCnFWzXilGVnMNUDiTAQ+12UmLtmS4usoEBlyloqAOSWrcefgW8St6r7T /0X7890vXO6ZCupy+Ajx0vNflGPDlYLfnId9MOlFiriFil5FC65wFcVsl449LTdQgQQ== X-Received: by 2002:ac8:7950:: with SMTP id r16mr22367111qtt.12.1542653870116; Mon, 19 Nov 2018 10:57:50 -0800 (PST) X-Google-Smtp-Source: AJdET5d3Qb/kji8ahTzGLEtQ5T46+oFz3bDEQYHfQZyoNYeBwzX2s8couKEKEq6obxGZQa94hPkr X-Received: by 2002:ac8:7950:: with SMTP id r16mr22367077qtt.12.1542653869404; Mon, 19 Nov 2018 10:57:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542653869; cv=none; d=google.com; s=arc-20160816; b=yO9UB/TR/a8+7O+3Rfun9J/I+km8iJyJIcdV/1BK6P0JHsfho955PNe1yPhg47bc3N 1jAFcwrqzJUI1eMpzxG//T5djHgy4A+4KJj0yMCxPP+sWrgPD0qNmhGUIUfidNkpsPD2 wgLMVKDdt59sNMZNkqRk+4+Yu+fkw61IDc+tDWV8pli3mH526VYxqJ8TiNa+frZDDo5X y8lwmQIeCfqzvIqdMCz5fKaRfL1+6xt0Ez/Zmxeu8ZbPirugQWgpR+NdjsjATBeuI6Cb 7ebW1TjrFohgZs37nDsJC5CdZ4nbCDx71uOF1CFYrtfVNmPEgbTt4Rj6L3dpgJbnYcLH J0bA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=SI7tz9eZrMp1hrTBYCrMNckVSLrQLCvVme6CnCUGkhE=; b=EV/fStv2QKHp/ttn1ni0S3t65Ait6awNbJhxlrGe75tt+Orl2MyLQvdb+L+Jw+63vZ qtlBYZiaJUJfbm3HzRe8cUuHrJR/L+cHiCh4MEO0Ct7iAHooz9iZkX1ywW1SxdDjT6K7 WHZfsFwcSYSZA86FOUBeZUQyuLe4Kz7u4xm5hngnrM9dowS2LmGKEFzpEHD0+bUwB0/B BM/W0/mlKt1tcw7Kp50J4UH+4p4lURpw7i8sedS0t0hLvho8d/GTte0VVixm9Wmq6sLF QUSMTT7maQu4xJ3Sn5AQzXkD25nfp0lEhk717LzXcv/bB9Mx5PmxJXqo59gp/Mmmgkuk davQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id v30si2955799qtd.97.2018.11.19.10.57.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Nov 2018 10:57:49 -0800 (PST) Received-SPF: pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of longman@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6DF963082E4C; Mon, 19 Nov 2018 18:57:48 +0000 (UTC) Received: from llong.com (dhcp-17-55.bos.redhat.com [10.18.17.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id F1BB5608E7; Mon, 19 Nov 2018 18:57:46 +0000 (UTC) From: Waiman Long To: Peter Zijlstra , Ingo Molnar , Will Deacon , Thomas Gleixner Cc: linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org, iommu@lists.linux-foundation.org, Petr Mladek , Sergey Senozhatsky , Andrey Ryabinin , Tejun Heo , Andrew Morton , Waiman Long Subject: [PATCH v2 17/17] locking/lockdep: Check raw/non-raw locking conflicts Date: Mon, 19 Nov 2018 13:55:26 -0500 Message-Id: <1542653726-5655-18-git-send-email-longman@redhat.com> In-Reply-To: <1542653726-5655-1-git-send-email-longman@redhat.com> References: <1542653726-5655-1-git-send-email-longman@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Mon, 19 Nov 2018 18:57:48 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP A task holding a raw spinlock should not acquire a non-raw lock as that will break PREEMPT_RT kernel. Checking is now added and a lockdep warning will be printed if that happens. Signed-off-by: Waiman Long --- include/linux/lockdep.h | 6 ++++++ include/linux/spinlock_types.h | 4 ++-- kernel/locking/lockdep.c | 15 +++++++++++++-- kernel/locking/spinlock_debug.c | 1 + 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h index b9435fb..9a6fe0e 100644 --- a/include/linux/lockdep.h +++ b/include/linux/lockdep.h @@ -150,12 +150,15 @@ struct lock_class_stats { * another lock within its critical section is not allowed. * 3) LOCKDEP_FLAG_TERMINAL_NESTABLE: This is a terminal lock that can * allow one more regular terminal lock to be nested underneath it. + * 4) LOCKDEP_FLAG_RAW: This is a raw spinlock. A task holding a raw + * spinlock should not acquire a non-raw lock. * * Only the least significant 4 bits of the flags will be copied to the * held_lock structure. */ #define LOCKDEP_FLAG_TERMINAL (1 << 0) #define LOCKDEP_FLAG_TERMINAL_NESTABLE (1 << 1) +#define LOCKDEP_FLAG_RAW (1 << 2) #define LOCKDEP_FLAG_NOVALIDATE (1 << 4) #define LOCKDEP_HLOCK_FLAGS_MASK 0x0f @@ -333,6 +336,8 @@ extern void lockdep_init_map(struct lockdep_map *lock, const char *name, do { (lock)->dep_map.flags |= LOCKDEP_FLAG_TERMINAL; } while (0) #define lockdep_set_terminal_nestable_class(lock) \ do { (lock)->dep_map.flags |= LOCKDEP_FLAG_TERMINAL_NESTABLE; } while (0) +#define lockdep_set_raw_class(lock) \ + do { (lock)->dep_map.flags |= LOCKDEP_FLAG_RAW; } while (0) /* * Compare locking classes @@ -448,6 +453,7 @@ static inline void lockdep_on(void) do { (void)(key); } while (0) #define lockdep_set_subclass(lock, sub) do { } while (0) +#define lockdep_set_raw_class(lock) do { } while (0) #define lockdep_set_novalidate_class(lock) do { } while (0) #define lockdep_set_terminal_class(lock) do { } while (0) #define lockdep_set_terminal_nestable_class(lock) do { } while (0) diff --git a/include/linux/spinlock_types.h b/include/linux/spinlock_types.h index 6a8086e..1d2114b 100644 --- a/include/linux/spinlock_types.h +++ b/include/linux/spinlock_types.h @@ -55,11 +55,11 @@ SPIN_DEP_MAP_INIT(lockname, f) } #define __RAW_SPIN_LOCK_UNLOCKED(lockname) \ - (raw_spinlock_t) __RAW_SPIN_LOCK_INITIALIZER(lockname, 0) + (raw_spinlock_t) __RAW_SPIN_LOCK_INITIALIZER(lockname, LOCKDEP_FLAG_RAW) #define __RAW_TERMINAL_SPIN_LOCK_UNLOCKED(lockname) \ (raw_spinlock_t) __RAW_SPIN_LOCK_INITIALIZER(lockname, \ - LOCKDEP_FLAG_TERMINAL) + LOCKDEP_FLAG_TERMINAL|LOCKDEP_FLAG_RAW) #define DEFINE_RAW_SPINLOCK(x) raw_spinlock_t x = __RAW_SPIN_LOCK_UNLOCKED(x) #define DEFINE_RAW_TERMINAL_SPINLOCK(x) \ diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index 5a853a6..efafd2d 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -3273,8 +3273,8 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass, * one isn't a regular terminal lock. */ prev_type = hlock_is_terminal(hlock); - if (DEBUG_LOCKS_WARN_ON((prev_type == LOCKDEP_FLAG_TERMINAL) || - ((prev_type == LOCKDEP_FLAG_TERMINAL_NESTABLE) && + if (DEBUG_LOCKS_WARN_ON((prev_type & LOCKDEP_FLAG_TERMINAL) || + ((prev_type & LOCKDEP_FLAG_TERMINAL_NESTABLE) && (flags_is_terminal(class->flags) != LOCKDEP_FLAG_TERMINAL)))) { pr_warn("Terminal lock error: prev lock = %s, curr lock = %s\n", @@ -3282,6 +3282,17 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass, return 0; } + /* + * A task holding a raw spinlock should not acquire another + * non-raw lock. + */ + if (DEBUG_LOCKS_WARN_ON((prev_type & LOCKDEP_FLAG_RAW) && + !(class->flags & LOCKDEP_FLAG_RAW))) { + pr_warn("Raw lock error: prev lock = %s, curr lock = %s\n", + hlock->instance->name, class->name); + return 0; + } + if (hlock->class_idx == class_idx && nest_lock) { if (hlock->references) { /* diff --git a/kernel/locking/spinlock_debug.c b/kernel/locking/spinlock_debug.c index 9aa0fcc..1794d47 100644 --- a/kernel/locking/spinlock_debug.c +++ b/kernel/locking/spinlock_debug.c @@ -22,6 +22,7 @@ void __raw_spin_lock_init(raw_spinlock_t *lock, const char *name, */ debug_check_no_locks_freed((void *)lock, sizeof(*lock)); lockdep_init_map(&lock->dep_map, name, key, 0); + lockdep_set_raw_class(lock); #endif lock->raw_lock = (arch_spinlock_t)__ARCH_SPIN_LOCK_UNLOCKED; lock->magic = SPINLOCK_MAGIC;