Skip to contentSkip to conversation

drdb: Switch to kvfree_rcu() API

PATCH Superseded Uladzislau Rezki (Sony) 4 participants 23 messages Dec 15, 2021 – Dec 17, 2021

Subsystems (15)
lore
Share & tools
lore

Uladzislau Rezki (Sony)

author maintainer
#0 lore raw

PATCH 1/1 drdb: Switch to kvfree_rcu() API

Instead of invoking a synchronize_rcu() to free a pointer after a grace period we can directly make use of new API that does the same but in more efficient way.

TO: Jens Axboe <[email protected]>
TO: Philipp Reisner <[email protected]>
TO: Jason Gunthorpe <[email protected]>
TO: [email protected]
TO: [email protected]

---
 drivers/block/drbd/drbd_nl.c       | 9 +++------
 drivers/block/drbd/drbd_receiver.c | 6 ++----
 drivers/block/drbd/drbd_state.c    | 3 +--
 3 files changed, 6 insertions(+), 12 deletions(-)
drivers/block/drbd/drbd_nl.c +3 -6
index 44ccf8b4f4b2..28f4d84945fd 100644
@@ -1679,8 +1679,7 @@ int drbd_adm_disk_opts(struct sk_buff *skb, struct genl_info *info)
 			drbd_send_sync_param(peer_device);
 	}
 
-	synchronize_rcu();
-	kfree(old_disk_conf);
+	kvfree_rcu(old_disk_conf);
 	kfree(old_plan);
 	mod_timer(&device->request_timer, jiffies + HZ);
 	goto success;
@@ -2511,8 +2510,7 @@ int drbd_adm_net_opts(struct sk_buff *skb, struct genl_info *info)
 
 	mutex_unlock(&connection->resource->conf_update);
 	mutex_unlock(&connection->data.mutex);
-	synchronize_rcu();
-	kfree(old_net_conf);
+	kvfree_rcu(old_net_conf);
 
 	if (connection->cstate >= C_WF_REPORT_PARAMS) {
 		struct drbd_peer_device *peer_device;
@@ -2925,8 +2923,7 @@ int drbd_adm_resize(struct sk_buff *skb, struct genl_info *info)
 		new_disk_conf->disk_size = (sector_t)rs.resize_size;
 		rcu_assign_pointer(device->ldev->disk_conf, new_disk_conf);
 		mutex_unlock(&device->resource->conf_update);
-		synchronize_rcu();
-		kfree(old_disk_conf);
+		kvfree_rcu(old_disk_conf);
 		new_disk_conf = NULL;
 	}
 
