linux-rt-devel.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	linux-rt-devel@lists.linux.dev,
	Thomas Gleixner <tglx@linutronix.de>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>, Will Deacon <will@kernel.org>,
	Waiman Long <longman@redhat.com>,
	Boqun Feng <boqun.feng@gmail.com>
Subject: Re: [PATCH 1/2] local_lock: Move this_cpu_ptr() notation from internal to main header.
Date: Sun, 18 May 2025 11:42:02 +0200	[thread overview]
Message-ID: <20250518094202.cVLMUcBN@linutronix.de> (raw)
In-Reply-To: <CAADnVQLz=+FN8-B_QmmT-eg7PB7jGHiah=9B-s5WpfmQbAF3eg@mail.gmail.com>

On 2025-05-14 17:46:43 [-0700], Alexei Starovoitov wrote:
> 
> Are you sure this is correct?

I hope so.

> Have you tested with gcc 14 or higher?

gcc version 14.2.0 (Debian 14.2.0-19) 

> It looks to me that moving this_cpu_ptr() up one level should
> still preserve __seg_gs modifier.

If I compile mm/memcontrol.o as-is I get no warnings. Adding

diff --git a/include/linux/local_lock_internal.h b/include/linux/local_lock_internal.h
index b4d7b24882835..112324bc362c1 100644
--- a/include/linux/local_lock_internal.h
+++ b/include/linux/local_lock_internal.h
@@ -102,11 +102,11 @@ do {								\
 		l = (local_lock_t *)(lock);			\
 		tl = (local_trylock_t *)l;				\
 		_Generic((lock),					\
-			local_trylock_t *: ({			\
+			__percpu local_trylock_t *: ({			\
 				lockdep_assert(tl->acquired == 0);	\
 				WRITE_ONCE(tl->acquired, 1);		\
 			}),						\
-			local_lock_t *: (void)0);		\
+			__percpu local_lock_t *: (void)0);		\
 		local_lock_acquire(l);					\
 	} while (0)
 
@@ -171,11 +171,11 @@ do {								\
 		tl = (local_trylock_t *)l;				\
 		local_lock_release(l);					\
 		_Generic((lock),					\
-			local_trylock_t *: ({			\
+			__percpu local_trylock_t *: ({			\
 				lockdep_assert(tl->acquired == 1);	\
 				WRITE_ONCE(tl->acquired, 0);		\
 			}),						\
-			local_lock_t *: (void)0);		\
+			__percpu local_lock_t *: (void)0);		\
 	} while (0)
 
 #define __local_unlock(lock)					\

which I assume is what you mean, results in

| In file included from include/linux/preempt.h:11,
|                  from include/linux/spinlock.h:56,
|                  from include/linux/swait.h:7,
|                  from include/linux/completion.h:12,
|                  from include/linux/crypto.h:15,
|                  from arch/x86/kernel/asm-offsets.c:9:
| include/linux/local_lock.h: In function ‘class_local_lock_destructor’:
| include/linux/local_lock_internal.h:173:26: error: ‘_Generic’ selector of type ‘struct <anonymous> *’ is not compatible with any association
|   173 |                 _Generic((lock),                                        \
|       |                          ^
| include/linux/cleanup.h:246:18: note: in definition of macro ‘DEFINE_CLASS’
|   246 | { _type _T = *p; _exit; }                                               \
|       |                  ^~~~~
| include/linux/local_lock.h:82:1: note: in expansion of macro ‘DEFINE_GUARD’
|    82 | DEFINE_GUARD(local_lock, local_lock_t __percpu*,
|       | ^~~~~~~~~~~~
| include/linux/local_lock_internal.h:183:17: note: in expansion of macro ‘__local_lock_release’
|   183 |                 __local_lock_release(lock);                     \
|       |                 ^~~~~~~~~~~~~~~~~~~~
| include/linux/local_lock.h:37:41: note: in expansion of macro ‘__local_unlock’
|    37 | #define local_unlock(lock)              __local_unlock(this_cpu_ptr(lock))
|       |                                         ^~~~~~~~~~~~~~
| include/linux/local_lock.h:84:14: note: in expansion of macro ‘local_unlock’
|    84 |              local_unlock(_T))
|       |              ^~~~~~~~~~~~
| include/linux/local_lock.h: In function ‘class_local_lock_constructor’:
| include/linux/local_lock_internal.h:104:26: error: ‘_Generic’ selector of type ‘struct <anonymous> *’ is not compatible with any association
|   104 |                 _Generic((lock),                                        \
|       |                          ^
| include/linux/cleanup.h:248:13: note: in definition of macro ‘DEFINE_CLASS’
|   248 | { _type t = _init; return t; }
|       |             ^~~~~
| include/linux/local_lock.h:82:1: note: in expansion of macro ‘DEFINE_GUARD’
|    82 | DEFINE_GUARD(local_lock, local_lock_t __percpu*,
|       | ^~~~~~~~~~~~
| include/linux/local_lock_internal.h:116:17: note: in expansion of macro ‘__local_lock_acquire’
|   116 |                 __local_lock_acquire(lock);                     \
|       |                 ^~~~~~~~~~~~~~~~~~~~
| include/linux/local_lock.h:16:41: note: in expansion of macro ‘__local_lock’
|    16 | #define local_lock(lock)                __local_lock(this_cpu_ptr(lock))
…

Sebastian

  reply	other threads:[~2025-05-18  9:42 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-14 11:07 [PATCH 0/2] local_lock: Move this_cpu_ptr() notation from internal to main header Sebastian Andrzej Siewior
2025-05-14 11:07 ` [PATCH 1/2] " Sebastian Andrzej Siewior
2025-05-15  0:46   ` Alexei Starovoitov
2025-05-18  9:42     ` Sebastian Andrzej Siewior [this message]
2025-05-14 11:07 ` [PATCH 2/2] cryptd: Use nested-BH locking for cryptd_cpu_queue Sebastian Andrzej Siewior
2025-05-14 11:09   ` Sebastian Andrzej Siewior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250518094202.cVLMUcBN@linutronix.de \
    --to=bigeasy@linutronix.de \
    --cc=alexei.starovoitov@gmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-devel@lists.linux.dev \
    --cc=longman@redhat.com \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).