lkml.org 
[lkml]   [2020]   [Oct]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Litmus test for question from Al Viro
On Sat, Oct 03, 2020 at 12:11:59PM -0400, joel@joelfernandes.org wrote:
> On Sat, Oct 03, 2020 at 12:08:46PM -0400, joel@joelfernandes.org wrote:
> [...]
> > static void code0(struct v_struct* v,spinlock_t* l,int* out_0_r1) {
> >
> > struct v_struct *r1; /* to_free */
> >
> > r1 = NULL;
> > spin_lock(l);
> > if (!smp_load_acquire(&v->b))
> > r1 = v;
> > v->a = 0;
> > spin_unlock(l);
> >
> > *out_0_r1 = !!r1;
> > }
> >
> > static void code1(struct v_struct* v,spinlock_t* l,int* out_1_r1) {
> >
> > struct v_struct *r1; /* to_free */
> >
> > r1 = v;
> > if (READ_ONCE(v->a)) {
> > spin_lock(l);
> > if (v->a)
> > r1 = NULL;
> > smp_store_release(&v->b, 0);
> > spin_unlock(l);
> > }
> >
> > *out_1_r1 = !!r1;
> > }
> >
> > Results on both arm64 and x86:
> >
> > Histogram (2 states)
> > 19080852:>0:r1=1; 1:r1=0;
> > 20919148:>0:r1=0; 1:r1=1;
> > No
> >
> > Witnesses
> > Positive: 0, Negative: 40000000
> > Condition exists (0:r1=1 /\ 1:r1=1) is NOT validated
> > Hash=4a8c15603ffb5ab464195ea39ccd6382
> > Observation AL+test Never 0 40000000
> > Time AL+test 6.24
> >
> > I guess I could do an alloc and free of v_struct. However, I just checked for
> > whether the to_free in Al's example could ever be NULL for both threads.
>
> Sorry, here I meant "ever be non-NULL".
>
> So basically I was trying to experimentally confirm that to_free could never
> be non-NULL in both code0 and code1 threads.

Thank you for running these! In conjunction with Alan's analysis,
this seems quite convincing. ;-)

Thanx, Paul

\
 
 \ /
  Last update: 2020-10-05 01:13    [W:0.073 / U:0.104 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site