drivers/block/drbd/drbd_receiver.c +2 -4
index 1f740e42e457..d73a53242a75 100644
@@ -3799,8 +3799,7 @@ static int receive_protocol(struct drbd_connection *connection, struct packet_in
 		drbd_info(connection, "peer data-integrity-alg: %s\n",
 			  integrity_alg[0] ? integrity_alg : "(none)");
 
-	synchronize_rcu();
-	kfree(old_net_conf);
+	kvfree_rcu(old_net_conf);
 	return 0;
 
 disconnect_rcu_unlock:
@@ -4168,8 +4167,7 @@ static int receive_sizes(struct drbd_connection *connection, struct packet_info
 
 			rcu_assign_pointer(device->ldev->disk_conf, new_disk_conf);
 			mutex_unlock(&connection->resource->conf_update);
-			synchronize_rcu();
-			kfree(old_disk_conf);
+			kvfree_rcu(old_disk_conf);
 
 			drbd_info(device, "Peer sets u_size to %lu sectors (old: %lu)\n",
 				 (unsigned long)p_usize, (unsigned long)my_usize);
drivers/block/drbd/drbd_state.c +1 -2
index b8a27818ab3f..826e496821c7 100644
@@ -2071,8 +2071,7 @@ static int w_after_conn_state_ch(struct drbd_work *w, int unused)
 		conn_free_crypto(connection);
 		mutex_unlock(&connection->resource->conf_update);
 
-		synchronize_rcu();
-		kfree(old_conf);
+		kvfree_rcu(old_conf);
 	}
 
 	if (ns_max.susp_fen) {
Signature · 1 line
2.30.2
author maintainer
#1 lore raw

PATCH RESEND 1/1 ext4: Replace ext4_kvfree_array_rcu() by kvfree_rcu() API

The ext4_kvfree_array_rcu() function was introduced in order to release some memory after a grace period during resizing of a partition. An object that is freed does not contain any rcu_head filed.

To do so, it requires to allocate some extra memory for a special structure that has an rcu_head filed and pointer one where a freed memory is attached. Finally call_rcu() API is invoked.

Since we have a single argument of kvfree_rcu() API, we can easily replace all that tricky code by one single call that does the same but in more efficient way.

TO: "Theodore Ts'o" <[email protected]>
TO: [email protected]

---
 fs/ext4/ext4.h    |  1 -
 fs/ext4/mballoc.c |  2 +-
 fs/ext4/resize.c  | 31 ++-----------------------------
 fs/ext4/super.c   |  2 +-
 4 files changed, 4 insertions(+), 32 deletions(-)
fs/ext4/ext4.h +0 -1
index 404dd50856e5..7e8ff3ac2beb 100644
@@ -3089,7 +3089,6 @@ extern int ext4_generic_delete_entry(struct inode *dir,
 extern bool ext4_empty_dir(struct inode *inode);
 
 /* resize.c */
-extern void ext4_kvfree_array_rcu(void *to_free);
 extern int ext4_group_add(struct super_block *sb,
 				struct ext4_new_group_data *input);
 extern int ext4_group_extend(struct super_block *sb,
fs/ext4/mballoc.c +1 -1
index 215b7068f548..b0469f7a5c55 100644
@@ -3109,7 +3109,7 @@ int ext4_mb_alloc_groupinfo(struct super_block *sb, ext4_group_t ngroups)
 	rcu_assign_pointer(sbi->s_group_info, new_groupinfo);
 	sbi->s_group_info_size = size / sizeof(*sbi->s_group_info);
 	if (old_groupinfo)
-		ext4_kvfree_array_rcu(old_groupinfo);
+		kvfree_rcu(old_groupinfo);
 	ext4_debug("allocated s_groupinfo array for %d meta_bg's\n",
 		   sbi->s_group_info_size);
 	return 0;
fs/ext4/resize.c +2 -29
index b63cb88ccdae..ac6aa037aaab 100644
@@ -17,33 +17,6 @@
 
 #include "ext4_jbd2.h"
 
-struct ext4_rcu_ptr {
-	struct rcu_head rcu;
-	void *ptr;
-};
-
-static void ext4_rcu_ptr_callback(struct rcu_head *head)
-{
-	struct ext4_rcu_ptr *ptr;
-
-	ptr = container_of(head, struct ext4_rcu_ptr, rcu);
-	kvfree(ptr->ptr);
-	kfree(ptr);
-}
-
-void ext4_kvfree_array_rcu(void *to_free)
-{
-	struct ext4_rcu_ptr *ptr = kzalloc(sizeof(*ptr), GFP_KERNEL);
-
-	if (ptr) {
-		ptr->ptr = to_free;
-		call_rcu(&ptr->rcu, ext4_rcu_ptr_callback);
-		return;
-	}
-	synchronize_rcu();
-	kvfree(to_free);
-}
-
 int ext4_resize_begin(struct super_block *sb)
 {
 	struct ext4_sb_info *sbi = EXT4_SB(sb);
@@ -906,7 +879,7 @@ static int add_new_gdb(handle_t *handle, struct inode *inode,
 	n_group_desc[gdb_num] = gdb_bh;
 	rcu_assign_pointer(EXT4_SB(sb)->s_group_desc, n_group_desc);
 	EXT4_SB(sb)->s_gdb_count++;
-	ext4_kvfree_array_rcu(o_group_desc);
+	kvfree_rcu(o_group_desc);
 
 	lock_buffer(EXT4_SB(sb)->s_sbh);
 	le16_add_cpu(&es->s_reserved_gdt_blocks, -1);
@@ -969,7 +942,7 @@ static int add_new_gdb_meta_bg(struct super_block *sb,
 
 	rcu_assign_pointer(EXT4_SB(sb)->s_group_desc, n_group_desc);
 	EXT4_SB(sb)->s_gdb_count++;
-	ext4_kvfree_array_rcu(o_group_desc);
+	kvfree_rcu(o_group_desc);
 	return err;
 }
 
fs/ext4/super.c +1 -1
index 111b0498a232..3942cd271a00 100644
@@ -2759,7 +2759,7 @@ int ext4_alloc_flex_bg_array(struct super_block *sb, ext4_group_t ngroup)
 	rcu_assign_pointer(sbi->s_flex_groups, new_groups);
 	sbi->s_flex_groups_allocated = size;
 	if (old_groups)
-		ext4_kvfree_array_rcu(old_groups);
+		kvfree_rcu(old_groups);
 	return 0;
 }
 
Signature · 1 line
2.30.2
author maintainer
#2 lore raw

Re: [PATCH RESEND] ext4: Replace ext4_kvfree_array_rcu() by kvfree_rcu() API

Quoted 120 lines · Uladzislau Rezki (Sony)

The ext4_kvfree_array_rcu() function was introduced in order to release some memory after a grace period during resizing of a partition. An object that is freed does not contain any rcu_head filed.

To do so, it requires to allocate some extra memory for a special structure that has an rcu_head filed and pointer one where a freed memory is attached. Finally call_rcu() API is invoked.

Since we have a single argument of kvfree_rcu() API, we can easily replace all that tricky code by one single call that does the same but in more efficient way.

TO: "Theodore Ts'o" <[email protected]>
TO: [email protected]

---
 fs/ext4/ext4.h    |  1 -
 fs/ext4/mballoc.c |  2 +-
 fs/ext4/resize.c  | 31 ++-----------------------------
 fs/ext4/super.c   |  2 +-
 4 files changed, 4 insertions(+), 32 deletions(-)
fs/ext4/ext4.h +0 -1
index 404dd50856e5..7e8ff3ac2beb 100644
@@ -3089,7 +3089,6 @@ extern int ext4_generic_delete_entry(struct inode *dir,
 extern bool ext4_empty_dir(struct inode *inode);
 
 /* resize.c */
-extern void ext4_kvfree_array_rcu(void *to_free);
 extern int ext4_group_add(struct super_block *sb,
 				struct ext4_new_group_data *input);
 extern int ext4_group_extend(struct super_block *sb,
fs/ext4/mballoc.c +1 -1
index 215b7068f548..b0469f7a5c55 100644
@@ -3109,7 +3109,7 @@ int ext4_mb_alloc_groupinfo(struct super_block *sb, ext4_group_t ngroups)
 	rcu_assign_pointer(sbi->s_group_info, new_groupinfo);
 	sbi->s_group_info_size = size / sizeof(*sbi->s_group_info);
 	if (old_groupinfo)
-		ext4_kvfree_array_rcu(old_groupinfo);
+		kvfree_rcu(old_groupinfo);
 	ext4_debug("allocated s_groupinfo array for %d meta_bg's\n",
 		   sbi->s_group_info_size);
 	return 0;
fs/ext4/resize.c +2 -29
index b63cb88ccdae..ac6aa037aaab 100644
@@ -17,33 +17,6 @@
 
 #include "ext4_jbd2.h"
 
-struct ext4_rcu_ptr {
-	struct rcu_head rcu;
-	void *ptr;
-};
-
-static void ext4_rcu_ptr_callback(struct rcu_head *head)
-{
-	struct ext4_rcu_ptr *ptr;
-
-	ptr = container_of(head, struct ext4_rcu_ptr, rcu);
-	kvfree(ptr->ptr);
-	kfree(ptr);
-}
-
-void ext4_kvfree_array_rcu(void *to_free)
-{
-	struct ext4_rcu_ptr *ptr = kzalloc(sizeof(*ptr), GFP_KERNEL);
-
-	if (ptr) {
-		ptr->ptr = to_free;
-		call_rcu(&ptr->rcu, ext4_rcu_ptr_callback);
-		return;
-	}
-	synchronize_rcu();
-	kvfree(to_free);
-}
-
 int ext4_resize_begin(struct super_block *sb)
 {
 	struct ext4_sb_info *sbi = EXT4_SB(sb);
@@ -906,7 +879,7 @@ static int add_new_gdb(handle_t *handle, struct inode *inode,
 	n_group_desc[gdb_num] = gdb_bh;
 	rcu_assign_pointer(EXT4_SB(sb)->s_group_desc, n_group_desc);
 	EXT4_SB(sb)->s_gdb_count++;
-	ext4_kvfree_array_rcu(o_group_desc);
+	kvfree_rcu(o_group_desc);
 
 	lock_buffer(EXT4_SB(sb)->s_sbh);
 	le16_add_cpu(&es->s_reserved_gdt_blocks, -1);
@@ -969,7 +942,7 @@ static int add_new_gdb_meta_bg(struct super_block *sb,
 
 	rcu_assign_pointer(EXT4_SB(sb)->s_group_desc, n_group_desc);
 	EXT4_SB(sb)->s_gdb_count++;
-	ext4_kvfree_array_rcu(o_group_desc);
+	kvfree_rcu(o_group_desc);
 	return err;
 }
 
fs/ext4/super.c +1 -1
index 111b0498a232..3942cd271a00 100644
@@ -2759,7 +2759,7 @@ int ext4_alloc_flex_bg_array(struct super_block *sb, ext4_group_t ngroup)
 	rcu_assign_pointer(sbi->s_flex_groups, new_groups);
 	sbi->s_flex_groups_allocated = size;
 	if (old_groups)
-		ext4_kvfree_array_rcu(old_groups);
+		kvfree_rcu(old_groups);
 	return 0;
 }
 
Signature · 1 line
2.30.2

+ "Theodore Ts'o" <[email protected]>
+ [email protected]

--
Vlad Rezki

author maintainer
#3 lore raw

PATCH RESEND 1/1 ext4: Switch to kvfree_rcu() API

In reply to Uladzislau Rezki (Sony)

From: Uladzislau Rezki <[email protected]>

Instead of invoking a synchronize_rcu() to free a pointer after a grace period we can directly make use of new API that does the same but in more efficient way.

TO: "Theodore Ts'o" <[email protected]>
TO: [email protected]

---
 fs/ext4/super.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/ext4/super.c +1 -2
index 4e33b5eca694..111b0498a232 100644
@@ -1886,8 +1886,7 @@ static int clear_qf_name(struct super_block *sb, int qtype)
 		return -1;
 	}
 	rcu_assign_pointer(sbi->s_qf_names[qtype], NULL);
-	synchronize_rcu();
-	kfree(old_qname);
+	kvfree_rcu(old_qname);
 	return 1;
 }
 #endif
Signature · 1 line
2.30.2
author maintainer
#4 lore raw

Re: [PATCH RESEND] ext4: Switch to kvfree_rcu() API

Quoted 30 lines · Uladzislau Rezki (Sony)

From: Uladzislau Rezki <[email protected]>

Instead of invoking a synchronize_rcu() to free a pointer after a grace period we can directly make use of new API that does the same but in more efficient way.

TO: "Theodore Ts'o" <[email protected]>
TO: [email protected]

---
 fs/ext4/super.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/ext4/super.c +1 -2
index 4e33b5eca694..111b0498a232 100644
@@ -1886,8 +1886,7 @@ static int clear_qf_name(struct super_block *sb, int qtype)
 		return -1;
 	}
 	rcu_assign_pointer(sbi->s_qf_names[qtype], NULL);
-	synchronize_rcu();
-	kfree(old_qname);
+	kvfree_rcu(old_qname);
 	return 1;
 }
 #endif
Signature · 1 line
2.30.2

+ "Theodore Ts'o" <[email protected]>
+ [email protected]

--
Vlad Rezki

author maintainer
#5 lore raw

PATCH 1/1 fs: nfs: sysfs: Switch to kvfree_rcu() API

In reply to Uladzislau Rezki (Sony)

From: Uladzislau Rezki <[email protected]>

Instead of invoking a synchronize_rcu() to free a pointer after a grace period we can directly make use of new API that does the same but in more efficient way.

TO: Trond Myklebust <[email protected]>
TO: [email protected]

---
 fs/nfs/sysfs.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
fs/nfs/sysfs.c +3 -4
index 8cb70755e3c9..ff88d5d58e1e 100644
@@ -113,10 +113,9 @@ static ssize_t nfs_netns_identifier_store(struct kobject *kobj,
 	if (!p)
 		return -ENOMEM;
 	old = rcu_dereference_protected(xchg(&c->identifier, (char __rcu *)p), 1);
-	if (old) {
-		synchronize_rcu();
-		kfree(old);
-	}
+	if (old)
+		kvfree_rcu(old);
+
 	return count;
 }
 
Signature · 1 line
2.30.2
author maintainer
#6 lore raw

Re: [PATCH] fs: nfs: sysfs: Switch to kvfree_rcu() API

Quoted 34 lines · Uladzislau Rezki (Sony)

From: Uladzislau Rezki <[email protected]>

Instead of invoking a synchronize_rcu() to free a pointer after a grace period we can directly make use of new API that does the same but in more efficient way.

TO: Trond Myklebust <[email protected]>
TO: [email protected]

---
 fs/nfs/sysfs.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
fs/nfs/sysfs.c +3 -4
index 8cb70755e3c9..ff88d5d58e1e 100644
@@ -113,10 +113,9 @@ static ssize_t nfs_netns_identifier_store(struct kobject *kobj,
 	if (!p)
 		return -ENOMEM;
 	old = rcu_dereference_protected(xchg(&c->identifier, (char __rcu *)p), 1);
-	if (old) {
-		synchronize_rcu();
-		kfree(old);
-	}
+	if (old)
+		kvfree_rcu(old);
+
 	return count;
 }
 
Signature · 1 line
2.30.2

+ Trond Myklebust <[email protected]>
+ [email protected]

--
Vlad Rezki

author maintainer
#7 lore raw

PATCH 1/1 mfd: dln2: Switch to kvfree_rcu() API

In reply to Uladzislau Rezki (Sony)

Instead of invoking a synchronize_rcu() to free a pointer after a grace period we can directly make use of new API that does the same but in more efficient way.

TO: Lee Jones <[email protected]>
TO: Mike Marciniszyn <[email protected]>

---
 drivers/mfd/dln2.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/mfd/dln2.c +2 -4
index 852129ea0766..365e3e77cac4 100644
@@ -179,10 +179,8 @@ void dln2_unregister_event_cb(struct platform_device *pdev, u16 id)
 
 	spin_unlock_irqrestore(&dln2->event_cb_lock, flags);
 
-	if (found) {
-		synchronize_rcu();
-		kfree(i);
-	}
+	if (found)
+		kvfree_rcu(i);
 }
 EXPORT_SYMBOL(dln2_unregister_event_cb);
 
Signature · 1 line
2.30.2
author maintainer
#8 lore raw

Re: [PATCH] mfd: dln2: Switch to kvfree_rcu() API

Quoted 31 lines · Uladzislau Rezki (Sony)

Instead of invoking a synchronize_rcu() to free a pointer after a grace period we can directly make use of new API that does the same but in more efficient way.

TO: Lee Jones <[email protected]>
TO: Mike Marciniszyn <[email protected]>

---
 drivers/mfd/dln2.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/mfd/dln2.c +2 -4
index 852129ea0766..365e3e77cac4 100644
@@ -179,10 +179,8 @@ void dln2_unregister_event_cb(struct platform_device *pdev, u16 id)
 
 	spin_unlock_irqrestore(&dln2->event_cb_lock, flags);
 
-	if (found) {
-		synchronize_rcu();
-		kfree(i);
-	}
+	if (found)
+		kvfree_rcu(i);
 }
 EXPORT_SYMBOL(dln2_unregister_event_cb);
 
Signature · 1 line
2.30.2

+ Lee Jones <[email protected]>
+ Mike Marciniszyn <[email protected]>

--
Vlad Rezki

#9 lore raw

Re: [PATCH] mfd: dln2: Switch to kvfree_rcu() API

Quoted 20 lines · Uladzislau Rezki
Quoted 19 lines · Uladzislau Rezki (Sony)

Instead of invoking a synchronize_rcu() to free a pointer after a grace period we can directly make use of new API that does the same but in more efficient way.

TO: Lee Jones <[email protected]>
TO: Mike Marciniszyn <[email protected]>

---
 drivers/mfd/dln2.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/mfd/dln2.c +0 -0
index 852129ea0766..365e3e77cac4 100644
@@ -179,10 +179,8 @@ void dln2_unregister_event_cb(struct platform_device *pdev, u16 id)
 
 	spin_unlock_irqrestore(&dln2->event_cb_lock, flags);
 
Quoted 11 lines

drivers/mfd/dln2.c void dln2_unregister_event_cb(struct platform_device *pdev, u16 id) · line 186

Quoted 9 lines
drivers/mfd/dln2.c +2 -4
-	if (found) {
-		synchronize_rcu();
-		kfree(i);
-	}
+	if (found)
+		kvfree_rcu(i);
 }
 EXPORT_SYMBOL(dln2_unregister_event_cb);
 

+ Lee Jones <[email protected]>
+ Mike Marciniszyn <[email protected]>

I can't do anything with this.

Send it properly please.

Signature · 4 lines
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
author maintainer
#10 lore raw

Re: [PATCH] mfd: dln2: Switch to kvfree_rcu() API

Quoted 35 lines · Lee Jones
Quoted 20 lines · Uladzislau Rezki
Quoted 19 lines · Uladzislau Rezki (Sony)

Instead of invoking a synchronize_rcu() to free a pointer after a grace period we can directly make use of new API that does the same but in more efficient way.

TO: Lee Jones <[email protected]>
TO: Mike Marciniszyn <[email protected]>

---
 drivers/mfd/dln2.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/mfd/dln2.c +0 -0
index 852129ea0766..365e3e77cac4 100644
@@ -179,10 +179,8 @@ void dln2_unregister_event_cb(struct platform_device *pdev, u16 id)
 
    spin_unlock_irqrestore(&dln2->event_cb_lock, flags);
 
Quoted 11 lines

drivers/mfd/dln2.c void dln2_unregister_event_cb(struct platform_device *pdev, u16 id) · line 186

Quoted 9 lines
drivers/mfd/dln2.c +2 -4
-   if (found) {
-           synchronize_rcu();
-           kfree(i);
-   }
+   if (found)
+           kvfree_rcu(i);
 }
 EXPORT_SYMBOL(dln2_unregister_event_cb);
 

