From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f174.google.com (mail-pg1-f174.google.com [209.85.215.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D37C83594C for ; Sat, 21 Dec 2024 05:17:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734758279; cv=none; b=VoXS6RwuwpkK747CqorayqN0j75Ftd1wWoLSRaeAJJ4pgwmmOFVdIltVPjmWe5t56DkklmsL92bn98QXhGqNjpxuWTJtopfNnPmG/6mDA+yGxpq77ErNs+NFSPrrfzts93j+6E/yN0G5W0uaaeGcqDfiyKwO0YAzuVos5qqRigk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734758279; c=relaxed/simple; bh=tdhrviXUyYrOkJpK6TlNLvUEorJ/drEcGIS4XeLFDjI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=odpt4ipAH9rSq4kG1CuwonXfv+rhRj6xME4hI2JVEeZ7kpq+u6CV1o9bOzQUaKJUPKudWixwsQw7y6o28uvdV60f7Y13KzNrkBMrGrRFTGfZL2vO2dUwSBl/VWIbGZGpeqwLc+P0vpY4IxR3cNzCDdGomBusthqUU5vjVGSRJs8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=UAw1U+eQ; arc=none smtp.client-ip=209.85.215.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UAw1U+eQ" Received: by mail-pg1-f174.google.com with SMTP id 41be03b00d2f7-7e9e38dd5f1so1853116a12.0 for ; Fri, 20 Dec 2024 21:17:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734758277; x=1735363077; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0QC/72JjUekI5hebR4Z81Enr4PkYEQJAIEzWRLgLbhM=; b=UAw1U+eQsLzOUrs4ijOaNz8/4m8Q3hM0I9hlQ9u3ooiu2kooNpH0GUuYgCS8YCfh4z lMNYAaqyktrV1OAq6FrV0cRyzRi4iLNLp+fdzc6n4OoQ89vD6QEwl3kAofD+RV3zyo3O mxeFarYtPw124gHyhMkRLkw3cM97ANm9EiIaaakDtfmVfGOVQ41McExlpVYiQ0/El7aC HTyOfYYUS5Y02XfAvihCZS8xAUNpOo30U78j38lR/xF+SNb3N7cwfFp2Sf9XrXWYP3Sv 0/U9dokPdxv17hOGaWI1coe6UZvdX/AqZaux74y0ynhn183znYoRpliva/pneiKjcCCO Ga/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734758277; x=1735363077; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0QC/72JjUekI5hebR4Z81Enr4PkYEQJAIEzWRLgLbhM=; b=le0wyybvo0+k370bqEsTTCAcrmslcaF6IN7S8LfjOilQNFlbIYAuBhwnh626eSozGs l9pTG5Qe2/ce/RJKWhj6vYpvcrtQ8UBySWhI6Oo+CZNeUVjeWABe9c0lUH3OkDpPvatz Y95Am2MHmV+5UeHzqex7zhixz+uKnd+/3gJZ2O2nRDXH3xDYKVO/QRDY+k8ninS1IrSL 1GZpcgFH8jIO4ii2TaPYb7H1kAb8hUwqABKiES107Ku7ZgOAW23KbIqBMzEK7FYY5zKU 8BfQsJ3I5x5m6X/hCb6Q4Q80WwNuIYEEHVvzG8jmeaRpeDMMZL0xBMt1/f8XUsLlGhDt aG5A== X-Forwarded-Encrypted: i=1; AJvYcCVqd0hkctsP+XnBEjmJN92GthzUpNfooz29nQLXvwZMxMozgBSaotU/zfvPXxWg42wwR2ktioS44EtDvL0=@vger.kernel.org X-Gm-Message-State: AOJu0Yw54Kvg70+kfnQU8JMZArkG4FibF9K/PIiVlH+Xn80NDqZcvIor UTR9ylsIzovjNObVs1n2J38sOJpCgWjiFWJtwBR80tfiRg6srP0dlDfj0g== X-Gm-Gg: ASbGncuyrwtPCGnT2cDNEsU0sZjNKAZBhzW3pzgGbYv8sIbN4I4EajOn7oiLlalDmGs qaodYbN6LofnNSPW7zelLjzaZYamFyJLoR+UrOVi6hbp7i5qAv8OBMWTsb7U6BWfJGhyuQUbhN0 3cM6Us6/m1CCo6RhNnAPhYbpdkXYKnhJ1CGrLYZ9vrpgs9DmmSs+iJ8E4tDYp0w+Z/mE4G7xeKT i7PlCez7TKkxYEfz93r7R1HRh5B8+QjRYVddEDUykvDsflK3YcRtt3I+u8rTgxlKchp/C7I2bFj UsfPJ9Iy3wUyMm3c7Em01yaQjtkauo4WUIpnu+PuIUJr5wxr X-Google-Smtp-Source: AGHT+IFsYfJId669Yi/Z8RdORPq00z/V5HFURF3oX5eKRxEQc/+OrwIJnkALp4TOdHaEOZByd6fzuw== X-Received: by 2002:a17:903:234e:b0:216:46f4:7e3d with SMTP id d9443c01a7336-219e6e9fa68mr75551895ad.15.1734758277123; Fri, 20 Dec 2024 21:17:57 -0800 (PST) Received: from localhost.localdomain (p10213112-ipngn20001marunouchi.tokyo.ocn.ne.jp. [153.220.101.112]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-842b85efb81sm3672181a12.41.2024.12.20.21.17.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2024 21:17:56 -0800 (PST) From: Ryo Takakura To: boqun.feng@gmail.com, bigeasy@linutronix.de Cc: clrkwllms@kernel.org, linux-kernel@vger.kernel.org, linux-rt-devel@lists.linux.dev, longman@redhat.com, mingo@redhat.com, peterz@infradead.org, rostedt@goodmis.org, tglx@linutronix.de, will@kernel.org Subject: Re: [PATCH] lockdep: Fix wait context check on softirq for PREEMPT_RT Date: Sat, 21 Dec 2024 14:17:32 +0900 Message-Id: <20241221051732.218496-1-ryotkkr98@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit On Fri, 20 Dec 2024 11:00:13 -0800, Boqun Feng wrote: >On Sat, Dec 21, 2024 at 01:10:16AM +0900, Ryo Takakura wrote: >> On Thu, 19 Dec 2024 14:27:11 -0800, Boqun Feng wrote: >> >The following is the rough idea: >> > >> >Regards, >> >Boqun >> > >> >----->8 >> >diff --git a/include/linux/bottom_half.h b/include/linux/bottom_half.h >> >index fc53e0ad56d9..7191a753e983 100644 >> >--- a/include/linux/bottom_half.h >> >+++ b/include/linux/bottom_half.h >> >@@ -4,6 +4,7 @@ >> > >> > #include >> > #include >> >+#include >> > >> > #if defined(CONFIG_PREEMPT_RT) || defined(CONFIG_TRACE_IRQFLAGS) >> > extern void __local_bh_disable_ip(unsigned long ip, unsigned int cnt); >> >@@ -15,9 +16,12 @@ static __always_inline void __local_bh_disable_ip(unsigned long ip, unsigned int >> > } >> > #endif >> > >> >+extern struct lockdep_map bh_lock_map; >> >+ >> > static inline void local_bh_disable(void) >> > { >> > __local_bh_disable_ip(_THIS_IP_, SOFTIRQ_DISABLE_OFFSET); >> >+ lock_map_acquire_read(&bh_lock_map); >> > } >> > >> > extern void _local_bh_enable(void); >> >@@ -25,11 +29,13 @@ extern void __local_bh_enable_ip(unsigned long ip, unsigned int cnt); >> > >> > static inline void local_bh_enable_ip(unsigned long ip) >> > { >> >+ lock_map_release(&bh_lock_map); >> > __local_bh_enable_ip(ip, SOFTIRQ_DISABLE_OFFSET); >> > } >> > >> > static inline void local_bh_enable(void) >> > { >> >+ lock_map_release(&bh_lock_map); >> > __local_bh_enable_ip(_THIS_IP_, SOFTIRQ_DISABLE_OFFSET); >> > } >> > >> >diff --git a/kernel/softirq.c b/kernel/softirq.c >> >index 8b41bd13cc3d..17d9bf6e0caf 100644 >> >--- a/kernel/softirq.c >> >+++ b/kernel/softirq.c >> >@@ -1066,3 +1066,13 @@ unsigned int __weak arch_dynirq_lower_bound(unsigned int from) >> > { >> > return from; >> > } >> >+ >> >+static struct lock_class_key bh_lock_key; >> >+struct lockdep_map bh_lock_map = { >> >+ .name = "local_bh", >> >+ .key = &bh_lock_key, >> >+ .wait_type_outer = LD_WAIT_FREE, >> >+ .wait_type_inner = LD_WAIT_CONFIG, /* PREEMPT_RT makes BH preemptible. */ >> >+ .lock_type = LD_LOCK_PERCPU, >> >+}; >> >+EXPORT_SYMBOL_GPL(bh_lock_map); >> >> Self-tests are now all passing. Thanks! >> It looks good to me. > >Good! Do you want to continue working on this based on the above >changes? If so, feel free. Oh yes, for sure!! I'll send the next version based on it with the Sebastian's earlier suggestion included [0]. >Regards, >Boqun Sincerely, Ryo Takakura [0] https://lore.kernel.org/lkml/20241220071554.YAD157bS@linutronix.de/