Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2806053lqt; Tue, 23 Apr 2024 02:02:58 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX9FxKo8ZgimChelWUKiqf+9Dd+bMJtmglcl+MX8hn6S3vJNaXOL6HLL9fO/MmDFsHhbrNBql6MSlRntwSvnkjXRnXGQazSTdNqYNhyaw== X-Google-Smtp-Source: AGHT+IHKgJILCIWMxLyS2Fm0mUhXNdYDNUiJ6ydAoWIcnIQjvz8tbuaorM95aDUCzYO6E0zE/rz3 X-Received: by 2002:a05:622a:1986:b0:437:a1a2:f832 with SMTP id u6-20020a05622a198600b00437a1a2f832mr15630304qtc.11.1713862978235; Tue, 23 Apr 2024 02:02:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713862978; cv=pass; d=google.com; s=arc-20160816; b=wO47oWefpjQVVBmNU575yvQeBQkJwKRAqZr/jicCZjRSJwToSxas5QymwfoC0pJz9P tYOJze2YS22jo0lVzHGmUDsKibc64pPhnz4MhS3K9nTqqZQ1ossEWtm7+8sbjzuwJfVh Wbn/YEOaNFFkjWb9+0ZlpQpVm+F4QtuXMnnsZ6P0fh2iPd5sxsoxAVnXaPm2Kd9AthA5 h2oj1C1XY1sANQODv51Zi0OjeI6Ty+VE/YHfQLEiNWhgw//Fymvsjzz9xedrX8XLblrq j7tbe98QPM3Fh28vNyFiFdMehIBV9cZa5grWU90OH3DdtTCMBakV2TAmeSFL89UeRHuV Hq/w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=BXsOnG+unFLFOLCvhsKIlfWgz2bxnXfsLh7JooJSg6o=; fh=szU5Brvn2qdSWQF8Z1y6OPBut0nKvdbB8wHUwaFBH30=; b=N2G1c6T8gxrCiL9ScnFamRO/IKKTBg+uGh7/LiXAqkIczM1y8mRsdT8jAF0pcqHDT2 rPoxKRdoomKAT6xRaQ3j6c6+KNkcF6GxAqpO6pNa+JwqB6ivyeGq1HIurpNW7eHBDoyy ehj19m5CQTkGZ8zIknrSpKLo4O4o0hsErpgXS4mETQ9Wb+MSLaEhzfqF7+fcmeAu6HW8 pwsu7Al0PG8y4XLvpCnBasepytX2FCIdTQSCN4gUDBbw/CmVIIylmOVAOn8iJMuhCaQQ lyxVT6HSD+BmQk2eLRNhAio2f1rDjGWdrL93IxtpY1UgSvlR8pCQ+HvCf2J+B1bvl3Ry 8Ivg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="V0W+v8/c"; 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-154751-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154751-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d18-20020a05622a05d200b00437c14d4df6si9979167qtb.12.2024.04.23.02.02.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 02:02:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-154751-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="V0W+v8/c"; 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-154751-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154751-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id F07B11C21CD9 for ; Tue, 23 Apr 2024 09:02:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7C31F5647B; Tue, 23 Apr 2024 09:02:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="V0W+v8/c" Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) (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 5A200535DB; Tue, 23 Apr 2024 09:02:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713862970; cv=none; b=REsfvcocK/DF95GvH3DNJ357me03DjFE2shmGkObiOr2B7rAFDqT5JSHVTRygxSeHiIVGLGFUlM/BYtalG2KTKEdqsn7yS25tPAA7OCZs626yID+L7iM7IhqdVjwpJ0Mvq/y/N4uztaLYDLzF7vaqXqHbPqMVInmgwZ9kJSel8g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713862970; c=relaxed/simple; bh=Tf1WAE083iqElmWUjgIU3qiP70v7umc//U+zy4dFFjw=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=JjyZMdUObff9i9O5nd5dQUIXPHv1X2cSeuj12ouCAcb61wOsvwKZ2m/+3bl1R11LNCeLuEk7k4xe9mehPOjAjtJK0AvRyJ9jk1xz8aNwVwoipTj5STSQH3HRhwEN/zV1Xo0dKxqEdgj5OOnzubDTkNJ5JDUpt/DQIemvJg3eJH4= 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=V0W+v8/c; arc=none smtp.client-ip=209.85.216.53 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-pj1-f53.google.com with SMTP id 98e67ed59e1d1-2ae6c8745ffso802684a91.2; Tue, 23 Apr 2024 02:02:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713862968; x=1714467768; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=BXsOnG+unFLFOLCvhsKIlfWgz2bxnXfsLh7JooJSg6o=; b=V0W+v8/cOLxU3jH/RQyn2sz/K7z2CWF4V6XxFi+NOhXaXCYcEk7iERWbWuVoIdzQqA CkySKC/vvqtsVq8MJf9ieU8a1YPvmSp6A91VItbqHvTXst6KQxYdRTdg4JE52O15HJKq zY3Sd54/Xa+jvADHeryDXkJNZDOB5TXGf9mDHSkdWMlegmhkIA00tI/a9jZVeuw1fVrI MBh7R31n2F5oY5TAfFWh7eXDArFrrpN2lxdfEeQ0aI8bAw+00fpOl0f9jr0QC329PX/N 8yYzxu36phfm+F4sUKEUQrUgn+rtbcX53aqXQOjimjF1JBAomx91AxwCudb4fcuz2Fac zYpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713862968; x=1714467768; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BXsOnG+unFLFOLCvhsKIlfWgz2bxnXfsLh7JooJSg6o=; b=daq8BQWQxdPDr0V+jxNTs3ufQ77AnXrwKXjcL6xLg1TYivd//uLEkIUtkZo7ES20/u XPWp7p3VLNnJwVAADba4VG8QoeqAcNs4lcxGbVqvq6d15NUQtecqOdUTl/7Dv0LOlf8G 4pN8ou6oJlGQ+FQngBIGlIusLRKIS+GczHpUl+ns1sZ9y0MHkUa1Q9XdIOd4zgYL4F/u NCH5oir8z3odEGLw27NetMSpSIic4aa45xPbCpddTn+5JxmY4hHMri9CNI36R361yVtl v3iH1CR6fOEke8ZEtBdeWQQVoL/YZNgp8QVIgo+LhVsBgEg9MICFCFuqy7qGmrfYXXch x+RA== X-Forwarded-Encrypted: i=1; AJvYcCV1m1j5kyYDbjyRo8QaeQ87QJrwLEOVZ7B7BelF/hCs8g9V455AHYikxbbwNZ6jekkQlxbR0mAHTIJ7mkr+yLaHCenB X-Gm-Message-State: AOJu0Yw5VzZZYUNYCbFohTTAMIlgsVrKsAW5qHXJJO5p8BGJZdVPpt+a DW2M1VfQAMjKMMcNVuofsZ+gkJFq4Zzc3QW1W35QHzcXQjciq1asnPqXQzo3NV5MK1vadP+MRc9 zqtqSDGAfmU4BKBiI+7/cNC0yugo= X-Received: by 2002:a17:90a:5310:b0:2a2:97ce:24f5 with SMTP id x16-20020a17090a531000b002a297ce24f5mr12622248pjh.35.1713862968530; Tue, 23 Apr 2024 02:02:48 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240328075318.83039-1-jiangshanlai@gmail.com> <20240328075318.83039-10-jiangshanlai@gmail.com> In-Reply-To: From: Lai Jiangshan Date: Tue, 23 Apr 2024 17:02:35 +0800 Message-ID: Subject: Re: [PATCH 09/10] x86/rcu: Add rcu_preempt_count To: Frederic Weisbecker Cc: linux-kernel@vger.kernel.org, rcu@vger.kernel.org, x86@kernel.org, Lai Jiangshan , "Paul E. McKenney" , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Uros Bizjak , Josh Poimboeuf , Nadav Amit , Breno Leitao , Kent Overstreet , Pawan Gupta , Rick Edgecombe , Vegard Nossum , Daniel Sneddon , Nikolay Borisov Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hello, Frederic Thanks for reviewing. On Mon, Apr 22, 2024 at 7:05=E2=80=AFPM Frederic Weisbecker wrote: > > + > > +/* We use the MSB mostly because its available */ > > I think you can safely remove the "We " from all the comments :-) The file is mainly copied from arch/x86/include/asm/preempt.h. I will rephrase sentences in later iterations. > > > +#define RCU_PREEMPT_UNLOCK_SPECIAL_INVERTED 0x80000000 > > How about RCU_PREEMPT_UNLOCK_FASTPATH ? I'm not good at naming. But the MSB really means exactly the opposite of current->rcu_read_unlock_special and I think "UNLOCK_SPECIAL_INVERTED" fits the meaning. > > > + > > +/* > > + * We use the RCU_PREEMPT_UNLOCK_SPECIAL_INVERTED bit as an inverted > > + * current->rcu_read_unlock_special.s such that a decrement hitting 0 > > + * means we can and should call rcu_read_unlock_special(). > > + */ > > +#define RCU_PREEMPT_INIT (0 + RCU_PREEMPT_UNLOCK_SPECIAL_INVERTED) > > Or simply: > > #define RCU_PREEMPT_INIT RCU_PREEMPT_UNLOCK_FASTPATH > > Or you can even remove RCU_PREEMPT_INIT and use RCU_PREEMPT_UNLOCK_FASTPA= TH directly. "0" means the initial rcu_preempt_count is 0 for the initial task. > > + > > +#endif // #ifdef CONFIG_PCPU_RCU_PREEMPT_COUNT > > + > > +#endif /* __ASM_RCU_PREEMPT_H */ > > diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.= c > > index ba8cf5e9ce56..0b204a649442 100644 > > --- a/arch/x86/kernel/cpu/common.c > > +++ b/arch/x86/kernel/cpu/common.c > > @@ -1992,9 +1992,10 @@ static __init int setup_clearcpuid(char *arg) > > __setup("clearcpuid=3D", setup_clearcpuid); > > > > DEFINE_PER_CPU_ALIGNED(struct pcpu_hot, pcpu_hot) =3D { > > - .current_task =3D &init_task, > > - .preempt_count =3D INIT_PREEMPT_COUNT, > > - .top_of_stack =3D TOP_OF_INIT_STACK, > > + .current_task =3D &init_task, > > + .preempt_count =3D INIT_PREEMPT_COUNT, > > + .top_of_stack =3D TOP_OF_INIT_STACK, > > + .rcu_preempt_count =3D RCU_PREEMPT_INIT, > > #ifdef CONFIG_PCPU_RCU_PREEMPT_COUNT ? > > Thanks. Fixed in V2: https://lore.kernel.org/lkml/20240407090558.3395-1-jiangshanlai@gmail.com/ Thanks Lai > > > > }; > > EXPORT_PER_CPU_SYMBOL(pcpu_hot); > > EXPORT_PER_CPU_SYMBOL(const_pcpu_hot); > > -- > > 2.19.1.6.gb485710b > >