+ Lee Jones <[email protected]>
+ Mike Marciniszyn <[email protected]>

Quoted 4 lines

I can't do anything with this.

Send it properly please.

I got. Will do.

Thanks!

Signature · 1 line
Uladzislau Rezki
author maintainer
#11 lore raw

PATCH 1/1 misc: vmw_vmci: Switch to kvfree_rcu() API

In reply to Uladzislau Rezki (Sony)

Instead of invoking a synchronize_rcu() to free a pointer after a grace period we can directly make use of new API that does the same but in more efficient way.

CC: Greg Kroah-Hartman <[email protected]>
TO: Jorgen Hansen <[email protected]>
TO: Vishnu Dasa <[email protected]>
TO: [email protected]

---
 drivers/misc/vmw_vmci/vmci_context.c | 6 ++----
 drivers/misc/vmw_vmci/vmci_event.c   | 3 +--
 2 files changed, 3 insertions(+), 6 deletions(-)
drivers/misc/vmw_vmci/vmci_context.c +2 -4
index c0b5e339d5a1..6cf3e21c7604 100644
@@ -687,10 +687,8 @@ int vmci_ctx_remove_notification(u32 context_id, u32 remote_cid)
 	}
 	spin_unlock(&context->lock);
 
-	if (found) {
-		synchronize_rcu();
-		kfree(notifier);
-	}
+	if (found)
+		kvfree_rcu(notifier);
 
 	vmci_ctx_put(context);
 
