Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp98093rdd; Mon, 8 Jan 2024 19:51:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IHJ3mywoIj6nPJYDFlztMVpQD8ebCI1L5nhYJ2e759/MvkQD0U5oquq61lgfIdoGh6gVjRt X-Received: by 2002:a05:6358:6f87:b0:172:db95:fcaf with SMTP id s7-20020a0563586f8700b00172db95fcafmr3887186rwn.30.1704772291755; Mon, 08 Jan 2024 19:51:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704772291; cv=none; d=google.com; s=arc-20160816; b=w2GAEPBatC5zym3NOJlu+SsW3wZnKSO5mvX054YXaUWmAwZ4EOsdqSA5CWJ70U5qXt rZmMsk+TQN+mbg9FfOyKDj1zUDvMnEsdLtL21PhYLPkx8p8JuVRysvAnJrzmMWWZtGcG W+xGm751msKH80qUOiqVF9y7uAlaWROqogEWXTA+IAij0B1u16WXELKaP+l+HOGxhCTq +FKwND7MGxihwWkQhZnOG+p8Vr0KXk4AwQV+Neo11E/o4MHSkZPF0I9svv2uEQNpPGKc 7cBpWZEfGkh+GfRdeyKhMCH4DcGh7m8MmygX0eDNqy3O/lNXvBpq/0dpjp0Jro5Hu6ut UB8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=ZTfyJ0n3w4TT5PYd+Uem/XQgjKHsnfqZgaIdLhgNUL8=; fh=uwMliCsl47WR1XIcC3I1dY07+TVA/Ke7NhHuPgy+JWY=; b=zXI69U/izWu3axU79jTuXe70HdoL8AjU/JdBe81zqjrYFFr9WSSXmfzdR7nfLj9Rie IrOzvfLBCuJP4rze4312S0n5rEAZ+Y+5zOfsFdrUF7XCOeJOSvywiyrxXdAY+MGb0Huv an6HbWBIOs3NtsixDYKMJQS3fiKPOoEsfaICEGF0anfsKVeVm9bBJTZHQpiAYR0e6/rw AqrpGjnQO3mAsLsjCw6aCxLmSWX8iRVo4pYF7u+DVHrIOPdX8LbBxZRnbrkpWBwdaT11 l7oR4I0joaCGVmVPN3B3fpLr6wm1PVdaPgaV2VW00XNjbeDNCmlve5lqIL4bOrf2J0y0 YEEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KGonJbCR; spf=pass (google.com: domain of linux-kernel+bounces-20345-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-20345-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id ay9-20020a17090b030900b0028cf2b39b57si6627581pjb.109.2024.01.08.19.51.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 19:51:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-20345-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KGonJbCR; spf=pass (google.com: domain of linux-kernel+bounces-20345-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-20345-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id B71ADB2392C for ; Tue, 9 Jan 2024 03:50:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 845A14430; Tue, 9 Jan 2024 03:49:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="KGonJbCR" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 224FA566D for ; Tue, 9 Jan 2024 03:49:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1704772177; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZTfyJ0n3w4TT5PYd+Uem/XQgjKHsnfqZgaIdLhgNUL8=; b=KGonJbCR5QdxAAb6YDxwMhDOIYt4XyWboCwKoHWvfNNrc0KZcpKPwSuYosTl+rId2LwLz/ WQcabgCAuSTREXqaZhURtM/ZYXLsoxP+ONKdygMpvMM2g3X6GuStI+CdJb9ddNp2RyBIfj 6TNuuycnDIQ0qTcQ+j6j99US5jAUEx8= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-439-Tn6IMJMmOi-BvWKCm98MJg-1; Mon, 08 Jan 2024 22:49:31 -0500 X-MC-Unique: Tn6IMJMmOi-BvWKCm98MJg-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0A56E1C0BB44; Tue, 9 Jan 2024 03:49:28 +0000 (UTC) Received: from [10.22.16.105] (unknown [10.22.16.105]) by smtp.corp.redhat.com (Postfix) with ESMTP id 91EE0492BC9; Tue, 9 Jan 2024 03:49:30 +0000 (UTC) Message-ID: Date: Mon, 8 Jan 2024 22:49:30 -0500 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] lockdep: Add missing graph_unlock in check_prev_add Content-Language: en-US To: Xuewen Yan , peterz@infradead.org, mingo@redhat.com, will@kernel.org, boqun.feng@gmail.com Cc: zhiguo.niu@unisoc.com, ke.wang@unisoc.com, linux-kernel@vger.kernel.org References: <20240105060456.15331-1-xuewen.yan@unisoc.com> From: Waiman Long In-Reply-To: <20240105060456.15331-1-xuewen.yan@unisoc.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 On 1/5/24 01:04, Xuewen Yan wrote: > The check_prev_add() is held graph_lock, and it should unlock > the graph_lock before return 0. > But there is one condition where it will return 0 without unlock, > that is: > > /* is not found in ::locks_before */ > return 0; > > So add graph_unlock before return 0. > > Fixes: 3454a36d6a39 ("lockdep: Introduce lock_list::dep") > Signed-off-by: Xuewen Yan > Signed-off-by: Zhiguo Niu > --- > Change in V2: > -move the graph_unlock to check_prev_add from validate_chain(Boqun) > -Add fix tag > --- > --- > kernel/locking/lockdep.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c > index 151bd3de5936..c8602a251bec 100644 > --- a/kernel/locking/lockdep.c > +++ b/kernel/locking/lockdep.c > @@ -3178,6 +3178,7 @@ check_prev_add(struct task_struct *curr, struct held_lock *prev, > } > > /* is not found in ::locks_before */ > + graph_unlock(); > return 0; > } > } There are multiple places in check_prev_add() that will return 0. It will be odd to have just one of them has a graph_unlock(). It makes the code hard to understand. You should insert graph_unlock() in a place that matches the other places where graph_unlock() will be called. My suggestion is as follows: diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index 151bd3de5936..d9f2df36332c 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -3252,7 +3252,7 @@ check_prevs_add(struct task_struct *curr, struct held_loc>                 if (hlock->check) {                         int ret = check_prev_add(curr, hlock, next, distance, &>                         if (!ret) -                               return 0; +                               goto out_bug;                         /*                          * Stop after the first non-trylock entry, It looks like this bug was first introduced by commit 910b1b2e6d ("[PATCH] lockdep: internal locking fixes"). So you may also add a fixes tag. Cheers, Longman