FreeBSD Bugzilla – Attachment 243029 Details for
Bug 272238
False sharing with pthread rw and spin locks leads to severe perf degradation
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch to reduce false sharing with pthreads rw and spin locks
libthr-false-sharing.patch (text/plain), 1.77 KB, created by
Greg Becker
on 2023-06-27 01:26:59 UTC
(
hide
)
Description:
Patch to reduce false sharing with pthreads rw and spin locks
Filename:
MIME Type:
Creator:
Greg Becker
Created:
2023-06-27 01:26:59 UTC
Size:
1.77 KB
patch
obsolete
>From 150a2d68c91847bc80eb3d38a19a76dc48520e4d Mon Sep 17 00:00:00 2001 >From: Greg Becker <becker.greg@att.net> >Date: Mon, 26 Jun 2023 20:08:29 -0500 >Subject: =?UTF-8?q?Round=20up=20allocations=20of=20pthread=5Frwlock=20and?= > =?UTF-8?q?=20pthread=5Fspinlock=20to=20CACHE=5FLINE=5FSIZE=0Ato=20reduce?= > =?UTF-8?q?=20severe=20performance=20degradation=20due=20to=20false-sharin?= > =?UTF-8?q?g.=20=20Note=20that=20this=0Adoes=20not=20account=20for=20hardw?= > =?UTF-8?q?are=20which=20can=20perform=20adjacent=20cacheline=20prefetch.?= > >--- > lib/libthr/thread/thr_pspinlock.c | 2 +- > lib/libthr/thread/thr_rwlock.c | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) > >diff --git a/lib/libthr/thread/thr_pspinlock.c b/lib/libthr/thread/thr_pspinlock.c >index 089416a18a07..22016efb6211 100644 >--- a/lib/libthr/thread/thr_pspinlock.c >+++ b/lib/libthr/thread/thr_pspinlock.c >@@ -60,7 +60,7 @@ _pthread_spin_init(pthread_spinlock_t *lock, int pshared) > if (lock == NULL) > return (EINVAL); > if (pshared == PTHREAD_PROCESS_PRIVATE) { >- lck = malloc(sizeof(struct pthread_spinlock)); >+ lck = malloc(roundup(sizeof(struct pthread_spinlock), CACHE_LINE_SIZE)); > if (lck == NULL) > return (ENOMEM); > *lock = lck; >diff --git a/lib/libthr/thread/thr_rwlock.c b/lib/libthr/thread/thr_rwlock.c >index b7526376a9a3..0f66398989a4 100644 >--- a/lib/libthr/thread/thr_rwlock.c >+++ b/lib/libthr/thread/thr_rwlock.c >@@ -102,7 +102,7 @@ rwlock_init(pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *attr) > > if (attr == NULL || *attr == NULL || > (*attr)->pshared == PTHREAD_PROCESS_PRIVATE) { >- prwlock = calloc(1, sizeof(struct pthread_rwlock)); >+ prwlock = calloc(1, roundup(sizeof(struct pthread_rwlock), CACHE_LINE_SIZE)); > if (prwlock == NULL) > return (ENOMEM); > *rwlock = prwlock; >-- >2.40.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 272238
:
243025
| 243029