drivers/misc/vmw_vmci/vmci_event.c +1 -2
index e3436abf39f4..2100297c94ad 100644
@@ -209,8 +209,7 @@ int vmci_event_unsubscribe(u32 sub_id)
 	if (!s)
 		return VMCI_ERROR_NOT_FOUND;
 
-	synchronize_rcu();
-	kfree(s);
+	kvfree_rcu(s);
 
 	return VMCI_SUCCESS;
 }
Signature · 1 line
2.30.2
author maintainer
#12 lore raw

Re: [PATCH] misc: vmw_vmci: Switch to kvfree_rcu() API

Quoted 49 lines · Uladzislau Rezki (Sony)

Instead of invoking a synchronize_rcu() to free a pointer after a grace period we can directly make use of new API that does the same but in more efficient way.

CC: Greg Kroah-Hartman <[email protected]>
TO: Jorgen Hansen <[email protected]>
TO: Vishnu Dasa <[email protected]>
TO: [email protected]

---
 drivers/misc/vmw_vmci/vmci_context.c | 6 ++----
 drivers/misc/vmw_vmci/vmci_event.c   | 3 +--
 2 files changed, 3 insertions(+), 6 deletions(-)
drivers/misc/vmw_vmci/vmci_context.c +2 -4
index c0b5e339d5a1..6cf3e21c7604 100644
@@ -687,10 +687,8 @@ int vmci_ctx_remove_notification(u32 context_id, u32 remote_cid)
 	}
 	spin_unlock(&context->lock);
 
