From patchwork Tue Dec 12 17:26:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neeraj upadhyay X-Patchwork-Id: 13489708 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FPtY/QHU" Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 823E68E; Tue, 12 Dec 2023 09:27:20 -0800 (PST) Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1d06d42a58aso54601695ad.0; Tue, 12 Dec 2023 09:27:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702402039; x=1703006839; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KVgafbUy1yoVoGBH+PlApmsusqaMuafzZh+z/PK2PwE=; b=FPtY/QHUUehnBEd8W7/PYOvYwbxs1AO/MWVKbZjALE5XbeLpTl1Zi+kdsnp+Z454WS NE1ld8+Vha8xulthfQ4Mq7KI/iNEn9GnFRgc3VaHO8GJpmlt20EyAsgrEwJeqmCASAG5 sZEgxLswUt0hQ5iLq8z/BMPFGlGlR/g2JDqJ0Z4PdwWSPO3nJW4SOGlW7bQwW7tTKODU ehuP82rhIcCzJDDUL1HgH5ms0E6Neb678+IKAGl03W4lSYRAMj7s7dUb7hyQbeeO+jCj rS+CideBrZSdcpXKL+eCP916v0e+wYTW/n2914lKd3qyPGeV9hOTTjujqI7Gmk9KW3gE 8Nbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702402039; x=1703006839; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KVgafbUy1yoVoGBH+PlApmsusqaMuafzZh+z/PK2PwE=; b=KxXp64J5xPgGsT8Yytv2opBbld8hTVpPY36EvlYwTWXN56SEiMVR1BfKCH9UxwJigt 01CqH/dn8GwBbqi4teEEPcZKSughhOdZXaURLfaq8Wbu2MTQbtMRxc99rT49ixo7djRO J5n9QpQmTZRMMsHpzsMUnz1i42S0LieXD0AszalSRBloCGcNdFn8YQ2nli2Gtnp7WxLD lTlNdhRbCldzfV6bwGTsjWD61YHQZEBO6q471w7n8JPcqcOv2QDqS57gDHDI4ALgI7v4 YbgSvG3AaPvf3NwXpiHEAJVrm6M5jUUirnKClAOnFtNH1yRJKazk1k1Gp4gr+ccgAyOz YR/w== X-Gm-Message-State: AOJu0YzI0sqhVSnuo3aZ+JCbV0TP98EE7KaJrQuz4RcTzroLJdiaj+EF 8gfJa9UMN5LOldQPpKQ9k8cL0Y+3uG3YuOgo X-Google-Smtp-Source: AGHT+IGPGjbUX+hHxAoRGLSoyjCh5c5hQrmYfnnNqkcEghF336vceXn7APzJBUI2pAvCWoMY34jYMg== X-Received: by 2002:a17:902:ea0e:b0:1d0:cec3:4568 with SMTP id s14-20020a170902ea0e00b001d0cec34568mr7842357plg.54.1702402039260; Tue, 12 Dec 2023 09:27:19 -0800 (PST) Received: from localhost.localdomain ([101.0.63.152]) by smtp.gmail.com with ESMTPSA id b18-20020a170902d51200b001cf511aa772sm8863170plg.145.2023.12.12.09.27.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 09:27:18 -0800 (PST) From: "Neeraj Upadhyay (AMD)" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, paulmck@kernel.org, Neeraj.Upadhyay@amd.com, Charles Han , Neeraj Upadhyay Subject: [PATCH rcu 1/5] Documentation: RCU: Remove repeated word in comments Date: Tue, 12 Dec 2023 22:56:49 +0530 Message-Id: <20231212172653.11485-1-neeraj.iitr10@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231212172343.GA11383@neeraj.linux> References: <20231212172343.GA11383@neeraj.linux> Precedence: bulk X-Mailing-List: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Charles Han Remove the repeated word "of" in comments. Signed-off-by: Charles Han Signed-off-by: Paul E. McKenney Signed-off-by: Neeraj Upadhyay (AMD) --- Documentation/RCU/torture.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/RCU/torture.rst b/Documentation/RCU/torture.rst index b3b6dfa85248..49e7beea6ae1 100644 --- a/Documentation/RCU/torture.rst +++ b/Documentation/RCU/torture.rst @@ -185,7 +185,7 @@ argument. Not all changes require that all scenarios be run. For example, a change to Tree SRCU might run only the SRCU-N and SRCU-P scenarios using the --configs argument to kvm.sh as follows: "--configs 'SRCU-N SRCU-P'". -Large systems can run multiple copies of of the full set of scenarios, +Large systems can run multiple copies of the full set of scenarios, for example, a system with 448 hardware threads can run five instances of the full set concurrently. To make this happen:: From patchwork Tue Dec 12 17:26:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neeraj upadhyay X-Patchwork-Id: 13489709 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LuWmVF1Z" Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F10B9F; Tue, 12 Dec 2023 09:27:32 -0800 (PST) Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1d336a8e27fso4977145ad.2; Tue, 12 Dec 2023 09:27:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702402051; x=1703006851; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pAz4ODF6UTOOaFnSikdhsc6gxYzI76HyzuBIuPlXUuY=; b=LuWmVF1ZlfxEbcA1Ip24YNUouNfBptWYlMZNVsQhwm7YHjXeGtchzbeTECj0rCdMoR vMsNyi9e3Q1fa8EBAczvv6Q8JVMrd3nW/2WyYAvquthY/hDrEoGYzU+/7aT+S5PIj8qG cSeWTH/alO9zpBe/7SJutEZEeE2sdsff18aReYHoxl/zceRDnGCIh/aqsxKzC/lWlLhr k4tcGvZLHuyx6OfN/f+9xNWKCj+EQiHwaRZZNgZTY87dw+lDCBsCmuNWL/Y1f103DGXa WCD9+PbUvdazr5HJTMYXZHQkYUcAfwquYjF10J9yigj05RWKNlnMhi5yZOk1IfO68agY JWkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702402051; x=1703006851; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pAz4ODF6UTOOaFnSikdhsc6gxYzI76HyzuBIuPlXUuY=; b=ADnuixeS9hwA8Y80WBv097/9s5CXM/8rvjDZ+wOhdIXlw/7lw2DgTaAMOH09iCV/wX J87KksDYhTHw25dvuzI+iusbNMfHF8TulyIjBNEFoO6SAu6bfgsmQDxKAlDWPpONuj5E TrMun1I+gWmVNVdhzOjUVqn5VkknMF9rT0uH+KEcd4vWYG3BQy3vnGxgfMNnUsAvG0gK S/4WKdwvOv43AW/riqNm1xOmXxCPHjtVyIxta0rCfhXHJ7NDlThrkQOJV9RlUdE4wKNG j3et1ia1kzmoxGPFNRPI7gbxJNUWHkPIjJeFAxGSTtiveslyvLSJUBBwJrl4V6QyfPY+ ZiUA== X-Gm-Message-State: AOJu0YwrqdK+++EYBF1TY3AhC08dXDDkpfKN+x6pYjQfh0qsI/5KGr6v ZylWimfNo4GIkIgTxnSXF0edZRzpXGA/b56t X-Google-Smtp-Source: AGHT+IH/2CMXFQGUUfM9milW99DYW0Jq/Kybrqf9ebV6G3X/s1DcqvIZTHxAQsGIL5vUlYFD4tE+OA== X-Received: by 2002:a17:902:c943:b0:1d0:acd4:92ee with SMTP id i3-20020a170902c94300b001d0acd492eemr3860613pla.43.1702402051026; Tue, 12 Dec 2023 09:27:31 -0800 (PST) Received: from localhost.localdomain ([101.0.63.152]) by smtp.gmail.com with ESMTPSA id b18-20020a170902d51200b001cf511aa772sm8863170plg.145.2023.12.12.09.27.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 09:27:30 -0800 (PST) From: "Neeraj Upadhyay (AMD)" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, paulmck@kernel.org, Neeraj.Upadhyay@amd.com, Philipp Stanner , Neeraj Upadhyay Subject: [PATCH rcu 2/5] rculist.h: docs: Fix wrong function summary Date: Tue, 12 Dec 2023 22:56:50 +0530 Message-Id: <20231212172653.11485-2-neeraj.iitr10@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231212172343.GA11383@neeraj.linux> References: <20231212172343.GA11383@neeraj.linux> Precedence: bulk X-Mailing-List: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Philipp Stanner The brief summary in the docstring for function list_next_or_null_rcu() states that the function is supposed to provide the "first" member of a list, whereas in truth it returns the next member. Change the docstring so it describes what the function actually does. Signed-off-by: Philipp Stanner Signed-off-by: Paul E. McKenney Signed-off-by: Neeraj Upadhyay (AMD) --- include/linux/rculist.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/rculist.h b/include/linux/rculist.h index d29740be4833..3dc1e58865f7 100644 --- a/include/linux/rculist.h +++ b/include/linux/rculist.h @@ -355,7 +355,7 @@ static inline void list_splice_tail_init_rcu(struct list_head *list, }) /** - * list_next_or_null_rcu - get the first element from a list + * list_next_or_null_rcu - get the next element from a list * @head: the head for the list. * @ptr: the list head to take the next element from. * @type: the type of the struct this is embedded in. From patchwork Tue Dec 12 17:26:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neeraj upadhyay X-Patchwork-Id: 13489710 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Y0KyrIu2" Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 351779F; Tue, 12 Dec 2023 09:27:37 -0800 (PST) Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1d0c94397c0so34705025ad.2; Tue, 12 Dec 2023 09:27:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702402056; x=1703006856; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=oy94NtGvJMR2W5ZqUeOhkG8IQpCje9YrX1YzEkIZAAM=; b=Y0KyrIu26IiCXkXXXMv8JuE9bV146lAYbphRQWJPzj+Pukgp5a1w22HlOTpjWF4J4Z JA6HtNihTmyG1emfB6BkNiNN36MNnX1C0VY+I9l/rU5Ev1ZZ2cw+kQ418Bj4US5TcNRD Bvg2LPZ6SyIePc3qBI3lKN7X1zYZSumcP4zGexJUDM8fFPj0bs/3+VQ25dMAGOeq/ATG 0RqadBiUjFGLTX4ZkGGMFf9Y40JYaae/bgMoltkVKDd8xRW5H6jRhh0QG7dhMfJofZu/ i1C1f3r+Hi7dhHw4cOMLZENFMTzhthMKmyg0GgjN7SQfHpQO4n96Zlph2ZMRCH6AaCMb /JxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702402056; x=1703006856; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oy94NtGvJMR2W5ZqUeOhkG8IQpCje9YrX1YzEkIZAAM=; b=S2q0LiQj3J5g+Xdl9OYR0lsn9IOhMBbXAdsJNng+NDrMX/jcxemxQzr6oNx/7A+dVY iod0ozAJG6xh3ZD4N/0NiJ1OwLfoiwKXsBdQzsGYxwJ73C4P4aOLcQ3v7DQNsBWiGGh/ 2C8s14DS73Gbh92fjNy32gVnPt/H0MOIqnERKzuNPbpP0Fr/tLVxRtsjjjDfMYHDdvJg 088V1M0tzMsX3FhzMPi9NUSVmoHBCZhsu90uRdiTGFgyDBCkc+JDu+Ov7awb29J3Tj1w /w1vuQvwDx5isy4xI+Dr/GkUrEQFc8fi/EVKJHjzpMDZ4dmcojRlc8PREx5uqcg2/0HB kWTA== X-Gm-Message-State: AOJu0YygTsKzYc/P+r+2HvLayJGyEmY3JjKnuwdnMlXgDa0v01bpopNd i/sIpypGZmoaO2vTuK+Ypw6o3dbOyAtHgTuN X-Google-Smtp-Source: AGHT+IGALwTtO0ngxAfBMYyJcAkEuG1b3rOwoiD6koZuZtCc8fHOHJYlSLgdrvsE41zp1hguGM8P8w== X-Received: by 2002:a17:902:e789:b0:1d0:b8dc:ec90 with SMTP id cp9-20020a170902e78900b001d0b8dcec90mr3964074plb.64.1702402055592; Tue, 12 Dec 2023 09:27:35 -0800 (PST) Received: from localhost.localdomain ([101.0.63.152]) by smtp.gmail.com with ESMTPSA id b18-20020a170902d51200b001cf511aa772sm8863170plg.145.2023.12.12.09.27.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 09:27:35 -0800 (PST) From: "Neeraj Upadhyay (AMD)" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, paulmck@kernel.org, Neeraj.Upadhyay@amd.com, Mathieu Desnoyers , Neeraj Upadhyay Subject: [PATCH rcu 3/5] doc: Clarify RCU Tasks reader/updater checklist Date: Tue, 12 Dec 2023 22:56:51 +0530 Message-Id: <20231212172653.11485-3-neeraj.iitr10@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231212172343.GA11383@neeraj.linux> References: <20231212172343.GA11383@neeraj.linux> Precedence: bulk X-Mailing-List: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "Paul E. McKenney" Currently, the reader/updater compatibility rules for the three RCU Tasks flavors are squished together in a single paragraph, which can result in confusion. This commit therefore splits them out into a list, clearly showing the distinction between these flavors. Link: https://lore.kernel.org/all/20231002211936.5948253e@gandalf.local.home/ Reported-by: Steven Rostedt Signed-off-by: Paul E. McKenney Reviewed-by: Mathieu Desnoyers Reviewed-by: Steven Rostedt (Google) Signed-off-by: Neeraj Upadhyay (AMD) --- Documentation/RCU/checklist.rst | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/Documentation/RCU/checklist.rst b/Documentation/RCU/checklist.rst index bd3c58c44bef..c432899aff22 100644 --- a/Documentation/RCU/checklist.rst +++ b/Documentation/RCU/checklist.rst @@ -241,15 +241,22 @@ over a rather long period of time, but improvements are always welcome! srcu_struct. The rules for the expedited RCU grace-period-wait primitives are the same as for their non-expedited counterparts. - If the updater uses call_rcu_tasks() or synchronize_rcu_tasks(), - then the readers must refrain from executing voluntary - context switches, that is, from blocking. If the updater uses - call_rcu_tasks_trace() or synchronize_rcu_tasks_trace(), then - the corresponding readers must use rcu_read_lock_trace() and - rcu_read_unlock_trace(). If an updater uses call_rcu_tasks_rude() - or synchronize_rcu_tasks_rude(), then the corresponding readers - must use anything that disables preemption, for example, - preempt_disable() and preempt_enable(). + Similarly, it is necssary to correctly use the RCU Tasks flavors: + + a. If the updater uses synchronize_rcu_tasks() or + call_rcu_tasks(), then the readers must refrain from + executing voluntary context switches, that is, from + blocking. + + b. If the updater uses call_rcu_tasks_trace() + or synchronize_rcu_tasks_trace(), then the + corresponding readers must use rcu_read_lock_trace() + and rcu_read_unlock_trace(). + + c. If an updater uses call_rcu_tasks_rude() or + synchronize_rcu_tasks_rude(), then the corresponding + readers must use anything that disables preemption, + for example, preempt_disable() and preempt_enable(). Mixing things up will result in confusion and broken kernels, and has even resulted in an exploitable security issue. Therefore, From patchwork Tue Dec 12 17:26:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neeraj upadhyay X-Patchwork-Id: 13489711 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hwjbdDt1" Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8954A1; Tue, 12 Dec 2023 09:27:41 -0800 (PST) Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1d32c5ce32eso13394155ad.0; Tue, 12 Dec 2023 09:27:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702402061; x=1703006861; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=cn4VwDYjNkD85ZVWjPPzSfZ086ShlP6kMAwWhA80/9Q=; b=hwjbdDt1O/UJWL+mAlcCuRSporlwunbYdqIYobRXPTbY+CsuZJ0nu/rqZ5H6XZK1Yx B2tANzCcDgFXTcNPnS+Mp9bU/7NuT4VABqL/KwfVkxbPGefRwGT70u4AhOfKzkegycO8 5FEpVCrDSsGXwVTXPzvEwqdpVhfJWHCuMyqjlUKQY+W9ItQYAuAuW6zlbojkTVs2sKss a3v85Y4K8kffoFAYxY0mEyLCyEI70AO4E8BMRe7ATSVMFBf3Xq0kCT9n7VvXVEs31MfY cIsLkDsT0bn+sBvDGXTYkfxjF0WFc4eEoVsMvELQUjV7QcDSrtuyGB1u1Sdm6FV7V+jx KFbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702402061; x=1703006861; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cn4VwDYjNkD85ZVWjPPzSfZ086ShlP6kMAwWhA80/9Q=; b=POSfohYV2tdmzjTx4B+nmWfRiMXmbRWTvjJsylFVOEhnR/PH55rs8z0ubqOqrK9Iiy OO92p5iYku8CvBUb1HoTv17Ch5pmE51gy77QBrPa/wu10rw+eTw68r9pTdXsGiY8ttVJ 0IrburKnsaPi+1CBYmG6wsNrUTSDq1O8NjYF/IZeyQdVX3GZoK/G+KMm7ej65juHVQny ic/OvsD5jJLMvtxMz+HvJa8Z/osWXaaB8LXUVUXcLV8W5xDpB+elAOAwg3MybKAPLhb6 q6C/UUcxz/HNJlLJHNz7qgWeATtr7L+Hx/rgCZ5CMYC033z58kxQR3dTtSTm3Lyiu3OJ QBjQ== X-Gm-Message-State: AOJu0Yx9JqWxhRHpXim3wAwuQeiLyILI0sR95/O3JDjQbJ/jqe263GTj F2MBnb2O3/Tj780HDsV7nilbI7zyxN8k0LlB X-Google-Smtp-Source: AGHT+IFZs+JB5hYaYxpCKaDVO+hzH3H9IIfhFRwa61QlJh+ZDnX9OI3Q1+wWJTWNAzF1pn8LBJozPg== X-Received: by 2002:a17:902:7202:b0:1d0:5fd7:867c with SMTP id ba2-20020a170902720200b001d05fd7867cmr8234831plb.4.1702402060726; Tue, 12 Dec 2023 09:27:40 -0800 (PST) Received: from localhost.localdomain ([101.0.63.152]) by smtp.gmail.com with ESMTPSA id b18-20020a170902d51200b001cf511aa772sm8863170plg.145.2023.12.12.09.27.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 09:27:40 -0800 (PST) From: "Neeraj Upadhyay (AMD)" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, paulmck@kernel.org, Neeraj.Upadhyay@amd.com, Jonas Oberhauser , Akira Yokosawa , Neeraj Upadhyay Subject: [PATCH rcu 4/5] doc: Mention address and data dependencies in rcu_dereference.rst Date: Tue, 12 Dec 2023 22:56:52 +0530 Message-Id: <20231212172653.11485-4-neeraj.iitr10@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231212172343.GA11383@neeraj.linux> References: <20231212172343.GA11383@neeraj.linux> Precedence: bulk X-Mailing-List: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "Paul E. McKenney" This commit adds discussion of address and data dependencies to the beginning of rcu_dereference.rst in order to enable readers to more easily make the connection to the Linux-kernel memory model in general and to memory-barriers.txt in particular. Reported-by: Jonas Oberhauser Reported-by: Akira Yokosawa Signed-off-by: Paul E. McKenney Signed-off-by: Neeraj Upadhyay (AMD) --- Documentation/RCU/rcu_dereference.rst | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/Documentation/RCU/rcu_dereference.rst b/Documentation/RCU/rcu_dereference.rst index 3b739f6243c8..659d5913784d 100644 --- a/Documentation/RCU/rcu_dereference.rst +++ b/Documentation/RCU/rcu_dereference.rst @@ -3,13 +3,26 @@ PROPER CARE AND FEEDING OF RETURN VALUES FROM rcu_dereference() =============================================================== -Most of the time, you can use values from rcu_dereference() or one of -the similar primitives without worries. Dereferencing (prefix "*"), -field selection ("->"), assignment ("="), address-of ("&"), addition and -subtraction of constants, and casts all work quite naturally and safely. - -It is nevertheless possible to get into trouble with other operations. -Follow these rules to keep your RCU code working properly: +Proper care and feeding of address and data dependencies is critically +important to correct use of things like RCU. To this end, the pointers +returned from the rcu_dereference() family of primitives carry address and +data dependencies. These dependencies extend from the rcu_dereference() +macro's load of the pointer to the later use of that pointer to compute +either the address of a later memory access (representing an address +dependency) or the value written by a later memory access (representing +a data dependency). + +Most of the time, these dependencies are preserved, permitting you to +freely use values from rcu_dereference(). For example, dereferencing +(prefix "*"), field selection ("->"), assignment ("="), address-of +("&"), casts, and addition or subtraction of constants all work quite +naturally and safely. However, because current compilers do not take +either address or data dependencies into account it is still possible +to get into trouble. + +Follow these rules to preserve the address and data dependencies emanating +from your calls to rcu_dereference() and friends, thus keeping your RCU +readers working properly: - You must use one of the rcu_dereference() family of primitives to load an RCU-protected pointer, otherwise CONFIG_PROVE_RCU From patchwork Tue Dec 12 17:26:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neeraj upadhyay X-Patchwork-Id: 13489712 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ePqER2dE" Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12422B9; Tue, 12 Dec 2023 09:27:51 -0800 (PST) Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1d336760e72so8029535ad.3; Tue, 12 Dec 2023 09:27:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702402070; x=1703006870; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jynICPKoLwHaNl/nb1iCaIX3mL0xnnXkT4vQVCsRZhA=; b=ePqER2dELffZ7v0W6QBXdxpdZnF+D8lY3wgasOxEsI8ltHVpGR9O+qOLLaREPEmR9m Q3G3aObWHyQMzkWtgOhu/aw9G30sPpXW/zQNdQgTMv6KHR3i4k427Zk+G7iv56g4YF86 kIVY/WdvGjv7c/dW0JfGHbN33SfXctAy6bbc5pbIFCWqBAAaCgCiSy6baBxzS70gqIvp 6y1lXechWjKDEK2SwKMhX4vhknxjfQhM2lZdulQ3URg4j5QIxQZWwAi8WGcMTacLriSH V63sCPpLGvuz4UuzMgcfmwRgGSZbsAOl5jzoPBxXh2Jldpb+cTPFOL8cFx1pzFAGttPc xz3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702402070; x=1703006870; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jynICPKoLwHaNl/nb1iCaIX3mL0xnnXkT4vQVCsRZhA=; b=FsvyzRLY2K8k13aVQ9qLCnIfbR0pr1McdnMrVqJGgJ6Y84j5TFgZxlxahWOxy/oX22 atSS1T3BbJIPc1163TQpGvIdh0LmQZUCNrhqypDTpprb+J+t8H1MJHTTGjnoj5S0y1Z8 ekBfi1kVZGXB9DvRGyYQve8WOALD5gU+Gpz7Rt6eoQYFYkJ3UpYiaZLFTsTANvaXg9/f V0Y8Fx/el6AFDUjiLCMKwLQUthp5CsTxGQDxRKBMBTWfV4h6yTWUAoZ8ckr5/hh+Ho69 isA26V4poNkYppVF33Jo7AjdD3WER9dKXrT+wluvLLhBz+jyjvjtskDOjt0aUCPSBt0E ZYjQ== X-Gm-Message-State: AOJu0YxfynQ/klHz5HIOfjhW6TrjgUxTSPlhfJjBOTVk90nIZ3B1oGOc ujTLc+FemEHODqFQmeEJVnNZjZLtzC9yl+v0 X-Google-Smtp-Source: AGHT+IEmzmstegOSP1NfPzK2eL1lR3d6LdaJTZkEhbecs67QjwOFdMmSiK5G1lV1xqQY3ZbScwc06A== X-Received: by 2002:a17:902:d64a:b0:1d3:479d:3d56 with SMTP id y10-20020a170902d64a00b001d3479d3d56mr379083plh.133.1702402069993; Tue, 12 Dec 2023 09:27:49 -0800 (PST) Received: from localhost.localdomain ([101.0.63.152]) by smtp.gmail.com with ESMTPSA id b18-20020a170902d51200b001cf511aa772sm8863170plg.145.2023.12.12.09.27.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 09:27:49 -0800 (PST) From: "Neeraj Upadhyay (AMD)" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, paulmck@kernel.org, Neeraj.Upadhyay@amd.com, Jonas Oberhauser , Alan Stern , Andrea Parri , Will Deacon , Peter Zijlstra , Boqun Feng , Nicholas Piggin , David Howells , Jade Alglave , Luc Maranget , Akira Yokosawa , Daniel Lustig , Joel Fernandes , Jonathan Corbet , linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, Neeraj Upadhyay Subject: [PATCH rcu 5/5] doc: Clarify historical disclaimers in memory-barriers.txt Date: Tue, 12 Dec 2023 22:56:53 +0530 Message-Id: <20231212172653.11485-5-neeraj.iitr10@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231212172343.GA11383@neeraj.linux> References: <20231212172343.GA11383@neeraj.linux> Precedence: bulk X-Mailing-List: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "Paul E. McKenney" This commit makes it clear that the reason that these sections are historical is that smp_read_barrier_depends() is no more. It also removes the point about comparison operations, given that there are other optimizations that can break address dependencies. Suggested-by: Jonas Oberhauser Signed-off-by: Paul E. McKenney Cc: Alan Stern Cc: Andrea Parri Cc: Will Deacon Cc: Peter Zijlstra Cc: Boqun Feng Cc: Nicholas Piggin Cc: David Howells Cc: Jade Alglave Cc: Luc Maranget Cc: Akira Yokosawa Cc: Daniel Lustig Cc: Joel Fernandes Cc: Jonathan Corbet Cc: Cc: Signed-off-by: Neeraj Upadhyay (AMD) --- Documentation/memory-barriers.txt | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Documentation/memory-barriers.txt b/Documentation/memory-barriers.txt index d414e145f912..4202174a6262 100644 --- a/Documentation/memory-barriers.txt +++ b/Documentation/memory-barriers.txt @@ -396,10 +396,11 @@ Memory barriers come in four basic varieties: (2) Address-dependency barriers (historical). - [!] This section is marked as HISTORICAL: For more up-to-date - information, including how compiler transformations related to pointer - comparisons can sometimes cause problems, see - Documentation/RCU/rcu_dereference.rst. + [!] This section is marked as HISTORICAL: it covers the long-obsolete + smp_read_barrier_depends() macro, the semantics of which are now + implicit in all marked accesses. For more up-to-date information, + including how compiler transformations can sometimes break address + dependencies, see Documentation/RCU/rcu_dereference.rst. An address-dependency barrier is a weaker form of read barrier. In the case where two loads are performed such that the second depends on the @@ -560,9 +561,11 @@ There are certain things that the Linux kernel memory barriers do not guarantee: ADDRESS-DEPENDENCY BARRIERS (HISTORICAL) ---------------------------------------- -[!] This section is marked as HISTORICAL: For more up-to-date information, -including how compiler transformations related to pointer comparisons can -sometimes cause problems, see Documentation/RCU/rcu_dereference.rst. +[!] This section is marked as HISTORICAL: it covers the long-obsolete +smp_read_barrier_depends() macro, the semantics of which are now implicit +in all marked accesses. For more up-to-date information, including +how compiler transformations can sometimes break address dependencies, +see Documentation/RCU/rcu_dereference.rst. As of v4.15 of the Linux kernel, an smp_mb() was added to READ_ONCE() for DEC Alpha, which means that about the only people who need to pay attention