From: Gao Xiang <hsiangkao@aol.com>
To: Gao Xiang <gaoxiang25@huawei.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Philippe Ombredanne <pombredanne@nexb.com>,
Kate Stewart <kstewart@linuxfoundation.org>,
Thomas Gleixner <tglx@linutronix.de>,
Will Deacon <will.deacon@arm.com>,
linux-kernel@vger.kernel.org,
Peter Zijlstra <peterz@infradead.org>,
Miao Xie <miaoxie@huawei.com>, Chao Yu <chao@kernel.org>
Subject: Re: Re: [PATCH v2] bit_spinlock: introduce smp_cond_load_relaxed
Date: Tue, 6 Nov 2018 01:11:44 +0800 [thread overview]
Message-ID: <f30835ca-f6e8-1e31-3364-cb1d958d76bf@aol.com> (raw)
In-Reply-To: <3455f753-8f7c-91a8-c926-e06f5ed2d1bb@huawei.com>
Hi all,
ping... is there someone interested in this patch?
It seems bit_spinlock performs much better by using
smp_cond_load_relaxed than just do busy-loop in arm64...
Thanks,
Gao Xiang
On 2018/10/30 13:52, Gao Xiang wrote:
> Hi,
>
> On 2018/10/30 14:04, Gao Xiang wrote:
>> It is better to use wrapped smp_cond_load_relaxed
>> instead of open-coded busy waiting for bit_spinlock.
>>
>> Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
>> ---
>>
>> change log v2:
>> - fix the incorrect expression !(VAL >> (bitnum & (BITS_PER_LONG-1)))
>> - the test result is described in the following reply.
>>
>> Thanks,
>> Gao Xiang
>
>
> Simple test script:
> #include <linux/kthread.h>
> #include <linux/bit_spinlock.h>
> #include <linux/module.h>
>
> unsigned long global_lock;
>
> int test_thread(void *data)
> {
> unsigned long thread_id = (unsigned long)data;
> int i;
> u64 start = ktime_get_ns();
>
> for (i = 0; i < 500000; ++i) {
> bit_spin_lock(0, &global_lock);
> __asm__("yield");
> bit_spin_unlock(0, &global_lock);
> }
> pr_err("Thread id: %lu time: %llu\n", thread_id, ktime_get_ns() - start);
>
> do_exit(0);
> }
>
>
> static int __init bitspinlock_test_module_init(void)
> {
> int i;
>
> for (i = 0; i < 8; ++i) {
> if (IS_ERR(kthread_run(test_thread, (void *)(unsigned long)i, "thread-%d", i)))
> pr_err("fail to create thread %d\n", i);
> }
>
> return 0;
> }
>
> static void __exit bitspinlock_test_module_exit(void)
> {
> }
>
> module_init(bitspinlock_test_module_init);
> module_exit(bitspinlock_test_module_exit);
> MODULE_LICENSE("GPL");
>
>
> ...and tested in the following ARM server environment:
>
> Processor: HI1616 (https://en.wikichip.org/wiki/hisilicon/hi16xx/hi1616)
> Board: HiSilicon D05 Development Board (http://open-estuary.org/d05/)
> Memory: 512GB
> Host OS: Ubuntu 18.04.1 LTS (Ubuntu 4.15.0-29.31-generic 4.15.18)
> QEMU KVM OS: Linux 4.19 + buildroot
> QEMU KVM cmdline: qemu-system-aarch64 -enable-kvm -cpu host -smp 4 -m 256M -kernel Image -M virt,kernel_irqchip=on -nographic -hda rootfs.ext2 -append 'root=/dev/vda console=ttyAMA0 earlycon=pl011,0x9000000' -serial mon:stdio -net none
>
> Without this patch:
> Thread 0 Thread 1 Thread 2 Thread 3 Thread 4 Thread 5 Thread 6 Thread 7
> 1 1283709480 1271869280 454742480 1173673820 1145643640 1118846920 774616920 1144146140
> 2 643580180 625143860 576841700 322982340 649987880 585749000 529178880 373374780
> 3 672307220 847315000 880801860 1039502040 667086380 1033939940 1035381120 1046898300
> 4 568635580 440547020 737000380 910040880 804543740 712314280 868896880 867049000
> 5 749107320 726397720 776134480 611970100 756721040 753449440 711691300 609343300
>
> With this patch:
> Thread 0 Thread 1 Thread 2 Thread 3 Thread 4 Thread 5 Thread 6 Thread 7
> 1 170327620 196322160 169434180 74723860 178145600 178873460 143843260 70998780
> 2 166415220 129649200 166161240 175241520 155474460 112811860 157003140 150087420
> 3 511420780 117655640 598641860 596213720 462888760 430838600 554346300 428035120
> 4 174520240 156311800 120274280 87465380 172781400 136118620 163728340 63026360
> 5 153677940 202786860 183626500 140721300 150311360 161266840 168154340 107247460
>
> Thanks,
> Gao Xiang
>
next prev parent reply other threads:[~2018-11-05 17:11 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-13 6:47 [RFC PATCH] " Gao Xiang
2018-10-13 7:04 ` Greg Kroah-Hartman
2018-10-13 7:22 ` Gao Xiang
2018-10-13 7:30 ` Greg Kroah-Hartman
2018-10-13 7:44 ` Gao Xiang
2018-10-13 7:30 ` Gao Xiang
2018-10-30 6:04 ` [PATCH v2] " Gao Xiang
2018-10-30 5:52 ` Gao Xiang
2018-11-05 17:11 ` Gao Xiang [this message]
2018-11-05 22:49 ` Will Deacon
2018-11-06 1:45 ` Gao Xiang
2018-11-06 9:06 ` Peter Zijlstra
2018-11-06 10:22 ` Gao Xiang
2018-11-06 11:00 ` Peter Zijlstra
2018-11-06 11:36 ` Gao Xiang
2018-11-06 12:27 ` Peter Zijlstra
2018-11-06 12:33 ` Gao Xiang
2018-11-06 12:38 ` Gao Xiang
2018-11-06 12:43 ` Peter Zijlstra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f30835ca-f6e8-1e31-3364-cb1d958d76bf@aol.com \
--to=hsiangkao@aol.com \
--cc=chao@kernel.org \
--cc=gaoxiang25@huawei.com \
--cc=gregkh@linuxfoundation.org \
--cc=kstewart@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=miaoxie@huawei.com \
--cc=peterz@infradead.org \
--cc=pombredanne@nexb.com \
--cc=tglx@linutronix.de \
--cc=will.deacon@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®