Received: by 10.223.176.5 with SMTP id f5csp487608wra; Tue, 6 Feb 2018 02:22:00 -0800 (PST) X-Google-Smtp-Source: AH8x225+i2hLng+HFsFoI1YJ4rEWreqKvnc1+9pJqi/3JruAAuXSCXs9NqA+sKBA9w/txueo27t1 X-Received: by 2002:a17:902:6e01:: with SMTP id u1-v6mr1954933plk.12.1517912520105; Tue, 06 Feb 2018 02:22:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517912520; cv=none; d=google.com; s=arc-20160816; b=Ks+fVci4zTvfbLRXixU2oUN032bO69RRxA61RPd0eWXX/63V6VV6XMJ1fFou1tAFql dRMqBLpflwu4XvwsYMMmI/ZITImJBu1rwbi3NCs/JqT0sKBLauewsTQ7tlu7FANb36Qr Z2TUt8DVRORz/MtYkljPPd+uLNnlcfh7Cm6r6XQ/t5ug0SCsAHTyPnpYC0x/IuRrmjZ6 5I6hoWHyR+R+/hqj7O255qR9DuoLyLkOfu7o5L19pmw0EPvHNPaQYTAWawkuHXIQPbXj gBtNCrYXc6f/Amn++bQf8BqyLdQkLEs7YX3E1V8NKXxNN+Eki1Iqo4VjiQiXdrYMWTnW A9WA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:to:from:subject :dkim-signature:arc-authentication-results; bh=3YtKVnArlXGXu99cSHFO4grxXo0IeaYQnucTggVenmY=; b=iqf89WlxKGKzcI7CzOAP7nXJ7hZgvsyIWQwHNVWVfhm7d2o2pT9ljitGS/H1FG01Vm 2zcbVxWyhpYPTtBeC1M4OpJgxF6aNcxQWaoycIjeN7iApcTESnD7EIsCxYutnNuPnEjd bZIavXQyAqvzOjDQ0aNIxOurrb8wlIxSRR1lwgvaprff0R+3WmeX3mQzi9AA3ZWH9M4m n/AtVfzBVrhXsO5BRdmW3CLH9bp3sVWq+YXdoXHozrGKy3BhVv3JpmO7T1UAWueF1j5H E82oPRBxy+I7UBRKw/ZvOOjYdvnm8XEU9eKSV198ozvto46npba35bOz3FT74FGC9jY6 KCZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=selector1 header.b=GCe6WTzq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g4si1936634pfm.125.2018.02.06.02.21.45; Tue, 06 Feb 2018 02:22:00 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=selector1 header.b=GCe6WTzq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752743AbeBFKUH (ORCPT + 99 others); Tue, 6 Feb 2018 05:20:07 -0500 Received: from mail-db5eur01on0111.outbound.protection.outlook.com ([104.47.2.111]:6209 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752248AbeBFKT4 (ORCPT ); Tue, 6 Feb 2018 05:19:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=3YtKVnArlXGXu99cSHFO4grxXo0IeaYQnucTggVenmY=; b=GCe6WTzq+G4jRbTumMAGMObySv0Qwr/nWRRXXxfO5/0N8kImiWitfts6VfebYHd4XQJbNR8ycrxVmHh3RQ3yyr/iyLQHFphKI5T7Mg/I7DxOJ2dbm9u9ohuBDVqYwoOe/d+w1bhgI19MA+4tMY/tQakrb+zgcbPnMnlRzduTGNY= Received: from localhost.localdomain (195.214.232.6) by HE1PR0801MB1339.eurprd08.prod.outlook.com (2603:10a6:3:3a::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.464.11; Tue, 6 Feb 2018 10:19:49 +0000 Subject: [PATCH 1/2] rcu: Transform kfree_rcu() into kvfree_rcu() From: Kirill Tkhai To: paulmck@linux.vnet.ibm.com, josh@joshtriplett.org, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, jiangshanlai@gmail.com, mingo@redhat.com, cl@linux.com, penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, akpm@linux-foundation.org, ktkhai@virtuozzo.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Date: Tue, 06 Feb 2018 13:19:45 +0300 Message-ID: <151791238553.5994.4933976056810745303.stgit@localhost.localdomain> In-Reply-To: <151791170164.5994.8253310844733420079.stgit@localhost.localdomain> References: <151791170164.5994.8253310844733420079.stgit@localhost.localdomain> User-Agent: StGit/0.18 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [195.214.232.6] X-ClientProxiedBy: VI1PR0501CA0007.eurprd05.prod.outlook.com (2603:10a6:800:92::17) To HE1PR0801MB1339.eurprd08.prod.outlook.com (2603:10a6:3:3a::7) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a534421c-ac89-49bd-7afb-08d56d4b288c X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(5600026)(4604075)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(2017052603307)(7153060)(7193020);SRVR:HE1PR0801MB1339; X-Microsoft-Exchange-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h4iOZF5Z4U/curyQy6HgpJa6c6yHnBUhiLUoI5oQONAW7dbKoEUoAR1OIIpzYEH6/PHrdDx+PfWjGPfjLoxxMDZ0iO0+wEXSsoUuqDS4LZyRFD9tDT2pXyGfY66LECb1PKGXHVsDyoK6WreHDYOxEV1ptMWYhBS0C7OYjFFKbeQeag5zVmvR3hWNPJlwRpoTv1ftKmr0ojLZVTLltNiXzYBC5KITi+iUG6vW9gKXmYT04USqcZ+aO0W9GfDF9hMGMCgWc5+Oh1jnlEOVFvqhtKI0=;4:TH/7lOhhnUTnbuijA1B9vbzbJGzExLqticbd+HcsXD1EJ/+p2bP+KR5IV9K9aD9FnSq5/tGCqVZ0Wb3iviGNM9Ks1gIicga2Y+BkjBUrpVhPDEDpFQtO1Pn+YcRLL4XUbCVwMvxwbLde88ivtAeqN7R+Wa/LL1iQ5A11HHttqtIVt43Gfpvlfr0A8IDMjYjqa38u5gp2/fOKhdJkTkV1MIlPwSDI6n8NGvJW4p9K74Q80pYSK5HHbooOtDztCFdjQRvZ+xzHL2peCD8hTN0/R0r4tlULEzqCTpDCp5+vZ3tZBWnsZZT2RlQBafvQ7GqYqXbHYxuJ0GeTQocT638a3g== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(788757137089)(17755550239193); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040501)(2401047)(5005006)(8121501046)(3002001)(93006095)(93001095)(3231101)(2400082)(944501161)(10201501046)(6041288)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123558120)(20161123560045)(20161123562045)(6072148)(201708071742011);SRVR:HE1PR0801MB1339;BCL:0;PCL:0;RULEID:;SRVR:HE1PR0801MB1339; X-Forefront-PRVS: 0575F81B58 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(6069001)(396003)(39380400002)(376002)(366004)(346002)(39840400004)(199004)(189003)(26005)(52116002)(50466002)(25786009)(2950100002)(6666003)(105586002)(47776003)(61506002)(86362001)(106356001)(8936002)(81156014)(81166006)(8676002)(66066001)(5660300001)(230700001)(68736007)(478600001)(103116003)(83506002)(2906002)(39060400002)(6116002)(58126008)(316002)(76176011)(6346003)(16526019)(186003)(55016002)(7696005)(55236004)(3846002)(386003)(9686003)(7416002)(53936002)(6506007)(33896004)(59450400001)(7736002)(2486003)(305945005)(23676004)(97736004)(921003)(1121003);DIR:OUT;SFP:1102;SCL:1;SRVR:HE1PR0801MB1339;H:localhost.localdomain;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; Received-SPF: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=ktkhai@virtuozzo.com; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtIRTFQUjA4MDFNQjEzMzk7MjM6bkFTMFI5WjZhRnlwQmhRL2Q1NVdneTA2?= =?utf-8?B?dHdFRUZQZys4UlJNbGY1aHJuVGRjTktKNExia2IrR083SVhCZkRtb0FWNEVw?= =?utf-8?B?ZVJYNk5ZMUhjRmV4Y0FTZXIrRDg3NGg5a1BVWkJOOTZ4S2lZMHJNM251TkhZ?= =?utf-8?B?MVlvQlJkY1VkNVNBU1VoOVFhU2hUdU5vSC9CU2dhUlpxRVdWdFdPL28zZkNU?= =?utf-8?B?dTJlUDN2cTg1YzZiUnFyZmRsRUFvNE9zVUNPYXZZLzJZQS93bW8xSmg3TW5t?= =?utf-8?B?dmQ3TU9tSFZrSlJIM2w1NWJ4TnBXd2sxaTRYeXFzYmw2VkZtV1VwRmZYSHF1?= =?utf-8?B?UDdtTitQanJBRGgreUl1dFA2M3RPenY4cTY4OUliWk92S0JQUjBMWUNLYVAv?= =?utf-8?B?NmtHRWVBY3FJd1VPOUZGdmRwU0t1RytlRzBrekIxRGxtVDloYk9wQkdJK2lS?= =?utf-8?B?VGV3ZUNRai90b0tYM3dzaGNKaFJrOFhwU0EzWHRYVkl1Q1UyTDVDMXJkT3FQ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oNSdCB0imrWYiEdxi5YzdJs8WCKf6o4s1CO+nWETGFCKeQ=;7:1A4NKG8savSN04ur6LPoG4xhnEvb00hxVlhzClZ6hg0Yc4tES7P3RP5w53CZdPf6cRj95wIcStd6edSqbAssVRgb9rAuvffp2oype44tugT1RkHHAYSk/+pNFy4nE5cWYIa5NYIDzke7tAxIq3bzECsgVEKYdBNXYPhboWb7v679z6B5ZDiLLqLG4gB5ScKkX++usXcitcWlWhGx8FbVJPQCykGka1kIZFnEa7x/83d3x9qQkzFLvDWpwgsjx9jf SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;HE1PR0801MB1339;20:8m2yhQ+qS1vivOIMeZwLJbm5ihY3w0857lZcd7g/TLf7Jh6NK4giyfNXrTWZVvccV0SXQD7n5hgp59qAGviRQ5ojAzkf+KrHxOmuSbADByoxWv7N8SJNnK/0FBixg41KteNxhuCxmj+VJy/qUtWLF3wdE1ze4UAWJrZDoKag6uY= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Feb 2018 10:19:49.7749 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a534421c-ac89-49bd-7afb-08d56d4b288c X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0801MB1339 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Recent times kvmalloc() begun widely be used in kernel. Some of such memory allocations have to be freed after rcu grace period, and this patch introduces a generic primitive for doing this. Currently, there is kfree_rcu() primitive in kernel, which encodes rcu_head offset inside freed structure on place of callback function. We can simply reuse it and replace final kfree() in __rcu_reclaim() with kvfree(). Since this primitive is able to free memory allocated via kmalloc(), vmalloc() and kvmalloc(), we may have single kvfree_rcu(), and define kfree_rcu() and vfree_rcu() through it. This allows users to avoid to implement custom functions for destruction kvmalloc()'ed and vmalloc()'ed memory. The new primitive kvfree_rcu() are used since next patch. Signed-off-by: Kirill Tkhai --- include/linux/rcupdate.h | 31 +++++++++++++++++-------------- include/linux/rcutiny.h | 4 ++-- include/linux/rcutree.h | 2 +- include/trace/events/rcu.h | 12 ++++++------ kernel/rcu/rcu.h | 8 ++++---- kernel/rcu/tree.c | 14 +++++++------- kernel/rcu/tree_plugin.h | 10 +++++----- 7 files changed, 42 insertions(+), 39 deletions(-) diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h index 043d04784675..22d4086f50b2 100644 --- a/include/linux/rcupdate.h +++ b/include/linux/rcupdate.h @@ -832,36 +832,36 @@ static inline notrace void rcu_read_unlock_sched_notrace(void) /* * Does the specified offset indicate that the corresponding rcu_head - * structure can be handled by kfree_rcu()? + * structure can be handled by kvfree_rcu()? */ -#define __is_kfree_rcu_offset(offset) ((offset) < 4096) +#define __is_kvfree_rcu_offset(offset) ((offset) < 4096) /* - * Helper macro for kfree_rcu() to prevent argument-expansion eyestrain. + * Helper macro for kvfree_rcu() to prevent argument-expansion eyestrain. */ -#define __kfree_rcu(head, offset) \ +#define __kvfree_rcu(head, offset) \ do { \ - BUILD_BUG_ON(!__is_kfree_rcu_offset(offset)); \ - kfree_call_rcu(head, (rcu_callback_t)(unsigned long)(offset)); \ + BUILD_BUG_ON(!__is_kvfree_rcu_offset(offset)); \ + kvfree_call_rcu(head, (rcu_callback_t)(unsigned long)(offset)); \ } while (0) /** - * kfree_rcu() - kfree an object after a grace period. - * @ptr: pointer to kfree + * kvfree_rcu() - kvfree an object after a grace period. + * @ptr: pointer to kvfree * @rcu_head: the name of the struct rcu_head within the type of @ptr. * - * Many rcu callbacks functions just call kfree() on the base structure. + * Many rcu callbacks functions just call kvfree() on the base structure. * These functions are trivial, but their size adds up, and furthermore * when they are used in a kernel module, that module must invoke the * high-latency rcu_barrier() function at module-unload time. * - * The kfree_rcu() function handles this issue. Rather than encoding a - * function address in the embedded rcu_head structure, kfree_rcu() instead + * The kvfree_rcu() function handles this issue. Rather than encoding a + * function address in the embedded rcu_head structure, kvfree_rcu() instead * encodes the offset of the rcu_head structure within the base structure. * Because the functions are not allowed in the low-order 4096 bytes of * kernel virtual memory, offsets up to 4095 bytes can be accommodated. * If the offset is larger than 4095 bytes, a compile-time error will - * be generated in __kfree_rcu(). If this error is triggered, you can + * be generated in __kvfree_rcu(). If this error is triggered, you can * either fall back to use of call_rcu() or rearrange the structure to * position the rcu_head structure into the first 4096 bytes. * @@ -871,9 +871,12 @@ static inline notrace void rcu_read_unlock_sched_notrace(void) * The BUILD_BUG_ON check must not involve any function calls, hence the * checks are done in macros here. */ -#define kfree_rcu(ptr, rcu_head) \ - __kfree_rcu(&((ptr)->rcu_head), offsetof(typeof(*(ptr)), rcu_head)) +#define kvfree_rcu(ptr, rcu_head) \ + __kvfree_rcu(&((ptr)->rcu_head), offsetof(typeof(*(ptr)), rcu_head)) +#define kfree_rcu(ptr, rcu_head) kvfree_rcu(ptr, rcu_head) + +#define vfree_rcu(ptr, rcu_head) kvfree_rcu(ptr, rcu_head) /* * Place this after a lock-acquisition primitive to guarantee that diff --git a/include/linux/rcutiny.h b/include/linux/rcutiny.h index ce9beec35e34..2e484aaa534f 100644 --- a/include/linux/rcutiny.h +++ b/include/linux/rcutiny.h @@ -84,8 +84,8 @@ static inline void synchronize_sched_expedited(void) synchronize_sched(); } -static inline void kfree_call_rcu(struct rcu_head *head, - rcu_callback_t func) +static inline void kvfree_call_rcu(struct rcu_head *head, + rcu_callback_t func) { call_rcu(head, func); } diff --git a/include/linux/rcutree.h b/include/linux/rcutree.h index fd996cdf1833..4d6365be4504 100644 --- a/include/linux/rcutree.h +++ b/include/linux/rcutree.h @@ -48,7 +48,7 @@ void synchronize_rcu_bh(void); void synchronize_sched_expedited(void); void synchronize_rcu_expedited(void); -void kfree_call_rcu(struct rcu_head *head, rcu_callback_t func); +void kvfree_call_rcu(struct rcu_head *head, rcu_callback_t func); /** * synchronize_rcu_bh_expedited - Brute-force RCU-bh grace period diff --git a/include/trace/events/rcu.h b/include/trace/events/rcu.h index 0b50fda80db0..9507264fa8f8 100644 --- a/include/trace/events/rcu.h +++ b/include/trace/events/rcu.h @@ -496,13 +496,13 @@ TRACE_EVENT(rcu_callback, /* * Tracepoint for the registration of a single RCU callback of the special - * kfree() form. The first argument is the RCU type, the second argument + * kvfree() form. The first argument is the RCU type, the second argument * is a pointer to the RCU callback, the third argument is the offset * of the callback within the enclosing RCU-protected data structure, * the fourth argument is the number of lazy callbacks queued, and the * fifth argument is the total number of callbacks queued. */ -TRACE_EVENT(rcu_kfree_callback, +TRACE_EVENT(rcu_kvfree_callback, TP_PROTO(const char *rcuname, struct rcu_head *rhp, unsigned long offset, long qlen_lazy, long qlen), @@ -591,12 +591,12 @@ TRACE_EVENT(rcu_invoke_callback, /* * Tracepoint for the invocation of a single RCU callback of the special - * kfree() form. The first argument is the RCU flavor, the second + * kvfree() form. The first argument is the RCU flavor, the second * argument is a pointer to the RCU callback, and the third argument * is the offset of the callback within the enclosing RCU-protected * data structure. */ -TRACE_EVENT(rcu_invoke_kfree_callback, +TRACE_EVENT(rcu_invoke_kvfree_callback, TP_PROTO(const char *rcuname, struct rcu_head *rhp, unsigned long offset), @@ -767,12 +767,12 @@ TRACE_EVENT(rcu_barrier, #define trace_rcu_fqs(rcuname, gpnum, cpu, qsevent) do { } while (0) #define trace_rcu_dyntick(polarity, oldnesting, newnesting, dyntick) do { } while (0) #define trace_rcu_callback(rcuname, rhp, qlen_lazy, qlen) do { } while (0) -#define trace_rcu_kfree_callback(rcuname, rhp, offset, qlen_lazy, qlen) \ +#define trace_rcu_kvfree_callback(rcuname, rhp, offset, qlen_lazy, qlen) \ do { } while (0) #define trace_rcu_batch_start(rcuname, qlen_lazy, qlen, blimit) \ do { } while (0) #define trace_rcu_invoke_callback(rcuname, rhp) do { } while (0) -#define trace_rcu_invoke_kfree_callback(rcuname, rhp, offset) do { } while (0) +#define trace_rcu_invoke_kvfree_callback(rcuname, rhp, offset) do { } while (0) #define trace_rcu_batch_end(rcuname, callbacks_invoked, cb, nr, iit, risk) \ do { } while (0) #define trace_rcu_torture_read(rcutorturename, rhp, secs, c_old, c) \ diff --git a/kernel/rcu/rcu.h b/kernel/rcu/rcu.h index 6334f2c1abd0..696200886098 100644 --- a/kernel/rcu/rcu.h +++ b/kernel/rcu/rcu.h @@ -151,7 +151,7 @@ static inline void debug_rcu_head_unqueue(struct rcu_head *head) } #endif /* #else !CONFIG_DEBUG_OBJECTS_RCU_HEAD */ -void kfree(const void *); +void kvfree(const void *); /* * Reclaim the specified callback, either by invoking it (non-lazy case) @@ -162,9 +162,9 @@ static inline bool __rcu_reclaim(const char *rn, struct rcu_head *head) unsigned long offset = (unsigned long)head->func; rcu_lock_acquire(&rcu_callback_map); - if (__is_kfree_rcu_offset(offset)) { - RCU_TRACE(trace_rcu_invoke_kfree_callback(rn, head, offset);) - kfree((void *)head - offset); + if (__is_kvfree_rcu_offset(offset)) { + RCU_TRACE(trace_rcu_invoke_kvfree_callback(rn, head, offset);) + kvfree((void *)head - offset); rcu_lock_release(&rcu_callback_map); return true; } else { diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index 491bdf39f276..8e736aa11a46 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -3061,10 +3061,10 @@ __call_rcu(struct rcu_head *head, rcu_callback_t func, if (!lazy) rcu_idle_count_callbacks_posted(); - if (__is_kfree_rcu_offset((unsigned long)func)) - trace_rcu_kfree_callback(rsp->name, head, (unsigned long)func, - rcu_segcblist_n_lazy_cbs(&rdp->cblist), - rcu_segcblist_n_cbs(&rdp->cblist)); + if (__is_kvfree_rcu_offset((unsigned long)func)) + trace_rcu_kvfree_callback(rsp->name, head, (unsigned long)func, + rcu_segcblist_n_lazy_cbs(&rdp->cblist), + rcu_segcblist_n_cbs(&rdp->cblist)); else trace_rcu_callback(rsp->name, head, rcu_segcblist_n_lazy_cbs(&rdp->cblist), @@ -3134,14 +3134,14 @@ EXPORT_SYMBOL_GPL(call_rcu_bh); * This will likely be later named something like "call_rcu_lazy()", * but this change will require some way of tagging the lazy RCU * callbacks in the list of pending callbacks. Until then, this - * function may only be called from __kfree_rcu(). + * function may only be called from __kvfree_rcu(). */ -void kfree_call_rcu(struct rcu_head *head, +void kvfree_call_rcu(struct rcu_head *head, rcu_callback_t func) { __call_rcu(head, func, rcu_state_p, -1, 1); } -EXPORT_SYMBOL_GPL(kfree_call_rcu); +EXPORT_SYMBOL_GPL(kvfree_call_rcu); /* * Because a context switch is a grace period for RCU-sched and RCU-bh, diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h index fb88a028deec..85715963658e 100644 --- a/kernel/rcu/tree_plugin.h +++ b/kernel/rcu/tree_plugin.h @@ -1984,11 +1984,11 @@ static bool __call_rcu_nocb(struct rcu_data *rdp, struct rcu_head *rhp, if (!rcu_is_nocb_cpu(rdp->cpu)) return false; __call_rcu_nocb_enqueue(rdp, rhp, &rhp->next, 1, lazy, flags); - if (__is_kfree_rcu_offset((unsigned long)rhp->func)) - trace_rcu_kfree_callback(rdp->rsp->name, rhp, - (unsigned long)rhp->func, - -atomic_long_read(&rdp->nocb_q_count_lazy), - -atomic_long_read(&rdp->nocb_q_count)); + if (__is_kvfree_rcu_offset((unsigned long)rhp->func)) + trace_rcu_kvfree_callback(rdp->rsp->name, rhp, + (unsigned long)rhp->func, + -atomic_long_read(&rdp->nocb_q_count_lazy), + -atomic_long_read(&rdp->nocb_q_count)); else trace_rcu_callback(rdp->rsp->name, rhp, -atomic_long_read(&rdp->nocb_q_count_lazy),