Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3952067ybi; Mon, 27 May 2019 08:29:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqwtBBU6w94k1c4cDfNMWG0gwgWj8xK8xb8vYiNY5NEvvEUUMPegBRIIPZHRpX/2GVHUB11Y X-Received: by 2002:a17:90a:ac03:: with SMTP id o3mr32414359pjq.114.1558970957375; Mon, 27 May 2019 08:29:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558970957; cv=none; d=google.com; s=arc-20160816; b=FHtNwMBHKkbQMT4iAC11WYDmSMCLBU/UcavHlwjM9kielXBrYl1kZf+zHPsQMvNg9A sujOmO6kPQtzKb7A1x2S+CBOOutN3e4L9eVe3y4ccetw8p2FQnurfCCfCMh8JlRA6WTl kMXUCQ+VwrXJAUHmHyxFK5dbKhBhQBcpJJGq19nnX3QHegDTxyEZfaaW1mZKRYYzQhcv q90VW1eQLcWzZLl0dPLwd3UABV7XtmqrAGkWRimLv0u4KsiNJ0BsNIH/A2KtPIdYrBuJ vhsIKujrJ01/jZWVEdXxdH5WFOYoDvwJyJjBzxjtFtfkDB1yDR/gh7e9BHnYEFAzoQXe 9HRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=x8YEUSs0VWayL9Nd4vTM3zWomPzr+SfoM35cTc7hwl8=; b=sODANfbTHh2v06axTgJClGUqz3aVjH9+EVRjgUZGX//8eNOa8/uWgoyg23E+3SZotu gIDjyh4lEQYlLbe2w0yVrUV6cU1Avmq+8ttKbFgWZgQfRlJtTfJ1Chu/8KMU9S28DcpM eJMG9+q8q0SLZRlQwpJr3E8uKcWjznNS1l0zdiE0Mm6Civw9h9EUAdg0nhqs+6X2ju+H Ac7Hj0s9LH9lSn37+gaYzkQfVpOsixc1RjimKRgm8uuxHzqLATB//WGovTWMZuPLiIFY x+8N0Obd/vp1G41zE0XCUGnHUvPyZkJQejSEFJsfHRF9pYr1Fwb8u0P+t3WIp3qtGX8D wDVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b="TjO/6smU"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d23si17100194pgh.448.2019.05.27.08.29.01; Mon, 27 May 2019 08:29:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b="TjO/6smU"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726688AbfE0PPC (ORCPT + 99 others); Mon, 27 May 2019 11:15:02 -0400 Received: from merlin.infradead.org ([205.233.59.134]:41082 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725991AbfE0PPC (ORCPT ); Mon, 27 May 2019 11:15:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=x8YEUSs0VWayL9Nd4vTM3zWomPzr+SfoM35cTc7hwl8=; b=TjO/6smU6keeXgs6XWfSHKkn/ RyGFCUscaykDuKu5DdcppZBmcsP1uYWnXWcjLzkgB4Vq7ZZLs+Ns6RrJFDJ8n9PENh9GEmNbBJld6 Wg8FPTtTF1jwZATlPKeh0YZAeGmRYxLQCFBJ7JqP9RtvjHJvlbZ18vcka+blKZm0e9+yNKR2ZI0Jv 54ZTnBrMdpmzeTDHgLigHodGO00pjtuBhZY/rqlDTyzugJ2i9v7ncFm/rc27ESt9Kk+HJnWwOuer7 S7t+pPYZB1TX6fOv9cx0eg5MsWZO4FAw9ca2TF9prMQHTAc5m2q4QQS5zIlmlVpao1HAi0ZJZpZOQ vWcq5kZOw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1hVHKi-0004X0-5C; Mon, 27 May 2019 15:14:40 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id A2204201E33E5; Mon, 27 May 2019 17:14:38 +0200 (CEST) Date: Mon, 27 May 2019 17:14:38 +0200 From: Peter Zijlstra To: Imre Deak Cc: LKML , Ville =?iso-8859-1?Q?Syrj=E4l=E4?= , Ingo Molnar , Will Deacon Subject: Re: [PATCH v2 2/2] lockdep: Fix merging of hlocks with non-zero references Message-ID: <20190527151438.GF2623@hirez.programming.kicks-ass.net> References: <20190524201509.9199-1-imre.deak@intel.com> <20190524201509.9199-2-imre.deak@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190524201509.9199-2-imre.deak@intel.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 24, 2019 at 11:15:09PM +0300, Imre Deak wrote: > diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c > index 967352d32af1..9e2a4ab6c731 100644 > --- a/kernel/locking/lockdep.c > +++ b/kernel/locking/lockdep.c > @@ -3637,6 +3637,11 @@ print_lock_nested_lock_not_held(struct task_struct *curr, > > static int __lock_is_held(const struct lockdep_map *lock, int read); > > +static int hlock_reference(int reference) > +{ > + return reference ? : 1; > +} > + > /* > * This gets called for every mutex_lock*()/spin_lock*() operation. > * We maintain the dependency maps and validate the locking attempt: > @@ -3702,17 +3707,15 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass, > if (depth) { > hlock = curr->held_locks + depth - 1; > if (hlock->class_idx == class_idx && nest_lock) { > - if (hlock->references) { > - /* > - * Check: unsigned int references overflow. > - */ > - if (DEBUG_LOCKS_WARN_ON(hlock->references == UINT_MAX)) What tree is this against? Afaict this is still 12 bits ?! > - return 0; > + /* > + * Check: unsigned int references overflow. > + */ > + if (DEBUG_LOCKS_WARN_ON(hlock_reference(hlock->references) > > + UINT_MAX - hlock_reference(references))) Idem. Also very weird overflow check.. > + return 0; > > - hlock->references++; > - } else { > - hlock->references = 2; > - } > + hlock->references = hlock_reference(hlock->references) + > + hlock_reference(references); > > return 2; > } > -- > 2.17.1 >