Received: by 2002:ab2:6c55:0:b0:1fd:c486:4f03 with SMTP id v21csp462113lqp; Wed, 12 Jun 2024 07:00:56 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX90GMBJgAAoAoxwN73+7Ic5tlSmFcA7wHGXvy5zZ6dJTopxMxUJe+BpH/xetTB7/YS1TAl13/Yw94gnfyIeJN9GOLW+D0OF3n0nR8e8g== X-Google-Smtp-Source: AGHT+IGHn2U9QoPG47+/XjAeAfJd35ma5g6eLtZBqWPzSt+hR6JZGUUw1yo5I3M2DIR2L0TZpPBH X-Received: by 2002:a17:906:1354:b0:a6f:1473:379c with SMTP id a640c23a62f3a-a6f47d56e26mr116582766b.45.1718200856711; Wed, 12 Jun 2024 07:00:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718200856; cv=pass; d=google.com; s=arc-20160816; b=w0Z5nJmA0USs2iAT2G7AjO+SJ0TPrn2HbahR2/+gLAX1u3Qa4XP7yeEZf+JI7mg/Sq /gzlituFSRryjR1LM0JXGd1UeLDjem8UbPgWspgAY8K82RsYbLIwQnbKmrETg9g0jc8t u2Neb5zap7zRxx+PC4hZRVsQJBIsBDglpxSPkyx8vMhY6RNwn4okNugjyJsPr3tGTums 7XLyB/VzZzw0kX3r4sijLyrJUCCVSzYUd1ClsUm1iHpbwMxgDQF8VnMzJJCdCkX5I6Rv JPj5ZiDCQyqI7cLNV+DFfMYSuxVS3QdkKudLIQqkU7HGoctjeoL/S/NtNmu2HsEsil1w qHVg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=bAU+NAmzf19Ylr7LCKll4QKmndTbiCGZt3MgtjOKBe0=; fh=naf3q25yijQQntonruDpn3dGxETgkL/NSuCsAFw40O8=; b=Gy9iuGIm1Hnntkizn+WGdw4HIql45TdcQ8r17qymdcFJ2RfqfGPXnle206c4oucSBl iBiKF2KEdrpRYJKdCuWPNaW0OW1QxCT3I7gH21aMWh/Pbzr54yEENx92tljde62z1VoZ 5B5Mrit8jke2PbkUjtFnSQk/jN1fLWaf18KWP4IYYDr6ZdTdcI71q4Hb9k7SjinZNYe0 mEBriAHjSYw12DC8ncmiZLTuMs0Sdet+0xeIdwG2Vil0Tgs5bPmjhHLlE+4bPZAYtATo H7HMSgtokiQxpF9deTJOKN48Hwalejs23mbgH1uyDVSqw2JdM9I8IjK6Y+92D3P2gwww FXqg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=mVSuHYBh; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-211626-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-211626-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a6f2ee645cfsi240256666b.359.2024.06.12.07.00.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 07:00:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-211626-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=mVSuHYBh; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-211626-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-211626-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 am.mirrors.kernel.org (Postfix) with ESMTPS id 07C8E1F2244D for ; Wed, 12 Jun 2024 14:00:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 799D517D8B5; Wed, 12 Jun 2024 13:57:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mVSuHYBh" Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (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 288BC17CA1D for ; Wed, 12 Jun 2024 13:57:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718200634; cv=none; b=a/wBTg+hdaRUJesC0HZ969/eEPvY8ts3/7go3r6yaredFMGU0WM28ykD8ailG40E2atG8EU32VGrf+L0DFvIydr3brI9tTniL6qw5Fx1SXGekqizCSzTyaFB6u8BM/LnIokzDQI0xesSX4jKUwAHD9P3q8X73aBYxnW/0E5XAqs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718200634; c=relaxed/simple; bh=i4c48ygCfSU6WdCIpYbNWrvciGw+hJsYn2TXRdffl3o=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=PoT1B5a0kxhB7bTOIkG1amxCIFR4PPkoWX/REzEXs3eNrHGoWtX+oEfT5w04Ro5c3H9vnz9JAe7mEJQkvb2p1aY6RI2NoOAgaSNNwojZC7Kc0f3wNaBvdrJ5dJW1aRvzZX0B1mIN3jLv151cOKdoUMN6RZL4Bxci6CkLehgAN8o= 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=mVSuHYBh; arc=none smtp.client-ip=209.85.128.47 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 Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-4217d808034so34767635e9.3 for ; Wed, 12 Jun 2024 06:57:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718200631; x=1718805431; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=bAU+NAmzf19Ylr7LCKll4QKmndTbiCGZt3MgtjOKBe0=; b=mVSuHYBhMVl+hRkgJGyYBSPAxG0Fezsd26hXl7Bk4jInE9l/ZJMQrewbQ98Njt/ifd OYeV08vnnEqmtHw+8pumBNNLgcDTrhBwUBUsJAwqk942icGa/ou83mIEfkUcwXZROFn8 G45j3u2wpBiX+2T6++4B7CNth2N6gI/0Mox7F7RqXrVKQ9F5HKKRmVBHX7KDT5Hd3Qr8 gQt7sDfpW4fkp3gIuj+DnbTnra4iZ901zPUUb8L/0NHpIoYcI/3MV87rJVsosnRwyJDZ 8E+a3M/ykF6RLZ06i1iHmUB99NHpbBSfw8CHlxRKtVB7loGC9wWAZa0VZudP6C0fvOff G3xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718200631; x=1718805431; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=bAU+NAmzf19Ylr7LCKll4QKmndTbiCGZt3MgtjOKBe0=; b=NflOg8CFT0K3iyTIlSPp6NwGGlSyCOxrPdUpWlBWk5rOj9ch/BcEAYoNXwRDaZRWRM V/pcNlezRpKuyhgZGch4GXMP/HLfp5sI7jumEpkANX7Y6n5tuQvuoqyt0h3kfGxqcPnQ q9/YndRAXVxLTke64hfTCcNS566E8kyjVZDLmPRpjWQ5h8PsW0NqO1ZeSNasqt1VRPQv O5sdugeSV84LxtsBItDN8GwOxFnOdmTxA48epibBab42SgwEsh9fagEY7cmadorTc0B8 dd3PUOhIGG+93DF1J1jEsSW1bBiaSBgiqTqIwv9xll1uTB7B5bcxEv/A87TA5vbrDImH wDcQ== X-Forwarded-Encrypted: i=1; AJvYcCU8T4L4XSY6ICyfH2W3gV+uytsXbbS0foD55FYsHcHDwmNmOUnEIOmfniJrAdM/OKbv7E1hFPf57Wt4gpyrlys0DqYM/IsmZL+tRbQw X-Gm-Message-State: AOJu0Yxi8ia+qhUbfl+JQsCdXCZ2rASVwt3DFDHgCHyZm66M6GvP50x4 GbB++Qt1mNE2YluO+kyDMLmvXQcmKGJnv8D2fSCev4K4LTv7TXKT X-Received: by 2002:a05:600c:3551:b0:421:de31:81 with SMTP id 5b1f17b1804b1-422864af043mr16574585e9.24.1718200631175; Wed, 12 Jun 2024 06:57:11 -0700 (PDT) Received: from [192.168.1.100] ([46.248.82.114]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42286fe75c4sm27831985e9.5.2024.06.12.06.57.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 12 Jun 2024 06:57:10 -0700 (PDT) Message-ID: <0b8b2ea4-e07f-086f-c14b-0c9acb151aa1@gmail.com> Date: Wed, 12 Jun 2024 15:57:09 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [patch 4/4] jump_label: Simplify and clarify static_key_fast_inc_cpus_locked() To: Thomas Gleixner , LKML Cc: Steven Rostedt , Sam Sun , x86@kernel.org, syzkaller-bugs@googlegroups.com, xrivendell7@gmail.com References: <87bk49xf15.ffs@tglx> <20240610124258.109097511@linutronix.de> <20240610124406.548322963@linutronix.de> Content-Language: en-US From: Uros Bizjak In-Reply-To: <20240610124406.548322963@linutronix.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit > Make the code more obvious and add proper comments to avoid future head > scratching. > > Signed-off-by: Thomas Gleixner > --- > kernel/jump_label.c | 20 +++++++++++--------- > 1 file changed, 11 insertions(+), 9 deletions(-) > > --- a/kernel/jump_label.c > +++ b/kernel/jump_label.c > @@ -162,22 +162,24 @@ bool static_key_slow_inc_cpuslocked(stru > if (static_key_fast_inc_not_disabled(key)) > return true; > > - jump_label_lock(); > - if (atomic_read(&key->enabled) == 0) { > - atomic_set(&key->enabled, -1); > + guard(mutex)(&jump_label_mutex); > + /* Try to mark it as 'enabling in progress. */ Missing closing quotation mark above. > + if (!atomic_cmpxchg(&key->enabled, 0, -1)) { This can be: int tmp = 0; if (atomic_try_cmpxchg(&key->enabled, &tmp, -1)) { ... and will result in more optimal code and will IMO also be more readable because it is clear that the code is executed when cmpxchg succeeds. (BTW: The atomic_read()/atomic_set() pair can also be converted to cmpxchg in static_key_enable_cpuslocked().) Uros.