-	if (found) {
-		synchronize_rcu();
-		kfree(notifier);
-	}
+	if (found)
+		kvfree_rcu(notifier);
 
 	vmci_ctx_put(context);
 
drivers/misc/vmw_vmci/vmci_event.c +1 -2
index e3436abf39f4..2100297c94ad 100644
@@ -209,8 +209,7 @@ int vmci_event_unsubscribe(u32 sub_id)
 	if (!s)
 		return VMCI_ERROR_NOT_FOUND;
 
-	synchronize_rcu();
-	kfree(s);
+	kvfree_rcu(s);
 
 	return VMCI_SUCCESS;
 }
Signature · 1 line
2.30.2

+ Jorgen Hansen <[email protected]>
+ Vishnu Dasa <[email protected]>
+ [email protected]

--
Vlad Rezki

author maintainer
#13 lore raw

PATCH 1/1 mlxsw: core: Switch to kvfree_rcu() API

In reply to Uladzislau Rezki (Sony)

Instead of invoking a synchronize_rcu() to free a pointer after a grace period we can directly make use of new API that does the same but in more efficient way.

TO: David S. Miller <[email protected]>
TO: Jakub Kicinski <[email protected]>
TO: [email protected]

---
 drivers/net/ethernet/mellanox/mlxsw/core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/core.c +1 -2
index 3fd3812b8f31..47c29769759b 100644
@@ -2190,8 +2190,7 @@ void mlxsw_core_rx_listener_unregister(struct mlxsw_core *mlxsw_core,
 	if (!rxl_item)
 		return;
 	list_del_rcu(&rxl_item->list);
-	synchronize_rcu();
-	kfree(rxl_item);
+	kvfree_rcu(rxl_item);
 }
 EXPORT_SYMBOL(mlxsw_core_rx_listener_unregister);
 
