Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp578133lqt; Mon, 18 Mar 2024 17:51:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWK0DV4J9ouFRLXJ5kefGFmzkMqCICNIBktnyyhTOe2GcDnqA2RvUhMsYsjvtgew7mNMX1ifgOs7wqdP8jqjaOxG94ZaXAOSR0yvqnREw== X-Google-Smtp-Source: AGHT+IFEM6igdLJaHJpolXsfYQNild2t/wMouicO6HBMq5vpLRBRjhzJRaSHuMmYXTx+5nKMFpY1 X-Received: by 2002:a9d:6189:0:b0:6e4:8fa3:d861 with SMTP id g9-20020a9d6189000000b006e48fa3d861mr13911892otk.34.1710809467624; Mon, 18 Mar 2024 17:51:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710809467; cv=pass; d=google.com; s=arc-20160816; b=kQJVbBE9+wqda2d730xg4KeRe8ZyQXkXKp1K1ifrb2Cm9HqaJE/7ZNccUwW7d1vRj6 BScxPWd5NntruZzGwE5kAV62MeBctUSzMeYVPoK7kshI5WihEw5S5cA6ymp7sfkUrJLk yIQMiy9TsMedObKubUyufILRV/wkbgJUlyqfDeugYCszZuTij75edddvd9EllBbPZ/H2 mzmOJdcr90qLAFDV+vuQm/psvKdnS4ZtH3CdPJ7OxJ1mw08iJXdXyb6sFbdd/qQY/VPb C2bxpzOOL5GtDJGTd3RPwza7jdTcbM+Yo54mVJ90JiA+IqqaG7ixxq69NqJniyId2+nS K7sw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=4d6qJ5WBSXyvd5gKY/blIvNFMP9EdNN0VHAYdQgc4TA=; fh=UfGyiCDCnSBjD0xieps3xKu0OiOfZT5MuPwxXsSlR3w=; b=yv5xrn2fBjKFn/FpLIpbL5l3e5bEAJ03ZA5Qch6oL9aoVCzFYD3kRwLkMCk1YeZPio 592N9VdTxpfu39sAu49BSr81tFJQ4GSRUnsBu3r5KpBLN0Q3620kiZfOPN8VuSemKCYb DMtiwx8Jdw4MujlHhqNG0yDuLmBVqBqvLPgCzvRaMBJIhnDxNXnmvRP8etXQhd4kuF6V zxM/2Rtd2BMDNSS5PligTWbQX2YryxQq49hM3/br1VhHD1HgckwJ/RB2bpe4XUkibp07 s5khyAizWBAbYtCVW3vMM2fqTc/hjZPkmfKpJlLgX5SkzFKiG09DKXgclu6/RtdlRc0d 4RgA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Zs7UEoiR; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-106872-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106872-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. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id q27-20020a63505b000000b005e42b4c5437si7544253pgl.586.2024.03.18.17.51.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 17:51:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-106872-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Zs7UEoiR; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-106872-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106872-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 23651B20F5B for ; Tue, 19 Mar 2024 00:51:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 21AC6816; Tue, 19 Mar 2024 00:50:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Zs7UEoiR" 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 A26EB363 for ; Tue, 19 Mar 2024 00:50:54 +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=1710809456; cv=none; b=laFChGGNCGNjBR65PcCn5qg3/9RS7XM+z07/Eq5dbD1Ql+vBhPLrps89x6gfSB/DLmIfWq1OHM6yNaeMWbUTVlSOW0zMjF9PG2ciVbz4n5NiF5bq9Rm8XqD+28EWuiUCIVlViLUsbnFKvlQecezMciuj8bdfuxpPJ4I/f38G2DI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710809456; c=relaxed/simple; bh=T2xYr/VrtWPcd5kQXh6hL6/nbNnJNAdr7tnOCwTsMho=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=dKIFzKJqv4AzFdCaLzorwPrkdZj5PKFRvrL9UbpNO2UpboVKH6Pgj9kh7O5Px69sEMiuIYIAWHFtJyRisFzNVd1yofeSwAQa8VBA0djVp7YFq+PcaXMG/5flsTl3ms6og3IHmUCwpNc30PNsS8d6mZ7/rVj5/gHTsc+lwnrCT8I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none 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=Zs7UEoiR; arc=none smtp.client-ip=170.10.133.124 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=1710809453; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=4d6qJ5WBSXyvd5gKY/blIvNFMP9EdNN0VHAYdQgc4TA=; b=Zs7UEoiRdEHHorKDcaYFRWihBjZgDFFuS/GV+5YgFmB1TsfXxFYA1dXl1lqiI3KKjkstAH v2KqCIqkxPi65N4j/PjQPLs88kHX0L7qSA1faCxdfGTTcvnNmE+5pvrs4hyCrP5MqWkG3d C13dcnVxOg9GE8dX56HVdhYmklhEkxo= 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-584-23gRmf0LMTy0Iu58eDjqLg-1; Mon, 18 Mar 2024 20:50:49 -0400 X-MC-Unique: 23gRmf0LMTy0Iu58eDjqLg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (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 C870138009F1; Tue, 19 Mar 2024 00:50:48 +0000 (UTC) Received: from llong.com (unknown [10.22.34.80]) by smtp.corp.redhat.com (Postfix) with ESMTP id 34B6C40C6DB5; Tue, 19 Mar 2024 00:50:48 +0000 (UTC) From: Waiman Long To: Peter Zijlstra , Ingo Molnar , Will Deacon , Boqun Feng Cc: linux-kernel@vger.kernel.org, Waiman Long , Ingo Molnar Subject: [PATCH] locking/qspinlock: Always evaluate lockevent* non-event parameter once Date: Mon, 18 Mar 2024 20:50:04 -0400 Message-Id: <20240319005004.1692705-1-longman@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 The inc parameter of lockevent_add() and the cond parameter of lockevent_cond_inc() are only evaluated when CONFIG_LOCK_EVENT_COUNTS is on. That can cause problem if those parameters are expressions with side effect like a "++". Fix this by evaluating those non-event parameters once even if CONFIG_LOCK_EVENT_COUNTS is off. This will also eliminate the need of the __maybe_unused attribute to the wait_early local variable in pv_wait_node(). Suggested-by: Ingo Molnar Signed-off-by: Waiman Long --- kernel/locking/lock_events.h | 4 ++-- kernel/locking/qspinlock_paravirt.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/locking/lock_events.h b/kernel/locking/lock_events.h index a6016b91803d..d2345e9c0190 100644 --- a/kernel/locking/lock_events.h +++ b/kernel/locking/lock_events.h @@ -53,8 +53,8 @@ static inline void __lockevent_add(enum lock_events event, int inc) #else /* CONFIG_LOCK_EVENT_COUNTS */ #define lockevent_inc(ev) -#define lockevent_add(ev, c) -#define lockevent_cond_inc(ev, c) +#define lockevent_add(ev, c) do { (void)(c); } while (0) +#define lockevent_cond_inc(ev, c) do { (void)(c); } while (0) #endif /* CONFIG_LOCK_EVENT_COUNTS */ diff --git a/kernel/locking/qspinlock_paravirt.h b/kernel/locking/qspinlock_paravirt.h index ae2b12f68b90..169950fe1aad 100644 --- a/kernel/locking/qspinlock_paravirt.h +++ b/kernel/locking/qspinlock_paravirt.h @@ -294,7 +294,7 @@ static void pv_wait_node(struct mcs_spinlock *node, struct mcs_spinlock *prev) { struct pv_node *pn = (struct pv_node *)node; struct pv_node *pp = (struct pv_node *)prev; - bool __maybe_unused wait_early; + bool wait_early; int loop; for (;;) { -- 2.39.3