Thread View: org.kernel.vger.linux-raid
1 messages
1 total messages
Started by Coly Li
Tue, 06 May 2025 05:07
Re: [RFC PATCH] fix a reshape checking logic inside make_stripe_request()
Author: Coly Li
Date: Tue, 06 May 2025 05:07
Date: Tue, 06 May 2025 05:07
61 lines
6259 bytes
6259 bytes
> 2025ๅนด5ๆ6ๆฅ 11:34๏ผYu Kuai <yukuai1@huaweicloud.com> ๅ้๏ผ
>
> Hi,
>
> ๅจ 2025/05/06 10:34, Coly Li ๅ้:
>> For the above code, I donโt see how only unlikely(previous) help on branch prediction and prefetch,
>> IMHO the following form may help to achieve expected unlikely() result,
>> if (unlikely(previous && !stripe_ahead_of_reshape(mddev, conf, sh))) {
>> Thanks.
>
> What you mean you don't see *only unlikely*, for example:
>
> int test0(int a, int b)
> {
> if (a && b)
> return 1;
> return 0;
> }
>
> int test1(int a, int b)
> {
> if (unlikely(a) && b)
> return 1;
>
> return 0;
> }
>
> You can see unlikely will generate setne/movzbl/test assemble code:
>
> test0:
> 0x0000000000401130 <+10>: cmpl $0x0,-0x4(%rbp)
> 0x0000000000401134 <+14>: je 0x401143 <test0+29>
> 0x0000000000401136 <+16>: cmpl $0x0,-0x8(%rbp)
> 0x000000000040113a <+20>: je 0x401143 <test0+29>
>
> test1:
> 0x0000000000401154 <+10>: cmpl $0x0,-0x4(%rbp)
> 0x0000000000401158 <+14>: setne %al
> 0x000000000040115b <+17>: movzbl %al,%eax
> 0x000000000040115e <+20>: test %rax,%rax
> 0x0000000000401161 <+23>: je 0x401170 <test1+38>
> 0x0000000000401163 <+25>: cmpl $0x0,-0x8(%rbp)
>
> BTW, what you suggested is the same as:
>
> if (unlikely(previous) && unlikely(!stripe_ahead_of_reshape(mddev, conf, sh)))
I seldom use unlikely() this way, it is confused as well.
Anyway since the result seems to be similar as including whole checking statement by unlikely(), I donโt insist on this.
Thanks for the patient explanation.
Coly Li
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads