From mboxrd@z Thu Jan 1 00:00:00 1970 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 3F9BA33E36B for ; Wed, 26 Nov 2025 19:19:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764184783; cv=none; b=V7vteK4p8uheSaXQQRXzRV2BEqkeF3CpypM2+84dHjnk3czsgCWK+pvELC5Q0kDN7TKGOKHxoiOYrTCrBe5RZ5OXUdlSEIR3avp7VK/CZlBpo7AkHRIQoDqhr6BXE4tmOcHTDyQePT0sIY8rRnrCIzLQfNGZBle9nI+6RhP706E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764184783; c=relaxed/simple; bh=Rml2Q/C984N7U3HL4SvaVeeSYPDl0+/AXDYPEYEzjmA=; h=From:Message-ID:Date:MIME-Version:Subject:To:Cc:References: In-Reply-To:Content-Type; b=IhUC+prHM2zYpWgXs09t5ysH0CrjTMzqhH4Y9w+KaFFk1jjgVTaA+vPuveh2zrefRjEV1D71EOtPFfbDKLXXdLNT2g8sPQwmyMYWqEPR0Nu1ZJ2dnulOlMJac0adm6IIiZq55Enu/nN7q3ziTlRoVR8cnn/TcIRDCt6vC+zGPzI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=gP/mdz2Z; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=IXhsIPd3; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="gP/mdz2Z"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="IXhsIPd3" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1764184780; 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=rNkgEMhQkNATDZNnLpA8AMHPsnTaYsF1eWOhO1Fhd24=; b=gP/mdz2Z0DeNXSu4CfRLk5QLtCzf2N64ozoARyQEiGkK/lw3Xh4+JkQJyDQydcpsm4FoNP lSdVQ7Ny4YwKUSNJBnihTZ/7n1583PT+lFIf0GRI29OQm7Bsz6S8gpU/WBE1e2+CAyJ87P zQKuE1NWoiK0OsOgwy4NF4df6pqV6S4= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-246-vej3Oj3_MEazgxEDAPxl5Q-1; Wed, 26 Nov 2025 14:19:38 -0500 X-MC-Unique: vej3Oj3_MEazgxEDAPxl5Q-1 X-Mimecast-MFC-AGG-ID: vej3Oj3_MEazgxEDAPxl5Q_1764184778 Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-8b24b811fb1so24952385a.1 for ; Wed, 26 Nov 2025 11:19:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1764184778; x=1764789578; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:user-agent:mime-version:date:message-id:from:from:to :cc:subject:date:message-id:reply-to; bh=rNkgEMhQkNATDZNnLpA8AMHPsnTaYsF1eWOhO1Fhd24=; b=IXhsIPd3PYLOYNh2DLmS3SYJMlONmO7PyFvTKc9bxj2sK5EE/SGg+o23XD4aSNZCMJ E/JCXagvFRQXNpxGmsDOfn+wNPleazTlH3AjoFzFsPusajamIt1M9JR7pFZ+sWESgy8M juhB7FVaoR18FVvJcQwZ+zcA8wISz/xFfXVAKKyf5CupN5qF5xKTxEiNy0S98RtxcdP+ hir+TwIUNwSs++NAKdRiLo3VZkr92IyjR4GYu1aZrzKA0RuiN3ckIFlPM7u0Os3ekSmC m5xSWDZ7Ybl/Dy0T+yaINLu+uR5EKIUj5tMJaWRWJmuVCsgtOYKdt7gFlPLSthEkems6 cQ/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764184778; x=1764789578; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:user-agent:mime-version:date:message-id:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=rNkgEMhQkNATDZNnLpA8AMHPsnTaYsF1eWOhO1Fhd24=; b=TdBFVylMhO3CnDjIKi0Xyn6J2aTtEPTfX5M3djlkMxYQ85ldZiytnBCnoXVCupcG2b gDpEd/XPZTasQUefK1B/m8FKnHx779jGo+/O74KuXJieASIrLu5VGOcBGPiJagjdXayj T/qgCapopSLXxcQMgcmhvFKdm5xo5pR15rWDaI9zEFvo3fRePvxcac8nD1yKXeeAUjBy 49uTPI50drzaRw2yi9pLVJb4KtIsnxIN9mPbTfa04THSQsPkthnHf1RkeZC0weqd1g8M ElKHPzChiGQVuws7tv9LhgpHvUgOermam5iDyZ+jksa2mcTiaVow1knqvnI/rE9VpaSP XgwQ== X-Forwarded-Encrypted: i=1; AJvYcCVxZi6MlA0sjEIHxilF4hrkT9FD6rsv7yNKOcgJ3LttJLFklI9BBM7wziw+0pstkomI5Ozv/wHUNJZ9O+8=@vger.kernel.org X-Gm-Message-State: AOJu0YwQYzo5IO92U3J33Tir3Kcw280q0iHCxe4JQHvh9QST0VzaLe1o bet5g9hNRtx4J9k8r5c1GfCYB6TwAaLuDjqBdoWBnt8VY7g70e+ihPj1LOpJ8RVefDfhGMIyn09 ReXuEYTZbPh5gKRQ7gao6OImRq4hMkw52GysmDsYAZL8CbU6jdFqKzDLdf/G1o/EVIg== X-Gm-Gg: ASbGncvBKhrJ5elwvkFnQi/CSyzGyeAqRsNLm7v+DDoQpb1lcbYnGG2BdpqnAoU+K3+ I3zLayv6UUFUi/kh8jV2Bfjfiro+UCdUNCKq2NpT4riTSZTqxraXs6OE5tUZMr3ZWpFc9EH0+HD 3IXXorQpoLKP/5yW/27ZoU/uolo9MbvxTATPTv+SuFkrtoZP2t4c3ATgc3Irw5DhpF+4tr0zByT Sm/K5zFttN4JACllPKrxiDgiUutgl7nAQC1FdDca4zUK/hYJXs7/EBB6W6ZJ+3d2yqHHZ8o6Imu mFIYOkYLs8ERT3ioOsHOJ3WSOBV2hQXlt4CUPq6L3LcSQE4ysZRtP9T0Yh3RC5iJ42g+RFauuSn tSyo8/BUjRnEqjx+fyYnXIVyKG9fqRON1/0cCwZQU45LdvjN4KdsNTjbH X-Received: by 2002:a05:620a:4413:b0:8a1:e798:bd67 with SMTP id af79cd13be357-8b33b89691bmr2395454985a.0.1764184778194; Wed, 26 Nov 2025 11:19:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IEE1J0gSnfaXytUhxpCrs+skCYiZQ3jlJSWEsYp0hGOjYsDkFAyCWmDJyd+fETrBVio3c/rww== X-Received: by 2002:a05:620a:4413:b0:8a1:e798:bd67 with SMTP id af79cd13be357-8b33b89691bmr2395451885a.0.1764184777727; Wed, 26 Nov 2025 11:19:37 -0800 (PST) Received: from ?IPV6:2601:188:c102:b180:1f8b:71d0:77b1:1f6e? ([2601:188:c102:b180:1f8b:71d0:77b1:1f6e]) by smtp.gmail.com with ESMTPSA id af79cd13be357-8b32953735dsm1433315685a.24.2025.11.26.11.19.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 26 Nov 2025 11:19:37 -0800 (PST) From: Waiman Long X-Google-Original-From: Waiman Long Message-ID: Date: Wed, 26 Nov 2025 14:19:35 -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 v3] locking/local_lock: s/l/__l/ and s/tl/__tl/ to reduce risk of shadowing To: Sebastian Andrzej Siewior , linux-kernel@vger.kernel.org Cc: Peter Zijlstra , Ingo Molnar , Will Deacon , Vincent Mailhol , Vlastimil Babka References: <20251009103900.2Fk8stnM@linutronix.de> Content-Language: en-US In-Reply-To: <20251009103900.2Fk8stnM@linutronix.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 10/9/25 6:39 AM, Sebastian Andrzej Siewior wrote: > From: Vincent Mailhol > > The Linux kernel coding style advises to avoid common variable > names in function-like macros to reduce the risk of collisions. > > Throughout local_lock_internal.h, several macros use the rather common > variable names 'l' and 'tl'. This already resulted in an actual > collision: the __local_lock_acquire() function like macro is currently > shadowing the parameter 'l' of the: > > class_##_name##_t class_##_name##_constructor(_type *l) > > function factory from linux/cleanup.h. > > Rename the variable 'l' to '__l' and the variable 'tl' to '__tl' > throughout the file to fix the current name collision and to prevent > future ones. > > [ bigeasy: Rebase, update all l and tl instances in macros ] > > Signed-off-by: Vincent Mailhol > Signed-off-by: Sebastian Andrzej Siewior > --- > > Looks harmless enough to make everyone happy. > > v2…v3: > - Rebase > > v1…v2: https://lore.kernel.org/all/20250925-local_lock_internal_fix_shadow-v2-1-d3b85ee775a4@kernel.org/ > > - __lock conflicted with an existing definition in lockdep.c. Use > instead __l (and also, to keep things consistent, use __tl instead > of tl for the trylock). > > - Apply the renaming to the entire file and not just to > __local_lock_acquire(). > > - Rewrite the patch description accordingly. > > v1: https://lore.kernel.org/r/20250923-local_lock_internal_fix_shadow-v1-1-14e313c88a46@kernel.org > > include/linux/local_lock_internal.h | 62 ++++++++++++++--------------- > 1 file changed, 31 insertions(+), 31 deletions(-) > > diff --git a/include/linux/local_lock_internal.h b/include/linux/local_lock_internal.h > index a4dc479157b5c..8f82b4eb542f2 100644 > --- a/include/linux/local_lock_internal.h > +++ b/include/linux/local_lock_internal.h > @@ -99,18 +99,18 @@ do { \ > > #define __local_lock_acquire(lock) \ > do { \ > - local_trylock_t *tl; \ > - local_lock_t *l; \ > + local_trylock_t *__tl; \ > + local_lock_t *__l; \ > \ > - l = (local_lock_t *)(lock); \ > - tl = (local_trylock_t *)l; \ > + __l = (local_lock_t *)(lock); \ > + __tl = (local_trylock_t *)__l; \ > _Generic((lock), \ > local_trylock_t *: ({ \ > - lockdep_assert(tl->acquired == 0); \ > - WRITE_ONCE(tl->acquired, 1); \ > + lockdep_assert(__tl->acquired == 0); \ > + WRITE_ONCE(__tl->acquired, 1); \ > }), \ > local_lock_t *: (void)0); \ > - local_lock_acquire(l); \ > + local_lock_acquire(__l); \ > } while (0) > > #define __local_lock(lock) \ > @@ -133,36 +133,36 @@ do { \ > > #define __local_trylock(lock) \ > ({ \ > - local_trylock_t *tl; \ > + local_trylock_t *__tl; \ > \ > preempt_disable(); \ > - tl = (lock); \ > - if (READ_ONCE(tl->acquired)) { \ > + __tl = (lock); \ > + if (READ_ONCE(__tl->acquired)) { \ > preempt_enable(); \ > - tl = NULL; \ > + __tl = NULL; \ > } else { \ > - WRITE_ONCE(tl->acquired, 1); \ > + WRITE_ONCE(__tl->acquired, 1); \ > local_trylock_acquire( \ > - (local_lock_t *)tl); \ > + (local_lock_t *)__tl); \ > } \ > - !!tl; \ > + !!__tl; \ > }) > > #define __local_trylock_irqsave(lock, flags) \ > ({ \ > - local_trylock_t *tl; \ > + local_trylock_t *__tl; \ > \ > local_irq_save(flags); \ > - tl = (lock); \ > - if (READ_ONCE(tl->acquired)) { \ > + __tl = (lock); \ > + if (READ_ONCE(__tl->acquired)) { \ > local_irq_restore(flags); \ > - tl = NULL; \ > + __tl = NULL; \ > } else { \ > - WRITE_ONCE(tl->acquired, 1); \ > + WRITE_ONCE(__tl->acquired, 1); \ > local_trylock_acquire( \ > - (local_lock_t *)tl); \ > + (local_lock_t *)__tl); \ > } \ > - !!tl; \ > + !!__tl; \ > }) > > /* preemption or migration must be disabled before calling __local_lock_is_locked */ > @@ -170,16 +170,16 @@ do { \ > > #define __local_lock_release(lock) \ > do { \ > - local_trylock_t *tl; \ > - local_lock_t *l; \ > + local_trylock_t *__tl; \ > + local_lock_t *__l; \ > \ > - l = (local_lock_t *)(lock); \ > - tl = (local_trylock_t *)l; \ > - local_lock_release(l); \ > + __l = (local_lock_t *)(lock); \ > + __tl = (local_trylock_t *)__l; \ > + local_lock_release(__l); \ > _Generic((lock), \ > local_trylock_t *: ({ \ > - lockdep_assert(tl->acquired == 1); \ > - WRITE_ONCE(tl->acquired, 0); \ > + lockdep_assert(__tl->acquired == 1); \ > + WRITE_ONCE(__tl->acquired, 0); \ > }), \ > local_lock_t *: (void)0); \ > } while (0) > @@ -223,12 +223,12 @@ typedef spinlock_t local_trylock_t; > #define INIT_LOCAL_LOCK(lockname) __LOCAL_SPIN_LOCK_UNLOCKED((lockname)) > #define INIT_LOCAL_TRYLOCK(lockname) __LOCAL_SPIN_LOCK_UNLOCKED((lockname)) > > -#define __local_lock_init(l) \ > +#define __local_lock_init(__l) \ > do { \ > - local_spin_lock_init((l)); \ > + local_spin_lock_init((__l)); \ > } while (0) > > -#define __local_trylock_init(l) __local_lock_init(l) > +#define __local_trylock_init(__l) __local_lock_init(__l) > > #define __local_lock(__lock) \ > do { \ Make sense. Acked-by: Waiman Long