Signature · 1 line
2.30.2
author maintainer
#14 lore raw

Re: [PATCH] mlxsw: core: Switch to kvfree_rcu() API

Quoted 29 lines · Uladzislau Rezki (Sony)

Instead of invoking a synchronize_rcu() to free a pointer after a grace period we can directly make use of new API that does the same but in more efficient way.

TO: David S. Miller <[email protected]>
TO: Jakub Kicinski <[email protected]>
TO: [email protected]

---
 drivers/net/ethernet/mellanox/mlxsw/core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/core.c +1 -2
index 3fd3812b8f31..47c29769759b 100644
@@ -2190,8 +2190,7 @@ void mlxsw_core_rx_listener_unregister(struct mlxsw_core *mlxsw_core,
 	if (!rxl_item)
 		return;
 	list_del_rcu(&rxl_item->list);
-	synchronize_rcu();
-	kfree(rxl_item);
+	kvfree_rcu(rxl_item);
 }
 EXPORT_SYMBOL(mlxsw_core_rx_listener_unregister);
 
Signature · 1 line
2.30.2

+ David S. Miller <[email protected]>
+ Jakub Kicinski <[email protected]>
+ [email protected]

--
Vlad Rezki

maintainer
#15 lore raw

Re: [PATCH] mlxsw: core: Switch to kvfree_rcu() API

Quoted 22 lines · On Wed, 15 Dec 2021 20:46:34 +0100 Uladzislau Rezki wrote:
Quoted 21 lines · Uladzislau Rezki (Sony)

Instead of invoking a synchronize_rcu() to free a pointer after a grace period we can directly make use of new API that does the same but in more efficient way.

TO: David S. Miller <[email protected]>
TO: Jakub Kicinski <[email protected]>
TO: [email protected]

---
 drivers/net/ethernet/mellanox/mlxsw/core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/core.c +0 -1
