Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp160262lqd; Tue, 23 Apr 2024 19:43:28 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWn6nUk5G7r83fSpUF3oU6sQwI3bCPYjuvI2/AdwqRMgZfM+pntKUMaeonabQlgpoazo4wsJBtehLWRi50TCw6PEOjfTPXGVgSk6YPXQg== X-Google-Smtp-Source: AGHT+IHwo1EJlUlqF+xHAwLAaX+Lz1x4zW96VGgjKCjC5xLZMG2htBj3TsKwFpoIYRTKvpTvJBUL X-Received: by 2002:a05:620a:1a95:b0:78f:13d3:693e with SMTP id bl21-20020a05620a1a9500b0078f13d3693emr1758416qkb.5.1713926607710; Tue, 23 Apr 2024 19:43:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713926607; cv=pass; d=google.com; s=arc-20160816; b=O7SFlI6YxRNgHL9cOOVyPySTlAVVt4CFDe0jAaqpsI+CsWbFjp2pfoC1I7UmTjrMqJ NMTMykObvNfP4Dv4aHuLYxXQlN3ExfR5oFJ9QJ8cz3cbP1htWcToat/WOmuuu0R49MNw 6BqazZxAbK5X7j2yvgzn4XTZiC32lckRUsoG5zCfem5OJIFCYdy+scUbtb9FSREkWAFc hz3VWoW1THk5gerZlKrMrPXu1c6pbxILj9mPnoRV6GAWe2+xuxTP2DTDDRK4HJeAgNYp 2blv4PXfwxo9fizgGxkL0Dqo56MHWNMEaP7ICQeeU6dTkCoMc0oS7dFgySn6afcYs7Wo KPMQ== 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=cU+Gx/Z2QqbJeW/dEu6ETFyj9ZvH8Y+qoiAfHayNmPo=; fh=5WmY3wD+I7yupo6sR1C+aGvCsuneGOZBZvskoymctUY=; b=Upqze1NACUk+FKWY5Xa7ARa/o/IJOLlhL5hGsoAyS+lqBi7pJ6KXqUFFgvTLIUevfc 1Pis93PfnwDn5z2S/tngVQ6OhqeM126W8ydehijvdKutjZEaZtosnQ7G4NrMJTXBV0vn xOtMWQA7u3op50nJZhy5P95B+uWxQfIWjat7njqHHkeB62bICo5pDqyEXc30D15zmHJD uH7x34WUIsCZJDlojvog7QSv/jMLK5cFzsGMbNsD2Tm+5/2QUtHddatbwHxeQ3lEQLid eUzlg3klqPI5W/nQNL3U/d5AiDHQ3mhtLbxZBfCOUoRlZOvo4xnEffos6cvHmsu2qool rSbw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Cy0TP06p; 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-156152-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-156152-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 w4-20020a05620a444400b007906cb4c457si8708967qkp.282.2024.04.23.19.43.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 19:43:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-156152-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=Cy0TP06p; 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-156152-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-156152-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 624EF1C221AB for ; Wed, 24 Apr 2024 02:43:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C1DC283CA6; Wed, 24 Apr 2024 02:43:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Cy0TP06p" Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) (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 7EC5A28DDA; Wed, 24 Apr 2024 02:43:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713926599; cv=none; b=jmy2vUoB1wnsoIyjZ8s5xTTF90fw3tV0nC8iBr4CsyTV4ZAQa9xojSpvvNB9HG6H+bsqhqCrQUkJ6nOH+/jV8L25/3m27u0n9NDHC4x4h0TtG9H5cLd1mTxDV2OiE5LC8zo/5dW6USvlgv580ZQGb8DQ0JfLerA9riAK6YNhcrA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713926599; c=relaxed/simple; bh=QZR2aHS7+AW6lzCqR7AodE3BpdZxWXr/i2FA4YX8x1g=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=Jk4BulAqxIfV85+MVr2aDcexRPU+gwCVohDorywVKPgkKbZzNNInqq9zzHP3wCnaRghQWzbAWUhuIzspcppRkwYcYsKRRU9KydOApPSUBrYDDsGfS848KJsqc7ohj6N47rvgrWG4Jl69mZNwf6a2eIrUxZ9GWuscgPe5AlcTUwA= 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=Cy0TP06p; arc=none smtp.client-ip=209.85.210.173 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-pf1-f173.google.com with SMTP id d2e1a72fcca58-6f2f6142d64so2373854b3a.2; Tue, 23 Apr 2024 19:43:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713926598; x=1714531398; 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=cU+Gx/Z2QqbJeW/dEu6ETFyj9ZvH8Y+qoiAfHayNmPo=; b=Cy0TP06pE/XW3Hn5UGhJOZALv+I30bb0ICUFoQd1aCxLbpZULnp8X+9RjJZXFE4wnD C+5rexJJzBcGeAi/EK+3zZUd18eucEtDFCLnVrmCv/6ZT2yi4wdT8dh1iGy5ENtFgyZT kYYNqij0CsTLXhTJ3I4h40mFAATHURI3oR41B9AYzCFFhcpe5Aga8Xnl1z20pcoGsckm cWfoj7PgRUXRqNGT9SWeiw6j7WC+X9+6OZ5e5nAOTfLTAzGEY5vefuyQLp4MkxTkusfP oi/Qs/yPMtUzO+5RWu1gehK3deBMs2bZ4xJqV3MtGHp3dsPro1Q+aTk6fVUbq5pxDl/I lzrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713926598; x=1714531398; 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=cU+Gx/Z2QqbJeW/dEu6ETFyj9ZvH8Y+qoiAfHayNmPo=; b=KUowtbsZOFxt6eBEnOLqgcOWgFUF4Ul2LcC1ELf5s6V+qBaGoeANtoQnsYP2J4Xsum 823T61ohkf3YJnmHJtqIDueww/BQHffLX4DBYBJmuFdRWWSMiuIpNyMuztm3MSBSX/Ta psXYxih4nf7QIgwYfjTPVGfQowYZkEguajAh0B4qE8zMLLUfLfedgADJAT7R054i9wZz ifa8nwpBFW8nhrXv/JKmD1m4KKBa7ggazZ2Wowfc5JkAzUbJQDgxAWLMd7uk/MEX7S8L ByX/rKf3q1PNPTlsPEngVj/uDiiLX8gpdY42tevSoHLpg7NDdFc0IE617hkpCslPwCKS pPSQ== X-Forwarded-Encrypted: i=1; AJvYcCXKhbQTBsbIadPcTRbI/gnPuvGHetUDTw/+pclMYw/qBGeeS/i7wFvOX+PbDmrl6gK/a5v/oV0sk0Ovdy7G6e4EcXyl X-Gm-Message-State: AOJu0YwWDfP7erZXsauoNMNDe1v+hCJPMUJKMiZTh5nAt7t2pH6PT9aH t1ZDngn+cmeuAApm53sNIIsBIjjfWXQuFS3a2IiKHQ2z7++LXuoUBmAenMTAlQWjLlayiJ+Y0TR aDPlkLwyt2tNcRfuDr6PUujHNDEY= X-Received: by 2002:a05:6a20:d412:b0:1a9:eeef:f6b3 with SMTP id il18-20020a056a20d41200b001a9eeeff6b3mr1040126pzb.53.1713926597666; Tue, 23 Apr 2024 19:43:17 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240407090558.3395-1-jiangshanlai@gmail.com> <20240407090558.3395-12-jiangshanlai@gmail.com> In-Reply-To: From: Lai Jiangshan Date: Wed, 24 Apr 2024 10:43:05 +0800 Message-ID: Subject: Re: [PATCH V2 11/11] x86/rcu: Add THUNK rcu_read_unlock_special_thunk To: Joel Fernandes Cc: linux-kernel@vger.kernel.org, rcu@vger.kernel.org, x86@kernel.org, Lai Jiangshan , "Paul E. McKenney" , Peter Zijlstra , Frederic Weisbecker , Andy Lutomirski , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Apr 24, 2024 at 1:26=E2=80=AFAM Joel Fernandes wrote: > > Hello Lai, > > On Sun, Apr 7, 2024 at 5:07=E2=80=AFAM Lai Jiangshan wrote: > > > > From: Lai Jiangshan > > > > Add rcu_read_unlock_special_thunk(), so that the inlined rcu_read_unloc= k() > > doesn't need any code to save the caller-saved registers. > > > > Make rcu_read_unlock() only two instructions in the slow path at the > > caller site. > > > > Cc: "Paul E. McKenney" > > Cc: Peter Zijlstra > > Cc: Frederic Weisbecker > > Signed-off-by: Lai Jiangshan > > --- > > arch/x86/entry/thunk.S | 5 +++++ > > arch/x86/include/asm/rcu_preempt.h | 4 +++- > > 2 files changed, 8 insertions(+), 1 deletion(-) > > > > diff --git a/arch/x86/entry/thunk.S b/arch/x86/entry/thunk.S > > index 119ebdc3d362..10c60369a67c 100644 > > --- a/arch/x86/entry/thunk.S > > +++ b/arch/x86/entry/thunk.S > > @@ -13,3 +13,8 @@ THUNK preempt_schedule_thunk, preempt_schedule > > THUNK preempt_schedule_notrace_thunk, preempt_schedule_notrace > > EXPORT_SYMBOL(preempt_schedule_thunk) > > EXPORT_SYMBOL(preempt_schedule_notrace_thunk) > > + > > +#ifdef CONFIG_PCPU_RCU_PREEMPT_COUNT > > +THUNK rcu_read_unlock_special_thunk, rcu_read_unlock_special > > +EXPORT_SYMBOL_GPL(rcu_read_unlock_special_thunk) > > +#endif /* #ifdef CONFIG_PCPU_RCU_PREEMPT_COUNT */ > > diff --git a/arch/x86/include/asm/rcu_preempt.h b/arch/x86/include/asm/= rcu_preempt.h > > index cb25ebe038a5..acdd73b74c05 100644 > > --- a/arch/x86/include/asm/rcu_preempt.h > > +++ b/arch/x86/include/asm/rcu_preempt.h > > @@ -97,9 +97,11 @@ static __always_inline bool pcpu_rcu_preempt_count_d= ec_and_test(void) > > __percpu_arg([var])); > > } > > > > +extern asmlinkage void rcu_read_unlock_special_thunk(void); > > + > > #define pcpu_rcu_read_unlock_special() = \ > > do { = \ > > - rcu_read_unlock_special(); > > Instead, can you not use __no_caller_saved_registers attribute for > definition of rcu_read_unlock_special() or does that not work for what > you're trying to do here? > I think it is paramount to make it the same as preempt_schedule[_thunk]() when it comes to avoiding the caller-saving-registers-procedures in the unlock paths. I had no idea of 'no_caller_saved_registers' before, so I haven't tried it. And there are limits to 'no_caller_saved_registers' either: https://clang.llvm.org/docs/AttributeReference.html#no-caller-saved-registe= rs: Functions specified with the =E2=80=98no_caller_saved_registers=E2=80=99 at= tribute should only call other functions with the =E2=80=98no_caller_saved_register= s=E2=80=99 attribute, or should be compiled with the =E2=80=98-mgeneral-regs-only=E2= =80=99 flag to avoid saving unused non-GPR registers. https://gcc.gnu.org/onlinedocs/gcc/x86-Function-Attributes.html#index-no_00= 5fcaller_005fsaved_005fregisters-function-attribute_002c-x86: Since GCC doesn=E2=80=99t preserve SSE, MMX nor x87 states, the GCC option -mgeneral-regs-only should be used to compile functions with no_caller_saved_registers attribute. And I don't think =E2=80=98-mgeneral-regs-only=E2=80=99 is being used in th= e kernel for x86. Thanks Lai