Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ntb: Add mutex to make link_event_callback executed linearly.

Since the CPU selected by schedule_work is uncertain, multiple link_event
callbacks may be executed at same time. For example, after peer's link is
up, it is down quickly before local link_work completed. If link_cleanup
is added to the workqueue of another CPU, then link_work and link_cleanup
may be executed at the same time. So add a mutex to prevent them from being
executed concurrently.

Signed-off-by: fuyuanli <fuyuanli@didiglobal.com>
Reviewed-by: Logan Gunthorpe <logang@deltatee.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Jon Mason <jdmason@kudzu.us>

authored by

fuyuanli and committed by
Jon Mason
3db835dd eb4431bf

+7
+7
drivers/ntb/ntb_transport.c
··· 59 59 #include <linux/slab.h> 60 60 #include <linux/types.h> 61 61 #include <linux/uaccess.h> 62 + #include <linux/mutex.h> 62 63 #include "linux/ntb.h" 63 64 #include "linux/ntb_transport.h" 64 65 ··· 242 241 struct work_struct link_cleanup; 243 242 244 243 struct dentry *debugfs_node_dir; 244 + 245 + /* Make sure workq of link event be executed serially */ 246 + struct mutex link_event_lock; 245 247 }; 246 248 247 249 enum { ··· 1028 1024 struct ntb_transport_ctx *nt = 1029 1025 container_of(work, struct ntb_transport_ctx, link_cleanup); 1030 1026 1027 + guard(mutex)(&nt->link_event_lock); 1031 1028 ntb_transport_link_cleanup(nt); 1032 1029 } 1033 1030 ··· 1051 1046 resource_size_t size; 1052 1047 u32 val; 1053 1048 int rc = 0, i, spad; 1049 + 1050 + guard(mutex)(&nt->link_event_lock); 1054 1051 1055 1052 /* send the local info, in the opposite order of the way we read it */ 1056 1053