index 3fd3812b8f31..47c29769759b 100644
@@ -2190,8 +2190,7 @@ void mlxsw_core_rx_listener_unregister(struct mlxsw_core *mlxsw_core,
 	if (!rxl_item)
 		return;
 	list_del_rcu(&rxl_item->list);
-	synchronize_rcu();
Quoted 8 lines

drivers/net/ethernet/mellanox/mlxsw/core.c void mlxsw_core_rx_listener_unregister(struct mlxsw_core *mlxsw_core, · line 2195

Quoted 4 lines
drivers/net/ethernet/mellanox/mlxsw/core.c +1 -1
-	kfree(rxl_item);
+	kvfree_rcu(rxl_item);
 }
 EXPORT_SYMBOL(mlxsw_core_rx_listener_unregister);

+ David S. Miller <[email protected]>
+ Jakub Kicinski <[email protected]>
+ [email protected]

Impressive CC list. Please make a fresh posting to netdev@ and use ./scripts/get_maintainer.pl.

author maintainer
#16 lore raw

PATCH 1/1 RDMA/hfi1: Switch to kvfree_rcu() API

In reply to Uladzislau Rezki (Sony)

Instead of invoking a synchronize_rcu() to free a pointer after a grace period we can directly make use of new API that does the same but in more efficient way.

TO: [email protected]
TO: Jason Gunthorpe <[email protected]>
TO: Mike Marciniszyn <[email protected]>

---
 drivers/infiniband/hw/hfi1/sdma.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/infiniband/hw/hfi1/sdma.c +1 -2
index f07d328689d3..7264a35e8f4c 100644
@@ -1292,8 +1292,7 @@ void sdma_clean(struct hfi1_devdata *dd, size_t num_engines)
 	sdma_map_free(rcu_access_pointer(dd->sdma_map));
 	RCU_INIT_POINTER(dd->sdma_map, NULL);
 	spin_unlock_irq(&dd->sde_map_lock);
-	synchronize_rcu();
-	kfree(dd->per_sdma);
+	kvfree_rcu(dd->per_sdma);
 	dd->per_sdma = NULL;
 
 	if (dd->sdma_rht) {
Signature · 1 line
2.30.2
author maintainer
#17 lore raw

Re: [PATCH] RDMA/hfi1: Switch to kvfree_rcu() API

Quoted 30 lines · Uladzislau Rezki (Sony)

Instead of invoking a synchronize_rcu() to free a pointer after a grace period we can directly make use of new API that does the same but in more efficient way.

TO: [email protected]
TO: Jason Gunthorpe <[email protected]>
TO: Mike Marciniszyn <[email protected]>

---
 drivers/infiniband/hw/hfi1/sdma.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/infiniband/hw/hfi1/sdma.c +1 -2
index f07d328689d3..7264a35e8f4c 100644
@@ -1292,8 +1292,7 @@ void sdma_clean(struct hfi1_devdata *dd, size_t num_engines)
 	sdma_map_free(rcu_access_pointer(dd->sdma_map));
 	RCU_INIT_POINTER(dd->sdma_map, NULL);
 	spin_unlock_irq(&dd->sde_map_lock);
-	synchronize_rcu();
-	kfree(dd->per_sdma);
+	kvfree_rcu(dd->per_sdma);
 	dd->per_sdma = NULL;
 
 	if (dd->sdma_rht) {
Signature · 1 line
2.30.2

+ [email protected]
+ Jason Gunthorpe <[email protected]>
+ Mike Marciniszyn <[email protected]>

--
Vlad Rezki

maintainer
#18 lore raw

Re: [PATCH] RDMA/hfi1: Switch to kvfree_rcu() API

Quoted 25 lines · Uladzislau Rezki
Quoted 24 lines · Uladzislau Rezki (Sony)

Instead of invoking a synchronize_rcu() to free a pointer after a grace period we can directly make use of new API that does the same but in more efficient way.

TO: [email protected]
TO: Jason Gunthorpe <[email protected]>
TO: Mike Marciniszyn <[email protected]>

 drivers/infiniband/hw/hfi1/sdma.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/infiniband/hw/hfi1/sdma.c +2 -2
index f07d328689d3..7264a35e8f4c 100644
+++ b/drivers/infiniband/hw/hfi1/sdma.c
@@ -1292,8 +1292,7 @@ void sdma_clean(struct hfi1_devdata *dd, size_t num_engines)
 	sdma_map_free(rcu_access_pointer(dd->sdma_map));
 	RCU_INIT_POINTER(dd->sdma_map, NULL);
 	spin_unlock_irq(&dd->sde_map_lock);
-	synchronize_rcu();
-	kfree(dd->per_sdma);
+	kvfree_rcu(dd->per_sdma);
 	dd->per_sdma = NULL;
 
Quoted 4 lines

drivers/infiniband/hw/hfi1/sdma.c void sdma_clean(struct hfi1_devdata *dd, size_t num_engines) · line 1298

Quoted 1 line
drivers/infiniband/hw/hfi1/sdma.c +0 -0
 	if (dd->sdma_rht) {

+ [email protected]
+ Jason Gunthorpe <[email protected]>
+ Mike Marciniszyn <[email protected]>

If it is not in the rdma patchworks it won't get applied..

https://patchwork.kernel.org/project/linux-rdma/list/

Jason

author maintainer
#19 lore raw

Re: [PATCH] RDMA/hfi1: Switch to kvfree_rcu() API

Quoted 27 lines · Jason Gunthorpe
Quoted 25 lines · Uladzislau Rezki
Quoted 24 lines · Uladzislau Rezki (Sony)

Instead of invoking a synchronize_rcu() to free a pointer after a grace period we can directly make use of new API that does the same but in more efficient way.

TO: [email protected]
TO: Jason Gunthorpe <[email protected]>
TO: Mike Marciniszyn <[email protected]>

 drivers/infiniband/hw/hfi1/sdma.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/infiniband/hw/hfi1/sdma.c +2 -2
index f07d328689d3..7264a35e8f4c 100644
+++ b/drivers/infiniband/hw/hfi1/sdma.c
@@ -1292,8 +1292,7 @@ void sdma_clean(struct hfi1_devdata *dd, size_t num_engines)
    sdma_map_free(rcu_access_pointer(dd->sdma_map));
    RCU_INIT_POINTER(dd->sdma_map, NULL);
    spin_unlock_irq(&dd->sde_map_lock);
-   synchronize_rcu();
-   kfree(dd->per_sdma);
+   kvfree_rcu(dd->per_sdma);
    dd->per_sdma = NULL;
 
Quoted 9 lines
Quoted 4 lines

drivers/infiniband/hw/hfi1/sdma.c void sdma_clean(struct hfi1_devdata *dd, size_t num_engines) · line 1298

Quoted 1 line
drivers/infiniband/hw/hfi1/sdma.c +0 -0
    if (dd->sdma_rht) {

+ [email protected]
+ Jason Gunthorpe <[email protected]>
+ Mike Marciniszyn <[email protected]>

If it is not in the rdma patchworks it won't get applied..

https://patchwork.kernel.org/project/linux-rdma/list/

Do you mean that i should:

Cc Jason Gunthorpe <[email protected]>
Cc Mike Marciniszyn <[email protected]>

instead?

Thanks!

Signature · 1 line
Uladzislau Rezki
author maintainer
#20 lore raw

PATCH 1/1 scsi: core: Switch to kvfree_rcu() API

In reply to Uladzislau Rezki (Sony)

Instead of invoking a synchronize_rcu() to free a pointer after a grace period we can directly make use of new API that does the same but in more efficient way.

TO: James E.J. Bottomley <[email protected]>
TO: Martin K. Petersen <[email protected]>
TO: [email protected]

---
 drivers/scsi/device_handler/scsi_dh_alua.c | 3 +--
 drivers/scsi/device_handler/scsi_dh_rdac.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)
drivers/scsi/device_handler/scsi_dh_alua.c +1 -2
index 37d06f993b76..308246ce346a 100644
@@ -1238,8 +1238,7 @@ static void alua_bus_detach(struct scsi_device *sdev)
 		kref_put(&pg->kref, release_port_group);
 	}
 	sdev->handler_data = NULL;
-	synchronize_rcu();
-	kfree(h);
+	kvfree_rcu(h);
 }
 
 static struct scsi_device_handler alua_dh = {
drivers/scsi/device_handler/scsi_dh_rdac.c +1 -2
index 66652ab409cc..dc687021ff3a 100644
@@ -782,8 +782,7 @@ static void rdac_bus_detach( struct scsi_device *sdev )
 	}
 	spin_unlock(&list_lock);
 	sdev->handler_data = NULL;
-	synchronize_rcu();
-	kfree(h);
+	kvfree_rcu(h);
 }
 
 static struct scsi_device_handler rdac_dh = {
Signature · 1 line
2.30.2
author maintainer
#21 lore raw

Re: [PATCH] scsi: core: Switch to kvfree_rcu() API

Quoted 44 lines · Uladzislau Rezki (Sony)

Instead of invoking a synchronize_rcu() to free a pointer after a grace period we can directly make use of new API that does the same but in more efficient way.

TO: James E.J. Bottomley <[email protected]>
TO: Martin K. Petersen <[email protected]>
TO: [email protected]

---
 drivers/scsi/device_handler/scsi_dh_alua.c | 3 +--
 drivers/scsi/device_handler/scsi_dh_rdac.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)
drivers/scsi/device_handler/scsi_dh_alua.c +1 -2
index 37d06f993b76..308246ce346a 100644
@@ -1238,8 +1238,7 @@ static void alua_bus_detach(struct scsi_device *sdev)
 		kref_put(&pg->kref, release_port_group);
 	}
 	sdev->handler_data = NULL;
