Return-Path: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682159882; x=1684751882; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=P41rtjhvziZ0onKre5YUyXufEzJnWS3yegvDoiWGZCw=; b=oJLPbDvvyComot7f6UclSlqi3uVutu6klyV/0Mb6fDO4zG0DgLb1mvGxgSL3CxkySL kYPzJk6OKWnnPu3LBL/jOaebH8/WzEQbYJ8N+3g5A0p8fwRTteRxvSV5ecRfRS7BzQ2E GSBGRv423bUkssSQgaT41oTIMQtxipGlYUe0v50XU9gW2hgwAYzv+KmwOCbnIYD73Wqc ZCL+RJhMW+OdjaDwsKrJ7WtjPMbqI0Jl9AU1scxtQ9M+bY1YDQwYIGm85zHQLhhrMCC1 79KsTxrYYeeecU+2fqamrpBqw1rshNnQ0jMNyi0IgT7g8Cch4JplzQPKWdoRPzTAMPPv n0Gg== From: Alan Huang Message-Id: Content-Type: multipart/alternative; boundary="Apple-Mail=_D41B3786-F125-4B4B-A911-1EE3430D861C" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.400.51.1.1\)) Subject: Re: [PATCH] CodeSamples/defer: Fix hazard torture Date: Sat, 22 Apr 2023 18:37:36 +0800 In-Reply-To: References: <20230420072923.35042-1-mmpgouride@gmail.com> To: Akira Yokosawa Cc: paulmck@kernel.org, perfbook@vger.kernel.org List-ID: --Apple-Mail=_D41B3786-F125-4B4B-A911-1EE3430D861C Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Hi Akira, I have sent out the patch v2 with a more clear commit message. Thanks, Alan > 2023=E5=B9=B44=E6=9C=8822=E6=97=A5 16:28=EF=BC=8CAkira Yokosawa = =E5=86=99=E9=81=93=EF=BC=9A >=20 > Hi Alan, >=20 > On Thu, 20 Apr 2023 07:29:23 +0000, Alan Huang wrote: >> This patch fixes hazard torture. >=20 > Please describe what bug you are fixing. >=20 >>=20 >> Signed-off-by: Alan Huang >> --- >> CodeSamples/defer/hazptr.h | 2 +- >> CodeSamples/defer/hazptrtorture.h | 3 +-- >> 2 files changed, 2 insertions(+), 3 deletions(-) >>=20 >> diff --git a/CodeSamples/defer/hazptr.h b/CodeSamples/defer/hazptr.h >> index 759ab53d..e061303d 100644 >> --- a/CodeSamples/defer/hazptr.h >> +++ b/CodeSamples/defer/hazptr.h >> @@ -87,7 +87,7 @@ static inline void *hp_record(void **p, = //\lnlbl{hr:b} >> void *tmp; >>=20 >> do { >> - tmp =3D hp_try_record(*p, hp); >> + tmp =3D hp_try_record(p, hp); >=20 > This looks to me fixes the regression introduced by commit > a082aba85ce0 ("defer/hazptr: Checkpoint for text/code update") > made back on Apr 1, 2019. >=20 > Was it an April fool? I don't know, but Paul planted this bug to > see if there is somebody who would catch it. ;-) >=20 >> } while (tmp =3D=3D (void *)HAZPTR_POISON); >> return tmp; >> } //\lnlbl{hr:e} >> diff --git a/CodeSamples/defer/hazptrtorture.h = b/CodeSamples/defer/hazptrtorture.h >> index 53efa259..29761e3d 100644 >> --- a/CodeSamples/defer/hazptrtorture.h >> +++ b/CodeSamples/defer/hazptrtorture.h >> @@ -241,8 +241,7 @@ DEFINE_PER_THREAD(long long = [HAZPTR_STRESS_PIPE_LEN + 1], hazptr_stress_count); >>=20 >> void *hazptr_read_stress_test(void *arg) >> { >> - int me =3D (int)(long)arg; >> - int base =3D me * K; >> + int base =3D smp_thread_id() * K; >=20 > I'm not sure if this change is related to the fix above. >=20 > Or are you fixing an independent issue? If so, can you make this part > a follow-up patch, with the other patch squashed? >=20 > Thanks, Akira >=20 >> struct hazptr_stress *p; >> int pc; --Apple-Mail=_D41B3786-F125-4B4B-A911-1EE3430D861C Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 Hi = Akira,

I have sent out the patch v2 with a more clear = commit = message.

Thanks,
Alan

2023=E5=B9=B44=E6=9C=8822=E6=97=A5 = 16:28=EF=BC=8CAkira Yokosawa <akiyks@gmail.com> =E5=86=99=E9=81=93=EF= =BC=9A

Hi Alan,

On Thu, 20 Apr 2023 07:29:23 +0000, Alan = Huang wrote:
This patch fixes = hazard torture.

Please = describe what bug you are fixing.


Signed-off-by: Alan Huang = <mmpgouride@gmail.com>
---
CodeSamples/defer/hazptr.h =        | 2 = +-
CodeSamples/defer/hazptrtorture.h | 3 +--
2 files changed, 2 = insertions(+), 3 deletions(-)

diff --git = a/CodeSamples/defer/hazptr.h b/CodeSamples/defer/hazptr.h
index = 759ab53d..e061303d 100644
--- a/CodeSamples/defer/hazptr.h
+++ = b/CodeSamples/defer/hazptr.h
@@ -87,7 +87,7 @@ static inline void = *hp_record(void **p, //\lnlbl{hr:b}
void *tmp;

do = {
- = = tmp =3D hp_try_record(*p, hp);
+ tmp =3D hp_try_record(p, = hp);

This = looks to me fixes the regression introduced by commit
a082aba85ce0 ("defer/hazptr: Checkpoint for = text/code update")
made = back on Apr 1, 2019.

Was it = an April fool?  I don't know, but Paul planted this bug = to
see if there is somebody = who would catch it.  ;-)

} while = (tmp =3D=3D (void *)HAZPTR_POISON);
return tmp;
} = //\lnlbl{hr:e}
diff --git a/CodeSamples/defer/hazptrtorture.h = b/CodeSamples/defer/hazptrtorture.h
index 53efa259..29761e3d = 100644
--- a/CodeSamples/defer/hazptrtorture.h
+++ = b/CodeSamples/defer/hazptrtorture.h
@@ -241,8 +241,7 @@ = DEFINE_PER_THREAD(long long [HAZPTR_STRESS_PIPE_LEN + 1], = hazptr_stress_count);

void *hazptr_read_stress_test(void = *arg)
{
- int me =3D (int)(long)arg;
- int base = =3D me * K;
+ int base =3D smp_thread_id() * K;

I'm not sure if this change is related to = the fix above.

Or are = you fixing an independent issue?  If so, can you make this = part
a follow-up patch, with = the other patch squashed?

       Thanks, = Akira

struct = hazptr_stress *p;
int = pc;

= --Apple-Mail=_D41B3786-F125-4B4B-A911-1EE3430D861C--