Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1451530yba; Tue, 2 Apr 2019 09:06:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqyaaIK5Lige8eiLTQrCZkp9a5CrHQ8/83iI4iImfTDscvxJNVD4WsD2O5XCv7JVVjm4NOEc X-Received: by 2002:a63:5947:: with SMTP id j7mr17895868pgm.62.1554221205008; Tue, 02 Apr 2019 09:06:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554221204; cv=none; d=google.com; s=arc-20160816; b=IKvc3UaZ3/oiGbPSKkJFj0MSaWe29L4Rd/Rytg+V1/UOTq6WLrQQrmHf3SM2tjXFuN FHwC9ra9WoA64t8lauT3sMk9oUvvdEcSVsN7nyDbeogTvU/EDM/M+5xdD1Z3VuynwnFn dQD4Q/m44TFv2AXeGu3j2HCK0LNpTga4G3cXq8Nsa3kz84D5VSyCPKyRzLXjTWObvD/f m0ZZZtHMzRp5iaEucTroUGFUCpyFwqwbtI4xDfpoSCQIyTGAKnohq+Wf8B6AmJUsaslZ 90a2S9ZfVS9PCejx7A5MMRNTVmk5wWDBilWkug+8S/zPW4r9TqJhT6t27hyhfVLyq6HX 6I9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=lJvwuiQpDVRb+M2x+VJtHPUo/dNNlT+rjf3y9RzqSzo=; b=TzlDKA1HYcuVeVRmkeqkIaTGTZ7YZpWayfYTV4TI/irHev6UUAIl2YmjtlieTFeQKk aeStjhGqnlK5e3IliXMXJjWLlg5wJSWAttTZzhBZUYaIzXVSwNnYm1gF+/gX/RUeVMnb ROtKo4bcGtSfv9QeTIOhVZIBKKMudWA8g/LgeT+Fo2Tth2+Hi42LS8pqpSFOvwKUl4+y qPSJ0nUdwZIUgBYF4QYsJmNx+zEyBoTNw+ivd0JOVqr4pG9Vq6dpOXjr8baYDthLtpHV O8/sjKWH/0WRDS/gOwT9GeE9cmmHIGtbnooJI+Yp5jbKUYLObZBE2dhk3+amSVfNmOfL DfDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IzY0J1+G; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h69si11775707pfc.120.2019.04.02.09.06.29; Tue, 02 Apr 2019 09:06:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IzY0J1+G; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730487AbfDBQC7 (ORCPT + 99 others); Tue, 2 Apr 2019 12:02:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:42850 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729060AbfDBQC5 (ORCPT ); Tue, 2 Apr 2019 12:02:57 -0400 Received: from lenoir.home (lfbn-1-18527-45.w90-101.abo.wanadoo.fr [90.101.69.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7011520856; Tue, 2 Apr 2019 16:02:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554220976; bh=iKyjNLG9r0I0AqUzA6Jyys10Q65u+XWLvHv5QAfX1eI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IzY0J1+G+O1HP/bA5Ynzv9RJRyeWTMJN9FwXjNgjRDLHhQzUhcEVdc5sFk1o3zN85 CDsGmV9KDx4i4lBDCgrrNRb3Uz+eSzj3B/5cEOcHydDIn16/oGspnsMNiW2el0SPcA WYQgQJ8D1Y2+q8fp7lG5PsiuMKLSSp94hPSn2Gjk= From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , Ingo Molnar , Peter Zijlstra Subject: [PATCH 3/4] locking/lockdep: Use expanded masks on find_usage_*() functions Date: Tue, 2 Apr 2019 18:02:43 +0200 Message-Id: <20190402160244.32434-4-frederic@kernel.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190402160244.32434-1-frederic@kernel.org> References: <20190402160244.32434-1-frederic@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In order to optimize check_irq_usage() and factorize all the IRQ usage validations we'll need to be able to check multiple lock usage bits at once. Prepare the low level usage mask check functions for that purpose. Signed-off-by: Frederic Weisbecker Cc: Ingo Molnar Cc: Peter Zijlstra --- kernel/locking/lockdep.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index 2288aa2fa4c6..5e149dd78298 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -1682,9 +1682,9 @@ check_redundant(struct lock_list *root, struct lock_class *target, * without creating any illegal irq-safe -> irq-unsafe lock dependency. */ -static inline int usage_match(struct lock_list *entry, void *bit) +static inline int usage_match(struct lock_list *entry, void *mask) { - return entry->class->usage_mask & (1 << (enum lock_usage_bit)bit); + return entry->class->usage_mask & *(unsigned long *)mask; } @@ -1700,14 +1700,14 @@ static inline int usage_match(struct lock_list *entry, void *bit) * Return <0 on error. */ static int -find_usage_forwards(struct lock_list *root, enum lock_usage_bit bit, +find_usage_forwards(struct lock_list *root, unsigned long usage_mask, struct lock_list **target_entry) { int result; debug_atomic_inc(nr_find_usage_forwards_checks); - result = __bfs_forwards(root, (void *)bit, usage_match, target_entry); + result = __bfs_forwards(root, &usage_mask, usage_match, target_entry); return result; } @@ -1723,14 +1723,14 @@ find_usage_forwards(struct lock_list *root, enum lock_usage_bit bit, * Return <0 on error. */ static int -find_usage_backwards(struct lock_list *root, enum lock_usage_bit bit, +find_usage_backwards(struct lock_list *root, unsigned long usage_mask, struct lock_list **target_entry) { int result; debug_atomic_inc(nr_find_usage_backwards_checks); - result = __bfs_backwards(root, (void *)bit, usage_match, target_entry); + result = __bfs_backwards(root, &usage_mask, usage_match, target_entry); return result; } @@ -1935,7 +1935,7 @@ check_usage(struct task_struct *curr, struct held_lock *prev, this.parent = NULL; this.class = hlock_class(prev); - ret = find_usage_backwards(&this, bit_backwards, &target_entry); + ret = find_usage_backwards(&this, lock_flag(bit_backwards), &target_entry); if (ret < 0) return print_bfs_bug(ret); if (ret == 1) @@ -1943,7 +1943,7 @@ check_usage(struct task_struct *curr, struct held_lock *prev, that.parent = NULL; that.class = hlock_class(next); - ret = find_usage_forwards(&that, bit_forwards, &target_entry1); + ret = find_usage_forwards(&that, lock_flag(bit_forwards), &target_entry1); if (ret < 0) return print_bfs_bug(ret); if (ret == 1) @@ -2941,7 +2941,7 @@ check_usage_forwards(struct task_struct *curr, struct held_lock *this, root.parent = NULL; root.class = hlock_class(this); - ret = find_usage_forwards(&root, bit, &target_entry); + ret = find_usage_forwards(&root, lock_flag(bit), &target_entry); if (ret < 0) return print_bfs_bug(ret); if (ret == 1) @@ -2965,7 +2965,7 @@ check_usage_backwards(struct task_struct *curr, struct held_lock *this, root.parent = NULL; root.class = hlock_class(this); - ret = find_usage_backwards(&root, bit, &target_entry); + ret = find_usage_backwards(&root, lock_flag(bit), &target_entry); if (ret < 0) return print_bfs_bug(ret); if (ret == 1) -- 2.21.0