-	synchronize_rcu();
-	kfree(h);
+	kvfree_rcu(h);
 }
 
 static struct scsi_device_handler alua_dh = {
drivers/scsi/device_handler/scsi_dh_rdac.c +1 -2
index 66652ab409cc..dc687021ff3a 100644
@@ -782,8 +782,7 @@ static void rdac_bus_detach( struct scsi_device *sdev )
 	}
 	spin_unlock(&list_lock);
 	sdev->handler_data = NULL;
-	synchronize_rcu();
-	kfree(h);
+	kvfree_rcu(h);
 }
 
 static struct scsi_device_handler rdac_dh = {
Signature · 1 line
2.30.2

+ James E.J. Bottomley <[email protected]>
+ Martin K. Petersen <[email protected]>
+ [email protected]

--
Vlad Rezki

author maintainer
#22 lore raw
In reply to Uladzislau Rezki (Sony)
Quoted 91 lines · Uladzislau Rezki (Sony)

Instead of invoking a synchronize_rcu() to free a pointer after a grace period we can directly make use of new API that does the same but in more efficient way.

TO: Jens Axboe <[email protected]>
TO: Philipp Reisner <[email protected]>
TO: Jason Gunthorpe <[email protected]>
TO: [email protected]
TO: [email protected]

---
 drivers/block/drbd/drbd_nl.c       | 9 +++------
 drivers/block/drbd/drbd_receiver.c | 6 ++----
 drivers/block/drbd/drbd_state.c    | 3 +--
 3 files changed, 6 insertions(+), 12 deletions(-)
drivers/block/drbd/drbd_nl.c +3 -6
index 44ccf8b4f4b2..28f4d84945fd 100644
@@ -1679,8 +1679,7 @@ int drbd_adm_disk_opts(struct sk_buff *skb, struct genl_info *info)
 			drbd_send_sync_param(peer_device);
 	}
 
-	synchronize_rcu();
-	kfree(old_disk_conf);
+	kvfree_rcu(old_disk_conf);
 	kfree(old_plan);
 	mod_timer(&device->request_timer, jiffies + HZ);
 	goto success;
@@ -2511,8 +2510,7 @@ int drbd_adm_net_opts(struct sk_buff *skb, struct genl_info *info)
 
 	mutex_unlock(&connection->resource->conf_update);
 	mutex_unlock(&connection->data.mutex);
-	synchronize_rcu();
-	kfree(old_net_conf);
+	kvfree_rcu(old_net_conf);
 
 	if (connection->cstate >= C_WF_REPORT_PARAMS) {
 		struct drbd_peer_device *peer_device;
@@ -2925,8 +2923,7 @@ int drbd_adm_resize(struct sk_buff *skb, struct genl_info *info)
 		new_disk_conf->disk_size = (sector_t)rs.resize_size;
 		rcu_assign_pointer(device->ldev->disk_conf, new_disk_conf);
 		mutex_unlock(&device->resource->conf_update);
-		synchronize_rcu();
-		kfree(old_disk_conf);
+		kvfree_rcu(old_disk_conf);
 		new_disk_conf = NULL;
 	}
 
drivers/block/drbd/drbd_receiver.c +2 -4
index 1f740e42e457..d73a53242a75 100644
@@ -3799,8 +3799,7 @@ static int receive_protocol(struct drbd_connection *connection, struct packet_in
 		drbd_info(connection, "peer data-integrity-alg: %s\n",
 			  integrity_alg[0] ? integrity_alg : "(none)");
 
-	synchronize_rcu();
-	kfree(old_net_conf);
+	kvfree_rcu(old_net_conf);
 	return 0;
 
 disconnect_rcu_unlock:
@@ -4168,8 +4167,7 @@ static int receive_sizes(struct drbd_connection *connection, struct packet_info
 
 			rcu_assign_pointer(device->ldev->disk_conf, new_disk_conf);
 			mutex_unlock(&connection->resource->conf_update);
-			synchronize_rcu();
-			kfree(old_disk_conf);
+			kvfree_rcu(old_disk_conf);
 
 			drbd_info(device, "Peer sets u_size to %lu sectors (old: %lu)\n",
 				 (unsigned long)p_usize, (unsigned long)my_usize);
drivers/block/drbd/drbd_state.c +1 -2
index b8a27818ab3f..826e496821c7 100644
@@ -2071,8 +2071,7 @@ static int w_after_conn_state_ch(struct drbd_work *w, int unused)
 		conn_free_crypto(connection);
 		mutex_unlock(&connection->resource->conf_update);
 
-		synchronize_rcu();
-		kfree(old_conf);
+		kvfree_rcu(old_conf);
 	}
 
 	if (ns_max.susp_fen) {
Signature · 1 line
2.30.2

+ Jens Axboe <[email protected]>
+ Philipp Reisner <[email protected]>
+ Jason Gunthorpe <[email protected]>
+ [email protected]
+ [email protected]

--
Vlad Rezki