Received: by 2002:a05:7412:8d06:b0:f9:332d:97f1 with SMTP id bj6csp68229rdb; Mon, 18 Dec 2023 09:06:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IHuojWyLmKrDkOoMBX460iuUo4V5D1a8DAaRwZJQjCcBPpAYdEKYcSdGij8kgreXqRbrzDj X-Received: by 2002:a05:6358:715:b0:172:cb1a:931d with SMTP id e21-20020a056358071500b00172cb1a931dmr2998411rwj.3.1702919166949; Mon, 18 Dec 2023 09:06:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702919166; cv=none; d=google.com; s=arc-20160816; b=bsuzUymv08w46KRcNT7GdLoWfmAbzq7SK4a4h9B03DqBY0l2x7RqHWeffVhtko+kmY LxxiOh8AHCv4LPJprGcrl6H5afpcEwqPqNgGAbpgaOxFKIgyrnnJxu+DTMURrwRWoKZD pJ+VWy3xMkryfdAldTMJsnVQuSQkrz9l+O185tu/5g+yE62CsvegRhvJqzNNlGygWqOW c1uqFyh/tjThvfPYsL//vsnZqcAHYv2sm0gEH2G9J473BOVPrbtoHtEpWvfbODC/2Upm Zo7GgEBnro0RE+LztP5SzAKY3IuzVI0PVX+YATI/y3bUDz1WQQeN4GJd1Te66/lo7KRO FqFw== 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=ZHVXfapFaNpskuHSl3q7oII90SEseCDPP+ervZTtQgI=; fh=SQEPup4VoGWMBwUDE6t7BoLQRw6RRwwn9JDDrMA/QSU=; b=mfa/xz4DkAXn5gZxIUyAE/8vZgdVbJ89a83O5ZzZ+GEytycoIc5OHfEJkVxhSdNLkf +YJky0AwdBC27gsO1Rn6u9rKMH153+wdZCLfkutLEX+ml6GaF/sGZ1LRsiQVPXSE54oy M7Y7cCnMDhu6/1WMNWQoVxUVAGbgxJNO0syGDjoXPjplF31XZMIVkl68SjlcXUD16z0/ kAJTTLF2WsgBKu5opU1BbggiIj86wO+DqxcMHEnE4l6PLFHP+KzsZD8YldDC463bfL39 BAtilNkIEFawzveTATsi7gPRS8Oajnm/2V+7b3ijm0yUo8kvG5b9txRA6J+G0KwUvhn4 z/1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Q1lvtujs; spf=pass (google.com: domain of linux-kernel+bounces-4122-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4122-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id bn18-20020a056a02031200b005cd84f2c7a9si4191196pgb.763.2023.12.18.09.06.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 09:06:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-4122-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Q1lvtujs; spf=pass (google.com: domain of linux-kernel+bounces-4122-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4122-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 48235283CA5 for ; Mon, 18 Dec 2023 17:06:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 345414FF77; Mon, 18 Dec 2023 17:06:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Q1lvtujs" X-Original-To: linux-kernel@vger.kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 54D0C4FF9F for ; Mon, 18 Dec 2023 17:05:58 +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=1702919157; 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=ZHVXfapFaNpskuHSl3q7oII90SEseCDPP+ervZTtQgI=; b=Q1lvtujsR9Nx2rhZh1f8KpZ2X47TO0sGGSej425/1wQD3d6APiEmYfsfKkYtblVYqWskSi kNVRexgb03lkLAXFRHNMBWAAaWzX7JITz66MQ59h2lVFdzYKXVvUXkWPyCnWM40E9POBbf 9XjRTJ051ylrAV3FJL+pVp3V2e0SIAM= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-686-uYJsyWyCNqG8vqZW-oOiJw-1; Mon, 18 Dec 2023 12:05:55 -0500 X-MC-Unique: uYJsyWyCNqG8vqZW-oOiJw-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (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 53A27863E88; Mon, 18 Dec 2023 17:05:54 +0000 (UTC) Received: from [10.22.32.252] (unknown [10.22.32.252]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7A88E492BF0; Mon, 18 Dec 2023 17:05:53 +0000 (UTC) Message-ID: <91824e90-0319-467c-a7a7-acda9464a542@redhat.com> Date: Mon, 18 Dec 2023 12:05:53 -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 43/50] lockdep: move held_lock to lockdep_types.h Content-Language: en-US To: Kent Overstreet , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Cc: tglx@linutronix.de, x86@kernel.org, tj@kernel.org, peterz@infradead.org, mathieu.desnoyers@efficios.com, paulmck@kernel.org, keescook@chromium.org, dave.hansen@linux.intel.com, mingo@redhat.com, will@kernel.org, boqun.feng@gmail.com, brauner@kernel.org References: <20231216024834.3510073-1-kent.overstreet@linux.dev> <20231216033300.3553457-1-kent.overstreet@linux.dev> <20231216033300.3553457-11-kent.overstreet@linux.dev> From: Waiman Long In-Reply-To: <20231216033300.3553457-11-kent.overstreet@linux.dev> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 On 12/15/23 22:32, Kent Overstreet wrote: > held_lock is embedded in task_struct, and we don't want sched.h pulling > in all of lockdep.h > > Signed-off-by: Kent Overstreet > --- > include/linux/lockdep.h | 57 ----------------------------------- > include/linux/lockdep_types.h | 57 +++++++++++++++++++++++++++++++++++ > 2 files changed, 57 insertions(+), 57 deletions(-) > > diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h > index dc2844b071c2..08b0d1d9d78b 100644 > --- a/include/linux/lockdep.h > +++ b/include/linux/lockdep.h > @@ -82,63 +82,6 @@ struct lock_chain { > u64 chain_key; > }; > > -#define MAX_LOCKDEP_KEYS_BITS 13 > -#define MAX_LOCKDEP_KEYS (1UL << MAX_LOCKDEP_KEYS_BITS) > -#define INITIAL_CHAIN_KEY -1 > - > -struct held_lock { > - /* > - * One-way hash of the dependency chain up to this point. We > - * hash the hashes step by step as the dependency chain grows. > - * > - * We use it for dependency-caching and we skip detection > - * passes and dependency-updates if there is a cache-hit, so > - * it is absolutely critical for 100% coverage of the validator > - * to have a unique key value for every unique dependency path > - * that can occur in the system, to make a unique hash value > - * as likely as possible - hence the 64-bit width. > - * > - * The task struct holds the current hash value (initialized > - * with zero), here we store the previous hash value: > - */ > - u64 prev_chain_key; > - unsigned long acquire_ip; > - struct lockdep_map *instance; > - struct lockdep_map *nest_lock; > -#ifdef CONFIG_LOCK_STAT > - u64 waittime_stamp; > - u64 holdtime_stamp; > -#endif > - /* > - * class_idx is zero-indexed; it points to the element in > - * lock_classes this held lock instance belongs to. class_idx is in > - * the range from 0 to (MAX_LOCKDEP_KEYS-1) inclusive. > - */ > - unsigned int class_idx:MAX_LOCKDEP_KEYS_BITS; > - /* > - * The lock-stack is unified in that the lock chains of interrupt > - * contexts nest ontop of process context chains, but we 'separate' > - * the hashes by starting with 0 if we cross into an interrupt > - * context, and we also keep do not add cross-context lock > - * dependencies - the lock usage graph walking covers that area > - * anyway, and we'd just unnecessarily increase the number of > - * dependencies otherwise. [Note: hardirq and softirq contexts > - * are separated from each other too.] > - * > - * The following field is used to detect when we cross into an > - * interrupt context: > - */ > - unsigned int irq_context:2; /* bit 0 - soft, bit 1 - hard */ > - unsigned int trylock:1; /* 16 bits */ > - > - unsigned int read:2; /* see lock_acquire() comment */ > - unsigned int check:1; /* see lock_acquire() comment */ > - unsigned int hardirqs_off:1; > - unsigned int sync:1; > - unsigned int references:11; /* 32 bits */ > - unsigned int pin_count; > -}; > - > /* > * Initialization, self-test and debugging-output methods: > */ > diff --git a/include/linux/lockdep_types.h b/include/linux/lockdep_types.h > index 2ebc323d345a..9c533c8d701e 100644 > --- a/include/linux/lockdep_types.h > +++ b/include/linux/lockdep_types.h > @@ -198,6 +198,63 @@ struct lockdep_map { > > struct pin_cookie { unsigned int val; }; > > +#define MAX_LOCKDEP_KEYS_BITS 13 > +#define MAX_LOCKDEP_KEYS (1UL << MAX_LOCKDEP_KEYS_BITS) > +#define INITIAL_CHAIN_KEY -1 > + > +struct held_lock { > + /* > + * One-way hash of the dependency chain up to this point. We > + * hash the hashes step by step as the dependency chain grows. > + * > + * We use it for dependency-caching and we skip detection > + * passes and dependency-updates if there is a cache-hit, so > + * it is absolutely critical for 100% coverage of the validator > + * to have a unique key value for every unique dependency path > + * that can occur in the system, to make a unique hash value > + * as likely as possible - hence the 64-bit width. > + * > + * The task struct holds the current hash value (initialized > + * with zero), here we store the previous hash value: > + */ > + u64 prev_chain_key; > + unsigned long acquire_ip; > + struct lockdep_map *instance; > + struct lockdep_map *nest_lock; > +#ifdef CONFIG_LOCK_STAT > + u64 waittime_stamp; > + u64 holdtime_stamp; > +#endif > + /* > + * class_idx is zero-indexed; it points to the element in > + * lock_classes this held lock instance belongs to. class_idx is in > + * the range from 0 to (MAX_LOCKDEP_KEYS-1) inclusive. > + */ > + unsigned int class_idx:MAX_LOCKDEP_KEYS_BITS; > + /* > + * The lock-stack is unified in that the lock chains of interrupt > + * contexts nest ontop of process context chains, but we 'separate' > + * the hashes by starting with 0 if we cross into an interrupt > + * context, and we also keep do not add cross-context lock > + * dependencies - the lock usage graph walking covers that area > + * anyway, and we'd just unnecessarily increase the number of > + * dependencies otherwise. [Note: hardirq and softirq contexts > + * are separated from each other too.] > + * > + * The following field is used to detect when we cross into an > + * interrupt context: > + */ > + unsigned int irq_context:2; /* bit 0 - soft, bit 1 - hard */ > + unsigned int trylock:1; /* 16 bits */ > + > + unsigned int read:2; /* see lock_acquire() comment */ > + unsigned int check:1; /* see lock_acquire() comment */ > + unsigned int hardirqs_off:1; > + unsigned int sync:1; > + unsigned int references:11; /* 32 bits */ > + unsigned int pin_count; > +}; > + > #else /* !CONFIG_LOCKDEP */ > > /* Acked-by: Waiman Long