From patchwork Fri Feb 3 01:43:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 52262 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp595311wrn; Thu, 2 Feb 2023 18:15:20 -0800 (PST) X-Google-Smtp-Source: AK7set9SqhlMMMN1noe8RaWawVwvHd7oyYfnDx1hULPyDsgXiVVNsMfhgn8IkPb9NVxy6zgzHlrQ X-Received: by 2002:a17:903:1c6:b0:195:e590:c7c6 with SMTP id e6-20020a17090301c600b00195e590c7c6mr10433235plh.22.1675390519916; Thu, 02 Feb 2023 18:15:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675390519; cv=none; d=google.com; s=arc-20160816; b=JUn96kcneraPhHdOYkljOMA3EprNrs6t5jhzd1mQ5eIxLHrPRcEqi87LBIFQcyXXiv /d3jp/q9A0bUXr1Qiqv7+RQdDufzUheZWw2hurY16zrhzOw2c5FBXkxgAlrplU9TE2nP kejnRQrdzUI7xf1T7XWVj3buJ1OtdrmzicFDK8pUgEXn1TAeAMUvru8FsYI7AgGne/N5 98/Q9mSuy3ZIMCG47eirB37a5ZySUlzjqRFmlGnQPDrxPeJixMLnrGi4pmFyYDDRhBU2 eVrB0y+gjAK2qhNWieV3nYyEZyie/+XhngVQ1knBvgjyniAAP82zY2PxRU4CLL/S3tVc 4zLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=qP5EdYNRs5JRsp9U6yQlbqD8timimux0Zb0npUBhmAE=; b=iSqMTE7i5F5m3cbKW3g66/xN5uKZB4ykwXBOa2D1xmMyakCKv5BFK8oVTJFr/WhgLO 8VnqCOEs85rDSZuhzKTPxWsGLlT23fv6WqocROgXpu0lFqZmmM4eYT3MrO02sMhcoTSd Zyqgr64s+mXn9pRZK8argvIBjWsPQPMvykFBrvMoyPZxNnUbxn72Ix4sID0jyXojYjcn 9SLh4rcxql79Eo+mEDsNQGzJ9WlBP7huinla5GBHhNC/d3U2xriQq+SiZ/BOplGuI+K+ k+oK60D0Z6zCPjrWpmk5tUgpeBBZPbTbA+oxhB5MQPjAfWX7y5sgaxfyGJwzkruWIpt/ 14qA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sSzjqSKG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jj6-20020a170903048600b001978e84753csi923888plb.267.2023.02.02.18.15.07; Thu, 02 Feb 2023 18:15:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sSzjqSKG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232049AbjBCBnN (ORCPT + 99 others); Thu, 2 Feb 2023 20:43:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232050AbjBCBnK (ORCPT ); Thu, 2 Feb 2023 20:43:10 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76D0922A0E; Thu, 2 Feb 2023 17:43:07 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DFCE761D4B; Fri, 3 Feb 2023 01:43:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3FA1BC433EF; Fri, 3 Feb 2023 01:43:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675388586; bh=8zWI8bpAWD3oVlVykWtql5OSUtDYRERkD7toqAUb7R8=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=sSzjqSKG0c2v4pEaoyOyx0z3psnCdMrbABrkOsIQ7QR3fJYvsCR9bTr4H4GLesSt2 iFE4qI/QNPP83WUAsy6rsNZwOjk3r7pmuVDXSZ32g3gQGxHw/3bE5O0RJaLjpm17a4 UapoOYxj85CAZGh3VE5OuQOPT9oA9XvEUxW/AjzRNhRpLQq80yCu7yu4g+qgHI2dUo 5Mv7cjr1cMqFvM+/kton+7O9uFxzionWH7MdobojY0Gx97PiWCfwfqrmtwwJHfzHFM Ws2y3TFkDkt9vjP/M9/Du0L4a1lskYOIP/6w9kdurWRuldvah7clBRFP0HASL94ALN 15C9AAS1x6uzw== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id D608B5C0DE7; Thu, 2 Feb 2023 17:43:05 -0800 (PST) Date: Thu, 2 Feb 2023 17:43:05 -0800 From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org Subject: [PATCH rcu 9/8] Add kvfree_rcu_mightsleep() and kfree_rcu_mightsleep() Message-ID: <20230203014305.GA1075064@paulmck-ThinkPad-P17-Gen-1> Reply-To: paulmck@kernel.org References: <20230105002441.GA1768817@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230105002441.GA1768817@paulmck-ThinkPad-P17-Gen-1> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756774290194538660?= X-GMAIL-MSGID: =?utf-8?q?1756774290194538660?= The kvfree_rcu() and kfree_rcu() APIs are hazardous in that if you forget the second argument, it works, but might sleep. This sleeping can be a correctness bug from atomic contexts, and even in non-atomic contexts it might introduce unacceptable latencies. This commit therefore adds kvfree_rcu_mightsleep() and kfree_rcu_mightsleep(), which will replace the single-argument kvfree_rcu() and kfree_rcu(), respectively. This commit enables a series of commits that switch from single-argument kvfree_rcu() and kfree_rcu() to their _mightsleep() counterparts. Once all of these commits land, the single-argument versions will be removed. Signed-off-by: Uladzislau Rezki (Sony) Signed-off-by: Paul E. McKenney diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h index f38d4469d7f30..84433600885a6 100644 --- a/include/linux/rcupdate.h +++ b/include/linux/rcupdate.h @@ -1004,6 +1004,9 @@ static inline notrace void rcu_read_unlock_sched_notrace(void) #define kvfree_rcu(...) KVFREE_GET_MACRO(__VA_ARGS__, \ kvfree_rcu_arg_2, kvfree_rcu_arg_1)(__VA_ARGS__) +#define kvfree_rcu_mightsleep(ptr) kvfree_rcu_arg_1(ptr) +#define kfree_rcu_mightsleep(ptr) kvfree_rcu_mightsleep(ptr) + #define KVFREE_GET_MACRO(_1, _2, NAME, ...) NAME #define kvfree_rcu_arg_2(ptr, rhf) \ do { \